DEV Community


Terminal commands every developer should know

Software Engineer from Vienna, Austria. Building things, mainly in JavaScript.
Originally published at on ・4 min read

This article was originally published on

The terminal is the developers best friend. Since my change in careers (Marketing -> Software Developement) I really fell in love with the terminal. Maybe because I still know the good old MS DOS?

There are some terminal commands that are not that commonly used, but are super helpful and you can get things done faster.

I am using Ubuntu 18.04 and the bash terminal.

1. tig

_Tig is an ncurses-based text-mode interface for git. It functions mainly as a Git repository browser, but can also assist in staging changes for commit at chunk level and act as a pager for output from various Git commands._

tig is a git utility. Yes, tig is git written backwards 🤔 and the commands are nearly the same. The only differnce is that tig gives you more.

For expample: tig status is like git status.

If you type tig status you get an interactive status of your repository.

terminal tig status

you can select the changes and the diff opens. terminal tig status

Since I discovered this feature I am using tig status daily. Use j and k to move up and down, and enter to select. The key h opens the help menu with all the available commands. You can easily add changes to your commit without the need for git add insert-filename-of-your-changes.

2. grep

Grep is a command-line tool that allows you to find a string in a file or stream. It can be used with a regular expression to be more flexible at finding strings, more here or here.

It's very helpful, when you are debugging. Let's say you want to find an error in a 1000+ line log file.

grep error logfilename.log
Enter fullscreen mode Exit fullscreen mode

It will only log the lines where there is the string error found.

3. sudo!! (sudo bang bang)

The !! is called bang-bang operator it repeats your previous command and adds whatever you call it with in front of it.

So sudo!! does the following: instead of typing arrow-up, scrolling to the beginning of the line, adding sudo and hitting enter (imagine scrolling through those loooong apt-get commands).

4. figlet

Not by default installed, run sudo apt install figlet. With figlet you can draw large sized text banners. Useful, when writing a ReadMe or for welcome messages for services/servers or just for having fun with colleagues.

figlet Hello World
Enter fullscreen mode Exit fullscreen mode

outputs this

_ _ _ _ ____ _ _
| | | | ___| | |___ \ \ / / _____ | | __| |
| |_| |/ _ \ | |/ _ \ \ \ /\ / / _ \| '__| |/ _` |
| _ | __/ | | (_) | \ V V / (_) | | | | (_| |
|_| |_|\ ___|_|_|\___ / \_/\_/ \ ___/|_| |_|\__ ,_|
Enter fullscreen mode Exit fullscreen mode

5. history

history returns every command you have typed in. Why is this in this list and how could this be useful?

Well, let me tell you a story about me a person populating a database and chaining commands to make it quick, because you don't populate a database so often. And what happens after 5 hours into the code? Yes, database error, db needs rebuilding and repopulating. And what are the commands? Can you imagine how often I had to hit arrow-up? 😂

With the combination of history and grep I could have narrowed it down.

history | grep db_populate
Enter fullscreen mode Exit fullscreen mode

6. rig

The rig command generates random and possibly fake identities, which is perfect for testing. rig is not pre-installed.

sudo apt install rig
Enter fullscreen mode Exit fullscreen mode

Running rig would create random contacts:

Bettye Dunlap
799 Second St
Denver, CO 80202
(303) xxx-xxxx
Enter fullscreen mode Exit fullscreen mode

7. convert

With convert you can quickly Resize , Convert & Modify Images from the linux terminal.

With Ubuntu 18.04 it already comes installed, if you need to install it, convert is part of the imagemagick-bundle.

sudo apt install imagemagick
Enter fullscreen mode Exit fullscreen mode

You can quickly resize an image. I wanted to resize the title image for this post by 50%.

convert commands.jpg -resize 50% commands--web.jpg
Enter fullscreen mode Exit fullscreen mode

This would create an image with the name commands--web.jpg, which is 50% of the original commands.jpg.

Convert png to jpeg with setting a custom quality.

convert commands.png -quality 50 commands.jpg
Enter fullscreen mode Exit fullscreen mode

You can also modify images like rotate, apply filters and effects and much more.

convert commands.png -quality 50 commands.jpg
Enter fullscreen mode Exit fullscreen mode

To apply a polaroid filter and tilt the image by 25 degrees.

convert commands.jpg -polaroid 25 commands-polaroid.jpg
Enter fullscreen mode Exit fullscreen mode

There are plenty of options available. Check the docs.

The following code really helped me many times for batch rotating images. I was used to create a photoshop action.

for file in *.jpg; do convert $file -rotate 90 rotated-$file; done
Enter fullscreen mode Exit fullscreen mode

What are your favourite terminal commands? I'd love to hear them. Use the comments below or send me a message @mariokandut.

Thanks goes out to out Jackson, How to Geek, Canonical Ltd. and Linux Foundation.

Discussion (1)

muhsin7majeed profile image

that was useful, thank you :)