Common Linux log files names and usage



4910455-3175009525078105mobile itnTSolutions, LLC.00mobile itnTSolutions, LLC.4572002857500Linux Systems AdministratorProgramClass Notes:“Viewing File Contents”Part II00Linux Systems AdministratorProgramClass Notes:“Viewing File Contents”Part IIsViewing File Contents: - Part II tail : Shows the last 10 lines of a text file, if no option is givenExamples Below:tail myfile.txtOutputs the last 10 lines of the file myfile.txttail myfile.txt -n 100Outputs the last 100 lines of the file myfile.txttail –f myfile.txt Outputs the last 10 lines of myfile.txt, and monitors myfile.txt for updates; tail then continues to output any new lines that are added to myfile.txt.)Example to use on server: tail -f secure Another example: tail -f access.log | grep 24.10.160.10This is a useful example of using tail and grep to selectively monitor a log file in real time.In this command, tail monitors the file access.log. It pipes access.log's final ten lines, and any new lines added, to the grep utility. grep reads the output from tail, and outputs only those lines which contain the IP address 24.10.160.mon Linux log files names and usage/var/log/messages General message and system related stuff/var/log/auth.log Authenication logs/var/log/kern.log Kernel logs/var/log/cron.log Crond logs (cron job)/var/log/maillog Mail server logs/var/log/qmail/ Qmail log directory (more files inside this directory)/var/log/httpd/ Apache access and error logs directory/var/log/lighttpd/ Lighttpd access and error logs directory/var/log/boot.log System boot log/var/log/mysqld.log MySQL database server log file/var/log/secure or /var/log/auth.log Authentication log/var/log/utmp or /var/log/wtmp Login records file/var/log/yum.log Yum command log file.head : This command is opposite of tail command. It displays the 1st ten lines of a text fileExamples:head -15 myfile.txt (Displays the 1st 15 lines of my text file)head /etc/passwd (Displays the 1st 10 lines of passwd file)less : This command will open a plain-text file viewer to view the file. Just a little different than the other commands… you can browse the file using the “Page Down Key”, “Page Up Key”, or “spacebar”Example: less file.txt (views the file “file.txt”) / less –N file.text (displays a line # at beginning of each line)Offers a search capability: Ex: use “/sometext” to find sometext in the file.To Quit “less”, use “q”more : This command is a filter for paging through text one screen at a time. It does not provide as many options or enhancements as less, but is nevertheless quite useful and simple to use.Examples:more +3 myfile.txt (Display the contents of file myfile.txt, beginning at line 3.)more +/”hope” myfile.txt (Display the contents of file myfile.txt, beginning at the first line containing the string "hope". )ls | more (List the contents of the current directory with ls, using more to display the list one screen at a time. )grep command:The ultimate utility to work with regular expressions is grep, which stands for “general regular expression parser”This tool searches the contents of one or more text files or supplied input for a regular expressionIf the expression is matched, grep prints every line containing that expression on the screen without changing the source contentsRegular expression:Also referred to as pattern matching, regex, or regexp, is a pattern that is matched against a string of characters in a file or supplied input.The pattern can be a single character, series of characters, word, or sentenceAny pattern with one or more white spaces must be enclosed within quotesgrep examples:To search for the pattern user100 in the /etc/passwd file:# grep user100 /etc/passwdTo search for all lines in the /etc/passwd file that begin with the pattern rootThe bash shell treats the caret ^ sign as a special character which marks the beginning of a line or word# grep ^root /etc/passwdTo search for all empty lines in the /etc/passwd file:# grep ^$ /etc/passwd ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download