Unix Commands
Unix Commands
Description (short)
Example
Explanation
date
date
sort infile
sort names
who
who
None
who am I
who am i
whoami
None
clear
clear
None
banner hey!
df system
df ~
df $HOME
head file
head addresses
tail test.txt
more groceries
tail file
more input
Page 1
Copyright 2004 CNET Networks, Inc. All rights reserved.
To see more downloads and get your free TechRepublic membership, please visit
http://techrepublic.com.com/2001-6240-0.html.
Command
ls (-option-optional)
Description (short)
Lists all the nonhidden files and directories
Example
ls
ls bin
ls -l
or
ll
ls -a
ls -l
ll
ls -l work
ll work
ls -a
ls -a temp
ls -r
ls -r
ls -r abc
ls -t
ls -t
ls -t work
<
Wildcards
ls -al
ls -l | more
ls -l > myfiles
ls -l >> allfiles
xclock &
echo ~
ls *.c
ls file?
ls v[6-9]file
[ ]
Explanation
Lists all nonhidden files and directories in
the current directory
Lists all nonhidden files and directories in
the bin directory
Lists all nonhidden files and directories in
the current directory in long format
Lists all nonhidden files and directories in
the work directory in long format
Lists all files and directories, including
hidden, in the current directory
Lists all files and directories in the temp
directory.
Lists all nonhidden files and directories in
the current directory in reverse
alphabetical order
Lists all nonhidden files and directories in
the abc directory in reverse alphabetical
order
Lists all the nonhidden files in the current
directory in the order they were last
modified from most recent to last
Lists all the nonhidden files in the work
directory in the order they were last
modified from most recent to last
Lists all files (including hidden (-a)) in
long format (-l)
Page 2
Copyright 2004 CNET Networks, Inc. All rights reserved.
To see more downloads and get your free TechRepublic membership, please visit
http://techrepublic.com.com/2001-6240-0.html.
Command
cd directory
Description (short)
Example
cd bin
cd ..
cd ../..
cd cd ~
cd
mkdir dirname
Creates a directory
mkdir junk
mkdir ~/left
rm -i file1 file2
rm xyz
rm xyz abc
rm *
rm -i *
rm -f file1 file2
rm -r directory
rm -R directory
rmdir directory
****dangerous****
rm -fR name
rm -Rf name
rm -Ri directory
rm -f program
rm -r bin
rm -R bin
rmdir bin
rm -Rf c_ya
rm -Ri rusure
Explanation
Changes directory to the bin
directory
Moves you to the directory that
contains the directory you are currently
in
Ex. Current
directory=/home/users/bob/bin
execute cd ..
New directory= /home/users/bob
or executing cd ../..
New directory= /home/users.
Moves you to the directory you just
came from
Both move you to your home
directory (the directory you start from
initially)
Makes a directory named junk in
your current directory
Makes a directory in your home
directory named left
Deletes a file named xyz
Deletes the files named xyz and abc
Deletes everything nonhidden
Prompts at each nonhidden file and
lets you decide whether or not to
delete it
Removes the file program without
regard to permissions, status, etc.
Each of these will remove the bin
directory and everything inside of it.
Removes the bin directory if it is
empty
Forces removal without prompts of
the c_ya directory and anything
inside of it
Deletes anything in the directory
called rusure that you verify at the
prompt, and if you remove everything
in the directory, you will be prompted
whether you want to remove the
directory itself or not
rmdir -p /home/bin/dir1
Page 3
Copyright 2004 CNET Networks, Inc. All rights reserved.
To see more downloads and get your free TechRepublic membership, please visit
http://techrepublic.com.com/2001-6240-0.html.
Command
cp file1 newname
Description (short)
Copies a file (file1) and names the
copy the new name (newname)
Example
cp old new
cp file dir2/
cp ../dir1/* .
cp -p name target
cp -p execut1 execut2
cp -R directory target
cp -R old/ junk/
cp -f name target
mv initial final
none
mv temp script_1
Explanation
Makes a copy of the file/directory
named old and names the copy new,
all within the current directory
NOTE: If you copy a file to a newfile
name and newfile already exists, the
newfile contents will be overwritten.
Places a copy of file in dir2/ and it
retains its original name
Copies everything from the dir1
directory located just below where you
currently are and places the copy
here ( . ) in your current directory
Copies execut1 executable file and
calls the copy execut2, which also has
executable permissions
Makes a copy of the directory named
old and names the directory copy junk
No example or description needed
Renames the file (or directory) temp to
the name script_1 in the current
directory
Moves the script.exe file to the bin
directory that is in the home (~) parent
directory and it keeps its initial name
Moves both script_1 and script.exe to
the bin directory
mv script.exe ~/bin
pwd
pwd
pr (option) filename
pr userlist
pr +k filename
pr +5 userlist
pr -k filename
Prints in k columns
pr -2 userlist
pr -a filename
pr -3a userlist1
pr -d filename
pr -h header filename
pr -d userlist
pr -h users userlist
Page 4
Copyright 2004 CNET Networks, Inc. All rights reserved.
To see more downloads and get your free TechRepublic membership, please visit
http://techrepublic.com.com/2001-6240-0.html.
Command
Description (short)
Example
lpconfig prntr1 bobprt
lpconfig -r queue
lpconfig -r bobprt
lpconfig -d queue
lpconfig -d vpprnt
lpstat (-options)
lpstat
lpstat -ubob
lpstat s
lpstat -t
lpstat -d
lpstat -r
lp (-option) file(s)
lp -ddest file(s)
lp -nnumber file(s)
lp -ttitle file(s)
lp -ooption file(s)
Explanation
Configures a printer named prntr1
to accept print requests from a local
queue named bobprt
Removes bobprt queue from the
local system if the person removing
the queue is the owner or root
Makes vpprnt the default print queue
none
none
none
None
None
none
None
lp junkfile
lp -dbobsq zoom
lp -n5 crash
lp -od output
lp -tBobs cash
lp -obold output
lp -ohalf output
lp -oquarter output
lp -olandscape output
lp -oportrait output
cancel 5438
cancel -a bobsprt
cancel -u bob
Page 5
Copyright 2004 CNET Networks, Inc. All rights reserved.
To see more downloads and get your free TechRepublic membership, please visit
http://techrepublic.com.com/2001-6240-0.html.
Command
ps
Description (short)
Example
Explanation
ps
ps -f
ps -f
ps -u user_id
ps -u bob
ps -ef
ps -ef
kill process_id
kill -9 process_id
kill 6969
kill -9 6969
grep -i hi file1
ps -e
ps -e
Page 6
Copyright 2004 CNET Networks, Inc. All rights reserved.
To see more downloads and get your free TechRepublic membership, please visit
http://techrepublic.com.com/2001-6240-0.html.
Command
Description (short)
Example
Explanation
vuepad filename
none
None
vi filename
none
None
emacs filename
none
None
compress filename
uncompress filename
none
none
None
None
awk
none
None
eval `resize`
none
None
chexp # filename
qstat
qstat
qstat -a
qstat -l
qstat -m
qstat -u bob
qstat -x
xterm
xterm -option
xterm +option
xterm -help
xterm
xterm -help
Page 7
Copyright 2004 CNET Networks, Inc. All rights reserved.
To see more downloads and get your free TechRepublic membership, please visit
http://techrepublic.com.com/2001-6240-0.html.
Command
xterm -e program
xterm -sb
Description (short)
Example
xterm -e myprog.exe
xterm -sb
(Explanation)
This opens an xterm window and
executes the program myprog.exe
from that window so that you may
still work in your present window.
Puts a scroll bar on the right side of
the page for reviewing past lines in
the window
NOTE: When clicking in the scroll
bar, the left button scrolls down, the
right scrolls up, and the middle
snaps the scroll bar to the mouse
position for dragging up and down.
The xterm will save 1,000 lines of
work once it has moved off the
immediate viewing area; it can be
accessed using the scroll bar.
The first command will open a
window 80 pixels wide by 80 pixels
tall and position its top left-hand
corner at 0 pixels to the right of the
left edge and 50 pixels down from
the top of the screen.
Page 8
Copyright 2004 CNET Networks, Inc. All rights reserved.
To see more downloads and get your free TechRepublic membership, please visit
http://techrepublic.com.com/2001-6240-0.html.
Page 9
Copyright 2004 CNET Networks, Inc. All rights reserved.
To see more downloads and get your free TechRepublic membership, please visit
http://techrepublic.com.com/2001-6240-0.html.
Downloads:
50 essential Excel tips
Indispensable tips for Word users
Virus basics PowerPoint presentation
Sockets networking chapter from UNIX Network Programming: The Sockets Networking API, Vol.
1, Third Edition
Page 10
Copyright 2004 CNET Networks, Inc. All rights reserved.
To see more downloads and get your free TechRepublic membership, please visit
http://techrepublic.com.com/2001-6240-0.html.
TechRepublic:
The collective voice of IT professionals
TechRepublic communities engage IT professionals in the ultimate peer-to-peer experience, providing
actionable information, tools, and services to help members get their jobs done. TechRepublic serves the
needs of the professionals representing all segments of the IT industry, offering information and tools for
IT decision support and professional advice by job function.
CIO Republic: Get analysis and insight on e-business, leadership, executive careers, business strategy,
and technology.
IT Manager Republic: Access technology insights, project and personnel management tips, and training
resources.
NetAdmin Republic: Get tips on Windows, NetWare and Linux/UNIX administration, infrastructure
design, and network security.
Support Republic: Obtain detailed solutions to desktop hardware, software, and end-user support
problems.
IT Consultant Republic: Find information and advice on client and vendor relations, project
management, and technology.
Page 11
Copyright 2004 CNET Networks, Inc. All rights reserved.
To see more downloads and get your free TechRepublic membership, please visit
http://techrepublic.com.com/2001-6240-0.html.