This article was originally published on mariokandut.com.
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.
you can select the changes and the diff opens.
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
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.
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.
Thanks goes out to out Jackson, How to Geek, Canonical Ltd. and Linux Foundation.
Top comments (1)
that was useful, thank you :)