Most Used Ubuntu Commands

Commands used for System Information

date

The simple “date” command displays the current date and time (including the day of the week, month, time, time zone, year).
Syntax: date
Example:

12.png

set

Linux allows its user to set the current date and time of the system manually.
Syntax: date –set=”Date_in_format(YYMMDD) Time_in_format(HH:MM)”
Example:

13.png

df -h

The command “df -h” shows the same result as the command “df” but now the data is in a more human-readable form which can be easily comprehended by a new user.
Syntax: df -h
Example:

14.png

free

The command “free” displays the amount of free and used memory in the complete system.
Syntax: free
Example:

15.png

uptime

The command “uptime” provides information about how long the system has been running in one line. Result for this command includes the current time, the time duration system has been running for, the number of users who are currently logged on, and the system load averages for the past 1, 5, and 15 minutes respectively.
Syntax: uptime
Example:

16.png

passwd

The command “passwd” stands for password and it is used to change the password of the user.
Syntax: passwd user_name
Example:

17.png

 

exit

The command “exit” as the name says it is used to exit from the system and log out from the current user.
Syntax: exit
Example:

18.png

shutdown

The command “shutdown” is used to shut down the system.
Syntax: shutdown
Example:

19.png

 

Commands used for File Handling

mkdir

The command “mkdir” allows users to create directories/folders in the system. The user running this command must have suitable rights over the parent directory to create a directory or they will receive an error.
Syntax: mkdir New_Directory’s_Name
Example:

20.png

Entering the command “mkdir NewDirectory” will create the directory named as NewDirectory in the current directory.

rm

The command “rm” is used to remove files from the directory.
Syntax: rm file’s_name
Example:

21.png

This above-mentioned command will remove the file “Test_File” from the Desktop directory.

mv

The command “mv” is used for two purposes

  • To move files or directories from one path to another path in the system.
  • To rename a file or folder.

1. "mv" to move file or folder

Syntax: mv Source_File_name Destination_File_Name
Example:
Consider having two files in a directory (File1 and File2). Entering the command “mv File1 File2” will move data of File1 to File2 and delete source file(i.e. File1) from the system.

 

2. “mv” to Rename Files

Syntax: mv File_name New_name_for_file
Example:
Consider having two files in a directory (File1 and File2). Entering the command “mv File1 File_Rename” will rename File1 to File_Rename in the same directory.

cp

The command “cp” is used to copy data from a source file to the destination file. Its function is almost like the command “mv”. The only difference is by using the command “cp” the source file is not removed from the directory after its data is moved to the destination file.
Syntax: cp source_file_name destination_file_name
Example:

22.png

Consider having two files (A and B) in Desktop Directory. Entering the command “cp A B” will copy all the data from file A to file B and user can still access both files (A and B).

cat

Used to display each line of the file starting from the first row and finishing on its last row.

Syntax: cat file_name
Example:

23.png

head

The command “head” prints the top N rows of data of the given input or file. By default, it prints the first 10 lines of the specified files.
Syntax:

head -n File_name

Example:

head -5 New_Test.txt

The above-mentioned command will only print first 5 rows of the file New_Test.txt

tail

The command “tail” prints the last N rows of data of the given input or file. By default, it prints the last 10 lines of the specified files.
Syntax:

  • tail -n File_name

Example:

tail -5 New_Test.txt

The above-mentioned command will only print last 5 rows of the file New_Test.txt.

24.png

echo

The command “echo” used to display any expression that is passed as an argument.
Syntax:
echo expression_to_be_displayed
Example:

echo user

This command displays the expression “user” on the screen.

25.png

grep

The command “grep” is used to search for a text in the specified file/folder.
Syntax: grep “expression_to_be_Searched” file_name_to_search_in
Example:

grep “Are” B

The above-mentioned command will search for the word “Are” in the text of the file B.

26.png

sudo

The command “sudo -I” is used to continue the session as a root user which has a lot more privileges than normal system user.
Syntax: sudo -i

 

Basic Commands

history

The simple command “history” displays the list of all commands entered since the user started the session.
Syntax: history
Example:
Note: To clear all the previous history use command “history -c”.

27.png

help

The command of “help” provides you help to learn about all the built-in commands.
Syntax: help

ls

The command “ls” displays the list of all directories, folder, and files present in the current directory.
Syntax:

  • ls

Example:

28.png

cd

The command “cd” stands for change directory and it is used to change the current directory user is operating in via Terminal.
Syntax:

  • cd destination_directory’s_name (to move forward from your current directory to the next directory within current directory)
  • cd .. (to move back in the previous directory from your current directory)

Example:

cd Desktop

This command takes you from Directory /home/user to the destination directory which is /home/user/Desktop.

Note: You cannot only use cd when the destination directory is within your current directory.

29.png

cd ..

This command takes you from directory /home/user/Desktop back to /home/user.

30.png

pwd

The command “pwd” displays the path of the current directory user is operating in via Terminal.
Syntax: pwd
Example:

31.png

clear

The command “clear” is to clear the screen of Terminal.
Syntax: clear

 

 

Was this article helpful?
0 out of 1 found this helpful

Articles in this section

Become a Certified Logsign User/Administrator
Sign-up for Logsign Academy and take the courses to learn about Logsign USO Platform in detail. Enjoy the courses, and get your badges and certificates. In these courses, you'll learn how to use Logsign in your work and add value to your career.
Visit Our Blog
Our Logsign USO Platform illustrate our expertise. So do the blog. Through our blog posts, deepen your knowledge on various SecOps topics or get updated about important news & modern approaches for cybersecurity. Get into the habit of reading valuable information provided by Logsign. Be a step ahead.