Posts Tagged ‘Linux’

Using tail to recieve live log updates

Sunday, August 23rd, 2009

                              
Checking log files can be such a pain sometimes, especially if you’re doing it regularly. For example, when I’m coding up a web app, I find it useful to keep an eye on the Apache error logs with something like this :

tail /var/log/apache2/error.log

However, if I add the option -f to tail, it will follow the file I’m reading and give me live updates as and when new lines are added.

tail -f /var/log/apache2/error.log

Instead of exiting after it has read the file, tail will now stay open and update new lines in the terminal as they appear.
To exit, just use ctrl-c

This will work with any other text files that get updated, for example, if you like to know when people are viewing your page, live, check out the access logs with :

tail -f /var/log/apache2/access.log

Chown time saver

Sunday, August 23rd, 2009

                              
Here’s another little time saver that I use quite a lot with the chown command.

If you want to change the ownership of a file in linux to a user and group that have the same name, you could use the command :


chown mike:mike filename


A nifty little short cut here is to write it as :


chown mike. filename



Here, the . (full-stop / period) after the username mike, also sets the group to mike!