I know I can find logs in /var/log/
, they contain powerful information, but I don't really use them often (on desktop or server).
Is there any good guide to learn how to make use of system logs on Ubuntu? Top things an user/basic admin needs to know?
E.g.
- check this log weekly
- keep this file clean
- set up log notification this way
- when somethings wired happened, start here
- use this tool to simplify your life
- common command line usages
- common uses of
grep
searching the logs
or any other tips to new users coming from Windows?
1st have a look at the answer by MaroCeppi here: Which logs should I pay attention to? It explains what some of the more common logs are used for. There is one more log named
.xsession-errors
in your home dir (and this records your login and has amongst others errors on loading indicators and laucher items), and often grows VERY large, especially if you never log out.In general there is no need to check logs weekly. Security might be an exception but if that's the case your system probably is hosting a server (Apache for instance) and then it is more for seeing irregular access instead of errors. I tend to not look at them unless something is really broken.
Specifically targeting your questions:
log file viewer
is a good place to start:It is a bit hard to answer this but I always start with
dmesg
or with the log related to the problem (no need to look in .xsession-errors when you get an error during booting ;) )Commands that are rather useful:
cat
will list the whole file.grep
will filter commands.tail -f
will keep a file active and you will see new notices show up in it when they happen. Rather helpful when tracking down what action you do results in a problem. (tail -100
will show the last 100 lines)wc -l
to count how many times some search happend.more
andless
show the file too.One example of this:
How many times did someone try to login on 'our' apacher server using IP address 111.111.111.111:
grep "GET /login.js" /var/log/httpd/access.log | grep 111.111.111.111 | wc -l
Just after an "event" that you need to investigate, do a
ls -rlt /var/log
to get a reversed, time-ordered (by modification time) list of log files (most recently modified file last) to look at.