+ All Categories
Transcript
Page 1: Linux Command Syntax Reference  Poster

Linux Command Syntax Reference PosterLinux Command Syntax Reference PosterLinux Command Syntax Reference PosterAdministrator CommandsAdministrator CommandsAdministrator CommandsShutdown and restart server … reboot shutdown -r nowKill all processes using pattern xxx pkill [-9] “xxx”Kill all processes for user xxx pkill [-9] -u xxxShow swap space usage by device swapon -sShow Linux syslog errors tail /var/log/messagesKill a stubborn process kill –9 pid#See shared memory segments ipcs -mRemove shared memory segment xxxx ipcrm –m xxxxShow processes with CPU and MEM usage ps auxShow Linux system parms (root) sysctl -aDisplay most active processes topWatch active file writes (appends) tail –f filenameCreate Hex dump of file od –x filenameMail a set of files cat file1.tst file2.txt > mail –s “Daily Files” [email protected] of online users uptime Display users wList process IDs for user xxx ps -u xxxLinux command history one screen at a time history | moreShow task dispatching priority ps lax | moreCreate a complex alias alias alert='tail -200 filename.log | more'Delete files > 20 days old find . –mtime +20 -exec rm {} \;

File CommandsFile CommandsFile CommandsMount a remote file system mount host:/hostpath /alias/pathnameRemount a lost file system mount –aRemote file copy scp hostname:/file/name .Create a symbolic link to a file ln –s destination_name file_nameShow file space usage summary du –sk * |sort –nCreate an archive of a directory tar cvf file.tar directorynameExtract from an archive tar xvf file.tarFind most recent file in directory ls -t|headDisplay last 100 lines of file xxx tail -100 xxx|moreCreate a new file named xxx touch xxxRename file xxx to yyy mv xxx yyyPrevent accidental file deletion … confirm alias rm='rm -i'

vi Commandsvi Commandsvi Commands

Search CommandsSearch CommandsSearch CommandsSee most recent changed file ls –alc|headSee most recent file touch ls –alt|headSearch binary file for xxx string strings filename|grep xxxFind files < 3 days old find . –mtime –3 –printFind files size > 10k find . –size +10 –printFind strings in directory grep -ri string .Find file columns with column 4=x or y egrep ‘^…(x|y)’ < inputfileFind directory for file xxx in $PATH which xxxFind process 999 ps u 999

Crontab ExamplesCrontab ExamplesCrontab Examples#****************************************************************# This is a weekly task, Sunday at 7:30 AM#****************************************************************30 7 * * 0 /home/analyze.ksh > /home/analyze.lst#****************************************************************# This is the daily 1:00 PM task#****************************************************************00 13 * * * /home/statspack/statspack_alert.ksh prodsid#****************************************************************# This task is scheduled every 2 minutes#****************************************************************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,51,53,55,57,59 * * * * /home/trace_alert.ksh prodsid > /dev/null 2>&1Script CommandsScript CommandsScript Commands

Display command return code echo $?Increment a counter count=`expr $count + 1` Add two variables TOT=`expr $SYS + $USR`

Security CommandsSecurity CommandsSecurity CommandsGrant execute permission to all for *.ksh files chmod +x *.kshAllow the owner write and execute permission chmod u+wx *See default settings for userx cat /etc/passwd|grep userx

Disk and Filesystem CommandsDisk and Filesystem CommandsDisk and Filesystem CommandsMount points for disk df –P Show volume groups vgdisplayDisplay disk usage of current mount point df -h .

Linux File LocationsLinux File LocationsLinux File LocationsUser identification file /etc/passwdSystem error log /var/log/messages

Date Display CommandsDate Display CommandsDate Display Commandsroot> date "+DATE: %m/%d/%y%nTIME: %H:%M:%S" DATE: 09/04/01 TIME: 09:37:49

File Permission CommandsFile Permission CommandsFile Permission Commandschmod ogw filename chmod 744 /etc/passwdOwner Group World Meaning7 7 7 Read + Write + execute6 6 6 Read + Write5 5 5 Read + execute4 4 4 read only3 3 3 Write + execute2 2 2 write only1 1 1 Execute onlyPermission Meaning-rw------- This file has read-write permissions for the file owner-rw-r--r-- This file has read-write for the owner, read for group & worlddrwxr-xr-x Directory – Read-write-execute owner, read-execute group & world-r-xr----- Read-execute for owner, read for group-r-------- Read for owner-rw-rw-r-- Read-write for owner and group, read for world

ISBN: 0-9759135-8-1Price: $2.95

Copyright © 2004Rampant Tech PressAll Rights Reserved

CPU & RAM CommandsCPU & RAM CommandsCPU & RAM CommandsDisplay the number of CPUs cat /proc/cpuinfo|grep processor|wc –lShow top CPU% ps aux|sort -n +2|tail -1Display top-10 CPU consumers ps aux|sort -rn +2|grep –v USER|head -10RAM memory display free

dG:r filename<esc>:.,$s/xxx/yyy/g<esc>:x<esc>/xxxcw yyy <esc>./

Delete lines to EOFRead-in new fileChange all xxx to yyySave and exitFind string xxxChange word (from cursor) to yyyRepeat last commandRepeat last find command

7809759 913581

ISBN 0-9759135-8-150295>

Top Related