bits of handy code

Some handy code which is useful when its really needed.

  1. pretify json via commandline
    cat myfile.json | python -m json.tool

  2. Start Unetbootin in debian. change sudo to su accordingly.
    sudo export QTX11NO_MITSHM=1 unetbootin
    archlinux forum

  3. Reset git HEAD
    git reset HEAD~1

  4. Include full path in the output of find command for current directory
    find -name "filename" -exec readlink -f {} \;

  5. Check progress of dd command while writing to a drive. Very useful while creating bootable pen drives

    Create bootable drive
    dd if=[iso path] of=[device] bs=4

    While the above command is running open another terminal and give this command and check output in previous terminal
    watch -n5 'sudo kill -USR1 $(pgrep ^dd)'

  6. To encrypt file or folder from cli. make sure you have gpg and tar
    tar zcvf - [file1|folder1] [file2|folder2] | gpg -c > myfiles-backup.tar.gz.gpg
    this will ask for passphrase
    and to decrypt
    gpg myfiles-backup.tar.gz.gpg
    For more details

  7. How to come out of ssh connections that got closed or froze.
    Enter, ~, . type these on the terminal whose connection is lost

  8. Play music from a folder and sub folders
    mplayer -playlist <(find "$PWD" -name "*.mp3" -type f)

  9. One command to backup whole system
    rsync -aAXv --exclude={"/dev/","/proc/","/sys/","/tmp/","/run/","/mnt/","/media/*","/lost+found"} / /path/to/backup/folder
    for more details check this link
    Arch Linux Page

  10. Running x11 applications in wayland especially chromium
    GDK_BACKEND=x11 chromium

Bhuvan Krishna

Read more posts by this author.