Skip to content

Instantly share code, notes, and snippets.

@julienbenjamin
Created November 5, 2017 18:08
Show Gist options
  • Save julienbenjamin/668d5991ca6c99a2c95269db3546756e to your computer and use it in GitHub Desktop.
Save julienbenjamin/668d5991ca6c99a2c95269db3546756e to your computer and use it in GitHub Desktop.
Miscellaneous Linux tips

#1 Fix funny behaviour of a terminal

# reset

#2 Backup bootsector

  • Create backup (if sda is your booting disk)

$ dd if=/dev/sda of=bootsector.img bs=512 count=1

  • Restore backup

$ dd if=bootsector.img of=/dev/sda

#3 Selective files deletion

If you have a directory that contains tons of subdirectories and you want to delete just some of them, the slow way to do it would be like this:

$ rm -rf /home/plop/work $ rm -rf /home/plop/projects $ rm -rf /home/plop/foo

But that's pretty slow and error-prone - a better way is to perform multiple filename expansion by placing the options inside braces. For example, this would achieve the same as the lines above:

rm -rf /home/plop/{work,projects,foo}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment