Vous êtes sur la page 1sur 102

!

"
#$ %
& ' (
#) *
+ $ )
, $
! -
. )
& / #) - &
%

/ ) 0
! 0
,
! #+ / )
1 23 - / 4
& 5 /

! 6 #) %
! %
! 7 *
! *
! 8 *
& !
!
% !
0 !
( !
*! ) 0
! )7 (
! #) *
! *
! 7
!
!
& ! &
! &
% ! )
0 ! + %
( ! # (
*! 9 &
! &
! &
! &
! 6 - &
! &
! &&
! # &&
! &
& ! - &
! 8# &%
! 6 &%
! &%
! 8 &0
! &(
& ! &(
& ! 7 *
& ! ) 7 *
& !
& ! ))
&& ! )#
! / #
! 7)
! 7)
! -
!
& !
! &
% ! &
% ! " &
% ! &
% ! +
0 !
0 ! 7
0 ! + %
0 ! %
( ! %
( ! " %
( ! 0
*! %*
* ! ) %
* ! %
* ! %
* ! / %
! 6 / %
! " %
! %
! %
! %
! %
! %
! %
! - %&
! %&
! 7) %&
! %
1 %%

2 6 0
2 0
2 0%
2 7 -"7 0(
! " #
& ! (
& (
& (&
& 2 # (&
& 2 7) (&
& 2 (
& 2 : #; (
& & 2 < : ; (%
& = (0
&& ((
$ % !& ' () & *
,/ - *
,/ , " >/ *
,/ >/ *
1. Introducción a UNIX
1.1. Historia de UNIX
, 4+ ? *, : ;@
- / 6/ 6 - :
;@ @ - 9 # - 9
/ / " 6 9 A
2 ( ( ! " : ; ' ,B ! 9 =2!
= C%@ 9 # : ; : (%*; 9 = C 3* -
/ 2 / @ - / +
+ 6 ,3
2 (% $ % " :6 " ; + 6 + @- /
+ 6 D %* < # @ -
# + # @ + " =
+
D# %*@ " & ' ( $ ) $*
- ' # - ' + ' +- $
/ @ $ # 4
@ 0* # #6 + ,- .@ 9 @
+ + @ / / # / @- 9 6
, B/ +

+ ,! % -.
' - /0
- ) 1* ' $
$ - 231 $ % " $ "
. =# - $ % 0444
%. " "
- " 5- ) + + /0
6,7 . 6 ( 7, & 6 ( 7, &
: </ ; $- /0@ 8 "8, ( , 8, (
2 $ : </ ; $ /0
- $ : </ ; $ /0@ "@ @ 6,@

2 + /A @ @ ( 9
- / # + # ' "#
# /0 - 0/ @ -# @ @9 / +
/ / # -+ @ $ ? $
&

2 ((* 6 : ; - @9 /
$ / (( / :** ; :/0 D
$ @ + $ @ , "
/A + - 9 ) @ < ? @ - /A "
+ D 4@ + / , "@ +
@ 4 # @- < # E /0@ 0/&@ $ "@
@ - ,( , , B/ + , "
2 , " </ : ) 9 A ) ) + ;@
9 + ! " " #2 +
# #4 , "E #7 - ! 9 # - / : 9
) ) @ 6 @ < @9
;@ F , @ 6 @ # @ / 9 )+ @
/+ / + # 6 + 9 # - /

/ ! )
- 5 ? -
' ) # $ #/ 2 )
$ # 3
6
= / @ " - @ /
% 6
9
) 7 / E @ 6 @
&(
- $ +
- ) ; # - #+ @9 -+
+ -
& + . #
,, ,( ,
, +
< ' ) # @ = 3G 7
& ,(
- # 6@ - A = / @ " -
,( ,
; . , , '
$ . # 9 @&H
$- = ? = 3G 7
! / < 9 @&H - ) # -
#)

$ "

01-2
D 9 /6 @ -, "@ ) -) / H
H@ - , " H = # .H D 4@ -, " $@ # 9
# , "@ 9 /A " , "
1.2. Introducción a los sistemas UNIX
- @ @9 6
+ @ -9 + @ # @ 6
$ # # 9 $
9 # 9 ? D 4@
2 " # D @
+ $ + @ # 9 @ @ #
+ @ @ +
+ E - ,
: /A / / 7 ; ) $ 9
@ , 9 + 9 #+
9 /6 " + 4
/6 9 $ - @
9 # A D - 9
@- -# $ 9 ) 9 - /6
D A 6 - # @ # 9 +
6 @ - $
! @ 9 / ) #
: @ ; - : ( ; ! /
# @- + 9 / ! )
+ @ 9 + # @# ) - 9
$ $ @ # 9
# :# ) @ + @ ;

1.3. Conexión a un sistema UNIX


D $ 9 , "@ "
# 9 , " , )/ A
9 9 6 , " - /
, 9 @9 + 9 $
" / # - , "@ $
/ + /A telnet 6 @ G 7@ +
c:\windows\telnet.exe@ - " = + # /
9 @- ) # = , 2 #
+

telnet polifemo
telnet 192.168.2.100

# 9 9 , "@ # ,
9 , " / 6 / - / E

Linux 2.0.30 (polifemo.diesia.uhu.es) (ttyp0)


polifemo login:_
%

D9 4 / / - D) , " 9 / (

Linux 2.0.30 (polifemo.diesia.uhu.es) (ttyp0)


polifemo login: llorente
Password:_

D ( @ # 9 9 / @
4 . @ @ @ , "
6 9 2 9 / / @
@- 9 / 9 /
$ $ /6 A
D + / 9 '
9 9@ / + H H + :
E shutdown@ halt@ reboot@ ; +
, " @ + 9 ) # ? -
A / 2 9 )- A : 6 ;@
< " @ - 9 , " + 9 +
, # / exit logoutI
A + , + 6 $
# E

Linux 2.0.30 (polifemo.diesia.uhu.es) (ttyp0)


polifemo login: llorente
Password:

Linux 2.0.30.
Last login: Fri Oct 15 12:20:22 on ttyp0 from jmal.diesia.uhu.es.
No mail.

polifemo:~$ exit
logout

[polifemo:23: remote disconnect]

1.4. Introducción al interfaz de UNIX


, #$ :-@ @ , "; > @
' C= > / 9 # < /
E 6 + @ 6 #) @ 2 - 9 !& 34 &
3 4 & : 9 ' C= ;@ @9 / ls -LS
$9 @ 2 4/ 9 9
9 / 2 4/ + + E J@ K@ L@ M@ N D
+ # / @ / 9 @
@ D ) 9 4/ HNH
, + @- " -# E
0

comando flags argumento1 argumento2 argumento3 ...

• comando / @- / 9 @
<

• , flags 6 # 9 ) 9 #
# @# @ + + :C; + @ @
: 9 -< - < # ;

• , argumentos / #) @- # /6 :# ) @ ; / 9

2 < - @ 4 4 5 6 2
ls ) : '; /
ls@ / #) E

$ls
a.out* mail/ mbox min* min.c nsmail/ p/ tmp/

D4 / / ) / #
$ # -lE

$ls -l
total 20
-rwxr-xr-x 1 llorente users 4261 May 4 10:40 a.out*
drwx------ 2 llorente users 1024 Jun 1 11:09 mail/
-rw------- 1 llorente users 2308 Jun 3 14:07 mbox
-rwxr-xr-x 1 llorente users 5643 Jun 3 14:54 min*
-rw-r--r-- 1 llorente users 1296 Jun 3 14:54 min.c
drwx------ 2 llorente users 1024 Apr 7 1999 nsmail/
drwxr-xr-x 2 root root 1024 Jun 8 10:46 p/
drwxr-xr-x 2 llorente users 1024 Apr 15 15:06 tmp/

$ # -a ) E

$ls -a
./ .less .netscape/ mbox
../ .lessrc .pinerc min*
.Xauthority .mc.hot .tkdesk/ min.c
.addressbook .mc.ini .xsession-errors nsmail/
.addressbook.lu .mc.tree a.out* p/
.bash_history .ncftp/ mail/ tmp/

B /A / # 9 / 6 @
- 9 :-a -l 9 -al - 9 -la - 9 -l -a;E

ls /A + / ) 9 9 6 @
9 # min.c -a.outE
(

$ls -l min.c a.out


-rwxr-xr-x 1 llorente users 4261 May 4 10:40 a.out*
-rw-r--r-- 1 llorente users 1296 Jun 3 14:54 min.c

" - 9
man + / 6 @ 9 "
ls@ / man ls D " # / 9 +
" $ / @ - -?

1.5. Mantenimiento de la clave


O / 9 9 2
- @- E

• '

• ' #
2 + 4 / 9 $ / 2"
# A 9 9 + @ A
/ H# H @ / / D @ /
9 )- -# + 6 @ / 4 $ + E

• @ / 6 < @

• . ) @ ? 9 # )

• / 4 @ @ @
D @ / @ / $ , 6
/ : -< - < ;@ < - 4/ 2
/ 9 #4 @ + 2 )
$ H# H: > ;I @ @ 9
/ / !
/ @ /A / @ 6 9
/ 5 )

$ 2 passwd 2 @ + 9
$ + : ;E

$ passwd
Changing password for llorente
Old password:_

+ @- E

$ passwd
Changing password for llorente
Old password:
Incorrect password for llorente.
The password for llorente is unchanged.
*

$_

2 @ 2 + / :
;

$ passwd
Changing password for llorente
Old password:
Enter the new password (minimum of 5, maximum of 8 characters)
Please use a combination of upper and lower case letters and numbers.
New password:_

/ A/ @ 6 : ( @ 9 ' ;-
9
= @ @ @ +
: ) # @- 9 9 / ;E

$ passwd
Changing password for llorente
Old password:
Enter the new password (minimum of 5, maximum of 8 characters)
Please use a combination of upper and lower case letters and numbers.
New password:
Re-enter new password:_

) @ )/ -passwd 6 /
E

$ passwd
Changing password for llorente
Old password:
Enter the new password (minimum of 5, maximum of 8 characters)
Please use a combination of upper and lower case letters and numbers.
New password:
Re-enter new password:
Password changed.
$

# - + # @ / @ 6
: "' A "B ' ;-
9 $9 :- A 9
;

1.6. Sistema de ficheros de UNIX


2 @ + 9 ' C= -G 7@ #) + $ @#
/ @ @ # A @ " H H@ 9 + $
/ @ < 4$ 2 ) /
+ / 2 % & & !
/ $ ) + @ / % & & @9
/ + ) 2 -
" 4/ @ 9 @ " @ 9 @ @ ?
#)
$ @ I

, 9 @ @ < 9 9
! /6 # : 6 ;@
#) 9

1.6.1. Organización de archivos


2 " #) ) E

• =

• . )

• . )
, #) - + ,
/ @ # 9 #) - , #)

, #) : 9 ; # / 2 / )
9 / @ / $ + 9 + #
+ 6 $ - < =/ 9 #
-< - <
, / #) # " , " :;-
@ - $ 9 ) 6 @
) 9 + # + + 6 ! " H.cH 2
@ " # ' C= - @- 9 ' C= " /+
: 9 A 4 9 " ;@ - + # / I 4 + 6 /
' C= / /+ " 6 / :.COM@ .EXE@ .BAT@ ; D @ ' C=
:; / " @
$ /
B #) / +< : " 4$@ 9
+ ; 2 9 ) -9 + 4$) #) : ";
#) @ / 9 @
/ :/@ ";@ + / #) 6 @ #) libvga.config 9
vga etc@ /etc/vga/libvga.config 2 9
"& "& D 4@/etc /etc/vga

= @ " 4$:/;@ " E H.H -H..H

• 2 . 9 9 2 @9 /etc/vga/
9 /etc/vga/./

• 2 .. 9 9 2 @9
/etc/ 9 /etc/vga/../

! 9 # ) / #
) " 9 "& '"&@
C ! # .@ 9 &% .@ 9
. 2 )- # # @ # 9 < # /
) @ 9 ) / ) #
B /A # 2 9 &
& @# & &@ 9 $ 4$:/; 6 @ #
/etc@ 9 vga/libvga.config -/etc/vga/libvga.config B /A $ . -..
6 @ # /etc/ppp@ 9 ../vga/libvga.config -
/etc/vga/libvga.config

2 pwd : ( & '; / # 2 cd


: " '; / # 9 + 6 E

$ pwd
/home/llorente

$ cd .
$ pwd
/home/llorente

$ cd ..
$ pwd
/home

$ cd /etc
$ pwd
/etc

! @ " 2 "
9 /6 @ 9 ) 9 @- +<
A: 9 " 4 ; "
/ 9 - /home@ 6
! $9 @ # " D @ $
cd @ # "
2 " 6 9 4# 2
/ @ + 9 B/

/ ' (
/ = 4$ !
/bin +
/dev ! #)
/etc ! ) = #) :passwd@ shadow; - + + 9
$
/home ! "
/tmp ! )
/usr ! ) - +
/usr/include ! ) / :#include; + 6!

( "& &)
1.6.2. Localización de comandos
B + 9 + /
9 / @ " 9 &* +, : "; 9
6 9 D 4@ /
# @ / + )
+ @ 6 I @+ 6
! 9 6 + 9 /A /
: );@ $ / :.; 6 @
mi_programa@ / + 4 E

