Terminal commands every developer should know
Tags: terminal, linux, magic
Published: 2019-11-04 17:05:46

---
title: Terminal commands every developer should know
published: true
date: 2019-11-01 00:00:00 UTC
tags: terminal, linux, magic
canonical_url: https://www.mariokandut.com/terminal-commands-every-developer-should-know
---

_This article was originally published on [mariokandut.com](https://www.mariokandut.com/terminal-commands-every-developer-should-know)._

`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](https://www.britannica.com/technology/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](https://github.com/jonas/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](https://www.mariokandut.com/static/0bc5de3106e08003347b546bb00bf845/b9e4f/terminal-1.png "terminal tig status")

you can select the **changes** and the **diff** opens. ![terminal tig status](https://www.mariokandut.com/static/362cfe3fcae6e10f825768c01c075a63/b9e4f/terminal-2.png "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](https://help.ubuntu.com/community/grep) or [here](http://manpages.ubuntu.com/manpages/trusty/man1/grep.1posix.html).

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
```

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
```

outputs this

```
_ _ _ _ ____ _ _
| | | | ___| | |___ \ \ / / _____ | | __| |
| |_| |/ _ \ | |/ _ \ \ \ /\ / / _ \| '__| |/ _` |
| _ | __/ | | (_) | \ V V / (_) | | | | (_| |
|_| |_|\ ___|_|_|\___ / \_/\_/ \ ___/|_| |_|\__ ,_|
```

## 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
```

## 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
```

Running `rig` would create random contacts:

```
Bettye Dunlap
799 Second St
Denver, CO 80202
(303) xxx-xxxx
```

## 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
```

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
```

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
```

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

```
convert commands.png -quality 50 commands.jpg
```

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

```
convert commands.jpg -polaroid 25 commands-polaroid.jpg
```

There are plenty of options available. Check the [docs](https://imagemagick.org/script/convert.php).

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
```

What are your favourite terminal commands? I'd love to hear them. Use the comments below or send me a message [@mariokandut](https://twitter.com/mariokandut).

Thanks goes out to out [Jackson](https://www-freecodecamp-org.cdn.ampproject.org/c/s/www.freecodecamp.org/news/terminal-tricks/amp/), [How to Geek](https://www.howtogeek.com/109369/how-to-quickly-resize-convert-modify-images-from-the-linux-terminal/), [Canonical Ltd.](http://manpages.ubuntu.com/manpages/trusty/man1/grep.1posix.html) and [Linux Foundation](https://www.linuxfoundation.org/).