View
238
Download
0
Category
Preview:
DESCRIPTION
Unix Linux Commands
Citation preview
Append
UNIX/
UNIX will be usesimilar. In essenceAIX, and others. source code is opwill be provideduse is increasing
When workinGUI interface (pimand line (variousystem not a line will be preseintuitive. Many son their machinecommand line (m
At the commaencounter, depenThe prompts youthe system ownecommands/configare others, the mo
Korn ShellBourne ShC Shell Pro
AU2768_book.fm Page 217 Tuesday, November 16, 2004 2:17 PM
Copyright 2005 CRC Press Lix D
Linux Commands
d to mean both UNIX and Linux, since they are very, Linux is another flavor of UNIX, similar to Solaris,
A great benefit of Linux is that it is open-source (theen for all to see). A UNIX system command reference since it has been widely used for decades and itsglobally.g on a UNIX system, you could encounter either actures/icons/words to point and click on) or a com-s UNIX commands must be typed to work with the
point-and-click operation). Working at the commandnted since the GUI is much easier to use and more
killed UNIX personnel do not have a GUI interface because they much prefer to type commands at theore powerful and versatile and more difficult).nd line, there are various prompts that you couldding on how the owner has configured the system. see are indicative of the type of shell (environment)r is using. The shell allows the user to use a fewurations that are peculiar to that shell. Although therest common prompts/shells you will come across are:
Prompt $ell Prompt $mpt %LC
Although there are many UNIX commands, I will cover those that aremost useful to an investigator and make extensive use of examples toshow how a comFTP commands:
? commandclose, discoUNIX comdelete filenget file1 [fihelphelp commlcd /usr/cemdelete filmget filenamkdir diremput filenaput file1 [fipwdrmdir direcrcv file1 [firemotehelprename filesend file1
AU2768_book.fm Page 218 Tuesday, November 16, 2004 2:17 PM
Copyright 2005 CRC Press L
Dow
nloa
ded
by [U
nivers
idade
Esta
dual
de C
ampin
as -
UNIC
AMP (
CRUE
SP)]
at 09
:13 07
July
2015
mand is most commonly used.
nnect, bye, quitmands such as cd, ls, etc.amele2]
andll_one/log (changes to local machine directory)ename(s).me(S)ctoryme(s)le2]
toryle2] (retrieve from remote). command1 file2[file2]
LC
UNIX Command Explanation Example End Result
date Writes the current date to the screen date Mon Nov 20 18:25:37 EST 2000sort
infile
f
names
in
whowho am Iclearecho
whateverI type
he screen
banner
big words
letters on the
cat
file1 file2 file3
to the screen first llows it with the
df
system
l print the total kb available, and e system (your
head
file
es of
addresses
to
es of
addresses
to
tail
file
es of
test.txt
to the
es of
test.txt
to the
AU
2768_book.fm Page 219 T
uesday, Novem
ber 16, 2004 2:17 PM
Copyright 2005 CRC Press LDo
w
n
l
o
a
d
e
d
b
y
[
U
n
i
v
e
r
s
i
d
a
d
e
E
s
t
a
d
u
a
l
d
e
C
a
m
p
i
n
a
s
-
U
N
I
C
A
M
P
(
C
R
U
E
S
P
)
]
a
t
0
9
:
1
3
0
7
J
u
l
y
2
0
1
5
Sorts the contents of the input file in alphabetical order
sort names Sorts the contents oalphabetical order
Tells who is logged onto your server whoTells you your user information who am iClears the window and the line buffer clearWrites whatever I type to the screen echo hey you! Writes hey you! to t
Does the same thing as echo only in BIG words
banner hey! Writes hey! in largescreen
Shows the three files in consecutive order as one document (can be used to combine files)
cat cheese milk Prints the cheese fileand immediately fomilk file
Reports the number of free disk blocks df ~df $HOME
Both commands wilspace, kb used, kb%used on the homsystem)
Prints the first 10 lines of the file to the screen
head addresses Prints the first 10 linthe screen
Number of lines can be modified head -25 addresses
Prints the first 25 linthe screen
Prints the last 10 lines of the file to the screen
tail test.txt Prints the last 10 linscreen
Number of lines can be modified tail -32 test.txt Prints the last 32 linscreen
LC
UNIX Command Explanation Example End Result
more
input
Prints to screen whatever is input more
groceries
Will list the
groceries
file to the screen
ls (-
option
-optional)
n files and directories
rectory
n files and directories
ls -l or ll n files and directories rectory in
n files and directories
tory in long formatls -a irectories, including
rrent directory
directories in the
AU
2768_book.fm Page 220 T
uesday, Novem
ber 16, 2004 2:17 PM
Copyright 2005 CRC Press LDo
w
n
l
o
a
d
e
d
b
y
[
U
n
i
v
e
r
s
i
d
a
d
e
E
s
t
a
d
u
a
l
d
e
C
a
m
p
i
n
a
s
-
U
N
I
C
A
M
P
(
C
R
U
E
S
P
)
]
a
t
0
9
:
1
3
0
7
J
u
l
y
2
0
1
5
useful because it only shows one screen at a time
scroll bar continues to the next screenreturn moves one line forwardQ quitsG goes to the end1G goes to the beginningCtrl u moves up _ screenCtrl d moves down _ screenLists all the nonhidden files and directories
ls Lists all nonhiddein the current di
ls bin Lists all nonhiddein thebin directory
Lists all nonhidden files and directories in long format
ls -lll
Lists all nonhiddein the current dilong format
ls -l workll work
Lists all nonhiddein the work direc
Lists all files and directories including hidden ones
ls -a Lists all files and dhidden, in the cu
ls -a temp Lists all files and temp directory
LC
ls -r Lists all files and directories in reverse alphabetical order
ls -r Lists all nonhidden files and directories in the current directory in reverse alphabetical order
ls -r
abc
Lists all nonhidden files and directories
abc
directory in reverse etical order
ls -t the nonhidden files in the t directory in the order they ast modified from most recent
the nonhidden files in the
work
ry in the order they were last
ed from most recent to last
Note:
Options can
files (including hidden (-a)) in rmat (-l)
| ur files in long format one at a time
>
our listing to a file named
>>
s your filenames to the end of
files
file& lock (a clock) allowing you to
orking
AU
2768_book.fm Page 221 T
uesday, Novem
ber 16, 2004 2:17 PM
Copyright 2005 CRC Press LDo
w
n
l
o
a
d
e
d
b
y
[
U
n
i
v
e
r
s
i
d
a
d
e
E
s
t
a
d
u
a
l
d
e
C
a
m
p
i
n
a
s
-
U
N
I
C
A
M
P
(
C
R
U
E
S
P
)
]
a
t
0
9
:
1
3
0
7
J
u
l
y
2
0
1
5
in the alphab
Lists all nonhidden files in the order they were last modified
ls -t Lists allcurrenwere lto last
ls -t work Lists all directomodifi
be combined using ls. ls -al Lists all long fo
pipe directs the output of the first command to the input of another
ls -l | more Lists yoscreen
Sends the output of a command to a designated file
ls -l > myfiles Prints ymyfiles
Appends the output of a command to a designated file
ls -l >> allfiles Appendthe all
Runs command in the background; you can still work in the window
xclock & Runs xckeep w
LC
ImportantCharacters Explanation Example End Result
~ Designates the home directory ($HOME)
echo ~ Writes your home directory to the screen
mymonth
Searches the file insensitive matchthe matching linmymonth
Description Example Explanation
Opens filename for editing/viewing in the vuepad editor
none None
Text editor that exists on every UNIX system in the world
none None
Another text editor none NoneCompresses the file to save disk space none None
LC
uncompress filename
Expands a compressed file none None
awk UNIX programming language none None
Command
eval `resize`
chexp # filename
omputer from starting with nr for 1
ose name starts with r be deleted (infinite)
qstat of the requests invoker of the rint request-name, ner, relative request
uest state (is it
s long format medium-length
sts belonging to the
hown in an extended
AU
2768_book.fm Page 231 T
uesday, Novem
ber 16, 2004 2:17 PM
Copyright 2005 CRC Press LDo
w
n
l
o
a
d
e
d
b
y
[
U
n
i
v
e
r
s
i
d
a
d
e
E
s
t
a
d
u
a
l
d
e
C
a
m
p
i
n
a
s
-
U
N
I
C
A
M
P
(
C
R
U
E
S
P
)
]
a
t
0
9
:
1
3
0
7
J
u
l
y
2
0
1
5
Description Example Explanation
Tells the target computer that the window has been resized during telnet
none None
Keeps the file(s) from expiring (being erased) on the target computer for # days
chexp365 nr*
Keeps the target cdeleting all files year (365 days)
chexp 4095 nr* Makes all files whnr never expire o
Displays the status of a process that has been submitted the Network Queuing System (basically a batch job)
qstat Shows the status submitted by thecommand will prequest-id, the owpriority, and reqrunning yet?)
qstat -a Shows all requestqstat -l Shows requests inqstat -m Shows requests in
formatqstat -u bob Shows only reque
user bobqstat -x Queue header is s
format
LC
Command Description Example Explanation
xterm Opens a new window(x-terminal) for you
xterm This opens another window like the one you are currently working in.
xterm -optionxterm +optionNote: Using xtermstrongly recomm
xterm -help s availablexterm -e program
indow and executes rog.exe from that ou may still work in dow
xterm -sb n the right side of the ng past lines in the
Note: When clickscrolls down, thethe scroll bar to tdown.
xterm -sl number
00 lines of work once the immediate an be accessed using
AU
2768_book.fm Page 232 T
uesday, Novem
ber 16, 2004 2:17 PM
Copyright 2005 CRC Press LDo
w
n
l
o
a
d
e
d
b
y
[
U
n
i
v
e
r
s
i
d
a
d
e
E
s
t
a
d
u
a
l
d
e
C
a
m
p
i
n
a
s
-
U
N
I
C
A
M
P
(
C
R
U
E
S
P
)
]
a
t
0
9
:
1
3
0
7
J
u
l
y
2
0
1
5
to work-option sets the option+option resets the option to default will eliminate desktop clutter. I end learning to use it in your scripts.Displays the xterm options xterm -help Shows the optionExecutes the listed program in the new xterm window; when the program is finished, the new xterm window goes away
xterm -e myprog.exe
Opens an xterm wthe program mypwindow so that yyour present win
Opens an xterm that saves a set number of lines when they go off the top of the page and makes them accessible with a scroll bar
xterm -sb Puts a scroll bar opage for reviewiwindow
ing in the scroll bar, the left button right scrolls up, and the middle snaps he mouse position for dragging up and
Specifies the number of lines to be saved once they go off the top of the screen (default is 64)
xterm -sl 1000 xterm will save 10it has moved offviewing area; it cthe scroll bar
LC
xterm -geom xxy+px+py
Option allows you to specify the size x pixels by y pixels and placement position x by position y of the new window when it opens
xterm -geom 80x80+0+50
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
m the top of the
Note: The size of position, so if yoscreen, it will po
ill open a window 35 pixels tall and t-hand corner 300 edge and 500 pixs
. will make a 5 by 5
ion its topt the top left-hand en.promise size when
xterm -title label
ndow with the title whatever follows
xterm -(areas) color lor
AU
2768_book.fm Page 233 T
uesday, Novem
ber 16, 2004 2:17 PM
Copyright 2005 CRC Press LDo
w
n
l
o
a
d
e
d
b
y
[
U
n
i
v
e
r
s
i
d
a
d
e
E
s
t
a
d
u
a
l
d
e
C
a
m
p
i
n
a
s
-
U
N
I
C
A
M
P
(
C
R
U
E
S
P
)
]
a
t
0
9
:
1
3
0
7
J
u
l
y
2
0
1
5
Position +0+0 is the top left-hand corner of the screen; and the bottom right is approx. +1200+1000 depending on the resolution
50 pixels down froscreen
the window takes precedence over u position it too close to the side of the sition at the edge with the correct size.
xterm -geom 10x35+300+500
Second command w10 pixels wide by position its top lefpixs from the left down from the top
xterm -geom 5x5+0+0
The third commandwindow and positleft-hand corner acorner of the scre
xterm will not compositioning.
Allows you to label your windows top title bar
xterm -title SCRIPTS
Opens an xterm wiSCRIPTS (default isthe -e option)
Allows you to modify different colors in your xterm window
xterm -bg white First command setsthe background coto white
LC
Command Description Example Explanation
xterm -bd huntergreen
Second command sets the window border color to huntergreen
xterm -fg red The third command window sets the
xterm -fn font rr18 (default is
xterm -iconic conic form with the
Note: Options c
Command
alias dir ls btain a directory rd in place of dir. erefore, now when
and line, it would ormally do.)
aliasunalias dir mand to be used
alias h history f the entire mmand gives a list ped on the system g on how history
tar -cvf a:archive stores the resulting
AU
2768_book.fm Page 234 T
uesday, Novem
ber 16, 2004 2:17 PM
Copyright 2005 CRC PresDo
w
n
l
o
a
d
e
d
b
y
[
U
n
i
v
e
r
s
i
d
a
d
e
E
s
t
a
d
u
a
l
d
e
C
a
m
p
i
n
a
s
-
U
N
I
C
A
M
P
(
C
R
U
E
S
P
)
]
a
t
0
9
:
1
3
0
7
J
u
l
y
2
0
1
5
text color to redSets the font in the new xterm window xterm -fn
courr18 Sets the font to coufixed)
Starts the new xterm as an icon (double-click to maximize)
xterm -iconic -title xyz
Opens an xterm in ititle xyz
an be combined using xterm.
Description
Enables typing of either dir or ls to olisting. (Note: I can substitute any woI can even use the word mouse. ThI type the word mouse at the commdo what the command ls would n
Displays all defined aliases.Now dir will no longer work as a comin place of ls.
Now I only have to type h instead ocommand history. The history coof the commands that have been ty(a certain number of them, dependinwas configured).
. Backs up the current directory (.) and archive on the diskette in a:
s LLC
Command Description
tar -cvf a:archive *.doc Backs up every file with the .doc suffix.tar -cvf a:archive - Used when you want to type filenames from the keyboard
ame on a separate line.
tar -tf a:archive | m tly contained in the
find / -ctime -7 > ed in the last 7 days. st.
tar -cvf a:archive -find / -ctime -7 | t ove
ng
dfdugrep -i ^ftp /etc/i ftp services:find / -name *s -p ectory
ing with and s and print
find / -name core ys since last access and portant since they
he failure of a system or system.
find / -ctime -2 -p en changed fewer than
AU
2768_book.fm Page 235 T
uesday, Novem
ber 16, 2004 2:17 PM
Copyright 2005 CRC Press LDo
w
n
l
o
a
d
e
d
b
y
[
U
n
i
v
e
r
s
i
d
a
d
e
E
s
t
a
d
u
a
l
d
e
C
a
m
p
i
n
a
s
-
U
N
I
C
A
M
P
(
C
R
U
E
S
P
)
]
a
t
0
9
:
1
3
0
7
J
u
l
y
2
0
1
5
(standard input). Type each filen^Z indicates end of list.
ore Produces a list of all files currenarchive.
weeklist Identify any files that have changPlace these filenames in weekli
< weeklist Backup all files in weeklist.ar -cvf a:archive - Does the same thing that the ab
2 commands do, but does it usia pipe (the | symbol).
Disk space usage on a file systemDisk space used by a directory
netd.conf Check to see if you are running rint Begins the search at the root dir
(/) and look for anything (*) endit to the screen.
-atime +7 -exec rm -f {}|; Finds all core files more than 7 daremoves them. Core files are imcontain information relating to tan application running on that
rint Returns all the files that have be2 days ago
LC
Command Description
find /users/jake -exec chown jake {} \; Makes the user jake the owner of the directory/users/jake and everything underneath it
find / -nogroup -p ot listed in /etc/groupfind / -nouser -pr ot listed in /etc/passwdfsck sistency of the information
systems listed in /etc/fstab.
ot)ems in some flavors
ftp o open communications to llows transfer of files to/lows (type the words in
key>
1 is the name of the system unications with>
our userID on TMG1>
AU
2768_book.fm Page 236 T
uesday, Novem
ber 16, 2004 2:17 PM
Copyright 2005 CRC Press LDo
w
n
l
o
a
d
e
d
b
y
[
U
n
i
v
e
r
s
i
d
a
d
e
E
s
t
a
d
u
a
l
d
e
C
a
m
p
i
n
a
s
-
U
N
I
C
A
M
P
(
C
R
U
E
S
P
)
]
a
t
0
9
:
1
3
0
7
J
u
l
y
2
0
1
5
rint Finds file owned by a user nint Finds files owned by a user n
Examines disks to ensure conthey contain. Checks all file
0 = successfulfsck -p /dev/rra1h (in rc.boBSD: /etc/fstab /etc/filesystATT: /etc/checklist
File Transfer Protocol: used tanother computer system. Afrom that system. Use as folitalics):
ftp open(to) TMG1
Recommended