Ubuntu General Tips – 1
June 13, 2011 Leave a comment
I have been using Ubuntu for almost two years and having faced few issues, I planned to write a series on the steps I followed to resolve it.
1. Append date into log in Ubuntu:
When we use commands in log, we write the output to some file, that will make debugging easier. Say for instance, we run an ant script and want to write the log to a file. In normal case, we would give the following command,
ant command > filename
But in cases where we need to take periodic backup or log the output, its better to append date with the log. You can assign the date to the log dynamically using the date property of Ubuntu. The Syntax for appending/setting date to a log dynamically is by using `date +”%F”`
Eg., When you want to take backup of postgres database daily, you can use this command in the terminal.
pg_dump -U postgres databasename > bkp-`date +"%F"`.out
2. Command to Compress and Extract files in Ubuntu:
Compress and Decompress using command line is a great utility to be aware of, specially when dealing with remote machines. You can use any good tool like 7zip, winrar. But when you are using remote connectivity using ssh, or putty, its better suited you remain aware of your Ubuntu commands..:)
Command to compress a folder in Ubuntu:
tar -czvf filename.tar.gz folder (relative to current directory with no slash)
Command to extract file in Ubuntu:
tar -C directory -zxvf filename
3. To change System name:
When we access the localhost server, we often use the name 127.0.0.1 or localhost or the IP of your machine. Won’t it be nice if we give http://shankar:8080 to access your localhost Tomcat? Won’t it be great to set your own domain?
For this modify in /etc/hosts/, find the following line and modify it as provided below
add the desired name to it.
127.0.0.1 localhost desiredname
and then Restart the System
4. Compositing Problem in Docky/Cairo-Dock:
When you use dockbars like Docky, Avant Window Manager, CairoDock, more often than not, we find that the app crashes with a notification, that enable composition manager in unix which is required to Docky. To resolve this,
Alt+F2 and enter
check the key in /apps/metacity/general/compositing_manager
Check the check box.
Now your dock app will work perfectly.