My Basic VPS Guide [15.] – The power of log files

Well, it’ a nice weekend and thus I will add another post :) We know a few useful commands to find out something more about our system and the resources various programs, scripts and system itself consumes. Now we should be able to know what’s going on from the resources point of view, but we still do not know where to look for some helpful warning messages. And Linux powered VPS machines give you a very good source to find out something more than raw data from the top or ps commands. The source is called LOG FILES and it is holds all the log files with various very important data in text format.

Log files – where are they?

The log directory is located in the /var/log/ and there is not only one single log file for the whole system and all the programs and scripts as it would be a big mess and not a big help ;) . There are many files. In fact there are files for the majority of the important things which are essential to be logged :) You can find the mail log for email messages and everything related to mail, clamav has its own log file and there are many more. to find out what log files are active on your system try this command ‘ls /var/log/’. This will list you all the files in the log directory.

Don’t be afraid and just “cd” into the directory and start to explore what’s in each file. It is very essential to look into each file and find out what can be found in as this will help you in the future if something goes wrong and you will need to quickly find it in the logs ;) You can use your favourite text editor [e.g. vi or nano...] and open the log files by issuing vi name_of_log_file or you might be interested only in the last few lines of a log file and thus issue the tail -10 log_file [the -10 tells to command to show you the last 10 lines ;) ].  You can even look at the beginning of a log file by issuing the head -10 log_file command [the -10 once again list 10 first lines ;) ].

Log files – how to use them?

I have already covered the way how to look at the beginning of a log file [head] or the end of a log file [tail]. But these are only the start and you should know what to look for and what can be found in log files. Log files are powerful when you learn how to use them. The best way to search trough them is to use the grep command like e.g. grep ‘search_term’ ‘file_name or wildcard *’. An example could be a network problem and you would not know where to look for it and thus you would issue a command like this grep network *‘ . This would look trough all the files in the directory and print the lines where the term network is mentioned. Then you would go into the file appropriate file and look what’s wrong;)

[ad#Adsense360]

Log files – are they always available and telling the truth?

Well, log files should always tell you the truth and they do. They are a great resource when you know how to use them in your favour. But I need to say here, that thee are not always available. It’s better to say they are not available under all circumstances as some virtualization technologies like OpenVZ work on a different principle than a standard Linux distribution and thus you will not be provided with some kernel or other problems and log files – they will be empty -  as OpenVZ is an OS layer based virtualization and your VPS does not directly communicate with the hardware.  This is the reason some log files might be empty and you will not be able to find more just from looking at them.

The majority of important log files are available and thus you should be able to find exactly what you are looking for. Any other problems should be communicated with your web hosting provider.

[ad#Adsense250]

Some useful log files on a Linux system are the dmesg, messages, boot.log, maillog and of course the rkhunter and clamav log files ;) Do not forget you need to look into the various manual pages and tutorials around the web as it is a very detailed topic and I can’t teach you everything in such a short time and space. Take this as the start point showing you where to look and what to search for ;) Have a nice day and see you next time!

No related posts.

, , , ,

Comments are closed.
Get Adobe Flash playerPlugin by wpburn.com wordpress themes