TOP-20 UNIX commands for Every Developer - ByteScout
  • Home
  • /
  • Blog
  • /
  • TOP-20 UNIX commands for Every Developer

TOP-20 UNIX commands for Every Developer

The current world is running on computers. Knowing simple Unix commands or basic Unix commands enables you to dive into the world of Unix or Linux system. It also allows confirming the current system state and control files or directories. Here is the list of Unix command line basics for beginners.

Once the Unix startup is concluded, it will display a login window for the user to insert a username and password. If the username and password are valid, then the Unix system will begin a login session. After this, the user can initiate a screen that operates a shell application.
Here’s an extensive Unix commands list you should know:

  1. Cal.
  2. Banner.
  3. Whoami.
  4. Ls command.
  5. Cat command.
  6. Rm command.
  7. Cp command.
  8. Pico command.
  9. Finger command.
  10. Lynx command.
  11. Man command.
  12. Pmap command.
  13. Touch Command.
  14. Grep command.
  15. Shutdown command.
  16. Useradd command.
  17. Uniq Command.
  18. Sort command.
  19. Wc command.
  20. Head command.

1. Cal

The cal command is one of the most important Unix commands. This command is used to display the calendar of the entered value. By default, cal command displays the current month calendar as a result. cal is a conventional and one of the most basic of all the Unix commands. It displays an ASCII calendar of the assigned month or year.

Example: The following command will display the calendar for July 2019.

$ cal 7 2019

2. Banner

The banner command is one of the common Unix commands. This command displays a large ASCII description variant of the text that is given to it as its application arguments. In other words, this command displays a large banner on the conventional output window.

Syntax: banner message

Example: Print “Hello World” as the banner

$ banner Unix

3. Whoami

If you want to learn Unix commands then you must know all the basic commands first. The whoami command is an important part of the UNIX command line tutorial. This command displays the username/userid of the currently logged-in user. This command is found in many Unix-like operating systems. It is also available in the Windows operating system.

Syntax: whoami [option]

Example: Diaply currently logged-in user

$ whoami

The above command will display the currently logged-in user.

4. Ls command

The ls the Unix command to list directories. If you want to view the list of files on the computer system then the ‘ls’ command is used. This is one of the most important Unix commands. It displays the files /directories present in the current directory. It also supports many options. For example, if you want to display hidden files then ls command is used with the -a parameter.

For example

 $ ls -a

The above command will display all the hidden files present in the computer system.

5. Cat command

The cat is the Unix command to create a directory. In other words, the ‘cat’ command is applied to present text files. The great thing about this command is that it can also be utilized for copying, merging, and creating new files. The cat is also known as a concatenating command. It is one of the most regularly used commands in Unix. It is one all singing all dancing command because it allows us to create single or many files, view check files, concatenate and redirect results in terminal or files.

Example: The following command is creating a new file test1 by using the cat command.

$ cat test1

6. Rm command

In UNIX, rm is a primary command used to remove things such as files, lists, and typical links from file systems and also specific files such as machine nodes, channels, and devices, just like the del command in MS-DOS. This command is one of the most important commands of the UNIX commands cheat sheet.

Syntax: rm filename

Example: rm test1

The above example is displaying the removal of the file named test1. rm eliminates each defined file. By default, it does not eliminate lists. If the -I or — the interactive=once alternative is provided, and the options -r, -R, or –recursive is mentioned, then rm hints to the user for whether to continue with the whole process.

7. Cp command

The cp command is the Unix command to copy the directory. This is one of the most used UNIX commands. It copies any text file to the directory. The only condition is that files should not exist already in the directory or are more latest than the files currently present in the directory. The alternative “-‐u” indicates “update,”

Syntax: cp filename.txt

Example:  cp test11.txt

8. Pico command

Pico is a part of a Pine command. This is one of the advanced Unix commands. This command begins an uncomplicated but powerful textbase mail application. Pine enables you to obtain, create, transmit, and secure e-mail communications, communicating with anyone who is connected to the World Wide Web.

Syntax:  pico -w nameoffile

To produce a file named "test" with pico type:

Example: pico -w test

Messages written in Pine are published utilizing a file editor application named “pico”.The pico can also be applied from the UNIX to build and publish other files. By default, pico splits long lines between words, which provides a more normal display in most mail-reading applications.

9. Finger command

The finger command is one important command of the Unix commands cheat sheet. It is utilized to show details about users on UNIX systems. Finger reveals a particular user’s complete name, last login, and when the user saw their mail. If you wanted to obtain details about a particular user, you would enter finger user_name. If you wanted to find a particular user on the Internet, just type finger username@host. You can also improve the performance of the finger by adding choices to the finger command. For example, if you have someone’s full user ID, then enter finger -m username, which is much faster than the regular finger command.


finger [-mlsqibfwhp] [username]

Example: finger

10. Lynx command

Lynx is actually a web browser available on the Unix system. Lynx is a text-only browser interface and it is one of the advanced Unix commands. Lynx can be very helpful if the user wants quick access to valuable information, or wants to use a text-based terminal.