$ ./mi_programa.c

1.6.3. Comodines y caracteres especiales


, :( ; 9 # /
#) : /A %) " ; 2 ) # + +<
) / #) 9 + 4 < 6 @ #) 9
+ " .c / $ @9 9
E

• , + :P; 9 :+ 9 ' C= ;

• 2 :Q; 9 @ 4:+ 9
' C= @ 9 ;

• 6 ) :RS; 9
# ) $ ] ) @ /
6 [

• = ) :RS; - + :C; 9
+ # : A ;@ +< D !
$ + ) @ / # :
[;@ : A [;

• B /A # 6 9 / # / #)
:!; 6 A [

B / / , B/ + 6
+ ' ( 5 & ( 6
* B )
? D ) - / + : # ;
*.* D ) 9 + + /
[a-z]* D ) 9 $ <
*.c D ) " H.cH
copia?.c copia1.c@ copia2.c@ copiaA.c@ copiaa.c@ copia_.c@
copia[123].c copia1.c@ copia2.c@ copia3.c
copia[123].* copia1.*@ copia2.*@ copia3.*
copia[1-5AB].c copia1.c@ copia2.c@ copia3.c@ copia4.c@ copia5.c@ copiaA.c@ copiaB.c
copia[!123].c B copia?.c@ " copia1.c@ copia2.c@ copia3.c
copia[123!].c copia1.c@ copia2.c@ copia3.c@ copia!.c
copia[.c 2 ) opia[.c
copia[]AB].c copia].*@ copiaA.*@ copiaB.*
copia[-AB].c copia-.*@ copiaA.*@ copiaB.*

- .% "% ' & '"*

D @ " @ @9 +< + #
A @ -@ @ @ $ / #)
6 E @ >@ &@ $@ / @- 9 / @ $
9 9 $ 4/ @ / + # B
/ E

• 2 / $ :´;

• 9 4/ + # , )
4/ / :\@ & ";

6 @ # #) con*asterisco / ´con*asterisco´ /
con\*asterisco

= # @ 4 ) A @-
# $ A

1.6.4. Ficheros especiales


, #) # @
! #) E

• , " 9 #)
/ B #) @ #)
) @ # 9 # #) @9 #
@- 9 # #)

D ) ) / T: ; + / U V
&

• , & 6 #A
2 #A 6 # #) 6 @ 6
#) /dev/tty@ # 9 / # #) @ # @ $
@ ! #A #) @ 9
@ - /dev , B / & + 6
#)

/ 7 ' (
/dev/tty B : ;
/dev/hda
/dev/hda1
/dev/hdb +
/dev/fd0 # "/
/dev/null = : # ;
/dev/ram ' 1D'

/ .% &

! 6 9 + @ A $ E &
&) @ &) -

• , & &) 9 + + @ # 9
/

• , &) 9 + @ #

• , 9 +

# @ # 9
@- -

1.6.5. Permisos sobre los ficheros y directorios


O / 9 #) @ 9
" 4 5 #
! #) :# ) @ @ @ ; ,
@ 9 : @ ;@ -
+ # # #) - #) E

• % "& E #)

• % "& E # #)

• % ." "0 E 6 #) :9 9 + ;
E

• % "& E : #) ;@
# : ? @ # )@ ; #) 9 + /A
6 -9 + / 9 A# ) ) -: / ;-
9A #) : / #) ;

• % "& E # E ? #) - #)
: 9 + / #) ; 1 9 #
#) 9 / #)

• % ." "0 E 9 / # @ 4
#) : 9 + #) ;
# #) - @(- : @ - 6 @
; D 4@ @ - C @ D @
# E

• % & E : @ (@ ; 9
) 2 ) 9 $@ 9 / /
:chown;

• % % % , & E : @ (@ ; 9
9 + 9 )

• % & E : @ (@ ; 9 9
+
# @ -- : W W@ + - @ ;
B /A ( ( ( @ -@
9 " @- " +
6 E 77 77 77@ ( 7 7 @ ( 777777@

, #) / @ chmod@ -
@ 9 + / #)
/ @ 6 #) $ 9
E :d;@ # ) :-;@ :c;@ / 9 :b;@
/ :l;@ 6 @ ( 7 7 @ 9 7 ( 7 7
#)
D @ " E / - + @

1.7. Procesos en UNIX


/ 9 @ 9 9 9
6 $ : # ; ! + 9
6 , # 9 <
), $*
2 A ! $9 6
@- 9 @ 9

2 / ( @ +
%

2" 9 6 2 ps 9
6 ! A + 9A ) -@ /A
=@ -
= @ A A
D E ? 6 < !
? : kill; / # : =; - <
? 9 9 ! / ? E

• < ? @A # < + ? @ -
A <

• < ? @A : ; #
@ 4 ?
0

2. Intérpretes de comandos
2 > #$ - / 9 # <
/ E 6 + @ 6 #) A 9
+ 9 9 / @- 6 2 @ # @
/ 9 # /6 : 6 ;
$ @ A / / * : $ ;
2 A ) + 9 A @- 9 ) 6
" 6 @ ' C= 1% & & @
9 , "@ *& 1 % @ G 7@ 6 ) 9
A
2" A @ - " @
9 6 D+ 6 E sh@ csh@ ash@ bash@ ksh
! @ / @ + @
" @ @ + ) # @9 9 $ $9 2
) / $ chsh D @ 9 ) 9 + @
) # ) 9

2.1. bash
*: " ; ) , "@ 9
" : ; :
4 ; # 4 : @
; = /
+ # ' 6 @ " @-
$ @ 9 /
# @ / ) ) <
/ :↑; - / 6 :↓; D @ #
A # ) $9 :←; - ) :→; - # "
< @ " $ / /
) 9 - " 6 @ Hls /etc/passwdH@ /
Hls /etc/paH - / 2 9 # / "
9A ) : 9 " +< ) 4$@ 9 " ;@
/ @ / ) 9 4$ @
/ / : ) /+X ;

2.1.1. Caracteres especiales


" 6 $ 4/ + # :B / ;
2 + @ - + # " ) @ 9 $
# A 9 D 6 : + + ;@
(

) - 6 / #) 9 ) @
9 / @ 6 #) - $
B $ /A : 6 9
# / #) ; $ @ -
9 : ;E

• , / :\; ) 9 9 $ + + #

• , :´; ) 9 + + #
@ 9

• , / :"; ) 9 + # :+
9 ;@ " 4/ 9 + E $@ ` \

6 @ $ / Habc*def$ghi\jkl mnoH + / E

• $ / E abc\*def\$ghi\\jkl\ mno

• 2 / E ´abc*def$ghi\jkl mno´

• 2 / / - / $ - \E
"abc*def\$ghi\\jkl mno"

B /A @ @ + # 4/ + #
E

• '\' /

• \\ /

• \´

• ´"´ /

• \´\\\´ /


- ,
% = 3' D

2 :`; 6 9
2 + 6 @ pwd I
/fd*@ - $ ) ls

$ ls `pwd`/fd*

2 :$;@ 9 -
/ # 6 @ / 9 '2 / 9
" @ + E

2 9 +< / ) @ ) / @
*

$ ls $HOME

2 {} /A / 2 / F9
19G
+ +

, 4/ & -; $ 2 :4 ;
@ + 4/ E

• $ ; 6 : $9 - +
);

• $ & 6 : $9 - )
$ $;
2 6 + " -
3 I + 6 / @ $ /

$ ls $HOME ; ls /bin
$ ls $HOME & ls /bin

& $ 6 + 6 @ + 6
+ @- # 9 / 9
9 ls E

$ ls /bin &

2 " $ @ 9 // A 9 )
8 ' (
2 " *@ ?@ [] -! + # 9
!
)
\ 9 9 $ + + #
´ 9 + + #
" , + # @ " $@ ` \
, - -
`
6
+
{} , / /
() , A # 6
$ , 9 / / @- -
; 9 6 : $9 ;
& 9 6 $: # ;
> 1 )
>> 1 ? ) "
< 1
9 6 $: # ;@ # 9
| $9 )
/ 4

2 3 % " "& " *

2.1.2. Los alias


, 9 ) #
+ / @9 / 6 #
HdirH - 9 HlsHE

alias dir='ls'

D $ dir + 9 ls @- 9
9 @ 6 @ 6 E

alias dir='ls -al'

D) $ dir ls@ ? A @
9 #9 –al 9 - 4@ - 9
/ 9 E

alias ls='ls -al'


= 9 + 6 # @
9 9 # $9 6
&
. @ 6 # @ / alias E

polifemo:~$ alias
alias d='dir'
alias dir='/bin/ls $LS_OPTIONS --format=vertical'
alias joe='joe -asis'
alias ls='/bin/ls $LS_OPTIONS'
alias v='vdir'
alias vdir='/bin/ls $LS_OPTIONS --format=long'

5 6 ls # @
6 + /
D 4@ E @
/ @ @ 6 6
9 ) @ -9
9 @ / / @- 9
@ @ @- -

2.1.3. Configuración de opciones de bash


2 ) " #
#+ 6 set 2
/ # @ ) $ A
#+
" 6 9 #
@ set 6 set –x HxH , + @
set +x HxH
, W"@ ) 9 " @ 6 @
9 ) 2 - -
@ / / @ -
#) @ = $ 9 6
@ 9A + H H

6 @ ls *.c@ ) ) 9 5 @ 4
9 $ + @9 - @ #
- *.c 6 #) 9

polifemo:~$ ls *.c
+ /bin/ls --8bit --color=tty -F -b -T 0 busqueda.c cgi.c cgi00.c libreria.c prueba.c
busqueda.c cgi.c cgi00.c libreria.c prueba.c

&
2 alias
+ @ + / E

polifemo:~$ echo Mi directorio es $HOME


+ echo Mi directorio es /home/llorente
Mi directorio es /home/llorente

/ ) –v 2 –x 9 6
9 6 @ # –x@ –v $ + @ 9
/ 2 + / @- 9
9 / / 6 : + ) )
;@ - 9 ) $ 9 6 @9
2 - 4 &@ "@ + (
, W# ) 9 / ) + /
#) 9 @ 9 6 E

polifemo:~$ set -f
polifemo:~$ ls *
/bin/ls: *: No such file or directory

2.1.4. Redirección de E/S y tuberías


! 6 "@ # @ $ -
9 "@ @ : - ; / +@ ) 9
@ 6 @ 9 @ + @
#) @ 4 @ @ 2 ""0 - @-
) / @6 @ 6

• "" & &) $ 9 :<; + / #)


#

• "" &) $ - 9 :>; + / #)


# B / E #)
@ / ? #) 9 - " 2 <
$ + - 9 :>>; $ / #)

• "" $ &> : /A >&; + /


#) #
, B/ % + 6
D 9 + 6 @
) @ ) $9
) + E

$ ls >temporal

2 more ) 9 #) + @) $9
$ more <temporal

2 -) / I " 9
< 2 $ $ #) " :temporal 6 ; $ 9
& 4 : ; / 4 #) 9 / - @
@ 9 # @- - $
$ / 4 $ 4/ - :|@ ; 2 6 9 4E

$ ls | more

/ 4 B 6 #
@ # 9 $9 | $
) |

' (
, ) - / #) mifichero #) - " @
ls >mifichero

ls >>mifichero , ) - ? #) mifichero #) "


, ) - / / #) mifichero
ls &>mifichero
#) - " @
ls &>/dev/null , ) - /
more <mifichero ' mifichero ) +
ls | more ' #) ) +

5 .% ""0

2.1.5. Variables de entorno


, / 6 / 9 -9 +
+ @ 4 ) @ $ / # @ #+ @
/ # @- :
$ 9 # -< - < ;
# / $ + : +< ; 6 @
# / TEMPORAL /tmp ) E

$ TEMPORAL=/tmp

$ / @ 4/ N 6 @ +
/ TEMPORALE

$ ls $TEMPORAL
&

D # / $ @ 9 6 E

$ ESTE_DIR=`pwd`
$ ls ${ESTE_DIR}/*.c

2 6 ) $ :{}; / / )/
:ls $ESTE_DIR/*.c;@ ) 4 9 / / -@ @ / :/;@
- 4
$ / # @ / 4
: ;

$ 4/ $ 9 / @ /
:´; / :\;
, / # ) ) ) 9 + $ )
$ / @ export :- ;

2" + / # - <@ 9 #6 B/ 0 ,
/ PATH@ 9 6 /< 9 $
: " HI ; D 4@ / @ 9 A
/ PATH PATH 6 ::;

' (
PATH 1 /< 9
HOME 1 "
PS1 ,
PS1 ,
SHELL ! $ )
LOGNAME / $ : / ;
HOSTNAME / 9

6 7 & %) % & &

? ) $ / 6 @ ?
/tmp )E

$ PATH=${PATH}:/tmp

/ 9 # ) / 9 9
) 9 9 / @ -9 4/ : $; 2 "
2 9 + @ 6 #
@- @ @
2 / @ @ @ 2
/ 9 @ 9 " + + 9
# : # ; , B/ ( + + +
)/ $ / B $ 4 / T@ 9 # /
)/ 9 $ / / 2 + 6 -
# / 9 @ + @ /6 - 4 / $ #E

PS1=\\h:\\w\\$

' ' (
\h / , "
\w 1 #
\t , ) # E' ' E
\d , # ) # H$ $DH : 6 HB ' - H;
\u 2 /
\$ 2 4/ $ #

8 10 % &
%

3. Comandos
2 @ +
+ + 4E

• ' 6 #)

• #)

• ' 6 -

• ' 6

• ' 6 /

• D


9 @ ) # @
$ B/ *E

' ' (
R S 2
Y Z [ =/ # + : ;
parametro... , 9

91 " " & "%

/ # 4 # --help
: , "; - man : 9 ;

3.1. Comandos de manejo de ficheros


2 + 4 6 #) :
/ #) @ ;

3.1.1. Comando ls
ls + # ' / #) - 9 )-
, " E

SINTAXIS
ls [modificadores] [ficheros...]

, # # # - , #)
#) 9 ) -9 @ #) D 4@
#) @ #/A :
/ /6 - + $9 )I -< - < @
-< ;E
0

polifemo:/boot$ ls
System.map any_d.b chain.b os2_d.b
any_b.b boot.b config

4 )/ @ + #) E

polifemo:/boot$ ls *.b
any_b.b any_d.b boot.b chain.b os2_d.b

/A E

polifemo:/boot$ ls a*.b b*
any_b.b any_d.b boot.b

2 ) , ) 9 $ :.;
) H H@ - @ 9 #9 2 )
# -aE

polifemo:/boot$ ls -a
./ System.map any_d.b chain.b os2_d.b
../ any_b.b boot.b config

/ 9 / + / #) 9
+ / :/; = , "- 9
/ 9 #) $ # 2 +
#) : @ @ ; ! ls@ / #) @ / # /
@ # -lE

polifemo:/boot$ ls -l
total 157
-rw-r--r-- 1 root root 143835 Jun 24 1997 System.map
-rw-r--r-- 1 root root 204 May 25 1996 any_b.b
-rw-r--r-- 1 root root 204 May 25 1996 any_d.b
-rw-r--r-- 1 root root 4416 May 25 1996 boot.b
-rw-r--r-- 1 root root 88 May 25 1996 chain.b
-rw-r--r-- 1 root root 5147 Jun 24 1997 config
-rw-r--r-- 1 root root 192 May 25 1996 os2_d.b

, # 9 + : $9 ) ;E :- ;@ <
9 " / #) @ @ + #) @ ? /- @ # )
# - / D @ < / 9 : 8 /-
@ 9 /A & /- ; 9 #)
2 + $ @- 9 -) / $
9 @ $ + @ $ +
(

#) 2 ) # -F : $
# @ 9 #9 ;E

polifemo:/lib$ ls -F
cpp@ libcurses.so.1@ libm.so.5@
ld-linux.so@ libcurses.so.1.0.0* libm.so.5.0.9*
ld-linux.so.1@ libdl.so@ libncurses.so@
ld-linux.so.1.9.5* libdl.so.1@ libncurses.so.1.9.9e@
ld.so* libdl.so.1.9.5* libncurses.so.3.0@
libc.so.4@ libe2p.so.2@ libncurses.so.3.0.0*
libc.so.4.7.6* libe2p.so.2.3* libss.so.2@
libc.so.5@ libext2fs.so.2@ libss.so.2.0*
libc.so.5.4.33* libext2fs.so.2.3* libtermcap.so.2@
libcom_err.so.2@ libgdbm.so.1@ libtermcap.so.2.0.8*
libcom_err.so.2.0* libgdbm.so.1.7.3* libuuid.so.1@
libcurses.so.0@ libm.so.4@ libuuid.so.1.1*
libcurses.so.0.1.2* libm.so.4.6.27* modules/

2 + ? / #) E* #) 6 / @/ @ @
%
/ @ ! ) @ ?

, B/ # ls

9 ( : &
-1 , #) < : #) 4 ;
-l . +E # #) : @ @ # )@ ;
-R 1 E @ /A #
-a B #) E - #) 9 $ :.;
-A ! #) E - #) 9 $ :.;@ " H H -H..H
/
-B & E #) & : + ;@ 9 #) 9 H~H
-d , / +
-t #) # ) -) #
-S #) ?
-X #) "
-r #) #
-U #) + # I 9
-s ' ? ) $9 / @ / 9
-F ' # / @9 #) : + ;
-i ' : $ ; 9 / # #)

'" "% ls

%
2 / ( @ +
0
' ) 9 @ @+ ) @
/ @ / H~H
*

2" ls 9 #) + E dir@
vdir@

3.1.2. Comando pdw


pdw : ( & '; #

polifemo:~$ pwd
/home/llorente

3.1.3. Comando cd
cd : " '; / # @ + /
D / 9 9 / E

SINTAXIS
cd [destino]

! / # /
@ cd / " 2 + 6 / / @
- pwd / /A 9 :
/home/llorente; /A 4/ H~HE

polifemo:~$ cd /usr/include
polifemo:/usr/include$ pwd
/usr/include
polifemo:/usr/include$ cd ..
polifemo:/usr$ cd .
polifemo:/usr$ cd /
polifemo:/$ cd /home
polifemo:/home$ cd llorente
polifemo:~$ pwd
/home/llorente
polifemo:~$ cd /tmp
polifemo:/tmp$ cd
polifemo:~$ cd /bin
polifemo:/bin$ cd ~
polifemo:~$

01-2
/ :cd; - , ' C= $ Hcd..H
@ ' C= : ;@

3.1.4. Comando mkdir


2 mkdir : & '; / @ +
/ @ # I
SINTAXIS
mkdir [opciones] directorios...

, # /
$ 6 @ " /tmp/1@
/tmp/1/2 D / /tmp/1@ / $ -p

polifemo:~$ mkdir /tmp/1/2


mkdir: cannot make directory `/tmp/1/2': No such file or directory

