Unknown and forgotten CLI commands

Each developer should master his/her skills of working with the command line.

Being physically near a computer is not always possible, so you have to connect remotely. Indeed, GUI may well handle this, but it often works slower than a terminal (after all, this is just a text exchange).

Regardless of whether you are a beginner or a guru, I’m sure you‘ll find useful information among following tips and recommendations.

1. man

Let’s start with the simple, man command, which means manual. If you want to read about another command, just type:

man [command]

You can read the man manual:

man man

“I already knew that!” you’ll say. However, I would like to draw your attention to some of its features.

You can read about the ASCII table, type the following:

man ascii

What is bigger: pico- or femto- ?

man units

2. cd -

If you accidentally changed the directory, you can just return to the last one by typing:

cd -

3. sudo !!

Sudo is a very important command in Unix systems. It executes a command with administrator rights.

If you typed a command without sudo, and then it turned out that it is necessary, type simply:

sudo !!

And it will start with administrator rights.

4. [space] command

Experienced users may know that the history of commands is stored in the ~ / .bash_history file.
If you don’t want to write the command to history file, just type a space before the command.

[space] [command]

5. jot

The jot utility is used to print out increasing, decreasing, random, or redundant data, usually numbers, one per line.

jot [number of digits] [starting from]

If you specify one argument, jot will generate numbers from 1 to the value of the argument.

6. df

Simply shows the free space on a drive

7. pkill

Pkill (or process kill) terminates the running process. This command is especially useful when the application does not respond:

pkill [application_name]

Be careful, when you launching this command on a remote machine — you can lose important data.

8. cal

Displays a calendar and the date of easter:

9. w

The w command shows who has logged on to the system, along with other useful information such as the operating time or CPU load.

10. yes

Funny command that prints the string several times:

yes [string]

Use it to confuse your friends. Attention, the only way to stop it is CTRL + C (or close the terminal).

11. nl

Nl numbers the lines. Most useful when using it as an argument:

12. Ctrl+R Autocomplete

An easy way to explore your command history is to press Ctrl+R and type the beginning of the wanted command. Cli will autocomplete your request.

I entered the ‘lsof’ command to get the PID of the applications that running at ports 35729 and 9005. As you can see, the terminal autocompleted my request. Truly a killer feature.

Thank you for attention. You can share useful commands and cli tricks in discussion.


❤ If this post was helpful, please hit the little heart! (and follow me on Twitter)