To initialize Lynx user has to just type lynx in any Unix session. By default, Lynx will begin showing the information. If you want to have lynx browse a particular page once it begins, then just type:

Syntax: lynx URL

Example: lynx

11. Man command

If you want to learn Unix commands then the man command is one of the important Unix commands. The man command will show the manual pages for most UNIX commands. If you want more information on any of the Unix commands then you can use the man command to see if there is an online page available. For instance, if you need assistance on the move (mv) command, you would enter:

man mv

Syntax: man command name

12. Pmap command

The Unix pmap command shows the process of memory usage or various processes. Pmap displays information about the memory usage map or the address space. Memory is the most important component of the operating system and pmap is the most important Unix command. You just have to mention the process id in order to find out the memory usage of the processes. In the result, it shows full address, kbytes, mode, and mapping.

Syntax: pmap options

Example:  pmap PID

13. Touch Command

Touch command is a command-line tool that is applied to update timestamps on files. UNIX operating system stores timestamp data of each file or directory including access time, update time, and change time. It can be used to alter timestamps by using the touch command either to update timestamps to the latest time or to alter it to a date in the past.

Syntax:  touch -a filename

Example: touch -a test11

The above command sets the current time and date on a file test11. -a is the option that can be used.

14. Grep command

The grep is one of the most advanced Unix commands. This command is used to search for a given string in a specific file. For example, if you have a file test11.txt. It contains an article of 1000 words. Now, if you want to search a particular text from this file then the grep command can be used.

Syntax: grep -i filename

Example:  grep -i “Jeff” test11.text

The above command will search for the string Jeff in the file test11.txt. Grep is a command-line tool for finding plain-text data that match a regular expression. In other words, this command filter searches a specific file for a specific pattern of characters.

15. Shutdown command

The shutdown command is an administrator-level command. This command as the name suggests is used to shut down the system and turn the power off instantly. If you want to shut down your system immediately then you can use the now option and if you want to shut down your system after 15 min then it can be done by adding +15 min as an extension.
shutdown -h now

The above command is used to shut down the system immediately. Now, if you want to reboot it then it can be done by using -r option.

Example: Shutdown after 15 min

shutdown -h +15

Example of rebooting the system

shutdown -r now

At this point, our UNIX commands tutorial is quite extensive for beginners or advanced developers. We’ll get back with more commands and examples.

16. Useradd Command

This command is used to create a new user for the operating system. For instance, you could easily use the following command to establish a new user account with the username “john” and a default home directory:

useradd john

The user account that is being created can be customized further by specifying additional settings.

You can add the following attributes in front of useradd:

c: Add a remark, such as a user’s full name or a description, to their account.

d: Establishes the user’s home directory.

g: Change the user’s default group.

G: Set the supplemental groups for the user.

m: Create a home directory if the user’s home directory doesn’t already exist.

s: Establish the user’s default shell.

You could use the following command to establish a user account for “john” with the full name “John Doe” and the home directory “/home/john”:

useradd -c "John Doe" -d /home/john john

17. Uniq Command

uniq is a Unix command that is used to remove duplicate lines from a file or stream of text. It analyzes the lines next to each other and eliminates duplicate lines, leaving only one instance of each distinct line.

To remove duplicate lines from a file called start.txt and write the output to a new file called end.txt, you could use the following command:

uniq start.txt > end.txt

18. Sort command

As the name implies, the command sorts the lines in a file alphabetically or numerically. The command can arrange the lines numerically, alphabetically, or according to particular fields contained within each line.

Here are some options to use with the sort command:

n: Sort the lines numerically, rather than alphabetically.

r: Reverse the sort order.

t: Use a specific character as the field delimiter when sorting.

k: Specify which field to sort on (for example, -k 2 would sort on the second field).

Imagine that we have a file called employees.txt that contains the following data:

John Smith, 30, Manager
Jane Doe, 25, Developer

To sort the employees by age in ascending order, we could use the sort command with the -n and -k options like so,

sort -n -k 2 employees.txt

Then, the output will look like this:

Jane Doe, 25, Developer
John Smith, 30, Manager

19. Wc command

Count the number of lines, words, or characters in a file using the ‘wc’ command.

Here are some common options for wc:

l: Count the number of lines in the input.

w: Count the number of words in the input.

c: Count the number of characters in the input.

Using our previous employees.txt file, we can use this command to count the lines.

wc -l employees.txt

The output will look something like this: 

2 employees.txt

20. Head command

Linux is full of files with tons of lines. Use the head command to display the first few lines of a file.

You can apply the following typical characteristics to the head command:

n: Indicate how many lines to display. For instance, the -n 10 option would show the input’s first 10 lines.

q: Quiet mode; the file name is not displayed before the output.

c: Indicate how many characters to display.

To display the first 1 line of a file, you could use the following command:

head -n 1 employees.txt

The output: 

John Smith, 30, Manager

Learn to code with our Free Courses for everyone!


About the Author

ByteScout Team ByteScout Team of Writers ByteScout has a team of professional writers proficient in different technical topics. We select the best writers to cover interesting and trending topics for our readers. We love developers and we hope our articles help you learn about programming and programmers.