Essential Administrative Tools - Michigan Technological University

Essential Administrative Tools

Use command man Piping into grep

r The grep command searches its input for lines containing a given pattern.

r The grep is commonly used to search files r Use grep with pipe is very useful

? Example: find out about a process owned by one certain user $ps ?ef | grep chavez $ps ?aux | grep chavez $ps ?aux | egrep `chavez|PID' $alias pu "ps ?aux | egrep `\!:1|PID" $ pu chavez

Administrative tools 1-1

Essential Administrative Tools

Piping into awk

r Manipulate the output of another command r Picking out the columns

Example: ? List the users that run dooms.

$ps ?ef | grep "[d]oom" | awk `{print $1}' $ps ?ef | grep doom| grep ?v grep | awk `{print $1}' ? Create a file to store the users that run dooms, include the data cpu time $ (date ; ps ?ef | grep "[d]oom" | awk `{print $1 " [ " $7

"]" }' | sort | uniq) >> doomed.users

Administrative tools 1-2

Essential Administrative Tools

Piping into awk

r Sum up a column of numbers

Example: search files owned by chavez and calculate the total size.

#find . -user chavez ?ls ?fstype 4.2| awk `{sum+=$7}; END {print "User chavez total disk use =" sum}'

r Generate a filename with current date, such as 24Oct2004.icu4.sysdoc

? $ sys_doc > `date | awk `{print $3 $2 $6}' `.`hostname`.sysdoc

Or on some systems date has the function ? $ date +report_%d%b%y%H%M%S.output

will be report_17Jan05223305.output

Administrative tools 1-3

Essential Administrative Tools

Finding files: find

r Find locates files having certain characteristics on where you tell it to look.

r Basic syntax

#find starting-dir(s) criteria-and-action

r Matching criteria r Action

? What to do with the files matches all the criteria

Administrative tools 1-4

Essential Administrative Tools

-atime n -mtime n -newer file -size n -type c -name nam -perm p -user usr -group grp -nouser

-nogroup

File was last accessed n days ago File was last modified exactly n days ago

File was modified more recently than file was File is exactly n 512-byte blocks long Specifies file typeL f, d The filename is nam The file's access mode is p The file's owner is usr The file's group owner is grp The file's owner is not listed in the password file The file's group owner is not listed in the group file

Administrative tools 1-5

................
................

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

Google Online Preview   Download