1. Change the default size of the terminal

When you open a new Linux terminal in Ubuntu 15.10 it is too small by default. This is annoying because you have to grab the mouse to resize it, or snap it left/right to fill half your screen. To change the default size of your terminal window, open a window and go to Edit -> Preferences -> Profile -> Edit. You can then select the initial terminal size. I use 80 columns by 48 rows:

resize ubuntu linux terminal window

2. Familiarise yourself with your bashrc file

Navigate to ~/ by running cd ~/, and then hit ls -a. The -a option forces the system to output all files, including those that start with a period .. You will see a .bashrc file. The .bashrc file defines your terminal configuration. For example, it will set your shell prompt. The .bashrc file is run each time you open a terminal.

As a general rule of thumb, if you want to make a change to your terminal settings you will make a change in your .bashrc file, so it is good to familiarise yourself with it. Open your file by running gedit .bashrc (or use another text editor if you prefer). Take a look around, we will be using it later!

3. Give your terminal windows titles

If you have multiple terminal windows open it can be difficult to select the correct one when you use ALT + TAB to switch between programs/terminal windows. To simplify this, give your terminal windows titles. Using this Stack Exchange answer, add the following code to your ~/.bashrc file:

function set-title() {
  if [[ -z "$ORIG" ]]; then
    ORIG=$PS1
  fi
  TITLE="\[\e]2;$*\a\]"
  PS1=${ORIG}${TITLE}
}

Save your .bashrc file, and reload it in your terminal by running source ~/.bashrc. Now, you can set the title of each terminal window using your set-title function. For example, if I'm using a terminal window as a Mongo shell, I would give it a title by running set-title Mongo Shell. The result would be as follows:

set title on ubuntu linux terminal window

4. Create terminal aliases

You should create terminal aliases so that you don't have to write out the same commands over and over again. The built in ls and cd commands are already pretty short, but you should create aliases for anything else that you use frequently. I use gc as an alias for git commit, gb as an alias for git branch and sc as an alias for scrapy crawl.

To create, aliases, open your ~/.bashrc file and add code in the following format:

alias gst='git status'
alias gc='git commit'
alias gp='git push'
alias gpull='git pull'
alias gd='git diff'
alias gb='git branch'
alias gr='git remote'
alias rhs='--remote=heroku-staging'
alias rh='--remote=heroku'
alias gaa='git add --all'
alias ga='git add'
alias gm='git merge'
alias gcheck='git checkout'
alias sc='scrapy crawl'
alias ssc='sudo scrapy crawl'
alias ss='scrapy shell'

Your bashrc file will load automatically when you open a new terminal, but if you want your aliases to work in the terminal that you already have open you will need to run source ~/.bashrc.

5. Create a function to move up several directories quickly

I get frustrated if I have to type cd .. 4 times to move up 4 directories. Instead, I created the following function in my ~/.bashrc file:

function up() {
    for i in `seq 1 $1`
    do
        cd ..
    done
}

You can then navigate up X directories by running the command up X. X can take any numeric value.

6. Open and exit terminal windows quickly

It is useful to know the shortcuts for opening and closing terminal windows - we don't want to use a mouse! In Ubuntu, use CTRL + ALT + T to open a new terminal, and use CTRL + SHIFT + W to close your terminal window.