polifemo:~$ mkdir /tmp/1 /tmp/1/2


polifemo:~$ mkdir -p /tmp/1b/2b/3b

, B/ # mkdir

9 ( : &
-p ! E @ : " ;
-m #

$ '" "% mkdir

3.1.5. Comando rmdir


2 rmdir : '; / / 4 /
@ # 4@ /
4 < H.H -H..H@ 9 /

SINTAXIS
rmdir [opciones] directorios...

$ C ) / @ 9 +
#) 6 @ ) rmdir -p /tmp/1/2/3@ /tmp/1/2/3I 4
/ @ I @ + / /tmp/1/2@ + /tmp/1@ -# /tmp

, B/ # rmdir

9 ( : &
-p > E A / @ /

( '" "% rmdir

3.1.6. Comando cp
2 cp : '; #) D # - @ #
9 ) # #
SINTAXIS
cp [opciones] origen... destino

- / ) : / ;@ / #)
9 + @ +
@ / B ) +

26 E

polifemo:~$ cp fichero1 fichero2


polifemo:~$ cp fichero1 /tmp/fichero2
polifemo:~$ cp *.c /tmp
polifemo:~$ cp fichero1 fichero2 /tmp

, ) A # ) - 9 $ @
9 # -p / : # ; cp B/

9 ( : &
-i E + / / #) "
-l 2 $ @
-s 2 $ @ =
-b ! + ) 9 / /
-P ! ) + - +
-p ' # )@ @ -+ ) +
-R 1 E /A #) 9 A
-u D $ E / / #) 9 + 9
-v ' / #)

- '" "% cp

3.1.7. Comando rm
2 rm : ; / #) D
/

SINTAXIS
rm [opciones] ficheros...

! / ) 9 / @ rm #
9 # $ # -f @ 9 #
#) : 9 + ; $ -i

