At
Commande
1 | # atq |
Liste les taches plannifiées
1 | atrm 13 |
Efface une tache
1 | at 17:33 |
at + la date souhaitée
ensuite, une liste de commande (enter entre chaque)
et “Ctrl-d” pour sortir
1 | # atq |
Liste les taches plannifiées
1 | atrm 13 |
Efface une tache
1 | at 17:33 |
at + la date souhaitée
ensuite, une liste de commande (enter entre chaque)
et “Ctrl-d” pour sortir
Minuscule à majuscule :
1 | echo "EEdddzZ" | tr '[:lower:]' '[:upper:]' |
Supprime les sauts de ligne
1 | tr -d '\r\n' |
Demande de pass interactive :
1 | echo -n Password: ; read -s pass ; for i in ` ls access.log*` ; do echo $pass | scp --stdin access.log* root@10.0.0.1:/toto ; done |
Affiche sans les commentaires
1 | sed -e '/^[ ]*#/d' -e '/^$/d' |
exec a partir de awk
1 | cat /etc/hosts | awk '{ system("echo " $2" "$1)}' |
Append 2 files in columns1
paste -d " " fileliste1 fileliste2
Dos2unix1
$ cat mon_fichier.txt | tr -d '\r' > mon_nouveau_fichier.txt
Kill un process zombi1
gdb -p <zombi_pid>
Affiche de 1 à 51
for i in {1..5} ; do echo $i ; done
Compare 2 lists1
$ comm list1.txt list2.txt
Chmod +x only directory1
$ chmod -R +X dir/
Random sleep max 10s1
sleep $(( RANDOM % 10 ))
Proxy tcp1
mkfifo /tmp/fifo.socket
nc -lk -p 8080 </tmp/fifo.socket | nc www.unvrai.info 80 >/tmp/fifo.socket
Close shell keeping all subprocess running1
disown -a && exit
Edit a file on a remote host using vim1
vim scp://user@host//etc/fstab
Find duplicate files (based on MD5 hash)1
find -type f -exec md5sum '{}' ';' | sort | uniq --all-repeated=separate -w 33
Show current working directory of a process1
pwdx <pid>
Limit the cpu usage of a process1
cpulimit -p pid -l 50
Start a command on only one CPU core1
taskset -c 0 <command>
Find which directory in one filesystem that contains most inodes or files.1
find / -xdev -printf '%h\n' | sort | uniq -c | sort -k 1 -n | tail │
Ctrl + a Go to the beginning of the line (Home)
Ctrl + e Go to the End of the line (End)
Ctrl + p Previous command (Up arrow)
Ctrl + n Next command (Down arrow)
Alt + b Back (left) one word
Alt + f Forward (right) one word
Ctrl + f Forward one character
Ctrl + b Backward one character
Ctrl + xx Toggle between the start of line and current cursor position
Editing:
Ctrl + L Clear the Screen, similar to the clear command
Alt + Del Delete the Word before the cursor.
Alt + d Delete the Word after the cursor.
Ctrl + d Delete character under the cursor
Ctrl + h Delete character before the cursor (Backspace)
Ctrl + w Cut the Word before the cursor to the clipboard.
Ctrl + k Cut the Line after the cursor to the clipboard.
Ctrl + u Cut/delete the Line before the cursor to the clipboard.
Alt + t Swap current word with previous
Ctrl + t Swap the last two characters before the cursor (typo).
Esc + t Swap the last two words before the cursor.
ctrl + y Paste the last thing to be cut (yank)
Alt + u UPPER capitalize every character from the cursor to the end of the current word.
Alt + l Lower the case of every character from the cursor to the end of the current word.
Alt + c Capitalize the character under the cursor and move to the end of the word.
Alt + r Cancel the changes and put back the line as it was in the history (revert).
ctrl + _ Undo
Ctrl+I = Tab
Ctrl+J = Newline
Ctrl+M = Enter
Ctrl+[ = Escape
Ctrl + r Recall the last command including the specified character(s)
searches the command history as you type.
Equivalent to : vim ~/.bash_history.
Ctrl + p Previous command in history (i.e. walk back through the command history)
Ctrl + n Next command in history (i.e. walk forward through the command history)
Ctrl + s Go back to the next most recent command.
(beware to not execute it from a terminal because this will also launch its XOFF).
Ctrl + o Execute the command found via Ctrl+r or Ctrl+s
Ctrl + g Escape from history searching mode
!! Repeat last command
!abc Run last command starting with abc
!abc:p Print last command starting with abc
!$ Last argument of previous command
ALT + . Last argument of previous command
!* All arguments of previous command
^abc^def Run previous command, replacing abc with def
Ctrl + C Interrupt/Kill whatever you are running (SIGINT)
Ctrl + l Clear the screen
Ctrl + s Stop output to the screen (for long running verbose commands)
Then use PgUp/PgDn for navigation
Ctrl + q Allow output to the screen (if previously stopped using command above)
Ctrl + D Send an EOF marker, unless disabled by an option, this will close the current shell (EXIT)
Ctrl + Z Send the signal SIGTSTP to the current task, which suspends it.
To return to it later enter fg ‘process name’ (foreground).
Afficher les lignes de 1 à 10 ou de 1 à la fin1
2sed -n 1,10p zob
sed -n '1,$p' zob
Suppression de la 3ème ligne1
sed '3d' mon_fichier.txt
Suppression de la ligne contenant la chaîne “awk”1
sed '/awk/d' mon_fichier.txt
Suppression de la dernière ligne1
sed '$d' mon_fichier.txt
Suppression de toutes les lignes vides1
2sed '/^$/d' mon_fichier.txt
sed '/./!d' mon_fichier.txt
Remplacement1
sed -i 's/GROS/PETIT/g' zob
Insert line at specific line1
sed -i '13i la ligne apres 12' plop
Insert before pattern1
sed '/^truc/i before' test.txt
Insert after pattern1
sed '/^truc/a after' test.txt
Suppression des lignes commentées d’un fichier1
sed -e '/^[ ]*#/d' -e '/^$/d'
Comment1
sed -i 's/^/#/' plopfile
uncomment1
sed -i 's/^#//' plopfile