Wednesday, May 6, 2009

Problem after update Ubuntu 8.04 Server software

I just update Ubuntu 8.04 Server software by command:

$ sudo apt-get update && sudo apt-get upgrade

The process it self is ok, but my apache web server can not run.

$ sudo /etc/init.d/apache2 restart

Say error in /etc/apache2/sites-enabled/000-default.save

I remove the file then apache work fine again :)

Root without password in Ubuntu

Since I use Hardy Heron, I found that we can get root console / command
prompt without a password.

I do not know, why Ubuntu team do this. But it was help me when I must
enter the admin functions but I do not know the admin user name and
password.

How to get in it?

When system is booting and prompt a GRUB menu, I press ESC key. Then I
select "Recovery mode". After the system show a selection action box, I
select "root". Than I get a sign: #

Sunday, February 8, 2009

Deleting Old Files In Linux

When my scheduled database backup run, I have many old files we do not neet them anymore. So, I have a question for my self: How to remove them automatically just after backup is done?

So, I try to read 'find' command manual. The command is "man find" (without double quotes) if you do not know :) then I found these option:

-atime n
File was last accessed n*24 hours ago. When find figures out
how many 24-hour periods ago the file was last accessed, any
fractional part is ignored, so to match -atime +1, a file has to
have been accessed at least two days ago.


-ctime n
File’s status was last changed n*24 hours ago. See the comments
for -atime to understand how rounding affects the interpretation
of file status change times.

-name pattern
Base of file name (the path with the leading directories
removed) matches shell pattern pattern. The metacharacters
(‘*’, ‘?’, and ‘[]’) match a ‘.’ at the start of the base name
(this is a change in findutils-4.2.2; see section STANDARDS CON‐
FORMANCE below). To ignore a directory and the files under it,
use -prune; see an example in the description of -path. Braces
are not recognised as being special, despite the fact that some
shells including Bash imbue braces with a special meaning in
shell patterns. The filename matching is performed with the use
of the fnmatch(3) library function. Don’t forget to enclose
the pattern in quotes in order to protect it from expansion by
the shell.

-delete
Delete files; true if removal succeeded. If the removal failed,
an error message is issued. If -delete fails, find’s exit sta‐
tus will be nonzero (when it eventually exits). Use of -delete
automatically turns on the -depth option.


So, with options combination I get a command:
$ find . -name 'backup_*.db' -ctime +30 -delete

That is! I put the command in my backup script than run by cron every weeks and my old files will be deleted just after backup is done.

Friday, October 17, 2008

Setup OpenVPN in Ubuntu

To get my work on time schedule, I must bring it as my homework. It is software development. For this purpose, I have to connect my office computer to home computer with VPN.
1st - ISP's Modem
Open firewall or port triggering: 1194 UDP
ThenVirtual Server, forward incoming connection 1194 port to my office computer's IP address.
2dn - Install OpenVPN
Office / Server: Ubuntu 8.04 (Hardy Heron) Server
Home / Client: Ubuntu 8.04 Desktop
Install openvpn in both computers:
sudo apt-get install openvpn
3rd - Configure the server: (see HOWTO for more)
cd /etc/openvpncp -r /usr/share/doc/openvpn/examples/easy-rsa/2.0/ ./easy-rsa/cd easy-rsa
(optionals)
nano ./vars
Change the values:
export KEY_COUNTRY=ID
export KEY_PROVINCE=KEPRIexport KEY_CITY=BATAMexport KEY_ORG="OpenVPN-TEST"
export KEY_EMAIL="eshabe@gimail.com"
(then):
source ./vars
./clean-all
./build-ca
Pay attention in “Common Name”. Example answer: "myfirstvpn"
./build-key-server server
Pay attention in...
“Common Name” - my answer is “server”
“Sign the certificate? [y/n]” - answer “y”
“1 out of 1 certificate requests certified, commit? [y/n]” - answer “y”
./build-key client1
./build-key client2
./build-key client3
./build-dh
Copy key files:
cd /etc/openvpn
cp easy-rsa/keys/server.crt .
cp easy-rsa/keys/server.key .
cp easy-rsa/keys/ca.crt .
cp easy-rsa/keys/dh1024.pem .
Copy example config file:
gunzip /usr/share/doc/openvpn/examples/sample-config-files/server.conf.gz
4th - Configure the client
Copy key files:
cd /etc/openvpn
scp eshabe@125.x.x.x:/etc/openvpn/easy-rsa/keys/client1.crt client.crt
scp eshabe@125.x.x.x:/etc/openvpn/easy-rsa/keys/client1.key client.key
scp eshabe@125.x.x.x:/etc/openvpn/easy-rsa/keys/ca.crt ca.crt
Copy example config file:
cp /usr/share/doc/openvpn/examples/sample-config-files/client.conf .
Edit config file:
nano client.conf
Change remote value:
remote 125.1.2.3 1194
5th - Try and activate
Try:
(server)
openvpn server.conf
(client)
openvpn client.conf
Yes!! openvpn is ready….
/etc/init.d/openvpn start

Sunday, October 5, 2008

HowTo: No waiting time in Ubuntu's GRUB

By default, Ubuntu display a GRUB menu and give us ten (10) seconds waiting time for user interaction. If you feel this waiting time is disturbing, you can remove the waiting time by edit the GRUB menu. Set 'timeout' value to 0 (zero).

From Terminal, type:

sudo nano /boot/grub/menu.lst

Change timeout value.

And, do not forget to activate hiddenmenu option. Why? By activating the option, although the timeout is 0 second, we can enter to the GRUB menu by pressing ESC key.

Save the file!