+ All Categories
Home > Documents > Linux Command Syntax Reference Poster

Linux Command Syntax Reference Poster

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

Recommended