Grimoire-Command.es

To content | To menu | To search

Tag - shell

Entries feed

2018-02-13

Test storage peripheral read / write speed

Tester la vitesse de lecture et écriture d'un périphérique de stockage

dd if=/dev/zero of=tempfile bs=1M count=1024 conv=fdatasync,notrunc [1]

1024+0 enregistrements lus
1024+0 enregistrements écrits
1073741824 bytes (1,1 GB, 1,0 GiB) copied, 2,34437 s, 458 MB/s

sync && echo 3 > /proc/sys/vm/drop_caches [2]
dd if=tempfile of=/dev/null bs=1M count=1024 [3]

1024+0 enregistrements lus
1024+0 enregistrements écrits
1073741824 bytes (1,1 GB, 1,0 GiB) copied, 2,76278 s, 389 MB/s

Notes

[1] Gives write speed of current folder storage

[2] As root

[3] Gives read speed

2018-01-12

Grep some text in some selected files

Trouver du texte dans une sélection de fichiers

find "$3" -name "$2" -print0 | xargs -0 grep -i -n --color $1

  • $1 : text to search
  • $2 : files to find and search in
  • $3 : where to search for files to find
  • find -print0 | xargs -0  : use zeros to separate elements, not spaces, to accept spaces in file names

2018-01-07

Immutable directory via chattr, avoid writing in unmounted partition

Rendre un dossier immuable (sans droit d'écriture) via chattr pour éviter d'écrire dans un dossier s'il n'est pas monté.

chattr +i /stockage/backup

Remerciements à /home/lord

2017-12-16

Rip music CD to MP3 or FLAC

Copier un CD de musique en MP3 ou Flac

CD -> WAV : cdparanoia -d /dev/hda -B
WAV -> MP3 : lame --vbr-new --preset extreme a_file.wav a_file.mp3
*.WAV -> MP3 : for x in `ls *.mp3`; do lame --vbr-new --preset extreme $x "`basename ${x} .wav`.mp3"; done; [1]
*.WAV -> MP3 in parallel : find . *.wav -print0 | xargs -0 -P $((`nproc` / 2)) -I {} lame --vbr-new --preset extreme {} {}.mp3 rename 's/\.wav\.mp3$/\.mp3/' *.mp3 [2]
*.WAV -> FLAC : flac --replay-gain --best *.wav
*.WAV -> FLAC in parallel : find . *.wav -print0 | xargs -0 -P $((`nproc` / 2)) -I {} flac --replay-gain --best "{}"

Notes

[1] --print0 / -0 options replace space by zeros at file name ends to deal with spaces in file names ; backticks call a sub-command ; basename isolate main part of name from extension

[2] $(()) for math operations ; backticks nproc for CPU number ; rename files in a second time

2017-11-22

Change automatic stop connection delay for SSH sessions

Changer le délais de déconnexion automatique pour les sessions SSH.

  • echo $TMOUT [1]
  • export TMOUT=600 [2]
  • export TMOUT= [3]

Notes

[1] Check if timeout is set in the distant machine shell (Bash, Zsh…)

[2] Set a session timeout of 10 minutes

[3] Disable session timeout

2017-11-16

cryptsetup: WARNING: invalid line in /etc/crypttab for luks-XX

If you get this message from cryptsetup instead of booting.
Si vous obtenez ce message et que votre machine ne démarre pas.

  1. cryptsetup luksOpen /dev/sda3 sda3_crypt [1]
  2. Apply chroot commands
  3. apt install lvm2 [2]
  4. update-initramfs -u [3]

Notes

[1] Open the LUKS container, sda3_crypt is the same name found in the last position in the file: /etc/crypttab

[2] If the package is missing. You can check that with: apt search lvm2 | grep --color "^lvm2"

[3] If you don't have the warning message, it's won !