random linux tips and tricks: february

Here are some random things I learned this month!

find files way faster than “find” with mlocate

This one is cool! “Find” can be a pain in the butt sometimes, and it’s really slow if you have a large drive with lots of files on it. Using mlocate, you can find files nearly instantly by name and not have to fool with special flags.

It’s super easy to use too:

  1. Install mlocate: sudo apt install mlocate
  2. Generate a file database: updatedb
  3. Locate a file by typing locate filename

Boom! Instant result.

Remember commands and flags easier with fish shell

Find yourself constantly reading the man page or googling new commands or commands that you haven’t used in a while? I do!

Fish shell (Friendly Interactive Shell) has awesome autosuggestion and autocompletion features that make remembering commands and flags a breeze. Mile-long commands pop up after typing the first few letters, and pressing tab will display a complete list of flags and their functions. See the difference here:

Bash: (I typed ls – and pressed tab)

Fish: (I typed ls- and pressed tab)

Which one is easier??

The autocompletes are super handy too–here is a recently used command that it suggests when I just type the letter T:

Rsync mastery

This is one most people probably already know, but I’m just learning how powerful rsync really is. In short, rsync:

  1. Can resume interrupted transfers easily
  2. Saves tons of time by doing incremental, rather than full backups
  3. Can keep folders synced between a remote server and a local machine when combined with a systemd timer
  4. Compresses and decompresses on the fly, also saving time and bandwidth
  5. When combined with ssh, it’s encrypted

The command with the flags I use most commonly is rsync -chavzP –stats /source/ /destination/

This combination of flags checks to see if files have changed, adds a progress bar, checks the folder recursively, enables compression, enables resuming an interrupted transfer, and gives verbose + human readable output.

Here’s an example:

Note the 82% speedup we get from the compression and decompression!

You can combine rsync with ssh like this:

rsync -chavzP –stats username@remote-server.com:/source/folder /destination/on/local/machine

Here’s what a backup of this website from my VPS to my laptop looks like:

106% speedup!

Last but not least– Explainshell.com

I found out about this handy website from a reddit comment. You can paste or type any command with any number of flags and it will explain what it does in a tree format:

That’s it for now. I’ll update when I learn more fun stuff!






Leave a Reply

Your email address will not be published. Required fields are marked *