Every developer needs to gain a certain mastery over the terminal. It’s not always possible to be physically present near the computer you are going to work on, in which case, you would need to remotely log into the machine. And while it’s true that GUI applications are available to accomplish this, they are often not as fast as getting terminal access (after all, it’s just the exchange of some text!).
Regardless of whether you are a beginner or an experienced user of the terminal, I’m sure you like to pick up new tips and tricks. In this post, I’ll introduce 15 Unix commands you might not have heard of before.
Note: For this post, I will use square brackets to denote any variables. When you actually run the command, you should substitute it with the actual value, with the square brackets removed. For instance, our first example,
man [command] can be used as
man cd or
Let’s start with a simple one. The
man command stands for “manual”, as in documentation. If you want to know about any Unix command, you can run the following:
The simplest use case for
man is to view the manual of the
man command itself:
man is not necessarily itself a little-known command, and you would probably find it in any Unix tutorial. However, there are certain special uses which I would like to highlight that likely wouldn’t be in a common tutorial.
If you need to know more about your ASCII characters, try this.
There are many more such manual pages, and some of them are really funny too! (Tip: Try
man xkill.) I will leave you to fiddle with that. Meanwhile, let’s move on to some more commands.
If you are working in a directory and accidentally changed to another one, there is an easy way to get back to the old one. Just run the following to get back to the last working directory:
This comic strip by XKCD emphasizes the importance of the
sudo command in Unix systems.
sudo runs a command with administrator privileges, provided your user is added to the sudo-ers group.
Let’s say you ran a command without prefixing
sudo. If you are reluctant to type the same command again, you could run the following to run the last command as
mtr is a powerful network diagnostic tool. It combines the functionality of the
mtr inspects the network connection between the host (from which
mtr is run) and a remote
[hostname]. Here is a detailed post on
mtr, demonstrating the full extent of the command.
5. [space] command
Frequent users of the terminal would probably know that every command they run gets logged in a file
~/.bash_history. To skip this logging step while running a command, just prefix a space, and the command will not be logged:
jot, as the name implies, generates some text — from numbers to characters to gibberish. If you want to generate numbers in a range, run the following:
jot [number_of_numbers] [starting_number]
If you provide a single argument, it will generate numbers from 1 to that number.
-r option produces random numbers. The syntax is as follows:
jot -r [number_of_numbers] [lower_limit] [upper_limit]
-b option repeats a given word. For a list of options, you could run
man jot or see this tutorial.
A relatively simpler command in our list,
df stands for “disk free” and shows the amount of free space in your disks.
pkill or “process kill”, terminates a running process. This command is particularly useful when an application is unresponsive. The syntax is:
A fun/cruel use-case for
pkill is when you have the ability to log remotely into a computer that someone else is using. Check what application they are running, and run the
pkill command for that application. Try to act normal when they are bewildered and look around to check who played the prank. Of course, you’ll want to make sure it’s not a critical application or something where important work could be lost!
The Discordian calendar is an alternate calendar, with 1 YOLD as 1166 BC.
ddate displays the Discordian date.
If you just want the plain old Gregorian calendar, just type
cal to get a nice looking view of the current month:
This is just the default view. The manual page for
cal lists the various options, which can display more months in a different way.
You’ve probably heard of the
cat command. It has a range of utilities including creating, copying, merging, and displaying text files. The
tac command does the same thing, but in reverse order! Have a look.
w shows who’s currently logged in to your system. It displays the list of logged in users, along with some more information like system uptime and loads.
If you want to factorize a number, do not look any further. Just run the following to get the prime factorization of a number:
Coming back to a fun command again,
yes prints a string a lot of times.
If you don’t provide a string, it prints “y” recursively until you stop the command. This function is so quick at printing the string that I was unable grab a screenshot with the command on the same screen as the output of the command! If you are doing something fishy and someone happens to pass by, make sure you run
yes to confuse them (provided they have little idea about Shell programming).
Note: If you plan to run this command, you should know that the only way to stop it is by pressing CTRL+C/CMD+C (or by closing the terminal).
nl attaches line numbers to text. It is best used by passing the output of some other command as an argument. The output of another function is passed as an argument using the pipe (“|”). Let’s look at two examples:
Know Any Others?
With this, we come to the end of this list of Unix commands you may not have seen before. How many of these did you know? Do you use some of them in your regular work? Let us know in the comments below how many you knew — 15/15 wins!
The Principles of Beautiful Web Design, 4th Edition
Learn PHP in One Day and Learn It Well
Docker for Web Developers