Tips for using the unix terminal like a cool programmer

Mallikarjuna J S
4 min readJun 17, 2018

--

Most of the programmers use terminal for running some or the other commands in their daily job. Some of them hate it and some of them cannot live without it. I love using the unix terminal for most of my jobs. Right from copying files to executing the program.

My personal experience with using terminal for running most of my jobs is that it has helped me improve my productivity and get things done faster. Though you might be skeptical initially, using terminal helps you when you master it.

For those who are interested in using terminal and mastering it, here are few tips and hacks.

1. Learn to navigate and use shortcuts.

Most important thing using terminal is to master the navigation so that you can execute commands much faster.

Ex: Clearing the screen on terminal can be one command clear or just (ctrl + L) on your keyboard.

Similarly you will make a lot of mistake while typing the commands on the terminal and navigation helps you quickly move between words delete words move to the start of line or move to end of the line.

Here are few shortcuts you need to master:

Terminal Shortcuts on Mac

2. Use a good terminal multiplexer

Use a good terminal multiplexer to manage the windows and learn to use it. (learn all the shortcuts so that you are fast at managing it.)

Terminal multiplexer helps to manage the terminals in one window. You can manage multiple terminals in one window without switching the windows.

Tmux is my favorite.

3. Use aliases for regular commands

You can add alias to the commands that you use regularly, so that it is easier for you to type in. Add it in your ~/.bash_profile so that its always loaded on terminal start.

Example:

Going to my project folder on my terminal is just by typing projects in my terminal , alias for the same looks like this in ~/.bash_profile.

alias projects=”cd /Users/mallikarjuna/Documents/projects”

Using alias for navigation

You can add as many aliases as you need. Other aliases I use are for git commands, so its’ easy to type in.

4. Learn basic Unix commands and master it

Learn the basic unix commands, these are very helpful in your day to day jobs. Some of the commands you need to know are mentioned below.

chmod, chown, grep, df, top, ping, ps, kill, ls, netstat, nohup, tail, xargs, pwd, touch, sftp, ssh etc.

Once you master these commands you can control most of the jobs through commands.

Example : creating an empty file is just this one command touch newfile.txt which takes atleast 4 to 5 clicks on the gui.

5. Learn atleast one terminal editor like vi or nano

Learn to use a terminal editor. Though you need not master it; you can just learn basic editing options and quick navigation inside the editor which helps you to modify configs or fix errors swiftly without switching windows.

6. Learn to use command history

Learning to use command history helps you save lot of time. You can rerun the commands without typing the command again.

Few of the tips are

Running the command when it needs sudo access and you forget to add sudo in the beginning. Most of us retype the command with sudo when all you need to do is just type

sudo !!

!! command represents the last executed command. Typing !! and hitting enter executes the last command you ran

Using !! command in terminal

history command lists all the commands you ran with the corresponding number. You can just type !number to execute the corresponding command.

history command usage in teriminal.

If you try to incorporate these tips in to your daily terminal usage definitely you can master the terminal and helps to be more productive.

--

--