You are on page 1of 1

Linux Command Syntax Reference Poster

Administrator Commands File Permission Commands


Shutdown and restart server … reboot shutdown -r now chmod ogw filename chmod 744 /etc/passwd
Kill all processes using pattern xxx pkill [-9] “xxx” Owner Group World Meaning
Kill all processes for user xxx pkill [-9] -u xxx 7 7 7 Read + Write + execute
Show swap space usage by device swapon -s 6 6 6 Read + Write
Show Linux syslog errors tail /var/log/messages 5 5 5 Read + execute
Kill a stubborn process kill –9 pid# 4 4 4 read only
See shared memory segments ipcs -m 3 3 3 Write + execute
Remove shared memory segment xxxx ipcrm –m xxxx 2 2 2 write only
Show processes with CPU and MEM usage ps aux 1 1 1 Execute only
Show Linux system parms (root) sysctl -a
Display most active processes top Permission Meaning
Watch active file writes (appends) tail –f filename -rw------- This file has read-write permissions for the file owner
Create Hex dump of file od –x filename -rw-r--r-- This file has read-write for the owner, read for group & world
Mail a set of files cat file1.tst file2.txt > mail –s “Daily Files” don@burleson.cc drwxr-xr-x Directory – Read-write-execute owner, read-execute group & world
Count of online users uptime -r-xr----- Read-execute for owner, read for group
Display users w -r-------- Read for owner
List process IDs for user xxx ps -u xxx -rw-rw-r-- Read-write for owner and group, read for world
Linux command history one screen at a time history | more
Show task dispatching priority ps lax | more File Commands
Create a complex alias alias alert='tail -200 filename.log | more' Mount a remote file system mount host:/hostpath /alias/pathname
Delete files > 20 days old find . –mtime +20 -exec rm {} \; Remount a lost file system mount –a
Remote file copy scp hostname:/file/name .
Security Commands Create a symbolic link to a file ln –s destination_name file_name
Show file space usage summary du –sk * |sort –n
Grant execute permission to all for *.ksh files chmod +x *.ksh Create an archive of a directory tar cvf file.tar directoryname
Allow the owner write and execute permission chmod u+wx * Extract from an archive tar xvf file.tar
See default settings for userx cat /etc/passwd|grep userx Find most recent file in directory ls -t|head
Display last 100 lines of file xxx tail -100 xxx|more
Search Commands Create a new file named xxx touch xxx
See most recent changed file ls –alc|head Rename file xxx to yyy mv xxx yyy
See most recent file touch ls –alt|head Prevent accidental file deletion … confirm alias rm='rm -i'
Search binary file for xxx string strings filename|grep xxx Linux File Locations
Find files < 3 days old find . –mtime –3 –print
User identification file /etc/passwd
Crontab Examples
Find files size > 10k find . –size +10 –print
System error log /var/log/messages #****************************************************************
Find strings in directory grep -ri string .
# This is a weekly task, Sunday at 7:30 AM
Find file columns with column 4=x or y egrep ‘^…(x|y)’ < inputfile
Find directory for file xxx in $PATH which xxx vi Commands #****************************************************************
30 7 * * 0 /home/analyze.ksh > /home/analyze.lst
Find process 999 ps u 999 Delete lines to EOF dG #****************************************************************
Read-in new file :r filename # This is the daily 1:00 PM task
Disk and Filesystem Commands Change all xxx to yyy <esc>:.,$s/xxx/yyy/g #****************************************************************
Save and exit <esc>:x 00 13 * * * /home/statspack/statspack_alert.ksh prodsid
Mount points for disk df –P
Find string xxx <esc>/xxx #****************************************************************
Show volume groups vgdisplay
Change word (from cursor) to yyy cw yyy <esc> # This task is scheduled every 2 minutes
Display disk usage of current mount point df -h .
Repeat last command . #****************************************************************
Repeat last find command / 1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,
CPU & RAM Commands 51,53,55,57,59 * * * * /home/trace_alert.ksh prodsid > /dev/null 2>&1
Display the number of CPUs cat /proc/cpuinfo|grep processor|wc –l Script Commands
Show top CPU% ps aux|sort -n +2|tail -1 Display command return code echo $? ISBN 0-9759135-8-1 ISBN: 0-9759135-8-1
Display top-10 CPU consumers ps aux|sort -rn +2|grep –v USER|head -10 Increment a counter count=`expr $count + 1`
50295> Price: $2.95
RAM memory display free Add two variables TOT=`expr $SYS + $USR`
Copyright © 2004
Date Display Commands Rampant Tech Press
All Rights Reserved
root> date "+DATE: %m/%d/%y%nTIME: %H:%M:%S" DATE: 09/04/01 TIME: 09:37:49 9 780975 913581

You might also like