Here are some nice tips you can use while on the command line. This is not an exhaustive list.

Bash commands

  • sudo !! to redo the command above as sudo. (which is a special case of a wider rule)
  • Use -x while running a script to have debug information.

Useful magic commands

Search and replace in “.md” files strings. This one has been tested on Mac (the -i '' -e is necessary for mac)

find . -type f -name "*.md" -exec sed -i '' -e 's/search/replace/g' {} +

You can also use awk in your grep to select specific things like:

awk -F"[:(]" '{print $2}'
# this:test(is super cool) -> returns test

Bash shortcuts

  • ctrl + R (reverse-i-search): allows you to search a command in your historic by typing it
  • ctrl + A: to go to the beginning of the line
  • ctrl + E: to go to the end of the line
  • ctrl + U: to remove from there to the beginning of the line
  • ctrl + K: to remove from there to the end of the line
  • ctrl + W: to remove word per word the line

Use bash files

Don’t forget to add some of your favourite alias in your ~/.bash_profile or ~/.bashrc. Basically they configure the bash for you, the difference is that:

  • bash_profile is executed once you log into the system (via ssh or else)
  • bashrc is executed at each new interactive terminal window

If you made a change to bash_profile and want to see the result, you can always refresh it using:

source ~/.bash_profile


You can check the one already existing using alias. For example here is how it would look:

alias ll='ls -la'


If you use proxy, or need to set/unset some env variable from time to time, you can set a script to do it for you:

export PROXY="http://annoying.proxy:1234"

function setproxy() {
    export {http,https}_proxy="$PROXY"
    export {HTTP,HTTPS}_PROXY="$PROXY"
    env | grep -i proxy

function noproxy() {
    unset {http,https}_proxy
    unset {HTTP,HTTPS}_PROXY
    echo no proxy