When I was first starting out in software engineering, it felt like there was a never-ending barrage of tooling to learn. After more than a decade in CLI environments, I still find myself constantly learning new features and fun facts - but it’s fairly rare that I learn something new that I end up using day-to-day.
I wanted to share some things I learned at relatively late stages in the game that ended up being significant productivity boosters for me - perhaps some of them are well-known, but in the spirit of this XCKD, I hope that someone reading this might pick up something new.
My favorite tips are:
You can filter the output of a command. Most commands return parameters like
(output, error)
so you can filter them by number like1>/dev/null
will filter the output and only show the errors, and2>/dev/null
will filter the output and only show the errors. Also if you want a command to run silently but it doesn’t have it’s own built-in quite mode you can add&>/dev/null
which will filter everything.Bash (and other shell’s I assume) can be fully customized. In addition to the .bashrc file in your home directory, there are also a few common files that bash will look for like
.bash_aliases, .bash_commands, .bash_profile
or you can create your own and just add to the end of the .bashrc file./YOUR_CUSTOM_BASH_FILE_NAME
Inside that file you can add any custom commands you want to run for every bash shell like aliases and what not.
I personally often use a simple update command like so
alias up='sudo apt update -y && sudo apt upgrade -y && sudo apt autoremove -y'
which just makes running updates, upgrades, and clean-up so much easier. Just typeup
and enter your password. I have previously added in things like&>/dev/null
to quiet the commands andecho Fetching updates...
to make some commands quieter but still give some simple feedback.There’s also the basics of moving around a terminal command as others have pointed out. The easiest and the one I use the most is if you hold CTRL+LEFT_ARROW the cursor will move entire words instead of one character at a time. Very helpful if you need to change something in the middle of a command.