D+ 6 rmE
polifemo:~$ rm .c *.h
polifemo:~$ rm -f /tmp/*

/ -R 2 +
:- / ; # E rm -fR * = / )
$ @ 9
01- 9 +0:1- 1 2
/ # rm / :mv; ' ) ' C= /
/ @- 9 ' C= rename ; . ! &

, B/ & + rm

9 ( : &
-i E # / #)
-f # #) "
-r 1 E/ #) / - /A /
-R + 9 -r
-v ' / #) /

/ '" "% rm

3.1.8. Comando mv
2 mv : ; / / #) @ /
=/ # ) + - )- + @
/ #) W W - mv / -3 ) I
/ @ )- + @ + + @ @
-mv < )

SINTAXIS
mv [opciones] origen... destino

, 9 B/ 6 9 $
cp

9 ( : &
-i E + / / #) "
-b ! + ) 9 / /
-u D $ E #) 9 + 9
-v ' / #)

2 '" "% mv

D + 6 E
• 1 / #) copia1 copia2

• ' - / #) copia1 copia2

• ' #)

• ' #)

polifemo:~$ mv copia1 copia2


polifemo:~$ mv copia1 ../copia2
polifemo:~$ mv *.tiff /tmp
polifemo:~$ mv /tmp/*.tiff .

3.1.9. Comando ln
2 ln : &; /
#) 2 #) 9 @ #
#) , E

• & :" ;E : / ;
# $ 9
) $ 2 $ @
< 9 ) 2 #) + /A D 4@ /
: 9 #) + ; 9 : / ;@
2 + < -@
9 @ #) ! $9 ?
#) @ <

• & !& E : / ; #) 9
: ;@ - " 9 # #) + 2 #)
+ # / / / #)
+ @ / 9 @ /6 9 - " :
G 7;

2 ln / #) + - E

SINTAXIS
ln [opciones] origen... [destino]

! + # #) @ ! #
/ : + < ) ;@ /
: + ) @ @ -
/ 9 + @ ; @ 9 @
9 + / #

2 # 9 $ -s@ 9 9 / +

# @ ln / / / #) 9 " @ + @
$ -f 9 D @ -i + / /
+< # ) "
&

2 : 4
) ; ) / 2 6
# @ " 9 / $ rmdir@ rm@ - 9
#)

# / $ : ) ; ls
-l@ - 9 6 #) 9 # #) @9
HlH 6 E + 9 " E Hdir1H -
/ A @ Hotro_dir1HI ) ls -l / 9 dir1 @ -
otro_dir1 9 @ @ dir1 : 6 / @ ) 4 ;E

polifemo:~$ mkdir dir1


polifemo:~$ ln -s dir1 otro_dir1
polifemo:~$ ls -l
total 1
drwxr-xr-x 2 llorente users 1024 Oct 15 09:59 dir1/
lrwxrwxrwx 1 llorente users 4 Oct 15 09:59 otro_dir1 -> dir1/

, # @- 9 9 + @- )-
+ A : A # ; , 9 4 +
/ $ : # ) ; B /A ) ls -l@ -
9 + < 9 #) 2 + 6
$ /A C 9 /A H.H -H..HE

polifemo:~$ ls -al
total 7
drwx--x--x 3 llorente users 1024 Oct 15 10:08 ./
drwxr-xr-x 16 root root 5120 Oct 14 11:27 ../
drwxr-xr-x 2 llorente users 1024 Oct 15 10:01 dir1/
lrwxrwxrwx 1 llorente users 4 Oct 15 09:59 otro_dir1 -> dir1/

/ 9 E

• 2 otro_dir1 @- 9 $ A

• 2 dir1 E - @- Hdir1/.H@ 9 dir1


: mkdir; dir1 :\
/ ];

• 2 H.H E H.H@ H/home/llorenteH -


H/home/llorente/dir1/..H

• 2 H..H < E H..H : H/home/llorente/..H;@


H/homeH @ H/home/.H - H..H home :
# H/home/USUARIO/..H;
, ) + # :
#) @ ?@ ;E

• 2 )

• 2
• 2 +

• ,

• , # ) # @ @

, B/ % 9 ln ' ) 6
$

9 ( : &
-s 9 9 / / :- ;
-f 9 / / #) "
-i E + / / #) "
-b ! + ) 9 / /
-v ' / #)

5 '" "% ln

D+ 6 lnE

• ! / ' / ttys

• ! acceso_a_dispositivos

• #) 9 + C practicas
practica_copiada@ / / #) 9 )/ A

• #) /home/profesor/notas_practicas #) mi_susupenso

polifemo:~$ ln -s /dev/tty* ttys


polifemo:~$ ln -s /dev/tty acceso_a_dispositivos
polifemo:~$ ln -f /home/fjgarcia/practica/* ~/practica_copiada
polifemo:~$ ln /home/profesor/notas_practicas mi_suspenso

=/ - / /6 /
# $ @ - 9 / /6 + +
# @ /
5 / 6

+ 9 E dir1 - dir2 = dir1@ #) mi_fichero@ -


) 9 / #) @ dir2E

Creación de la estructura
polifemo:~$ mkdir dir1
polifemo:~$ mkdir dir2
polifemo:~$ cat >dir1/mi_fichero
Este es el contenido de mi_fichero
^D

2 + D 9 ln : ) ls -l
;@ #) + E
%

polifemo:~$ ln -s dir1/mi_fichero dir2


polifemo:~$ cd dir2
polifemo:~/dir2$ ls -l
total 0
lrwxrwxrwx 1 llorente users 15 Jan 25 11:14 mi_fichero -> dir1/mi_fichero
polifemo:~/dir2$ cat mi_fichero
cat: mi_fichero: No such file or directory

, $ 9 @ 9 / ) + Hdir1/mi_ficheroH
/ :~/dir2/;@ @9 9 + H~/dir2/dir1/mi_ficheroH =
+ : $ / ;
H../dir1/mi_ficheroH , + 9 / 4 )/ @ 9 @
9 / @ < + :
9 9 4 / # ; 2 @ #
+ E

polifemo:~$ ln -s ../dir1/mi_fichero dir2


polifemo:~$ cd dir2
polifemo:~/dir2$ ls -l
total 0
lrwxrwxrwx 1 llorente users 18 Jan 25 11:24 mi_fichero -> ../dir1/mi_fichero
polifemo:~/dir2$ cat mi_fichero
Este es el contenido de mi_fichero
polifemo:~/dir2$

1 9 / /6 / I
9 / # 9
, / ) # / / +
6 @ / mi_fichero / : 6 dir3 dir2;@
6 E

polifemo:~/dir2$ mkdir dir3


polifemo:~/dir2$ mv mi_fichero dir3/
polifemo:~/dir2$ cd dir3/
polifemo:~/dir2/dir3$ ls -l
total 0
lrwxrwxrwx 1 llorente users 18 Jan 25 11:24 mi_fichero -> ../dir1/mi_fichero
polifemo:~/dir2/dir3$ cat mi_fichero
cat: mi_fichero: No such file or directory

2 9 @ / / @ 6 $ / 6 E

polifemo:~$ ln -s ~/dir1/mi_fichero dir2


polifemo:~$ cd dir2
polifemo:~/dir2$ ls -l
total 0
lrwxrwxrwx 1 llorente users 29 Jan 25 11:45 mi_fichero -> /home/llorente/dir1/mi_fichero
polifemo:~/dir2$ cat mi_fichero
Este es el contenido de mi_fichero
0

3.1.10. Comando chmod


2 chmod : " ; / #)
&, " ' : + &; chmod @
@- + ) : #) @ ; 9 ) -9
E

SINTAXIS
chmod [opciones] permisos ficheros...

, # # E / A 2 &"0 % 0 "@
# + "E

[{u|g|o|a}]{+|-|=}{r|w|x|s}

2 E 6 Y 8 8 8 [@ 4/ YJ8 K8 L[@ - Y 8 (8 8 [

• , # / E : ;@ + : ;@ : ;@ /
: ; @

• 2 4/ # / E ? :J;@ + :K;@
/ / < :L;

• , < # + E : ;@ :(;@ 6 : ;@
/ :; < : ;@ #
: ; + : ;
6 E

• D? E a+r

• 1 + 9 + E o-w

• 2 / rx : - 6 ; E =rx

• D? - + E ug+w

• D? # -+ E ug+s
$ . " & " "
6 @ / - 6 - 6 $ +
E a=x,u+r
2 &"0 %: " @ # < ) # @
# : < * - %; / @ @ + - @
@ # *C% +< B/ 0 2
/ @ @
(

4 < & ! +
0 000 ---
1 001 --x
2 010 -w-
3 011 -wx
4 100 r--
5 101 r-x
6 110 rw-
7 111 rwx

6 1 %: " % ""

# # @ 9 *@ 9 % 9 *%
, / $ @ 9
4+ @ # @ 9 < $ 5 +
6 E

• + E 777

• @- @ 6 - E 744

• - 6 E 555

• - @ 6 - + - 6 E 651

, # 9 chmod B/ (

9 ( : &
-v ' / 9 $ #)
-c ' / 9 $ #) $ +< /
-f / /
-R 1 E /A #) 9 A /

8 '" "% chmod

3.1.11. Comando chown


2 chwon : " ( ; / #) +
#) chwon /A / + 9 #) :
chgrp /A / + @ ;

SINTAXIS
chown [opciones] [propietario][{.|:}grupo] ficheros...

2 -+ # / # @ +
$2 / - + :.; ::;@
*

9 / + @ / /
+

, B/ * 5 ) + 6 chown

chown llorente /tmp/*.c /tmp/*.h


chown llorente:users /tmp/*.c
chown :users /tmp/inicio.c
chown root.root /tmp/inicio.c

9 ( : &
-R 1 E / 3
+ #) /
-v ' / #) 9
-c ' / #) 9 @ ) +< /
-f 6 / 3+

$9 '" "% chown

3.2. Comandos de procesamiento de ficheros


2 " + < ? #) " @
9 / + 9 , 9
$ #) " @ 9 9 9 $
#) /

3.2.1. Comando cat


2 cat : ; #) 2 :
; D #) 9 ) -9 2
9 # #) @ 9
#) : )/ cat; # +< # ) @
cat : ;

SINTAXIS
cat [opciones] [ficheros...]

cat $ 9 ? #) " 2 Hcat >nuevo_textoH


#) nuevo_texto 9 / , 9 )
: ; - @ 9 ) #)
nuevo_texto ! $ @ # "
9 / 9 M$ : $; 4 :)
+ ^=;@ 9 ^= 6 :^= ;E

polifemo:~$ cat >nuevo_texto


Este es el texto que va a contener (estas dos lineas las escribimos nosotros)
el fichero.
^D (pulsamos ^D)
polifemo:~$ cat nuevo_texto
Este es el texto que va a contener
el fichero.

2 cat # B/

9 ( : &
-n 9 4 : $ ;
-b 9 4 @ 4 / : 4;
-s 2 < 4 / + < 4 4
' / H^H@ - - + D ! - 9
-A
% HM-H

$ '" "% cat

3.2.2. Comando wc
2 wc :( ; 4 @ / - 9 #)
# #) @ / : ;
9 < 4 @ / - : ;- / #) D @
#) @ #

SINTAXIS
wc [opciones] [ficheros...]

wc / 6 9 )- / : @ / @
@ ; ! -c@ -w --l ) 9 $ @ -
B/ 2 9 / #) )
@ - < 4 @ / @ :
# $ ; 2 + 6 < 4 - / #) *.c

polifemo:~$ wc -wl *.c


3 11 f1.c
533 1118 data.c
24 121 x_2.c
0 0 empty.c
560 1250 total

+< # ) @
9 ( : &
-c < : < /- ;
-w < /
-l < 4

$$ '" "% wc

3.2.3. Comando sort


2 sort #/A 4 #) @ $ 4
#) - / #) , )
# -c --m

SINTAXIS
sort [opciones] [ficheros...]

• $ -c -m@ E #) # @ # @
-

• ! -c@ sort $ / #) @ ) I
(

• ! -m@ sort $ $ #) # 9 # @
9 9 #) # A ! 6@ A
9
2 # #/A / D ! @ 9 $
2 # -f ) 9 + -< - < @ -n 9
A :- #/A ;@ -b + @ , B/
#
/ #) 9 @ @ # / + $
# :4 ;- : +< @ 6 @ / ; 2
/ :# ) ; +< 9 9 4
/ sort E

• 2 9 $ -t + :) -
9 6 A -t - ;

• 2 < 9 : ; 2 +### -
-###@ KKK < : $ *; +###
--### < : A @ ) # 4 ; 2 9
+### - -###@ A 2 < #
< :.;I 9 9 $9 < I
9 9 ) : ; < : <
@ / ; = < : ; $
# : A @ + -< 3 < @ ;@

(
B
, -o + : ; / #) @ ) 9 4
#) + 2 9 $ #) #) @
) A $
< @ C #

9 ( : &
-b + / : @ / @ ; 4
-d + 9 <
-f + # -< - <
9 ? # HJANH@ HFEBH@ HDECH D
-M
+ # -< - <
-n 9 < : ;
-r
-o # #) +
-t #
+### KKK : *;
-### KKK < : *;

$( '" "% sort

26 E

• , #) - +< : ls -l /
9 ;E

polifemo:~$ ls -l|sort +2 -3
total 11
-rw-r--r-- 1 llorente users 99 Oct 19 14:35 nuevo_texto
-rw-r--r-- 1 llorente users 7869 Jul 10 1997 termcap
-rw-r-x--x 2 llorente users 41 Oct 19 14:47 fichero1*
-rw-r-x--x 2 llorente users 41 Oct 19 14:47 fichero2*
-rwsrwsrwx 1 root root 0 Oct 19 11:41 p*

• , #) - +< - A +< ?E

polifemo:~$ ls -l | sort +5M -6 +4n -5


total 11
-rw-r--r-- 1 llorente users 7869 Jul 10 1997 termcap
-rwsrwsrwx 1 root root 0 Oct 19 11:41 p*
-rw-r-x--x 2 llorente users 41 Oct 19 14:47 fichero1*
-rw-r-x--x 2 llorente users 41 Oct 19 14:47 fichero2*
-rw-r--r-- 1 llorente users 99 Oct 19 14:35 nuevo_texto

• ! #) - - 6 E

polifemo:~$ cat >animales


oso (esto lo escribimos nosotros)
pez
elefante
rana
^D (pulsamos ^D)
polifemo:~$ cat >plantas
pino (esto lo escribimos nosotros)
encina
rosa
alcornoque
^D (pulsamos ^D)
polifemo:~$ sort plantas animales
alcornoque
elefante
encina
oso
pez
pino
rana
rosa

3.2.4. Comando more


2 more #) ) + : ;
# #) @ @) 4 4
$

SINTAXIS
more [opciones] [ficheros...]

$ " + @ $ + E

• E $ +

• ED $ 4

• IE
! $9 $ #) @ 4 # @
$ ) /@ 9 -p@ 9 ) 9 +
9 $ $ : ; 9
B/

9 ( : &
-### < ### 4 +
+### < ### 4 9 ) -9 $
+/ + @) 9 #)
-p 9 + 9 $ $ : ;

$- '" "% more


&

3.2.5. Comando less


2 less $ #) 2 6 more@
# , 6 / more 9 + " )
)

SINTAXIS
less [opciones] [ficheros...]

$ - " + $ @ more@
D " - @9 man less =
/ 4 @ 9 ) -N

2 man $ less #

9 ( : &
-N ' < 4 6 4

$/ '" "% less

3.2.6. Comando tail


2 tail < 4 #) #
*< 4 @ <

SINTAXIS
tail [opciones] fichero...

, )/ -n@ 9 # < 4 9 ) -9
6 @ < 4 #) E

polifemo:~$ tail -n 3 mi_fichero

# #) $@ @ 4 @
9 -q 26 E

polifemo:~$ tail -n 2 animales plantas


==> animales <==
elefante
rana

==> plantas <==


rosa
alcornoque
polifemo:~$ tail -q -n 2 animales plantas
elefante
rana
rosa
alcornoque

, B/ + # 9 $ tail

9 ( : &
-c # < # 9 ) -9 : $ 4 ;
-q 4 #) )- #)
-n # < 4 9 ) -9 : # *;

$2 '" "% tail

3.2.7. Comando head


2 head 4 #) #
* 4 @ <

SINTAXIS
head [opciones] fichero...

, )/ -n@ 9 # < 4 9 ) -9
6 @ 4 #) E

polifemo:~$ head -n 3 mi_fichero

# #) $@ @ 4 @
9 -q 26 E

polifemo:~$ head -n 2 animales plantas


==> animales <==
oso
pez

==> plantas <==


pino
encina
polifemo:~$ head -qn 2 animales plantas
oso
pez
pino
encina

, B/ % + # 9 head
%

9 ( : &
-c # < 9 ) -9 : $ 4 ;
-q 4 #) )- #)
-n # < 4 9 ) -9 : # *;

$5 '" "% head

3.2.8. Comando grep


2 grep : ; 4 #) 9
@ 9 " # #) @ / I
# + /

SINTAXIS
grep [opciones] patrón [ficheros...]

2 # 4 9 :
# B/ *; D @ + $@
A" @ - @
2 , / 9
+ B/ 0

8 ' (
. ! 9
[] ! 9 6 + : [0-9A-Z];
^ ! $ 4
$ . 4
< ! $ / :T_;
> . / :TM;

$6 1 % )" , &; grep

! 4 - @ 9 / 4/
/ @ B/ ( 9 / 9 # 4: 6 @
9 / ;@ / = #
4I / ) @ 9 A /
@ / /
0

8 ' (
x* x * :x 4;
x? x * :x 4;
x+ x :x 4;
x{n} x n :x 4 -n < ;
x{n,} x n :x 4 -n < ;
x{,n} x * n :x 4 -n < ;
x{n,m} x n m :x 4 -n -m < ;

$8 1 % &"0 , &; grep

B /A + /" $ A - $ 1 +
4/ / 4 :|;

, ) -< - < 9
-i # grep 4 9 @ /
$ E

• 4 9 $ -v

• < 4 9 $ -c

• ) 9 + 4 $ -l

" 9 9 / $ + :C;@ 4 #
2 $ -e 6 " 9 9
@ " 6 @ $ H-v-H #) /
/E

grep -e -v- *

6 E

• > / 9 HaHE

grep "^a" /etc/passwd

• ' #) informe 4 9 + / HB 2!12BHE

grep -v "TOP SECRET" informe

• ' #) !9 4 4E
(

grep -l "^$" *.c

, B/ * grep

9 ( : &
-i ) -< - <
-v ' 4 9
-c ' < 4 9
-l ' ) 9 + 4 @ + 4
-e # 9 9 " :- ;
-n ' < 4 9 " #)
-s 6 +< # )
-q + I A"

(9 '" "% grep

2" grep@ 6 fgrep -egrep@ 9

3.2.9. Comando find


2 find / #) / 2 /< 9 -# "/ @
/ / @ ? @ # )@ B /A # /
9 / @- + $ #) $

SINTAXIS
find rutas... [criterios] [acción]

• rutas 6 $ / find / -
/

• /< 9 @- 9 # / : / @
# )@ ; - : / @ # )@ ; , B/ +
/ / @ A D = - 1
) D =@ / / /< 9 I ) 1@ -o
D @ :!; 9 #
:/ #) 9 ; D @ # 9 <
$ A 9 A ) @
/ A / :\;@ @

• acción 9 / 6 find $9 ) 9 #9
/< 9 , B/ /
@ #) 2
9 < < H-H " 9
9 @ H+H " 9 - 9
: # < + ;
&*

& ' ( 5 !4 . 6
-name nombre > #) - / nombre
> #) - modo , # # A :
-perm modo &, " ' + &; modo +
:-; / #) 9 + @- + :+;@
/ #) 9 + +
> #) - x@ x Ef / #) @d
-type x
/ @ l / / @ c / @
> #) 9 + < ### -KKK + # KKK
-links ###
+KKK + # KKK
> #) 9 + ? ### / 9 + 9 ? / 9
-size ### 8 /- KKKk D @ -KKK + # KKK/ 9 - +KKK
+ # KKK/ 9
-user nombre > #) 9 $ nombre
> #) 9 )- ) ### 4 -KKK + # KKK 4
-atime ###
+KKK + # KKK 4
> #) 9 )- # ) ### 4 -KKK + # KKK 4
-mtime ###
+KKK + # KKK 4
-newer nombre > #) 9 #) nombre

( " "& +, "% find

& ' ( 5 !4 . 6
-print / ) $
26 comando / #) $ @ $ Y[@
9 ) / D @ # @ / -
-exec comando
:;; / 9 ; ) ; 6 -
exec cat {} \; ) 9 #) $

($ " "" find

5 + 6 findE

• > #) 9 HaH - /tmp :- / / ; -


E

find . /tmp -name "a*" -print

• , $ #) passwd - E

find / -name passwd -print

• ' #) # llorente 9
/ 9 E
&

find /home/llorente -mtime -7 -size -2 -exec cat {} \;

• > #) 9 + / *.c - + * 4@- /A 9 9


E

find / \( -mtime +30 -name "*.c" \) -o -user fgarcia -exec rm -f {} \;

01- 9 +0:1- 1 2 -9 /< 9 / #) @- 9


4 / ) 9 6 @ 9 / 4 /
#) @ + / #) 9 9 / @
: 6 ;@ 9 + @- )
+
2 / / /A @ find

3.2.10. Comando uniq


2 uniq #) 4 2 #) /
# #) - #) : ; @
$ -

SINTAXIS
uniq [opciones] [entrada [salida]]

# #) @A @ -
" , 9 uniq # @ / B/

9 ( : &
-u 9 4 4
-d 9 4 4 : 4 ;
-c ' $9 4 < 9

(( '" "% uniq

3.2.11. Comando comm


2 comm 4 - #) :fichero1 -fichero2;
@ -+ # E 4 9 fichero1@
4 9 fichero2 - 4 9 #)

SINTAXIS
comm [opciones] fichero1 fichero2

, C @ C -C ) 9 @ B/
&

9 ( : &
-1 9 :4 9 #) ;
-2 9 + :4 9 + #) ;
-3 9 :4 9 / #) ;

(- '" "% comm

3.2.12. Comando cmp


2 cmp : ; #) @ ! @
69 < /- : ; #) - < 4
# #) : 4 - $ ;
#) + @

SINTAXIS
cmp [opciones] fichero1 fichero2

cmp # ! -l $ #
9 E # :/- ;@ + D ! 9
#) @ - + D ! 9 + #)
, B/ & # 9 $ cmp

9 ( : &
-l # - 9 #
-s #) # @ 9

(/ '" "% cmp

3.2.13. Comando lpr


2 lpr : ; D #)
I # + @

SINTAXIS
lpr [opciones] [ficheros...]

! -# + : ; <
B/
=/ 9 % , &; , &) " "& %), @ 9
+ 9 $ : ) # ;
&

9 ( : &
-#nnn nnn <
-Pxxxxxx xxxxxx / 9 ) -9 $
-r 9 #) $# $
-m 9 4 6 /6 )-

(2 '" "% lpr

3.3. Comandos de manejo de unidades y dispositivos


5 9 - 9 O /
9 # < @ + $ <
/ ! / 9 ? $ : 6 @
9 !=C1 ' ;@ 9A / 9
/ : ;@ - /A ) -9
9 : ; )
: 6 @ 9 ;@ ? /
/ - # $ @ /6

D $ /
2 / , B/ % +
, "
01-2
, / @ #) 9 / /dev ,
: / 9 @ I- @ ; , /dev / < 9
) 7 ! # @ #
/dev
, " / + ' C= 3G 7@ 9 "
9 # ' C= 3G 7

/ 7 : &
hda : =2;
hda1 : =2;
hda2 + : =2;
hda3 B : =2;
...
hdb + : =2;
hdb1 + : =2;
...
hdc B : =2;
hdd ! : =2;
...
fd0 # "/
&

/ 7 : &
fd1 + # "/
...

(5 & "

3.3.1. Comando mount


2 mount #) =/ 9A
- 9A / 9 /C / )

SINTAXIS
mount [opciones] [dispositivo directorio]

• dispositivo + /dev 9 # +< @ 6


+ B/ %

• disrectorio +< 9 A 9 4@
)+ : + ;@
I $ @ 9 /

# @ mount

, " #) :# ;@ 9
/ 9 /A + 9 # 9 2
) + : -t ; / 9 /
#) E minix@ ext@ ext2@ xiafs@ hpfs@ msdos@ umsdos@ vfat@ proc@ nfs@ iso9660@ smbfs@ ncpfs@ affs@ ufs@
romfs@ sysv@ xenix@ coherent , " #) @
" 4
@ 9
: 9 + /
6; 2 @ -r@
# 9 #

2 + 6 /mntE

mount /dev/hda1 /mnt

2 + @ 9 ' " /mntE

mount -t minix /dev/fd0 /mnt

, B/ 0 mount
&&

9 ( : &
-r '
-t # #)

(6 '" "% mount

3.3.2. Comando umount


2 umount mount = /
# 9 @ /

SINTAXIS
umount [opciones] {dispositivo|directorio}

" : ';@ @ #)
/ @ " - # $
, + 6 6 6
mountE

umount /dev/hda1
umount /dev/fd0

3.3.3. Comando df
2 df : & ; $ 9
E @

SINTAXIS
df [opciones]

6 @ + 9 #) polifemo #
:sda2@ 4$@ -sda3@ /home; 2 (0 ** / 9
* /- * : @ @0( F>;@ 9 ) 0 * */ 9 : L; - 9 / (& & &
/ 9 2 + ( 0%& / 9 : @*( F>;@ 9 ) 0 :
&(L; -9 / 0 *

polifemo:~$ df
Filesystem 1024-blocks Used Available Capacity Mounted on
/dev/sda2 1982006 684010 1195545 36% /
/dev/sda3 2191875 1218246 860324 59% /home

*
D $ / 9 & /- 9 9 +
&

B 9 9 0 *' > / / ) /home :-


/ ; @ F> /

3.3.4. Comando mdir


2 mdir : 7$- '; $ 9 : +
9 ; ' C= 3G 7 9 :
/ 9 # ; 2 ) dir
' C= 3G 7

SINTAXIS
mdir [opciones] directorio

2 # $ # , "-' C= 3G 7E

• 2 / # ' C= 3G 7@ + ::;

• , / :\;@ 9 9 :/;

2 + 6 $ 9 9 ' C=
9 E

mdir a:/copia/*.*

, # 9 B/ (

9 ( : &
-w ' # ) : /w ' C= 3G 7;
-a - #)
-f # / / : 4 ;

(8 '" "% mdir

3.3.5. Comando mcopy


2 mcopy : 7$- '; #) / , "-
9 : + ; # ' C= 3G 7
9 : / 9 # ; , $ ) ' C
= 3G 7

SINTAXIS
mcopy [opciones] origen... [destino]

, / #) 3 ' C= 3G 7 + +
9 mdir
&%

# #) + @- @ B /A
# #) + - #) @- / .
# #) + @- #

, 9 mcopy B/ *

9 ( : &
-t ! #) " :) CR CR+LF@ - ;
-n # / / #) , "
-o # / / #) ' C= 3G 7

-9 '" "% mcopy

3.3.6. Comando mkfs


2 mkfs : & ' ; # @ 9 , "
# #)

SINTAXIS
mkfs [opciones] dispositivo

= # + : / ; , B/ %:
+ & ; + + , "

! -t #) : mount;
D @ -c ) 9 #9 # / / 9 ?

9 ( : &
-t # #)
-c ! / / 9 #

- '" "% mkfs

3.4. Comandos de manejo de procesos


O / : 19
N, #. + ;9 + 9
6 -9 # <
), $*
2 ) 9 6

3.4.1. Comando ps
2 ps : ; 9
6

SINTAXIS
ps [-][opciones]
&0

, / # +< + :-; , + ps 4
/ + I ) : 9 @ 6 ;

# ps < 9 6 ps@
+ # E

• =E < #

• BBOE / 6 :-9 6 ;

• BDBE 2 E + + # E RE 6 @ SE : ;@
TE : +< ;@ ZE

• B ' 2E B 9 6 : < $9 6 ;

• ! ' ' D =E / 9 6 : ;
6 E

polifemo:~$ ps
PID TTY STAT TIME COMMAND
2500 p1 S 0:00 -bash
2897 p1 R 0:00 ps

, ps B/

9 ( : &
l . +E # /
u ' # / - 6
s ' # / ? 9 6
m ' # / 9 6
a ' /A
h 2 4 /$ : 4 ;
r 9 6 : ;

-$ '" "% ps

3.4.2. Comando kill


2 kill ? / ? @
6 : ; , ? ( : F` ,,; kill
@ )4 /

SINTAXIS
kill [opciones] procesos...

, # ,$ + = E
&(

• $ ps

• D 6 + : & 4 ;@ A
,$ 9 9 +

, 9 $ -s@ 9 # < ?
: / W -< W < ; ? / $
-l E

polifemo:~$ kill -l
1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL
5) SIGTRAP 6) SIGIOT 7) SIGBUS 8) SIGFPE
9) SIGKILL 10) SIGUSR1 11) SIGSEGV 12) SIGUSR2
13) SIGPIPE 14) SIGALRM 15) SIGTERM 17) SIGCHLD
18) SIGCONT 19) SIGSTOP 20) SIGTSTP 21) SIGTTIN
22) SIGTTOU 23) SIGURG 24) SIGXCPU 25) SIGXFSZ
26) SIGVTALRM 27) SIGPROF 28) SIGWINCH 29) SIGIO
30) SIGPWR

# kill $ ? SIGTERM@ ) / $ / ! -s
)/ @ /A @ / / < ? + ,
+ 6 4 ? - ,$ & : 9 ;E

kill -9 2543
kill -s 9 2543
kill -SIGKILL 2543
kill -s SIGKILL 2543

? 9 : 9 A
)- 6 ;
, B/ /

9 ( : &
-l ' / ? - <
-XXXXX -XXXXX / < ? 9 ) -9
-s # # / < ? 9 ) -9

-( '" "% kill

3.4.3. Comando top


top , " ps ' # / 9 @
# 9 # +

3.5. Comandos de administración


, 9 D+
$ I
*

3.5.1. Comando passwd


2 passwd : ( ; / D @
/

SINTAXIS
passwd [usuario]

2 / / 19
G @ + (

3.5.2. Comando shutdown


2 shutdown : " ( ; +
O / 9 + )/ ! shutdown@
+ @ # @
9 # $ /6

SINTAXIS
shutdown [opciones] hora [mensaje]

• hora ) 9 $ = 6 -)
9 +< , ) #
# / 2 # / hh:mm : 16:25@ - ;I
# +mm : +15@ & ; B /A $ / now@
9 +0

• 6 69 4 # "
/ /
6 @ !=C1 ' @ 9 + @-
+ + $ * E

shutdown +10 "El sistema será interrumpido para instalar una unidad de CD-ROM"

, 9 B/

9 ( : &
-k E 4 6 @
-r 9 A
+ # ) @ 4
-c
6 9 + )

-- '" "% shutdown

2" 9 E halt - reboot B / $


# "
3.5.3. Comando adduser
2 adduser : ; / @ # 9
adduser - $

SINTAXIS
adduser

! 6 + @ E / @ <
@ < + @ " @ ) @ -# ) " D @
@ / @ ) @ A# @ . )/ 9 +
2 ) adduser # @ // @
9 - 4 / -

5 + 6 @ 9 9 user133
+ " E

polifemo:~# adduser

Login name for new user (8 characters or less) []: user133


User id for user133 [ defaults to next available]:
Initial group for user133 [users]:
user133's home directory [/home/user133]:
user133's shell [/bin/bash]:
user133's account expiry date (MM/DD/YY) []:

OK, I'm about to make a new account. Here's what you entered so far:

New login name: user133


New UID: [Next available]
Initial group: users
Additional groups: [none]
Home directory: /home/user133
Shell: /bin/bash
Expiry date: [no expiration]

This is it... if you want to bail out, hit Control-C. Otherwise, press
ENTER to go ahead and make the account.

Making new account...

Changing the user information for user133


Enter the new value, or press return for the default

Full Name []: Usuario 133 de sistemas operativos


Room Number []: Laboratorio de informatica II
Work Phone []:
Home Phone []:
Other []:

Changing password for user133


Enter the new password (minimum of 5, maximum of 8 characters)
Please use a combination of upper and lower case letters and numbers.
New password:
Re-enter new password:
Password changed.
Done...
, # 9 + ) /etc/passwd : -
; -/etc/shadow : @ ;

3.5.4. Comando chsh


2 chsh : " " ; / ) #
D @ / ) 9

SINTAXIS
chsh [-s shell] [usuario]

! -s # ) : ) + 9 #
) # @# # @ adduser 2 + 6 @
/ ) llorente 9 /bin/csh

polifemo:~# chsh llorente


Changing the login shell for llorente
Enter the new value, or press return for the default

Login Shell [/bin/bash]: /bin/csh

B /A 4)/ ) ) $ -sE

polifemo:~# chsh -s /bin/csh llorente

3.5.5. Comando chfn


2 chfn : " ; # @9 6
addsuer D @ /
9 @ #

SINTAXIS
chfn [opciones] [usuario]

, E / @ ) @ A# )@ A# - !
B/ & # 9 ) -9 / # + @
+ # # @ adduser 6 E

polifemo:~# chfn llorente


Changing the user information for llorente
Enter the new value, or press return for the default

Full Name []: Jesús M. Alvarez Llorente


Room Number []: 101
Work Phone []: 2321
Home Phone []: 959222222
Other []:
9 ( : &
-f # / : ;
-r # < ) : ;
-w # A# ) :( & " ;
-g # A# :" " ;
-o # # : " ;

-/ '" "% chfn

3.6. Comandos de obtención de información


, / # @ # ) -) @ /
@ 9 /6 9 @

3.6.1. Comando who


2 who 9

SINTAXIS
who [opciones]

# @ who + # @ E /
@ / 9 @ ) @ 9
6 E

polifemo:~$ who
llorente ttyp0 Oct 22 10:18 (jmal.diesia.uhu.)
ggaleano ttyp2 Oct 22 11:13 (ggg.diesia.uhu.)
root ttyp1 Oct 22 11:03 (:0.0)

, who H-mH@ 9 /A / Ham iH 2 @ who #


whoami

3.6.2. Comando whoami


2 whoami :(" O; / /

SINTAXIS
whoami

26 E
polifemo:~$ whoami
llorente

3.6.3. Comando tty


2 tty / / 9
/6 : 9 $ ;

SINTAXIS
tty [opciones]

6 E

polifemo:~$ tty
/dev/ttyp1

3.6.4. Comando id
2 id / - < # : =;@ 4
/ + - < # :F =; 9 $

SINTAXIS
id [opciones]

6 E

polifemo:~$ id -a
uid=1000(llorente) gid=100(users) groups=100(users)

3.6.5. Comando date


$ - / # ) -) /
# ) -)

SINTAXIS
date [opciones]

6 E

polifemo:~$ date
Fri Oct 22 11:18:33 CEST 1999
&

3.6.6. Comando cal


2 cal $
? 9 9 ? +< ? @
I # ?@ @ ? # I-
# ?@ ?

SINTAXIS
date [opciones] [año [mes]]

6 E

polifemo:~$ cal
October 2000
Su Mo Tu We Th Fr Sa
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31

3.7. Comandos de control de sesión


2 -

3.7.1. Comando exit


2 exit / ) @ - A ) @

SINTAXIS
exit

3.7.2. Comando su
2 su : ; @ 9
# / : ;

SINTAXIS
su [usuario]

! @ 6 )/ 9 6 E

polifemo:~$ su chus
Password:
polifemo:/home/llorente#_
D) 6 #A # $ @ ) -9
) 9 @ exit@ 9 + +

/ $
/ @ @- 9 / )

3.7.3. Comando login


su@ 9 @ )/
2 6 $9 @-
9

SINTAXIS
login [usuario [variables de entorno]]

D # su@ + : " ;@ 9 exit@


" + + D @ login )
@ - / " @ 6 :
&& = + ((;@

2" # login -su@

3.8. Comandos de comunicación

3.8.1. Comando write


2 write 6 / # /
-@ @ / : '; 9 / 6

SINTAXIS
write usuario[@host] [tty]

/ 6 9 9 @ # /
9 / @: a;
2 6 @- / 9 A $
: " 4 ; D @ 6 / -
6 @ llorente / chusE

terminal del usuario llorente


polifemo:~$ write chus
Hola chus, estoy aquí.
^D

terminal del usuario chus


Message from llorente@polifemo.diesia.uhu.es on ttyp1 at 19:23 ...
Hola chus, estoy aquí.
EOF
%

3.8.2. Comando mesg


2 mseg : ; - 6 write

SINTAXIS
mesg [y] [n]

! y@ @- n@ # @ mseg
:His yH @ His nH ;-
# $ :* @ ;

3.8.3. Comando mail


2 mail 6 2 # @ 4
6 9 @ # / 9

SINTAXIS
mail usuario[@host] [opciones]

2 6:C ;@ 4 " /6
@ + 9 / " 2 9
/6 ) / 4@ 4 : ) ;
9 Hsubject:H 2 6 4 9 < :.; 2
#
6 @ 6 a ) E

SINTAXIS
polifemo:~$ mail llorente@uhu.es
Subject: hola
Hola. Acabo de llegar.
Saludos.
.
EOT

3.9. Comandos de cálculo


2 + $ @ + @ @

3.9.1. Comando expr


2 expr " A 2 /

SINTAXIS
expr expresión
0

, expresión : < ; - @
, 9 ) :
A ; / / 9 + #
, B/ expr 2"
A @ + - 6 , * # -
I + $ * # - 9 < * ,
$

0 ' (
+
- 1
*
/ =
% ' : ;
< ! I
<= !
= !
== ! : A =;
!= !
>= ! '
> ! '
| -% +
& #$ +
() #
= / 2 # substr cadena posición longitud@ - longitud
substr
posición cadena
length = + 2 # length cadena
= 2 # index cadena muestra@ -
index
cadena muestra

-2 < ) "% expr

2 + E -%@ #$@ @
@

2 + 6 / CONTADORE

CONTADOR=`expr $CONTADOR + 1`

3.9.2. Comando test


2 test / ! @ # +
/ @ A" : *;@ - @ : *;
(

SINTAXIS
test expresión

2 $ if - while 9 /
+ ) : G "@ + ( ; )
# @ " 2 )
@ 9 / / E

SINTAXIS ALTERNATIVA
[ expresión ]

2 ) $9 H[H + @ test@
+ / $ / 6
) $9 - "
, / " + B/ % B 9 # #) @ # #)
# " D @ / " $ B/ 0 D
+ 6 E

• ! / " #) /tmp/stastus

• ! / 4$

• ! / < - 9 &

• ! / 3 3 & % #) : @ @ ;

• ! / 9 " @ -9 /

[ -f /tmp/status ]
[ "/" = `pwd` ]
[ `who | wc -l` -gt 5 ]
[ -d /tmp/a35627 -o -f /tmp/a35627 ]
[ \( $HOME = `pwd` \) -a \( ! $USER = root \) ]

$ who : + 0; /
%*

; 7
-r ruta ruta #) : ;
-w ruta ruta #) : /;
-x ruta ruta #) 6 : 6 ;
-f ruta ruta #) : @ @ @ ;
-d ruta ruta
-b ruta ruta / 9
-c ruta ruta
-L ruta ruta /
-s ruta ruta #) ? - 9
-O ruta ruta #) -
-G ruta ruta #) - +
ruta1 -ot ruta2 ruta1 #) + 9 ruta2
ruta1 -nt ruta2 ruta1 #) 9 ruta2
-z cadena cadena +
-n cadena cadena + - 9
cadena1 = cadena2 cadena1 + cadena2
cadena1 != cadena2 cadena1 # cadena2
número1 -eq número2 número1 < + número2
número1 -ne número2 número1 < # número2
número1 -gt número2 número1 < - 9 número2
número1 -ge número2 número1 < - + 9 número2
número1 -lt número2 número1 < 9 número2
número1 -le número2 número1 < + 9 número2

-5 ) "% test

0 ' (
! +
-a D = +
-o 1 +
# :) -9 $ \ + #
()
) ;

-6 < ) "% test

3.10. Comandos de escritura


D + 9 /@ 6@/ @
%

3.10.1. Comando echo


2 echo / 6 2 6 #
/ 6 : ; /

SINTAXIS
echo [opciones] mensaje...

6# / # @ / /
@- 9 / @ - echo 9 ) /

= A 6@ echo : $ 4 ; @
$ -n

5 + 6 / < @
) 6 9 ) -n

polifemo:~$ echo Esto son 3 letras: a b c


Esto son 3 letras: a b c
polifemo:~$ echo "Esto son 3 letras: a b c"
Esto son 3 letras: a b c
polifemo:~$ echo -n "Esto son 3 letras: a b c"
Esto son 3 letras: a b cpolifemo:~$

echo $ / 6 @ / PATHE

polifemo:~$ echo "El path es $PATH"


El path es .:/usr/local/bin:/bin:/usr/bin:/usr/X11/bin:/usr/local/jdk/bin:/usr/o
penwin/bin:/usr/local/pascalfc/bin:/usr/lib/teTeX/bin

9 ( : &
-n 2 9 4 # 6

-8 '" "% echo

3.10.2. Comando clear


2 clear :/ ;

SINTAXIS
clear
%

3.10.3. Comando reset


2 reset / - 1 <
#+ )/ @ 6 @ / # + 9 )-
#+ #

SINTAXIS
reset

3.10.4. Comando banner


2 #

SINTAXIS
banner [opciones] mensaje

# ? - " -wtamaño 6 E

polifemo:~$ banner -w 20 hola


# #
##############
#
#
########
##
#######
#
# #
######
# #
##############
#
##### ##
# #
########
#

3.11. Comandos de manejo de variables


2 $ 6 / ) 2
F9
19G+ : + ;) 6 /

3.11.1. Comando export


2 export ) 9 / ) + 9
6 ) D 6 / 9 9 "

SINTAXIS
export [variable...]
%

# @ / # ) ) @- + 9
6 A ! ) 9 4 +
9 6

# +< @ export / 9 "

3.11.2. Comando set


2 set / # D @ -
+ ) : = / ) + ;

SINTAXIS
set

6 E

polifemo:~$ set
BASH=/bin/bash
BASH_VERSION=1.14.7(1)
EUID=1000
HISTFILE=/home/llorente/.bash_history
HISTFILESIZE=500
HISTSIZE=500
HOME=/home/llorente
HOSTNAME=polifemo.diesia.uhu.es
HOSTTYPE=i386
HUSHLOGIN=FALSE
LOGNAME=llorente
LS_OPTIONS=--8bit --color=tty -F -b -T 0
OSTYPE=Linux
PATH=.:/usr/local/bin:/bin:/usr/bin:/usr/X11/bin:/usr/local/jdk/bin:/usr/openwin/bin:/usr/local
/pascalfc/bin:/usr/lib/teTeX/b
in:/usr/local/pgsql/bin
PGDATA=/usr/local/pgsql/data
PGLIB=/usr/local/pgsql/lib
PPID=27357
PS1=\h:\w\$
SHELL=/bin/bash
SHLVL=1
TERM=vt220
UID=1000
USER=llorente

3.11.3. Comando alias


2 alias ) @ 4 - @
) : + ;

SINTAXIS
alias [nombre='comando [opciones]']
%

$ 6 # @ / @ - # @
/ / + 4/ =: 6 ;-
9 # @ /
6 E alias dir='ls -al'

3.12. Comandos de control de tiempo


, 9 ) @ - 6 +
) 4#

3.12.1. Comando sleep


2 sleep ) : 6 ; :
# + ;

SINTAXIS
sleep tiempo[unidad de tiempo]

2 tiempo < , unidad de tiempo + + Es: + ;@ m


: ;@ h :) ;@ d : 4 ; s: + ;

26 E) * + E sleep 10

3.12.2. Comando time


2 time 6 D
time 6 - A 9 ) 2
@ < @# )A@

SINTAXIS
time [opciones] comando [argumentos del comando]

6 E

polifemo:~$ time sleep 2


0.00user 0.00system 0:02.00elapsed 0%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (62major+8minor)pagefaults 0swaps

3.12.3. Comando at
2 6 )

SINTAXIS
at [opciones] comando [argumentos del comando]

2 + 6 6 + jesus1 ? / E
%&

polifemo:~$ at -f jesus1 11am Oct 23


Job 4 will be executed using /bin/sh

3.13. Comandos de ayuda


2 - 9 / # /

3.13.1. Comando man


2 man : ; $ + /
9 9 @ # $9
: I;

SINTAXIS
man [sección] tema...

, $ ) less@ 9 $
$ "
2 # @ #) @# + 6 !@ #
+ 6@ B # 9A
@ 6 @ #
mount # # ! mount() 2 9 $
9A 9 9 , #
< 6 E

• + mountE man 8 mount man mount

• + ! mount()E man 2 mount


= # @ ) # + @
/ - A <

# @ man / - 9
+ # + @ man /
, E

• 0E

• E

• E + 6!

3.13.2. Comando whatis


2 whatis :(" O; $ /
) @ + 6 + @ @

SINTAXIS
whatis [opciones] tema...
%

6 E

polifemo:~$ whatis ls
ls, dir, vdir (1) - list contents of directories
ls-R (5) - database for common TeX input files

2 @ $9 @ 6 9 :man;@
@- )@ / D + 9
@ # whatis less

3.13.3. Comando apropos


2 apropos 6 whatis@ # # 9 $ /< 9
"

SINTAXIS
whatis [opciones] tema...
%%

3.14. Resumen de comandos

' ( ' ) &


adduser D D?

alias ' 6 / # - "

apropos D- ' #

at ! 26 )

banner 2

cal # '

cat #) #) : ;

cd " ' ' 6#) ! / #

chfn " D ! /

chmod " ' 6#) ! / #)

chown " ( ' 6#) ! / -+ #)

chsh " " D ! / ) 9 $

clear 2 >

cmp #) > # #)

comm #) 4 - #)

cp ' ' 6#) ! #)

date # 5 $ / # ) -)

df & = @ - /

echo " 2 2 / 6

exit ! . $ )

export ' 6 / 9 / ) +

expr ! 2 < " A

find #) > #)

grep #) ' 4 #) 9

halt " D =

head " #) ' 4 #)

id # < # : =; -+ :F =;

kill & ! 2 ?

less ) * #) ' #) + @

ln & ' 6#) ! #)


%0

' ( ' ) &


login ! 2 )/

logout ! . $ )

lpr #) 2 4 #)

ls ' ' 6#) , /

mail ! 2 4 6

man D- 5 +

mcopy 7$- ' = ! #) 9 ' C=

mdir 7$- ' = , #) 9 ' C=

mesg ! D 6

mkdir & ' ' 6#) ! /

mkfs & ' = 9 # :, ";

more #) ' #) )

mount = '

mv ' 6#) ! / / -3 #) : ;

passwd ( D ! /

ps ! ,

pwd ( & ' ' 6#) ' #

reboot D + -

reset 2 1 -/

rm ' 6#) > #)

rmdir ' ' 6#) > /

set ' 6 / ' / - )

shutdown " ( D +

sleep !

sort #) 4 #)

su ! 2 @

tail #) ' < 4 #)

test ! ! /

time ! ! 9 6

top ! '

tty ' # /

umount = =
%(

' ( ' ) &


uniq I #) ' #) 4 + +

wc ( #) ! < 4 @ / - #)

whatis (" O D- ' #

who (" # , 9

whoami (" O # = /

write ( ! 2 4 6

/9 3 % "% = ' :&" % &


0*

' ( ' ) &


adduser D D?

chfn " D ! /

chsh " " D ! / ) 9 $

halt " D =

passwd ( D ! /

reboot D + -

shutdown " ( D +

apropos D- ' #

man D- 5 +

whatis (" O D- ' #

expr ! 2 < " A

test ! ! /

mail ! 2 4 6

mesg ! D 6

write ( ! 2 4 6

kill & ! 2 ?

ps ! ,

top ! '

exit ! . $ )

login ! 2 )/

logout ! . $ )

su ! 2 @

at ! 26 )

sleep !

time ! ! 9 6

df & = @ - /

mcopy 7$- ' = ! #) 9 ' C=

mdir 7$- ' = , #) 9 ' C=

mkfs & ' = 9 # :, ";

mount = '

umount = =

banner 2
0

' ( ' ) &


clear 2 >

echo " 2 2 / 6

reset 2 1 -/

cal # '

date # 5 $ / # ) -)

id # < # : =; -+ :F =;

tty ' # /

who (" # , 9

whoami (" O # = /

cd " ' ' 6#) ! / #

chmod " ' 6#) ! / #)

chown " ( ' 6#) ! / -+ #)

cp ' ' 6#) ! #)

ln & ' 6#) ! #)

ls ' ' 6#) , /

mkdir & ' ' 6#) ! /

mv ' 6#) ! / / -3 #) : ;

pwd ( & ' ' 6#) ' #

rm ' 6#) > #)

rmdir ' ' 6#) > /

alias ' 6 / # - "

export ' 6 / 9 / ) +

set ' 6 / ' / - )

cat #) #) : ;

cmp #) > # #)

comm #) 4 - #)

find #) > #)

grep #) ' 4 #) 9

head " #) ' 4 #)

less ) * #) ' #) + @

lpr #) 2 4 #)

more #) ' #) )
0

' ( ' ) &


sort #) 4 #)

tail #) ' < 4 #)

uniq I #) ' #) 4 + +

wc ( #) ! < 4 @ / - #)

/ 3 % "% = "& 4
0

4. Editores de texto
2 , " - " 5 / @
, "E

• C E $ 9 $ / 9 7, <
=2 > H H

• E -+ @ - " D # /6 + #

• E / 6@ 9 :
9 9 ;

• ( E + =2 >
H H @9 + - $

• ( E + # / 6 CG 7 (

4.1. Editor joe


2 C $ 9 $ / 9 7
, < =2 > H H@ 9 -#
D 6 @ / #) 9 9
/ @ - :man joe;

SINTAXIS
joe [opciones] [fichero]

, - 4 / 9 $ C #
6 @ M!6 : - !@ - + 6; C -
/ / ) 6 @
M; : - ;; / 4 #)
, B/ & / 9 $ C

! ' ) ' (
^KD D ) F #)
^KE D ) ! + #)
^KB > 9 ' / 9
^KC > 9 ! / 9
^KK > 9 ' # / 9
^KM > 9 ' / 9
^KR > 9 )
^KW > 9 F / 9 #)
^KY > 9 > / 9
^KF >< 9 # " / #)
0

! ' ) ' (
^L >< 9 1 < /< 9 $ :/ + ;
5 ) < / ) ) : ? @ ^' :
^^ 2
#; 2 " 4 / / #
= ) < / 2 " 4 / /
^_ 2
#
^D 2 > )
^O 2 > / $9
^W 2 > / )
^Y 2 > 4
Del 2 > $9
^A ' ' 4
^E ' ' # 4
^KL ' ' < 4 9
^KU ' ' #)
^KV ' ' # #)
^U ' 1 +
^V ' D $ +
^X ' ' / )
^Z ' ' / $9
^C 5 B - "
^KH 5 ' - /
^KX 5 F #) @ - "
^KZ 5 " 6 : exit;
D < #+ @9 / @
^T 5
@ / @ ? / @ + @

/$ 1 % " &" & .

#) ~/.joerc # @ @
- - : / ; $ )
/usr/lib/joe/joerc

4.2. Editor emacs


2 C @ ) - 6 2 <
# / " @ ) ,
) @ 9 "
, "
D 6 @ / #) 9 9

SINTAXIS
emacs [fichero]
0&

D+ / 9 $ #
6 @ M66 : - 6@ - + 6;
- @ 9 M. / ) 6 @ M
: - ; 4 B /A ) - / 9 $
. @ + / $ +
6 @ 2: - + 2;
! ' ) ' (
^X^F D ) ! + #)
^X^R D ) ! + #) @
^X^S D ) F #)
^X^W D ) F #) /
^XN D ) F #) /
^Espacio > 9 ' / 9
^W > 9 2 / 9
^X^I > 9 )
^Y > 9 + < / 9 :/ +< ;
Escape w > 9 ! / 9
^R >< 9 > )
^S >< 9 >
^XR >< 9 1 /< 9 )
^XS >< 9 1 /< 9
Escape ^R >< 9 > - $ #
Escape r >< 9 > - $: + ;
^D 2 > )
^K 2 > ) # 4
^T 2 / 9 +
^X^T 2 / 4 9 +
Escape c 2 -<
Escape d 2 > / )
Escape l 2 / < : ;
Escape t 2 / / / 9 9 +
Escape u 2 / -< : ;
^A ' 4
^B ' ' $9 :←;
^E ' # 4
^F ' ' ) :→;
^N ' ' / 6 :↓;
^P ' ' / :↑;

B /6 / 9 @ / 9 ^Espacio@ # @- <
# + / 9 @ 6 @ ^W / / 9
0

! ' ) ' (
^V ' D +
^X] ' D +
Escape : ' : 4 ;
Escape ; ' . :< 4 ;
Escape a ' 4
Escape b ' ' / $9
Escape f ' ' / )
Escape v ' 1 +
^X^C 5 B
^X^U 5 = ) < /
^XB 5 ! / : ) ;
^XX 5 ! / + : ) ;
Escape ^N 5 ! / /
Escape z 5 F #) -

/( " >" % & % "

2 /< 9 @ / / @ $ /< 9 :
HI ; , /< 9 $ 9 A)
/ 2 B/ &

0 -
^G !
? /
. - @
, : ;
y -/ +
Espacio -/ + :+ 9 y;
n -/ +

/- < " +, > && "0 & "&

# Escape - < @ -
6

) .emacs " #
# < /6 /6 + #
$ @ $ # A " 2 / @
" + # . @ + 9 " /
"
0%

4.3. Editor vi
" 2 / #4 6@
9 9 9 9 2 , "@
# + @ ) ? / ) @ @
' C= 3G 7 # + 2
@ @ / #) 9 9

SINTAXIS
vi [fichero]

# E " @ - =
9 / , .+ #

:sh Escape

exit ^D a i A I O
? ' " % &

• 2 " / - 6 ) $ @ )
) @ 6 +< @- + exit

• 2 /6 " E @ 4 / @
/ 4 @ 4 @ / / @ ) 3) @ / " @ + @ @ ,
+ : + -< - < ;
/ / +< 4 / @ 6 @ ::;

• 2 = ? " @
, B / && 9 $

! ' ) ' (
:w D ) F #)
:w fichero D ) F #) / fichero
^G D ) ' # / #) 9
##Y > 9 ! 4 - ##71 + : P p;
:r fichero > 9 #) fichero
p > 9 < / 9 / :dd; :Y; + 4
P > 9 < / 9 / :dd; :Y; 4
##G >< 9 4 < PP@ PP 9 <
00

! ' ) ' (
/patrón/ >< 9 " =
:## >< 9 4 < ##
?patrón? >< 9 =
n >< 9 1 < /< 9
N >< 9 1 < /< 9 @
~ 2 ! / / -< < @
a 2 @ ) : ;
A 2 @ # 4 : ;
C 2 2 4 ) - : ;
cw 2 2 / ) - : ;
D 2 > ) # 4
dd 2 > 4 : ;
dw 2 > ) ) # /
i 2 @ 6 : ;
I 2 @ 4 : ;
J 2 4 +
o 2 @ 4 + : ;
rx 2 1 $ / x
x 2 > ) : / ;
X 2 > $9 : ;
:w . ) F #)
- ' 4
$ ' # 4
^B ' 1 +
^D ' D +
^E ' D 4 :↓;
^F ' D +
^U ' 1 +
^Y ' 1 4 :↑;
+ ' 4 +
0 (cero) ' ' ) 4
b ' 1 /
B ' 1 / @ + /
Delete ' 1 :←;
e ' ' ) # /
E ' ' ) # / @ + /
Enter ' 4 +
Espacio ' D :→;
H '
0(

! ' ) ' (
L ' #
M '
w ' D $ / +
W ' D $ / + @ + /
z ' ! 9 9
z. ' !
:!comando ) 26 comando )
:sh ) ) 9 6 :exit + ;
:q 5 D/
:q! 5 D/ + /
:set 5 '
:set all 5 '
:wq 5 F #) -/
:x 5 F #) -/
u 5 = ) < /
U 5 1) < / ) )

// " >" % &

B < @ 9 ) 9
< 6 @ 3dd / 4 $@ 23P + < " / @

, /< 9 $ :.; 4 9 /
/ H\H 6 @ / Hetc.H / / +
E H3etc\.H

#+ @9 :set 2
/A / 6 @ C
H:set aiH H:set autoindentH@ - @ H:set noaiH H:set noautoindentH
9 HnuH : HnumberH;@ 9 < 4 $9 2
set /
, /A / ) #+ @ "
2 #) / H.exrcH - / vi 6 E

.exrc
set autoindent autowrite report=2 showmatch

4.4. Entornos wpe y xwpe


( :( ( ; + : ; 6
=2 > :> @ !@ ; 2 : .+ ; - "
# E

• , & E 6 / 9 @ @
(*

• E $ # +

• 7 & & E 4 -

• / ' E )/ $E 6 @ /6
: / ;@ @
) # 2 + $ 9
C -9 > ' C= @ <
2" + # : CG 7; ( @ A ( @ ,
.+ (

? $ "& & @

( /6 /6 + # @ 9 $ A "
+< " + # . @ @ @ /6
/ 6 .7( (
(

5. Scripts en bash
, ) @ @ + # /
@ ) # E " 7 @ @ @ #)
: "; ' C= :# ) Q9 ;@ )
D @ $ ) 4 +
E @ @
, A + : ;@ - /
D+ 4#

5.1. Creación de scripts


@ @ ) " 9 4 @ 4 / @
, $ #@ - 9 4
6 9 / $ 6 #)

9 +0:1- 1 2
2 ) #) " " 4 #) I A < " @
9 #) " - 6 / +@ +< 9
" @ 6 + :/ ; 2 4 /
E @ @ ? @ 4/ @ @

2 + 6 9 $ E # )@
- F #) / ejemplo_basicoE

ejemplo_basico
date # MUESTRA LA FECHA
cal # MUESTRA UN CALENDARIO DE ESTE MES
who # MUESTRA LA LISTA DE USUARIOS CONECTADOS

2 6 + E

polifemo:~$ ./ejemplo_basico
Tue Oct 26 10:05:15 CEST 1999
October 1999
Su Mo Tu We Th Fr Sa
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31
hans ttyrc Oct 26 09:52 (192.168.1.14)
javier ttyp4 Oct 26 09:49 (192.168.1.29)
amg ttyr9 Oct 26 09:51 (192.168.1.19)
jupamodo ttyrd Oct 26 10:00 (192.168.1.11)

/ $ / ) # "/ D /
9 - @ / $ E
(

• , /

• $

• 5 /

$ read@ + "E

SINTAXIS
read variable

variable / / : N; 6 E

ejemplo_read
echo Escriba algo:
read ALGO
echo Ha escrito lo siguiente: \"$ALGO\"

polifemo:~$ ./ejemplo_read
Escriba algo:
En un lugar de la mancha...
Ha escrito lo siguiente: "En un lugar de la mancha..."

, $ G9
F, R : + ( ; @
+ / $ E

• $!E = < 6 + 6 E

ejemplo_pid
sleep 3 & # Ejecuta algo en segundo plano
echo El proceso anterior tiene PID $!
ps # Muestra los PID de todos los procesos, para poder comparar

polifemo:~$ ./ejemplo_pid
El proceso anterior tiene PID 7515
PID TTY STAT TIME COMMAND
6650 r8 S 0:00 -bash
7514 r8 S 0:00 -bash
7515 r8 S 0:00 sleep 3
7516 r8 R 0:00 ps

• $?E < 6 ! + @
@9 < + # @ O
+< @ ' ) $ ,
< # / 26 E

ejemplo_test
test 0 -eq 1 # Debe terminar con error
echo $?
(

test 0 -eq 0 # Debe terminar correctamente


echo $?

polifemo:~$ ./ejemplo_test
1
0

2 / /A $ 4 : ;@
/

) 9 2 exit :9
) ) ) ; @
, " E

SINTAXIS
exit [estado]

estado < 9 # $ @9 / * -
: $ <
; estado@ *2 + 6
%E

ejemplo_exit
echo Hola
exit 17
echo Esto nunca se escribe!!!

6 - $ + @ / 9 # +
6 @ -9 %E

polifemo:~$ ./ejemplo_exit ; echo $?


Hola
17

5.2. Parámetros
, + # /
/ B/ &
(

< !& ' (


$1
$2 +
$3 B
...
${10} =A
${11} A
...
$* B : / IFS;
$0 / ) 6 : ;
$# <

/2 7 "" )% &

: 6 @ $4 )- ;@
4

$ # A : @ $10@ $11@ $12@ ; 9


< : @ ${10}@ ${11}@ ${12}@ ;@ - 9 # +
* + +< < : @ 9 ${1}0@ ${1}1@ ${1}2@ ;

2 shift ) :N ; - $
@ 9 N N@ N N@ - 4 2
$

5 6 - shift + @9
ejemplo_parE

ejemplo_par
echo Hay $# argumentos, que son: $*
echo Argumentos 1, 2 y 3:
echo $1 $2 $3
shift
echo Argumentos 2, 3 y 4:
echo $1 $2 $3

, + 6 6 E

polifemo:~$ ./ejemplo_par A B C D E
Hay 5 argumentos, que son: A B C D E
Argumentos 1, 2 y 3:
A B C
Argumentos 2, 3 y 4:
B C D
(&

5.3. Sentencias de control


= $ + )/ + 6 +
E :/ @ (" @ ;- : @ < @
;

5.3.1. Estructura iterativa for


6 @ - +
/ @ 6 /

SINTAXIS
for variable in conjunto
do
comandos
done

variable / / : N; conjunto 6 9 +
/ $ # 6 / #) : *.txt;@
6 : $*;@ $ / : *.txt $1 fichero1 palabra1 /tmp/*.c;
. comandos 4 9 6 6 E
) @) #) -# ) E

ejemplo_for
for I in $*
do
clear
echo Contenido del fichero $I
echo ---------------------------------------------
cat $I
sleep 1
done

2 / : do - done; + +
E

• breakE / @ 9 6 <
done :+ 9 & !;

• continueE + # : + done;@
# 9 " 9 6 + /
:+ 9 !;

5.3.2. Estructura iterativa while


6 A

SINTAXIS
while condición
do
comandos
done
(

condición 9 < A" @ <


I @ @ / comandos 4 9
6
5 6 E / < *E

ejemplo_while
NUM=1
while [ $NUM -le 30 ]
do
echo $NUM
NUM=`expr $NUM + 1`
done

2" -< $ / true -


falseE

• true 9 ) @ 9 A" :*;

• false ) @ : *;

@ $ " 9 < :true;


# :false; 2 @ ) / @ / #

2 wihle /A $ break -continueE

• breakE / @ 9 6 <
done :+ 9 & !;

• continueE + # : + done;@
# 9 " 9 6 :+ 9
!;

5.3.3. Estructura iterativa until


6 ) 9 A

SINTAXIS
until condición
do
comandos
done

2 # A (" @ " 9 /
A 6 if : ;

5.3.4. Estructura alternativa simple (if)


/# 6 @ +<

SINTAXIS
if condición
then
comandos
[else
(%

comandos_alternativos]
fi

condición 9 9A 6 @ " @ A" @


6 " I @ @ 6

comandos 4 9 6 " comandos_alternativos


,
5 6 E 6 + < / #) E

ejemplo_if
TAMANO=`wc -w <$1` # Numero de palabras
NUMERO=-1 # Iniciamos de manera que entre en el bucle

until [ $TAMANO -eq $NUMERO ]


do
echo Adivina el numero de palabras del fichero $1
read NUMERO
if [ $NUMERO -gt $TAMANO ]
then
echo El fichero $1 tiene menos palabras.
else
if [ $NUMERO -lt $TAMANO ]
then
echo El fichero $1 tiene mas palabras.
fi
fi
done
echo HAS ACERTADO!!!!

5.3.5. Estructura alternativa múltiple (case)


/# 6 @ +< "

SINTAXIS
case expresion in
valor1) comandos1
comandos1;;
[ valor2) comandos2
comandos2;;]
...
[ *) otros_comandos
otros_comandos;;]
esac

expresión 9 9A 6 2 / /
9 valor1@ valor2@ 2 9
+ @ 6 ) H)H - 4 )
H;;H + @- " *)@ 6
)
! < 6 @ HZ
H@ -
" 9
(0

2 + 6 < 6 #)
# @ @/ @

ejemplo_case
while true
do
echo OPCIONES
echo --------
echo L - listar información del fichero $1
echo V - visualizar contenido del fichero $1
echo E - editar fichero $1
echo R - borrar fichero $1
echo A - Abortar
echo
echo -n "Selecciona una opción: "
read OPCION
clear
case $OPCION in
L) ls -l $1;;
E) vi $1;;
V) more $1;;
R) rm -f $1
break;;
A) break;;
l|e|r|a|v) echo Debes escribir la opción en mayúsculas.;;
*) echo Esa opción no existe;;
esac
done

5.4. Depuración de scripts


! 6 @ 9 6 @ 9
W / )@ $ set : =
/ ) + ; 2 -< / 9A 9

5 6 6 + $ –vE

script cuenta
I=$1
while [ $I -gt 0 ]
do
echo $I
I=`expr $I - 1`
done

polifemo:~$ set -v
polifemo:~$ cuenta 5
cuenta 5
I=$1
while [ $I -gt 0 ]
do
echo $I
I=`expr $I - 1`
done
5
((

expr $I - 1
4
expr $I - 1
3
expr $I - 1
2
expr $I - 1
1
expr $I – 1

2 + W @ $ W"@ 9 9 6 E

polifemo:~$ set +v
set +v
polifemo:~$ set -x
polifemo:~$ cuenta 5
+ cuenta 5
++ I=5
++ [ 5 -gt 0 ]
++ echo 5
5
+++ expr 5 - 1
++ I=4
++ [ 4 -gt 0 ]
++ echo 4
4
+++ expr 4 - 1
++ I=3
++ [ 3 -gt 0 ]
++ echo 3
3
+++ expr 3 - 1
++ I=2
++ [ 2 -gt 0 ]
++ echo 2
2
+++ expr 2 - 1
++ I=1
++ [ 1 -gt 0 ]
++ echo 1
1
+++ expr 1 - 1
++ I=0
++ [ 0 -gt 0 ]

5.5. Scripts de iniciación


2" + 9 6 # $9
$ # + / : "; - 6 , B / &%
+ + , 9 " $/
I / +@ 9 /
**

, " &
~/.bash_profile 6 $9 @ bash ) #
6 $9 @ bash ) # @ -
~/.bash_login
" ~/.bash_profile
6 $9 @ 9 ) # : ) bash@
~/.profile
6 .profile " ~/.bash_profile ~/.bash_login;
/etc/profile 6 $9 @ bash ) #
6 $9 6 bash : ;
~/.bashrc
su

/5 " & " "0


*

6. Bibliografía complementaria
6.1. Libros de Sistemas Operativos y UNIX
R= ( S = @ ' @ U &% & $A "0 V@ D CG -@ ((

R' 00S ' 8 @ ' @ U &% < & 1 " & > B V@ ' F 7C @ (00

R' 00S ' 8 @ ' @ U &% & V@ ' F 7 @ (00

R' 0(S ' + @ 1 @ ' F @ @U & ""0 &% 7V@ ' F 7C @ (0(

R ( S / ) $@ D @ @ b@ F @ @ U &% & 1 " & ' % & (A "0 V@


D CG -@ ((

R (%S + @ G @ U &% & $A "0 V@ @ ((%

RB (0S B / @ D @ U &% < & B % % &"0 V@ C @ ((0

6.2. Libros de Linux en la Biblioteca


R> (%S > 8@ ' @ U C & V@ D CG -@ ((% : 0 * , ";

R> ( S > @ 5 b@ U D & "0 = % & "0 > &% V@ 1DC' D@ (( : 0 * , ";

R! (%S ! @1 = @2@' @ .@ U % "0 $ 9D &% >? " % & +" V@


F ***@ ((% : 0 * , ";

R' (0S ' 4 A $@ ! @ A $! @ @U V@ D - ' @ ((0 : 0 * , ";

R (0S @ 1@ U D&* 1 % &3 ' " V@ / @ ((0 : 0 * , ";

RB ( S B 8 @ b@ F @=@U & ; V@ @ (( : 0 * , ";

RB (0S B 8 @ b@ F @=@U D "0 " V@ @ ((0 : 0 * , ";

RG ( S G )@ ' @ ` # @ , @ U3 V@ c
1 -@ (( : 0 * , ";

6.3. Libros de UNIX en la Biblioteca


RD ( S D ) @ , b@ > @ B@ U * %% V@ b ) G -d @ (( : 0 * ;

R!) (*S !) @ ` @ U "" 1> V@ D - ' @ ((*: 0 * !@ 0 * ;

R!) ( S !) @`@U V@ # @ (( : 0 * ;

R! #(*S ! ## @ @ U D 3' " D " > &% 7 0 (V@ / 3' F 7C @ ((*


: 0 * ;
*

&%
R ( S @` @>@U > &% %% V@ D CG -@ (( : 0 * ;

R` ( S ` +) @ > G @ 8 @ 1 @ U & % "0 V@ C @ ((


: 0 * ;

R, >(*S , > @ F B@ > @ 1@ ' @G @U > &% 7D (V@ / 3' F 7C @ ((*


: 0 * ;

R (&S )@ 2 @ U > &% % && EV@ @ ((& : 0 * ;

R (%S @ D@ U & V@ D/ @ ((% : 0 * ;

R 0(S @ @' @ =@ U &% 7D 3' " & 1% > & V@


D - ' @ (0( : 0 * ;

R1 (%S 1 @` @U D &% 7= 0 -V@ / 3' F 7C @ ((% : 0 * ;

R ( S ) $@ @ U D 4 V@ 1DC' D@ (( : 0 * ;

RB) 0&S B) @ 1@ O @ b@ U &% < & D 4 V@ ' F 7C @ (0& : 0 *


;

RG 0 S G @'@' @ =@ @ @U & ""0 &% 7V@ D - ' @ (0 : 0 *


;

Vous aimerez peut-être aussi