Vous êtes sur la page 1sur 5

,QWURGXFFLyQ

/RV IOXMRV OD UHGLUHFFLyQ \ ODV WXEHULDV VRQ DOJXQDV GH ODV KHUUDPLHQWDV PiV SRWHQWHV GH OD OtQHD GH
FRPDQGRV/LQX[WUDWDODHQWUDGD\VDOLGDGHFRPDQGRVFRPRXQIOXMR GDWRVTXHSRGHPRVPDQLSXODU 
1RUPDOPHQWH OD HQWUDGD HV HO WHFODGR \ OD VDOLGD OD SDQWDOOD SHUR VH SXHGHQ UHGLULJLU HVWRV IOXMRV GH
HQWUDGD\VDOLGDKDFLDRWURVFRPDQGRVRDUFKLYRV/DWXEHULD>_@VHXWLOL]DSDUDUHGLULJLUODVDOLGDGHXQ
FRPDQGR KDFLD RWUR (VWR VXSRQH XQD PDJQtILFD KHUUDPLHQWD GH FRQH[LyQ HQWUH FRPDQGRV OR FXDO
SHUPLWHUHDOL]DUWDUHDVFRPSOHMDVFRPELQDQGRYDULDVKHUUDPLHQWDVVHQFLOODV

3DUDHPSH]DUDHQWHQGHUHOUHGLUHFFLRQDPLHQWR\WXEHUtDVKD\TXHFRPSUHQGHUSULPHURORVGLIHUHQWHV
WLSRVGHIOXMRVGHHQWUDGD\VDOLGD7RGRFRPDQGRHQ/LQX[SRVHHWUHVFDQDOHVEiVLFRVSRUGRQGHIOX\H
ODLQIRUPDFLyQ\HVWRVFDQDOHVVRQ

EntradaEstndarHQLQJOpVVWDQGDUGLQSXW stdin HVHOPHFDQLVPRSRUHOFXDOXQXVXDULROH


LQGLFD D ORV SURJUDPDV OD LQIRUPDFLyQ TXH HVWRV GHEHQ SURFHVDU (VWD LQIRUPDFLyQ VXHOH
LQWURGXFLUVHSRUHOWHFODGR(MHPSORV
$cat

$wc

$O HMHFXWDU HVWRV HMHPSORV VLQ DUJXPHQWRV HO FRPDQGR HVSHUD D TXH HO XVXDULR LQVHUWH
LQIRUPDFLyQ SDUD SRVWHULRUPHQWH SURFHVDUOD GLFKD LQIRUPDFLyQ GH HQWUDGD GHEH VHU
SURSRUFLRQDGDSRUODHQWUDGDHVWiQGDUHQHVWHFDVRSRUHOWHFODGR

SalidaEstndar  HQ LQJOpV VWDQGDUG RXWSXW  stdout  HV HO PpWRGR SRU HO FXDO HO SURJUDPD
SXHGH FRPXQLFDUVH FRQ HO XVXDULR 3RU GHIHFWR OD VDOLGD HVWiQGDU HV OD SDQWDOOD GRQGH VH
HMHFXWDQGLFKRVFRPDQGRV(MHPSORV

$lsl/etc/hosts/etc/passwd

rwrr1rootroot251feb2315:52/etc/hosts

rwrr1rootroot1635feb2719:05/etc/passwd

$head10/etc/shells

#/etc/shells:validloginshells
/bin/csh
/bin/sh

/usr/bin/es

/usr/bin/ksh
/bin/ksh

/usr/bin/rc

/usr/bin/tcsh
/bin/tcsh

/usr/bin/esh

$OWHUPLQDUGHSURFHVDUODLQIRUPDFLyQGDGDFRPRDUJXPHQWRVHOFRPDQGRPRVWUDUiXQPHQVDMH
HQ OD SDQWDOOD GRQGH VH KD HMHFXWDGR 'LFKD SDQWDOOD R YHQWDQD VHUi OD VDOLGD HVWiQGDU GHO
FRPDQGRHMHFXWDGR

ErrorEstndarHQLQJOpVVWDQGDUGHUURURXWSXW stderr HVXWLOL]DGRSDUDPRVWUDUPHQVDMHVGH


HUURU TXH VXUMDQ GXUDQWH HO WUDQVFXUVR GH VX HMHFXFLyQ $O LJXDO TXH  stdout, stderr  VHUi OD
SDQWDOODGRQGHVHSURFHVDURQODVLQVWUXFFLRQHV(MHPSORV
$rmesteArchivoNoExiste

rm:nosepuedeborraresteArchivoNoExiste:Noexisteelficherooeldirectori

$rmdir/carpetaInexistente

rmdir:falloalborrar/carpetaInexistente:Noexisteelficherooeldirectorio

'H LJXDO IRUPD stderr  GHYROYHUi PHQVDMHV TXH LQGLFDUiQ ORV HUURUHV GH ORV FRPDQGRV
HMHFXWDGRV

(O XMR GH GDWRV SDUD UHGLUHFFLRQDPLHQWR \ WXEHUtDV HQ OtQHD GH FRPDQGRV VH LQLFLD GH L]TXLHUGD D
GHUHFKD

5HGLUHFFLRQDPLHQWR
3DUDUHGLUHFFLRQDUODVDOLGDHVWiQGDUGHXQFRPDQGRDXQDUFKLYRVHXWLOL]DHOVtPEROR>GHVSXpVGHO
FXDOGHEHLQGLFDUVHHOQRPEUHGHODUFKLYRTXHVHFUHDUi

$cat/etc/passwd>copia_passwd

6L HO DUFKLYR H[LVWH SUHYLDPHQWH VH VREUHVFULELUi 3DUD DJUHJDU ORV YDORUHV VLQ ERUUDU HO FRQWHQLGR
H[LVWHQWHVHXWLOL]D>>

3DUDUHGLUHFFLRQDUHOFRQWHQLGRGHXQDUFKLYRDODHQWUDGDHVWiQGDUGHXQFRPDQGRVHXWLOL]D< (Q
HVWH FDVR HO XMR GH GDWRV YD GH GHUHFKD D L]TXLHUGD (VWH WLSR GH UHGLUHFFLyQ VH VXHOH XWLOL]DU FRQ
FRPDQGRVFRPRtrTXHQROHHDUFKLYRVGLUHFWDPHQWH

1RUPDOPHQWH VH VXHOH UHGLUHFFLRQDU OD VDOLGD HVWDQGDU SHUR VL VH TXLHUH UHGLUHFFLRQDU OD VDOLGD GH
HUURUHVSRGHPRVXWLOL]DU2>3DUDUHGLUHFFLRQDUDPERVVLPXOWiQHDPHQWHVHXVD&>

$lsx*z*
ls:z*:Nosuchfileordirectory
xaaxab

0XHVWUD XQ HUURU SRUTXH QR H[LVWH QLQJ~Q DUFKLYR TXH HPSLHFH SRU ] \ PXHVWUD ORV DUFKLYRV TXH
HPSLH]DQSRU[

$lsx*z*>stdout.txt2>stderr.txt

6H HMHFXWD HO PLVPR FRPDQGR DQWHULRU SHUR UHGLULJLHQGR OD VDOLGD GH HUURUHV DO ILFKHUR VWGHUUW[W \ OD
VDOLGDHVWiQGDUDOILFKHURstdout.txt
$lsw*y*
ls:w*:Nosuchfileordirectory
yaayab

6H HMHFXWD ls  GH QXHYR HQ HO GLUHFWRULR \ PXHVWUD XQ HUURU SRUTXH QR H[LVWH QLQJ~Q DUFKLYR TXH
HPSLHFHSRUZ\PXHVWUDORVDUFKLYRVTXHHPSLH]DQSRU\

$lsw*y*>>stdout.txt2>>stderr.txt

6HHMHFXWDHOPLVPRFRPDQGRDQWHULRUSHURUHGLULJLHQGRODVDOLGDGHHUURUHVDOILFKHURstderr.txt \ OD
VDOLGD HVWiQGDU DO ILFKHUR  stdout.txt  &RPR HVWRV ILFKHURV FRQWHQtDQ LQIRUPDFLyQ VH KD XWLOL]DGR HO
UHGLUHFFLRQDGRU!!SDUDDJUHJDUHOFRQWHQLGR\QRVREUHVFULELUOR

$catstdout.txt
xaa
xab
yaa
yab

6HPXHVWUDHOFRQWHQLGRGHOILFKHURDOTXHKHPRVUHGLUHFFLRQDGRODVDOLGDHVWiQGDU&RPRVHREVHUYD
FRQWLHQHODVDOLGDHVWiQGDUGHODVGRVHMHFXFLRQHVGHOFRPDQGRls.

$catstderr.txt
ls:z*:Nosuchfileordirectory
ls:w*:Nosuchfileordirectory

6H PXHVWUD HO FRQWHQLGR GHO ILFKHUR DO TXH KD UHGLUHFFLRQDGR OD VDOLGD GH HUURUHV &RPR VH REVHUYD
FRQWLHQHODVDOLGDGHHUURUHVGHODVGRVHMHFXFLRQHVGHOFRPDQGRls.

$FRQWLQXDFLyQVHOLVWDQORVRSHUDGRUHVGHUHGLUHFFLyQPiVXWLOL]DGRV

>   &UHD XQ ILFKHUR QXHYR FRQ HO FRQWHQLGR GH OD VDOLGD HVWiQGDU 6L HO DUFKLYR H[LVWH VH
VREUHVFULELUi

>>$xDGHODVDOLGDHVWiQGDUDOFRQWHQLGRGHXQDUFKLYRH[LVWHQWH6LQRVHHVSHFLILFDHODUFKLYRHVWH
VHFUHD

2>   &UHD XQ ILFKHUR QXHYR FRQ HO FRQWHQLGR GH OD VDOLGD GH HUURUHV 6L HO DUFKLYR H[LVWH VH
VREUHVFULELUi

2>>$xDGHODVDOLGDGHHUURUHVDOFRQWHQLGRGHXQDUFKLYRH[LVWHQWH6LQRVHHVSHFLILFDHODUFKLYR
HVWHVHFUHD

&>&UHDXQILFKHURQXHYRFRQHOFRQWHQLGRGHODVDOLGDHVWiQGDU\ODVDOLGDGHHUURUHV6LHODUFKLYR
H[LVWHVHVREUHVFULELUi

<(QYtDHOFRQWHQLGRGHOILFKHURHVSHFLILFDGRSDUDVXXVRHQODHQWUDGDHVWiQGDU
<<$xDGHPiVWH[WRDODHQWUDGDHVWDQGDU

<>8VDXQILFKHURWDQWRSDUDODHQWUDGDHVWiQGDUFRPRSDUDODVDOLGDHVWiQGDU

7XEHUtD SLSH
(V SRVLEOH HQYLDU OD VDOLGD GH XQ FRPDQGR D OD HQWUDGD GH RWUR FRPDQGR XWLOL]DQGR HO FDUiFWHU GH
WXEHUtD>_@3RUHMHPSOR

$cat/home/usuario/prueba.txt|grepilinea

)LOWUDODVOtQHDVTXHFRQWHQJDQODSDODEUDOtQHDHQHODUFKLYRprueba.txt.

7DPELpQ HV SRVLEOH UHGLUHFFLRQDU OD VDOLGD VLPXOWiQHDPHQWH WDQWR SDUD XQ DUFKLYR FRPR
SDUD stdout,  SRU PHGLR GHO FRPDQGR tee  3DUD HOOR VH UHGLULJH OD VDOLGD GHO FRPDQGR DO
FRPDQGRteeVXPLQLVWUDQGRDpVWHXQQRPEUHGHDUFKLYRSDUDDOPDFHQDUODVDOLGD

$cat/home/usuario/prueba.txt|teesalida

(OFRQWHQLGRGH/home/usuario/prueba.txtVHPRVWUDUiHQODSDQWDOOD\VHFRSLDUiHQHODUFKLYRVDOLGD

6XVWLWXFLyQGH&RPDQGRV
7DPELpQ HV SRVLEOH XWLOL]DU OD VDOLGD GH XQ FRPDQGR FRPR DUJXPHQWR SDUD RWUR XWLOL]DQGR FRPLOODV
HMHFXWLYDV>C@ HQHOWHFODGRVHXELFDHQODWHFODGHDSHUWXUDGHFRUFKHWHV 

$lsld`echo$PATH|tr':'''`

drwxrxrx2rootroot4096feb2413:50/bin

drwxrxrx2rootroot69632mar121:39/usr/bin

drwxrxrx2rootroot4096feb2413:46/usr/games

drwxrwsrx2rootstaff4096mar121:04/usr/local/bin

drwxrwsrx2rootstaff4096ago42010/usr/local/games

(Q HVWH HMHPSOR VH IRUPDWHD HO FRQWHQLGR GH OD YDULDEOH 3$7+ FRQ HO FRPDQGR tr  SDUD OLVWDU
FRQlsORVGLUHFWRULRVFRQWHQLGRVHQGLFKDYDULDEOH

(OUHVXOWDGRVHUiHOPLVPRFRQ

$lsld$(echo$PATH|tr':''')

drwxrxrx2rootroot4096feb2413:50/bin

drwxrxrx2rootroot69632mar121:39/usr/bin

drwxrxrx2rootroot4096feb2413:46/usr/games

drwxrwsrx2rootstaff4096mar121:04/usr/local/bin

drwxrwsrx2rootstaff4096ago42010/usr/local/game

3DUHFLGR D OD VXVWLWXFLyQ GH FRPDQGRV HO FRPDQGR  xargs  GHVHPSHxD OD IXQFLyQ GH LQWHUPHGLDULR
SDVDQGRORVGDWRVTXHUHFLEHSRUstdinFRPRDUJXPHQWRSDUDXQVHJXQGRFRPDQGR
$ls/home/usuario/Descargas/|xargsrmrf

(MHFXWDUPUISDUDFDGDDUFKLYRGHOGLUHFWRULR/home/usuario/Descargas.