8/9/2019 Ch03 Administration Utility
1/19
SAIGONLAB 83 Nguyn Th Nh, P9, Q.Tn Bnh, Tp. HCM LPI 102
Chapter 03Chapter 03
Administration UtilitiesAdministration Utilities
8/9/2019 Ch03 Administration Utility
2/19
SAIGONLAB 83 Nguyn Th Nh, P9, Q.Tn Bnh, Tp. HCM LPI 102
System Information
Finding Files
Text Processing
Scheduling Processes
8/9/2019 Ch03 Administration Utility
3/19
SAIGONLAB 83 Nguyn Th Nh, P9, Q.Tn Bnh, Tp. HCM LPI 102
System Information
Identifying the Systemuname command show system information
hostname command identifies the current host
Eg:
$uname a
Linux SAIGONLAB 2.4.20-8 #1 Thu Mar 13 17:54:28EST 2003 i686 i686 i386 GNU/Linux
$hostname
SAIGONLAB
see man uname and man hostname know detailed
information.
8/9/2019 Ch03 Administration Utility
4/19
SAIGONLAB 83 Nguyn Th Nh, P9, Q.Tn Bnh, Tp. HCM LPI 102
System Information
System default files
Linux store some command defaults in file in/etc/default
Filename same as command nameEntries in the file take the form of environment
variable definitions
Detail of defaults defined in command manual page
File usually edited manually
8/9/2019 Ch03 Administration Utility
5/19
SAIGONLAB 83 Nguyn Th Nh, P9, Q.Tn Bnh, Tp. HCM LPI 102
System Information
Identifying and Communicating with Active Users
who command show who is currently logged on to thesame system
Information kept in /var/run/utmp
last command show a history of every login to the samesystem
Information kept in /var/log/wtmp
Whoami and id command identify the current user
w command like who, in addition to show what theydoing.
8/9/2019 Ch03 Administration Utility
6/19
SAIGONLAB 83 Nguyn Th Nh, P9, Q.Tn Bnh, Tp. HCM LPI 102
Talking to Users
write command to display a message on a users terminalUsers can disable messages using mesg n
Root can always write to a user
write all (wall) to display to all logged-in users
Userful for sending out broadcasts
Used by the system shutdown mechanism
talkcommand to set up a two-way dialogue
8/9/2019 Ch03 Administration Utility
7/19
SAIGONLAB 83 Nguyn Th Nh, P9, Q.Tn Bnh, Tp. HCM LPI 102
System Information
Login Prompts
Greeting message when login locally contain in/etc/issue
Greeting message when login remotely contain in
/etc/issue.netSome simple in /etc/issue and /etc/issue.net
%h :print node name
man issue more informaiton
8/9/2019 Ch03 Administration Utility
8/19
SAIGONLAB 83 Nguyn Th Nh, P9, Q.Tn Bnh, Tp. HCM LPI 102
Finding Files
The find command: locate files using specified searchcriteria:find directory search_criteria.. Action
Directory: where we will search from
search_criteria:
-name name find only files called name
-user name find only files owned by user name
-type letter find files of specified type:f, d, etc..
action:
-print print filename found-exec and {} \; executes given command
-ok and cmd {} \; executes command but prompts forconfirmation
8/9/2019 Ch03 Administration Utility
9/19
SAIGONLAB 83 Nguyn Th Nh, P9, Q.Tn Bnh, Tp. HCM LPI 102
Finding Files
The locate commandeg:$locate /etc/dhcpoutpout: /etc/dhcpd.conf
which command
eg:$which findoutput:/usr/bin/find
whereis commandeg:$whereis findoutput:/usr/bin/find /usr/share/man/man1/find.1.gz
8/9/2019 Ch03 Administration Utility
10/19
SAIGONLAB 83 Nguyn Th Nh, P9, Q.Tn Bnh, Tp. HCM LPI 102
File Command
Interpreting files: file command identify the contents ofany file on the linux system.
The file /usr/share/magic (/etc/magic) contain magicnumbers used to determine the contents of the files
recognized bye the file commandeg:
$file *
feed.dat: ASCII text
myproc.c C source coderunsys: command text
8/9/2019 Ch03 Administration Utility
11/19
SAIGONLAB 83 Nguyn Th Nh, P9, Q.Tn Bnh, Tp. HCM LPI 102
Text Processing
The grep familygrep command:
syntax: grep [option] pattern [files]options:
-v Output nonmatched lines
-c Output count of lines matched
-I ignore lower/upper case
-n mark each matched line with its relative line number
Other version of grep: fgrep, egrep(using man moreinformation).
8/9/2019 Ch03 Administration Utility
12/19
SAIGONLAB 83 Nguyn Th Nh, P9, Q.Tn Bnh, Tp. HCM LPI 102
Text Processing
Regular Expressions
Two forms: Basic(grep) and extended (egrep)
Can match literal strings
Beware of meta characters!
Special syntax:
bracket expressions: [^0123456789]
special ranges: [:digit:]
wildcards: * ? + {1,3}
8/9/2019 Ch03 Administration Utility
13/19
SAIGONLAB 83 Nguyn Th Nh, P9, Q.Tn Bnh, Tp. HCM LPI 102
Text Processing
Filter: many utilities read from stdin, process it in someway and output their result to stdout.
Some program: cat, head, tail, wcEg:
$
cat /etc/passwd$tail /etc/passwd$wc l /etc/passwd
Sed: allow automatic editing of text filessed s/lpi/lpi2/g lpi1.doc >lpi2.doc
8/9/2019 Ch03 Administration Utility
14/19
SAIGONLAB 83 Nguyn Th Nh, P9, Q.Tn Bnh, Tp. HCM LPI 102
Scheduling Processes
at command: execute commands at a specified time.syntax: - Commands are read from stdin- Stdout and stderr are mailed to user
- Stdin is redirected from /dev/null- The job inherits current environmentCommands are run using the users shellUsef filename to have at read from a file rather than
stdineg: $at 8:00 tomorrow
echo Meeting at 9:30 today^D
Some options of at command: -l, -r and atq, and atrm
command.
8/9/2019 Ch03 Administration Utility
15/19
SAIGONLAB 83 Nguyn Th Nh, P9, Q.Tn Bnh, Tp. HCM LPI 102
Scheduling Processes
The crontab command: run jobs at periodic intervals.
Syntax:
Space/tab separated columns
Specify comma-separated list or range of values
Field in cron table specify:
The users crontab files usually live under /var/cron/tabsor /var/spool/cron
8/9/2019 Ch03 Administration Utility
16/19
SAIGONLAB 83 Nguyn Th Nh, P9, Q.Tn Bnh, Tp. HCM LPI 102
Scheduling Processes
crontab l [user]: list table cron table of user
Crontab e [user]: edit the cron table of user
If without user parameter, cron affect with current user.
Only super user can change crontab belong to other users.
An asterisk(*) in any of time fields mean all possible valuesfor this field.
8/9/2019 Ch03 Administration Utility
17/19
SAIGONLAB 83 Nguyn Th Nh, P9, Q.Tn Bnh, Tp. HCM LPI 102
Scheduling Processes
Administering at and crontab: control and configurationfiles kept in /etc
at.allow users allowed to use at
at.deny users denied use of at(only used if no
at.allow)cron.allow users allowed to use cron
cron.deny users denied use of cron
crontab system cron table
Only root can use system cron table.
*.deny check if *.allow not exists.
*.deny empty and *.allow not exists:Permit all users access
to the utility.
8/9/2019 Ch03 Administration Utility
18/19
SAIGONLAB 83 Nguyn Th Nh, P9, Q.Tn Bnh, Tp. HCM LPI 102
Scheduling Processes
Anacron: like cron, be designed for systems not running alltime.
Syntax:
Man anacron get more information
8/9/2019 Ch03 Administration Utility
19/19
SAIGONLAB 83 Nguyn Th Nh, P9, Q.Tn Bnh, Tp. HCM LPI 102
Summary
Demonstrate how to communicate with users
Identify system defaults
Demonstrate how to find files
Identify and use different text processing utilities such asgrep and sed
Explain process scheduling and process accounting