Administration Utilities Objectives to use standard administration utilities

  • Slides: 12
Download presentation
Administration Utilities • Objectives – to use standard administration utilities • Contents – –

Administration Utilities • Objectives – to use standard administration utilities • Contents – – – – – manual pages identifying your system communicating with Users finding files looking at files and logs system defaults Syslog Logrotate logserver • Practicals – to become familiar with these commands • Summary

On-Line Manuals • On-line manuals in many sections: May vary on systems 1 user

On-Line Manuals • On-line manuals in many sections: May vary on systems 1 user commands 4 file formats (8)1 M maintenance commands 5 miscellaneous 2 system calls 6 games 3 functions and libraries 7 special files • man command displays first manual page found – some systems display all matched pages – add section number before command name to man command line • Some systems provide a whatis database (originally BSD) – whatis command – apropos command – /usr/ucb/catman one line description of command keyword search for command re-creates database from manual source files $ $ man man man 1 intro passwd 4 passwd

Identifying the Unix System • The uname command (uname) shows system information – the

Identifying the Unix System • The uname command (uname) shows system information – the command hostname also identifies the current host • options -a all information -n system name (nodename on network) -s O/S name -r O/S release number -v O/S version number -mmachine hardware -p processor type $ uname -a Sun. OS mash 4077 5. 4 generic sun 4 c sparc $ hostname mash 4077

Identifying active users • The who command shows who is currently logged on –

Identifying active users • The who command shows who is currently logged on – information kept in /var/adm/utmp – a history of every login is also kept in /var/adm/wtmp • Who can also be used to identify the current user who am i • The command id also identifies the current user • some systems also have a w command (originally BSD) $ who trapper pts 001 Jul 25 11: 01 hawkeye console Jul 25 11: 31 $ who am i hawkeye console Jul 25 11: 31 $ id uid=318(hawkeye) gid=300(users) $ who /var/adm/wtmp history of all system logins

Talking to users • Use write to display a message on a user's terminal

Talking to users • Use write to display a message on a user's terminal – user's can disable messages using mesg n command – root can always write to a user • Write all (wall) will display to all logged in users – useful for sending out broadcasts – used by the system shutdown mechanism • Use the talk command to set up a two way dialogue. • Use the telephone $ write trapper Do you know where the system logbook is? ^D $ mesg is no $ mesg y $ talk trapper

Finding Files • The find command locates files using specified search criteria find directories.

Finding Files • The find command locates files using specified search criteria find directories. . . search_criteria. . . action • Search Criteria: -name finds only files called name (can use shell wildcards) -user name finds only files owned by user name -type letter finds files of specified type: f (plain files) d (dirs), etc. -mtime n finds files modified n days ago, less than (-n ), greater than (+n ) -size n[c|K] finds files of size n , larger than (+n ), smaller than (-n ), c=chars, K=kilobytes (when omitted, 512 block size is implied) -newer pathname finds files newer than specified file -mount don't cross disk boundaries • Action: -print filenames found -exec cmd {} ; executes given command (filename will be given in place of {}) -ok cmd {} ; executes command but prompts for confirmation

Exercise - Revision Of Using find • What do the following find commands mean?

Exercise - Revision Of Using find • What do the following find commands mean? # find. -print # find /etc -type d -print # find /home -name. profile -exec pg {} ; # find /dev -type f -mtime -7 -exec ls -l {} ; # find /sbin /usr/sbin -name "user*" -exec ls -ld {} ;

The grep Family • All grep commands provide pattern matching criteria for filtering lines

The grep Family • All grep commands provide pattern matching criteria for filtering lines containing a pattern fgrep [options] pattern [files. . . ] – fgrep uses fixed (simple patterns) grep [options] pattern [files. . . ] – grep uses "regular expressions" to define powerful pattern matching templates egrep [options] pattern|pattern [files. . . ] – egrep uses extended regular expressions, allows multi-pattern search • common options -v -c -i -n output non-matched lines output count of lines matched ignore lower/upper case mark each matched line with its relative line number

Exercise - Revision Of Using grep • Always usingle quotes round grep regular expression

Exercise - Revision Of Using grep • Always usingle quotes round grep regular expression • What do the following grep commands mean? # ls -l | grep '^d' # grep 'ksh$' /etc/passwd # ls -a | grep '^. [^. ]' # fgrep root /var/adm/sulog # who | egrep '(hawkeye|trapper)'

Looking Inside Files • Use the file command to identify a file type Then

Looking Inside Files • Use the file command to identify a file type Then for: • Text files: use pg or more to look at the file • Data files: use octal dump (od) – some systems supply a hex dump (hd) program – use the -c option to characters where possible # file * feed. dat: ASCII text myprog: i. APX 386 executable not stripped myprog. c: C source code runsys: commands text x. jpeg: data # od -c x. jpeg | pg • Use the strings command to list ASCII strings in a data file

Inspecting Log Files • Use a pager such as less or more – can

Inspecting Log Files • Use a pager such as less or more – can be slow when working with large log files • Use grep to look for particular words • Use the tail command to look at the last few lines – if the log file is growing than use the -f option • Use view (vi read only) to read the whole file # tail /var/messages SU 07/17 23: 47 + console root-lp SU 07/18 00: 37 - console alina-root Whatever method you choose: DO LOOK AT LOG FILES

System Default Files & logbooks • Red. Hat sysconfig /etc/sysconfig/ – Redhat specific setup

System Default Files & logbooks • Red. Hat sysconfig /etc/sysconfig/ – Redhat specific setup and boot files • General linux config /etc/ – Many files, system wide configs • Adduser enviroment /etc/default – When adding users, this apply in first line – Also /etc/skel is added to user enviroment • Red. Hat system logbooks Undependent of syslog: /var/log/maillog : Mail /var/log/httpd/access_log : Apache web server page access logs Red. Hat log catalog standards: /var/log/messages : (SYSLOG) Systems services & hardware log /var/log/samba/ : Samba messages /var/log/secure : Login details, ftp, pop, imap and so on. . /var/log/vsftpd : Very secure ftp server