admin:linux:cli:shell_tricks

Shell Tricks

Alt + .
Esc, .
Add last argument of most recent command.
Ctrl + A
Ctrl + E
Jump to start or end of the line.
Ctrl + D Disconnect / exit current shell

You can use find and the -exec option.

For example if you want to extract multiple .rar files:

find . -name '*.rar' -exec 'unrar' 'e' '{}' \;

{} gets replaced with the filename found by find . -name '*.rar'. Watch out that you have to single-quote (') every option to the program you're -executing.

open multiple files in image viewer

for file in *.jpg; do feh $file&; done

The & makes it run in the background and opens all files at once.

echo "text" | jq -sRr @uri

(source)

md5sum -c - <<<"b4460802b5853b7bb257fbf071ee4ae2 file_name.ext"
shuf -n 4 /usr/share/dict/ngerman
losetup --partscan --find --show sd.img
lsblk | grep loop
mount /dev/loop0p2 sd/
ssh -t user@host /bin/bash
mkpasswd # on debian
openssl passwd -crypt myPassword
tune2fs -O extents,uninit_bg,dir_index,has_journal /dev/sdx0
# Use 446 bytes to overwrite or restore your /dev/XYZ MBR boot code only with the contents of $mbr.backup.file.
# Use 512 bytes to overwrite or restore your /dev/XYZ the full MBR (which contains both boot code and the drive’s partition table) with the contents of $mbr.backup.file.
dd if=/dev/sdx of=mbr.img bs=512 count=1
badblocks -t random -wsv /dev/disk/by-id/drive-id
diff -rq dir1 dir2
passwd -d USERNAME
usermod -U USERNAME
chmod 0 /usr/bin/gnome-keyring-daemon
mount -o remount,rw,hidepid=2 /proc
sudo X :2 -configure
cat /proc/cmdline
  • commandlinefu.com – It's like Kung Fu, but for the command line. User contributed useful snippets.
  • Last modified: 2024-07-05 14:31