Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword
Like this
1Activity
0 of .
Results for:
No results containing your search query
P. 1
Unix Commands[1]

Unix Commands[1]

Ratings: (0)|Views: 14|Likes:
Published by Sandeep Chilukuri
UC
UC

More info:

Published by: Sandeep Chilukuri on Nov 03, 2012
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

09/24/2013

pdf

text

original

 
UNIX Command Cheat Sheets 
 ©2001 TechRepublic, Inc. www.techrepublic.com. All rights reserved.
 1
www.techrepublic.com
UNIX Command Cheat Sheets
 
Command Description (short) Example Explanation
date Writes the current date to the screen date Mon Nov 20 18:25:37 EST 2000sort
infile
Sorts the contents of the input file inalphabetical ordersort
names
Sorts the contents of 
names
inalphabetical orderwho Tells you who is logged onto your server who Nonewho am I Tells you your user information who am iwhoamiNoneclear Clears the window and the line buffer clear Noneecho
whatever I type
Writes
whatever I type
to the screen. echo
hey you!
Writes
hey you!
to the screenbanner
big words
Does the same thing as echo only in BIGwordsbanner
hey!
Writes
hey!
in large letters on thescreencat
file1 file2 file3
Shows the three files in consecutive orderas one document (can be used to combinefiles)cat
cheese milk
This prints the
cheese
file to thescreen first and immediatelyfollows it with the
milk
file.df 
system
Reports the number of free disk blocks df 
~
 df 
$HOME
 Both commands will print thetotal kb space, kb used, kbavailable, and %used on the homesystem (your system).head
file
Prints the first 10 lines of the file to thescreenhead
addresses
Prints the first 10 lines of 
addresses
to the screenNumber of lines can be modified head -25
addresses
Prints the first 25 lines of 
addresses
to the screentail
file
Prints the last 10 lines of the file to thescreentail
test.txt
Prints the last 10 lines of 
test.txt
 to the screenNumber of lines can be modified here,tootail -32
test.txt
Prints the last 32 lines of 
test.txt
 to the screenmore
input
This prints to screen whatever is input—useful because it only shows one screen ata time.more
groceries
This will list the
groceries
file tothe screen.
scroll bar 
continues to the next screen
return
moves one line forward
Q
quitsG goes to the end1G goes to the beginningCtrl u moves up ½ screenCtrl d moves down ½ screen
 
UNIX Command Cheat Sheets 
 ©2001 TechRepublic, Inc. www.techrepublic.com. All rights reserved.
 2
www.techrepublic.com
Command Description (short) Example Explanation
ls (-
option
-optional) Lists all the nonhidden files and directories ls Lists all nonhidden files anddirectories in the current
 
directoryls
bin
Lists all nonhidden files anddirectories in the
bin
directoryls -l or ll Lists all nonhidden files and directories inlong formatls -lllLists all nonhidden files anddirectories in the current directory inlong formatls -l
work
 ll
work
 Lists all nonhidden files anddirectories in the
work
directory inlong formatls -a Lists all files and directories includinghidden onesls -a Lists all files and directories,including hidden, in the currentdirectoryls -a
temp
Lists all files and directories in the
temp
directory.ls -r Lists all files and directories in reversealphabetical orderls -r Lists all nonhidden files anddirectories in the current directory inreverse alphabetical orderls -r
abc
Lists all nonhidden files anddirectories in the
abc
directory inreverse alphabetical orderls -t Lists all nonhidden files in the order theywere last modifiedls -t Lists all the nonhidden files in thecurrent directory in the order theywere last modified from most recent tolastls -t
work
Lists all the nonhidden files in the
work
directory in the order they werelast modified from most recent to last
 NOTE: Options can be combined using lsls -al Lists all files (including hidden (-a))in long format (-l)Important Characters
 |>>>&~<“pipe” directs the output of the firstcommand to the input of another.Sends the output of a command to adesignated fileAppends the output of a command to adesignated fileRuns command in the background; youcan still work in the windowDesignates the home directory($HOME)Designates input from somewhere otherthan terminalls -l | morels -l >
myfiles
 ls -l >>
allfiles
 xclock &echo ~progA <
input1
 Lists your files in long format onescreen at a timePrints your listing to a file named
myfiles
 Appends your filenames to the end of the
allfiles
fileRuns xclock (a clock) allowing you tokeep workingWrites your home directory to thescreenprogA program gets its input from afile named
input1
 
Wildcards
 *?[ ]
 
UNIX has a set of wildcards that it accepts.Any string of charactersAny one characterMatch any character in the brackets (ahyphen is used for ranges of characters)ls *
.c
 ls
file
?ls
v
[6-9]
file
 Lists any file or directory (nonhidden)ending with
c
 Lists any file/directory with
file
and 1character at the endLists
v6file, v7file, v8file,
and
v9file
 
 
UNIX Command Cheat Sheets 
 ©2001 TechRepublic, Inc. www.techrepublic.com. All rights reserved.
 3
www.techrepublic.com
Command Description (short) Example Explanation
cd
directory
Changes your current directory to the directoryspecifiedcd
bin
Changes directory to the
bin
 directorycd ..cd ../..Moves you to the directory thatcontains the directory you arecurrently inEx. Currentdirectory=/home/users/bob/binexecute cd ..New directory= /home/users/bob
or
executing cd ../..New directory= /home/users.cd - Moves you to the directory you just came fromcd ~cdBoth move you to your homedirectory (the directory you startfrom initially)mkdir
dirname
Creates a directory mkdir
 junk
Makes a directory named
 junk
inyour current directoryYou can also designate where the directory is toreside.mkdir ~/ 
left
Makes a directory in your homedirectory named
left
 rm
file1 file2 file3
Removes (deletes) file(s) rm
xyz
Deletes a file named
xyz
 rm
xyz abc
Deletes the files named
xyz
and
abc
 rm * Deletes everything nonhiddenrm -i
file1 file2
Prompts before deletion of files
*******
USE -i AT FIRST
*******
 rm -i * Prompts at each nonhidden fileand lets you decide whether ornot to delete itrm -f 
file1 file2
Forces deletion without prompt regardless of permissionsrm -f 
program
Removes the file
program
 without regard to permissions,status, etc.rm -r
directory
 rm -R
directory
 Remove a directory along with anything inside of itrm -r
bin
 rm -R
bin
 Each of these will remove the
bin
 directory and everything inside of it.rmdir
directory
Removes a directory like rm -r does if thedirectory is emptyrmdir
bin
Removes the
bin
directory if it isempty
****dangerous****
 rm -fR
name
 rm -Rf 
name
 This combination will force the removal of any file and any directory including anythinginside of itrm -Rf 
c_ya
Forces removal without promptsof the
c_ya
directory andanything inside of itrm -Ri
directory
Deletes the contents of a directory and thedirectory if it is empty by prompting the userbefore each deletionrm -Ri
rusure
Deletes anything in the directorycalled
rusure
that you verify atthe prompt, and if you removeeverything in the directory, youwill be prompted whether youwant to remove the directoryitself or not
NOTE: Options can be combined using rm
rmdir -p
directory
Removes a directory and any empty parentdirectories above it (-pi does the samething but it prompts before each removal)rmdir -p
 /home/bin/dir1
Deletes the
dir1
directory; if 
bin
 directory is empty, it is deleted,and if 
home
directory is empty itis also deleted

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->