Sunteți pe pagina 1din 2

Saul Coval Computers

http://www.coval.net
Basic Solaris Commands
Quick Reference Card
Conventions
<CR> RETURN key
<ESC> ESCAPE key
<DEL> DELETE key
<Ctrl-X> press <Control> key and type x
italics items to be replaced by yor o!n
re"irements
Shell Commands
passwd C#an$e pass!ord
logout End terminal session
File ierarch!
cd dir1 C#an$e to directory dir1
ls List %iles in directory
ls -l List %iles in detail
mkdir dir1 Create ne! directory dir1
rmdir dir1 Remo&e directory dir1
cp f1 f2 Copy %ile f1 to f2
mv f1 [f2] dir1 'o&e %iles f1 to fn to directory
dir1
mv dir1 dir2 Rename directory dir1 as dir2
rm filename Delete (remo&e) %ile filename
ln file1 name Create a #ard link to file1 called
name
ln -s file1 name Create a so%t link to file1 called
name
pwd S#o! pat# to crrent directory
"ettin# el$
man name S#o! man pa$e %or command
name
man -k subject S#o! man pa$es relatin$ to
subject
man -s# subject S#o! man pa$e relatin$ to
subject in section nmber #
man -s# Intro S#o! introdctory man pa$e %or
section #
File t!$es and Listin#
file filename Classi%y t#e %ile
strings filename S#o! any ASC** strin$s in a %ile
cat filename Display contents o% %ile to STD+UT
more filename Display contents o% %ile one
screen%l at a time
head filename Display %irst ,- lines o% %ile
head -n filename Display %irst n lines o% %ile
tail filename Display last ,- lines o% %ile
tail -n filename Display last n lines o% %ile
tail -f filename Recrsi&ely display last ,- lines o%
%ile
cut Extract c#aracter or %ields %rom
text
wc filename Cont lines. !ords and c#aracters
in %ile
diff f1 f2 /ind di%%erences bet!een t!o %iles
diff3 f1 f2 f3 /ind di%%erences bet!een 0 %iles
sort filename Sort %ile alp#abetically by %irst
letter
uniq Report or %ilter ot repeated lines
Redirection
STDI Standard *npt. typically t#e
keyboard
STD!"T Standard +tpt. typically t#e
screen
STD#$$ Standard Error. !#ere errors are
sent1 Typically t#e screen
comm % file +tpt o% comm creates file
comm & file Contents o% file sed as inpt to
comm
comm '% filename Error messa$es %rom comm sent to
file
comm %% filename +tpt %rom comm appended to
file
cat file &&#!( Create a docment called file
data) containin$ data
#!(
comm1 * comm2 +tpt %rom comm+ sed as inpt
to comm'
mkfifo name Create a named pipe called name
mknod name p Create a named pipe called name
File Securit!
chmod mode filename
C#an$e secrity settin$s on %ile
chown user ,:group- filename
C#an$e o!ner 2and o!nin$ $rop3 o%
%ile
chgrp group filename
C#an$e o!nin$ $rop o% %ile
umask mode Set de%alt creation permissions
S!m%olic modes
&ode &eanin# &ode &eanin#
u ser r read
g $rop w !rite
o ot#er . execte
a all u/s setid
0 assi$n g/s set$id
/ add /t sticky bit
- remo&e
'ctal modes
4ase directory mode is 5551 4ase %ile mode is 666
user #rou$ other
r w x r w x r w x
7 8 , 7 8 , 7 8 ,
( ( (
Shell )ildcards
&eta-
character
&eanin#
1
Any c#aracter
2
Any sin$le c#aracter
, -
A ran$e o% c#aracters
*ranslations and Searchin#
tr set1 set2 Translates set1 to set2
sed Po!er%l text maniplation tool
grep pattern filename
/inds lines containin$ pattern in
%ile
grep -v pattern filename
/inds lines +'* containin$
pattern in %ile
grep -i pattern filename
/inds all lines containin$
pattern in %ile i$norin$ case
find path condition
/inds %iles matc#in$ condition
%rom path do!n!ards
find path -inum n /inds #ard links. i1e1 All %iles !it#
t#e same i9node nmber
who Displays sers on system
who am i S#o!s real ser id
w Displays sers on system
id S#o!s e%%ecti&e sername : U*D.
and $rop members#ip
look word Searc#es /usr/dict/words %or
word
Re#ular E,$ressions
.
Any c#aracter
^
Start o% line
$
End o% line
*
Any nmber o% t#e precedin$ c#aracters
?
A sin$le c#aracter
[ ]
;olds a ran$e
,6 -
;olds a ne$ated ran$e
78 79
Creates a sbmatc#
7+-:
Re%erence a sbmatc#
\
Escapes special c#aracter meanin$s
+et-orkin#
telnet hostname ,port-
Connects to #ost and opens a
s#ell1 +ptionally on speci%ied port1
ftp hostname Connects to a remote #ost to
trans%er %iles
ssh hostname ,command -
'akes a secre connection to
#ost and opens a s#ell1
.rocesses and .rocess Control
ps Displays processes rnnin$ on a
#ost
prstat Displays iteratin$ list o% processes
by CPU sa$e
command ; Rn command in back$rond
<o3s Print list o% <obs
fg ,=n- Resme %ore$rond <ob n
3g ,=n- Resme back$rond <ob n
stop =n Sspend back$rond <ob n
kill ,=n- =ill <ob n
<Ctrl-c> *nterrpt process
<Ctrl-/> Sspend crrent process
kill n =ill process n
kill -: n Terminate process n
<Ctrl-s> Stop screen scrollin$
<Ctrl-0> Resme screen otpt
sleep n Sleep %or n seconds
Shells and 1aria%les
variable0value Create local &ariable variable
!it# &ale value
e.port variable 'ake variable an
en&ironmental &ariable
unset variable Remo&e en&ironment &ariable
set S#o! local &ariables
env S#o! en&ironmental &ariables
alias name1 name2 Create command alias
alias S#o! command aliases
unalias name1 Remo&e command alias name1
histor4 Display recent commands
> n Sbmit recent command n
set -o vi Recall commands. edit and re9
execte sin$ &i commands
set -o emacs Recall commands. edit and re9execte
sin$ emacs commands
Shell 2nitiali/ation
3etc3$rofile 45'&E36$rofile7
s#. bas#. ks# system !ide (per ser) init
(system !ide init #as no e%%ect in CDE en&ironment)1
3etc36lo#in 45'&E36lo#in7
cs#. tcs# system !ide (per ser) init
(system !ide init #as no e%%ect in CDE en&ironment)1
5'&E36cshrc
per ser cs#. tcs# init
(order> ?etc?1lo$in @;+'E?1cs#rc @;+'E?1lo$in)
5'&E36kshrc
per ser ks# init
(order> ?etc?pro%ile @;+'E?1pro%ile @;+'E?1ks#rc)
5'&E36%ashrc
per ser bas# init
(order> ?etc?pro%ile @;+'E?1pro%ile @;+'E?1bas#rc)
Shell .ro#rammin#
?>path/to/shell As#9ban$A is a special strin$ !#ic#
indicates t#at t#e pat# %ollo!in$
contains t#e location o% t#e command
to rn t#e script
Flo- Control
sh8%ash8ksh csh8tcsh
i%9
t#en9
else
if , condition -@
then
actions1@
elif , condition -@
then
actions2!
else
actions3@
fi
if 8condition"
then
action1@
else if 8condition9
then
action2!
else
action3@
endif
do
!#ile
while , condition -@
do
actions@
done
while 8condition9
actions
end
ntil
until , condition -@
do
actions!
done
+ot availa%le
%or for arg in list @
do
actions@
done
foreach arg 8list9
actions
end

S-ar putea să vă placă și