You are on page 1of 6

Algunos trucos sencillos.

Para ir terminando este curso, les dejo algunos trucos, que me son muy tiles, y algunas hojas,
llamadas cheats, que son los viejos trencitos del liceo... o sea, cartas u hojas con recordatorio de los
comandos ms usados en linux.
Muchas veces algo se queda atorado en la papelera y no se quiere ir, entonces corremos:
sudo rm -rf !.local!share!"rash!files!#
y listo.
Fsck $ com%ro&ar si el sistema est o', o en su defecto arreglar %ro&lemas de archivos corru%tos.
Para ejecutar el comando de&emos arrancar el sistema en el modo (recovery mode) -* desmontar
las %articiones : tanto ! como !home + o solo la %artici,n rai- ! si !home no es una %artici,n, sino
un directorio de%endiente de ! . -* ejecutar fsc'
/- Para sa&er que %articiones hay en el sistema, se ejecuta el comando fdis' -l + desde recovery
mode no hace falta %oner sudo %orque ya estas con %ermisos de root0 desde la sesi,n normal si que
ha&r1a que %oner: sudo fdis' -l . te dice el sda2 y el sda3: 4ista las ta&las de %articiones: las
%articiones son usualmente de uno de los siguientes ti%os: !dev!hda !dev!hd& + !dev!hd5a-h6
%ara discos 789, . , o !dev!sda !dev!sd& + !dev!sd5a-%6 %ara discos :;:7, . , !dev!ed5a-d6
%ara discos 9:87, !dev!xd5a&6 %ara discos 2"..
<- =na ve- hemos sa&ido cual es la %artici,n-es donde esta el sistema, + %ara verificar un sistema de
archivos es muy aconseja&le hacerlo mientras >ste est desmontado., si %or ejem%lo la %artici,n rai-
! esta en !dev!sda/ y la %artici,n !home en !dev!sda< las desmonto con sudo umount !dev!sda/
sudo umount !dev!sda<
?- 9jecuto el comando sudo fsc' -c -y !dev!sda/ !dev!sda< :e tardan un %oco, %ero te dejan los
discos y el sistema su%er finos
:acado de htt%:!!hatteras.@ord%ress.com!<AAB!AC!</!fsc'-file-system-consistency-chec'!
(mucho ojo con fsck, pueden quedarse sin nada en el home si no desmontan primero, estn
avisados...)
Hacer un backup de un dvd, o sea copiarlo a disco duro...
dvd&ac'u% -M -i !dev!dvd -o !donde!quieras!%onerlo
Keyboard shortcuts (tajos de teclado)
;trlDA E :elect all +7n 8ocuments, Firefox, Gautilus, etc, not "erminal.
;trlD; E ;o%y +7n 8ocuments, Firefox, Gautilus, etc, not "erminal.
;trlDH E Paste +7n 8ocuments, Firefox, Gautilus, etc, not "erminal.
FB E "oggle :ide&ar
F< E Iename
;trlD:hiftDG E ;reate ne@ folder
;trlDG E Ge@ +;reate a ne@ document, not in terminal.
;trlDJ E J%en +J%en a document, not in terminal.
;trlD: E :ave +:ave the current document, not in terminal.
;trlDP E Print +Print the current document, not in terminal.
;trlD9 E :end "o... +:end the current document to an email reci%ient or remote location, not in
terminal.
;trlDK E ;lose +;lose the current document, not in terminal.
;trlDL E Luit +Luit the a%%lication, not in terminal.
;trlDM E :ho@ hidden files
;trlDF E File &ro@ser
;trlD" E Move to trash +dangerous.
;trlD4 E J%en location +folders, files, =I4s, etc.
;trlDAltDF/ E :@itch to the first virtual terminal
;trlDAltDF<+F?.+FC.+FN.+FO. E :elect the different virtual terminals
;trlDAltDFP E :@itch to current terminal session @ith 2
;trlDAltD4 E 4oc' screen
;rtlDAltD8elete E 4og out
;trlDAltD8 E Mide all @indo@s and focus des'to%
AltDF/ E 4aunch a%%lications menu
AltDF< E 4aunch Qrun a%%licationQ dialogue
AltDFP E moves the current @indo@ +can &e moved @ith mouse JI R93SJAI8.
AltDFT E resi-es current @indo@ +again, @ith mouse JI R93SJAI8.
AltDFB E minimi-es current @indo@
AltDF/A E maximi-es current @indo@
AltD:%ace E &rings u% that funny @indo@ menu @ith @ith UAl@ays on "o%U and UMinimi-eU and
UMaximi-eU and all that ja--
AltDFN E returns @indo@ to UnormalU or %revious si-e
AltDFC E closes @indo@ +usually.
AltDMome E jum% to home folder
AltD9nter E file ! folder %ro%erties
;trlDAltDSac's%ace E Rill 2 server
AltD"a& E :@itch &et@een o%en %rograms
Printscrn E Print screen
VD:%ace E scrolls current ta&!@indo@ do@n
VDSac's%ace E scrolls current ta&!@indo@ u%
;trlDAltDIight!4eft Arro@ E Move to the next virtual des'to%
;trlDAltD:hiftDIight!4eft Arro@ E "a'e current @indo@ to the next virtual des'to%
;ommand line ! "erminal shortcuts
;trlD; E Rill %rocess +Rill the current %rocess in terminal, also used to co%y else@here.
;trlDW E :end %rocess to &ac'ground
;trlD8 E 4og out from the current terminal. 7n 2, this may log you out after a shuting do@n the
emulator.
;trlDA E Mome +Move cursor to &eginning of line.
;trlD9 E 9nd +Move cursor to end of line.
"a& E 4ist availa&le commands from ty%ed letters +9x: ty%e i@ and clic' ta&, out%ut E i@config
i@event i@getid i@list i@%riv i@s%y.
;trlD= E 8elete current line
;trlDR E 8elete current line from cursor
;trlDK E 8elete @ord &efore cursor in terminal +"erminal only, also used to close the current
document else@here.
Arro@s u% and do@n E Sro@se command history
;trlDI E Mistory search +Finds the last command matching the letters you ty%e.
:hiftDPage=% ! Page8o@n E :croll terminal out%ut
;trlD4 E ;lears terminal out%ut
:hiftDinsert E Paste
;trlD:hiftD; E ;o%y
;trlD:hiftDH E Paste
!ouse
Mouse@heel clic' or ?rd mouse &utton E Paste selected text +:elect any text in any @indo@ and
%aste @here you @ant. "erminal ! Firefox ! Xnome a%%s.
"rear un shortcut propio
"o ma'e a shortcut in Xnome, run gnome-'ey&inding-%ro%erties or goto :ystem-*Preferences-
*Rey&oard :hortcuts
#buntu linu$ cheatsheet % pache
htdocs folder
!var!@@@
a%ache configuration files
!etc!a%ache<!
vhosts definitions
!etc!a%ache<!sites-availa&le
;reate a lin' to each definition in !etc!a%ache<!sites-ena&led: ln -s !etc!a%ache<!sites-
ena&led!mysite.ln' !etc!a%ache<!sites-availa&le!mysite
Jr @ith ne@er versions of =&untu: a<ensite mysite for ena&ling and a<dissite mysite for
disa&ling
start!sto%!restart a%ache
sudo !etc!init.d!a%ache< start!restart!sto%
4ogs
!var!log!a%ache<
&H&
%h% ini
!etc!%h%N!a%ache<!%h%.ini
:essions tem% dir
!var!li&!%h%N
Pear and all of that stuff
!usr!share!%h%N
mysql
config file +my.cnf.
!etc!mysql!my.cnf
8elete ta&les @ith a certain %attern +dro% ta&les li'e.
mysql $userEtheuser $%ass@ordEthe%ass@ord -G -e Qsho@ ta&les li'e U@hateverYUQ d&Zname [
%erl -e U@hile+V*.\chom%0 %ush ]ta&les, ^Z0_%rint Qdro% ta&le Q . join +Q,Q ,]ta&les. . Q`nQ0U [ mysql
$userEtheuser $%ass@ordEthe%ass@ord d&Zname
rchivos
Find files @hich have &een modified today
find . -mtime -/ -%rint
Find all &ac'u% files in a directory
find . -name # -%rint
Find all &ac'u% files and delete thema
find . -name Q#Q -exec rm \_ `0
;hange %ermissions for all folders only
find . -ty%e d -exec chmod gDx \_ `0
:et the grou% id &it +so files created later in the folder &elong ot the folderUs grou%.
chmod gDs directory
=ncom%ress lots of -i%s @ith just one line of terminal commands
find #.-i% -exec un-i% \_ `0
Find only files
find . -ty%e f
Find only files b and delete thema
find . -ty%e f -delete
Iecursively find files @hich contain a given text
gre% -lir Qa given textQ #
Availa&le s%ace in dis'
df -h +in fact this return availa&le s%ace in each mount in the system.
:ho@ differences &et@een t@o files @ithout ta'ing into account @hites%ace +very useful @hen line
returns and s%aces!ta&s are messing u% normal diffs.
diff -@ file/ file<
'ackups
archive and com%ress a @hole directory
tar cvf- archive.tar.g- dname
&ac'u% a data&ase
mysqldum% d&Zname $userEusername $%ass@ordE%ass@ord * data&aseZdum%.sql
&ac'u% all data&ases
mysqldum% -u username -% $all-data&ases *!tm%!data&ases.dum%
All-in-one: get a remote data&ase dum%, com%ress it, do@nload and uncom%ress in your local
machine
ssh yourZhost Qcd dum%sZdir0 mysqldum% $user yourZuser $%ass@ordEyourZ%ass $hostEd&Zhost
data&aseZname [ g-i% * data&aseZname.g-Q
sc% yourZlogin]yourZhost:dum%sZdir!data&aseZname.g- .!sql!
gun-i% .!sql!data&aseZname.g-
;om%ress a file @ith -i%
-i% out%utfile.-i% file/ file< file?b fileG
8o@nload a remote directory to current directory
sc% -rv yourlogin]yourhost:!@e&!%u&licZhtml .
#pdates
Iemove unused %ac'ages
sudo a%t-get autoremove
Manually u%date greyed out entries in the u%date manager
Xo to :yna%tic Pac'age Manager, order &y the status column +i.e. the first one., select all the
%ac'ages @ith a star +#. over a green &ac'ground, and select QMar' for u%loadQ.
8istri&ution u%date
sudo a%t-get dist-u%grade
sudo g'su Qu%date-manager -cQ
;risisaa 2 server doesnUt @or' after u%dating the distri&ution - &oot in safe mode and run
sudo a%t-get install $reinstall xserver-xorg
sudo d%'g -reconfigure xserver-xorg
(ystem
"urn off
sudo shutdo@n
Ie&oot
sudo re&oot
4ist mounted devices and dis's and other info
sudo fdis' -l
:tatic file system information
!etc!fsta&
Fcs' - &oot from live ;8 +it @onUt allo@ you to fsc' a mounted drive.
o%en a console @ith ctrlDaltDf/
then sudo fsc' !dev!sd&, etc
Another o%tion: sudo e<fsc' -% -f -v !dev!sda
Force fsc' on &oot
sudo touch !forcefsc' and re&oota
)or*
Iestart xorg
%ress ctrlDaltD&ac's%ace
+edes
8o@nload a file @ith curl
curl -o out%utfile sourceZurl
(ubversion
4ist info for a remote re%ository
svn info svn:!!re%ositoryZurl +or htt%:!!re%ositoryZurl, etc.
svn info also @or's @ith local resources: svn info . lists info for current directory
4ist files in a re%ository %ath
svn list svn:!!re%ository!%ath
,irtual'o$

Iecom%iling 'ernel module after u%grading the 'ernel:
sudo a%titude install linux-headers-^+uname -r.
sudo !etc!init.d!v&oxdrv setu%
:ome %eo%le suggest using Qsudo a%titude install virtual&ox-ose-modules-genericQ @hich is Qa
meta%ac'ageQ. 7 havenUt tested it.
&ulseudio
:to% and restart
%'ill %ulseaudio0 %ulseaudio c
&-& . co
;learsign a file @ith a non-default 'ey
g%g $default-'ey 5R93786 $clearsign 5F749GAM96
3 con esto y las ;heats tienen %ara entretenerse, y em%e-ar a a%render...
Muchas gracias a todos.
8aniel Mato $ <P.P./A

You might also like