50 Most Used Linux Commands [Free PDF Download]

Suppose, you’ve started to use Linux recently, and you’re quite new to the command line interface. But one thing is certain if you want to learn about some frequently used Linux commands and practice them on your own then you’ve found the right place. Here, I’ve discussed the 50 most used Linux commands with a brief description and practical examples.

Download 50 Most Used Linux Commands

50 most used commands in Linux download overview image

Available Download Options


PDF (47 Pages)
DOC (47 Pages)

List of 50 Most Used Linux Commands

1. sudo Command

sudo can be referred to as the supreme command. It is the abbreviation for “Super User DO”. It allows a user to act as a superuser and run commands accordingly. One can run certain commands prefixed by sudo with boosted rights. It is considered analogous to the “run as administrator” process of Windows.

Synopsis:

Syntax, available options and required arguments for the sudo command.

Options:

  • -D directory, –chdir=directory (executes the command in the specific directory)
  • -e (edits one or multiple files instead of executing commands)
  • -l (runs specific commands as the root user)
  • -u user, –user=user  (executes the command as a user other than the specific default user. )

Example:

apt install <package name>

Denial of any random user for package installation permission on the machine.Any general user cannot install any packages on the machine. However, with sudo prefixed with the command, the user can execute his/her task by providing his/her password.

sudo apt install <package name>

Using sudo command to install any package as general user.

2. pwd Command

pwd is the abbreviation for Print Working Directory. As the name suggests, it prints the name of the current/working directory all the way beginning from the root(/) directory.

Synopsis:

pwd [OPTION]...

Options:

  • -L, –logical (Even as it carries symlinks, PWD utilizes from the environment. )
  • -P, –physical (avoid the symlinks) When no option is mentioned, it is assumed that option -P is being used.

Example:

pwd shows the current working directory.Generally, Terminal prompts have a complete directory in the name. Otherwise, pwd becomes a handy command to get insights about the current working directory.

3. cd Command

Change Directory(cd) allows one to change one’s current directory to the desired directory within the terminal.

Synopsis:

Syntax, available options and required arguments for the cd command.

Note: cd is a shell built-in command, it doesn’t have a dedicated man(manual) page. However, you can get help using command help!

Options:

  • cd ~[username] — change the directory to the home directory of the specified user.
  • cd .. — changes directory one directory up the current directory.
  • cd – — changes the directory to the previously changed directory.

Example:

In our Desktop directory, we have a 3-level nested directory. we want to leap forward to the level 3 directory by jumping one level at a time.Changing levels of directories using the cd command. We have changed our mind, now we want to be at level2. Therefore, we just need to go one directory backward which can easily be done by executing the command cd ..Backing up using cd.Lastly, we have concluded that we want to be in the home(~) directory. This can be simply done by executing cd ~ (tilde represents home directory).Jumping to home directory.

4. ls Command

Lists the contents, both files, and subdirectories of the current directory by default. It is one of the most used commands, as one can view the contents of a directory without exiting the terminal and perform their desired tasks on the specific contents.

Synopsis:

ls [OPTION]... [FILE]...

Options:

  • -a — doesn’t ignore the hidden files (files named with .(dot) at the beginning).
  • -h — print sizes in human-readable forms.
  • -l — lists in a long form.
  • -S — Sorts according to file size, largest first.

Example:

ls /

After being at the root(/) directory, if we run the ls command we can view the contents of the root directory.Listing the root directory.

5. cat Command

Prints the contents of the file specified. Generally, cat (concatenates) reads the contents of the files fed to its arguments and prints them serially on the terminal.

Synopsis:

cat [OPTION]... [FILE]...

Options:

  • -n, –number — Displays line numbers when utilized.

Example:

We can display the contents of a file simply by using the cat command followed by the file name.Concatenates a file.

6. mv Command

Mv is the abbreviation for move. As the name suggests it moves things from one place to another place. mv moves one or multiple files to the specified destination directory. If the directory doesn’t exist it just renames the files. mv can also be used to move directories and their contents.

Synopsis

Syntax, available options and required arguments for the mv command.

Options:

  • -i, –interactive (Displays interactive prompt before completing the modification)
  • -t, –target-directory=DIRECTORY (Moves every specified file to the targeted DIRECTORY)
  • -v, –verbose (Prints message of what is being performed.)

Example:

mv Folder2/file2 Foder1/

In the desktop directory, there are two subdirectories named Folder1 & Folder2 which respectively contain two files named file1 & file2. Now let’s move file2 to folder1.Moving contents using the mv command.

7. cp Command

Cp is the abbreviation for copy. As the name suggests it copies things from one place to another place. cp copies one or multiple files to the specified destination directory. If the directory doesn’t exist it just renames the files. cp can also be used to copy directories and their contents.

Synopsis

Syntax, available options and required arguments for the cp command.

Options:

  • -i, –interactive (Displays interactive prompt before completing the modification)
  • -R, -r, –recursive (Copies the directories as well as their contents recursively)
  • -v, –verbose (Prints message of what is being performed.)

Example:

cp Folder1/file2 Folder2/

In the desktop directory, there are two subdirectories named Folder1 & Folder2. In folder1 there is a file named file2. Let’s make a copy of file2 in the Folder2 directory.Copying contents using the cp command.

8. rm Command

Rm is the abbreviation for remove. As the name suggests it removes things and the removal is permanent, so be cautious while using it. rm can also be used to remove directories and their contents permanently.

Syntax:

rm [OPTION]... [FILE]...

Options:

  • -i  (Displays interactive prompt before completing the deletion each time)
  • -I (Less intuitive than -i, Only shows prompt while deleting 3 or more files or deleting recursively.)
  • -d, –dir (Removes the empty directories)
  • -R, -r, –recursive (Removes the directories as well as their contents recursively)
  • -v, –verbose (Prints message of what is being performed.)

Example:

In the desktop directory, there are two subdirectories named Folder1 & Folder2. Folder2 contains a file named file2. let’s remove file2.

rm Folder2/file2

removing a file using rm command.Now, Folder2 is empty let’s remove this directory. To remove an empty directory option -d has to be used.

rm-d Folder2

removing an empty directory using rm command.Finally, we have decided that Folder1 is also of no use to us. Let’s remove this directory. However, it is not an empty directory so -d will not work. Instead, we have to use -r.

rm -r Folder1/

removing a nonempty directory using rm command.

Disclaimer: You cannot retrieve anything after removing it through the rm command. So, better be careful with rm.

9. touch Command

The touch command allows us to update a file’s access or modification time. However, if the file doesn’t exist we can create that file. This ability to create files makes the touch command one of the most useful commands.

Syntax:

touch [OPTION]... [FILE]...

Options:

  • -a (changes only the access time)
  • -m (changes only the modification time)

Example:

touch file1 file2 file3

Creating files using the touch command.We created 3 files in our current directory, Desktop named file1, file2, and file3 with the help of the touch command.

10. mkdir Command

mkdir is the abbreviation for make directory. As the name suggests the mkdir command can be used to create one or more directories.

Syntax:

mkdir [OPTION]... DIRECTORY...

Options:

  • -p – -parents (Creates the necessary parent directories if required)
  • -v, –verbose (Prints message of what is being perfmkormed.)

Example:

Let’s make a directory named ‘Examples’ in our desktop directory which will contain one subdirectory named ‘NoExamples’.

mkdir -p Examples/NoExamples

Creating directories using the mkdir command.

Note: Option -p  is used to create the necessary parent directory, in this case, which is ‘Examples’.

11. locate Command

The locate command performs the search operation from an existing database and prints the results with the exact directory path.

Syntax:

locate [OPTION]... PATTERN...

Options:

  • -c (Does not print any matches but rather the total occurring number)
  • -e (Only prints the existing match)
  • -i (Ignores the sensitivity of cases)

Example:

We have a file named Greetings in our ‘/home’ directory. After changing our current directory from ‘/home’ to ‘/Desktop/Locate’ we operated the locate command.

locate Greetings

Locating files.

12. find Command

The find command searches in real-time not like the locate command from an existing file.

Synopsis:

Syntax, available options and required arguments for the find command.

Options:

  • -type d/f (d(limits the search to only directories), f(limits the search to only files)).
  • -size +n,n,-n (Finds for a specific size n.)
  • -name pattern (Will search for the given pattern)
  • -exec (can be used to perform our customized tasks on the matches.)

Example:

find -type d

This will only the find operation to directory type only.Searching the directories only using find command.

13. grep Command

The grep command can be used to search patterns in specific files or each file. Then prints the entire line containing the match.

Synopsis:

Syntax, available options and required arguments for the grep command.

Options:

  • -c (Does not print any matches but rather the total occurring number)
  • -i (Ignores the sensitivity of cases)
  • -w (search for a whole word)

Example:

We have a text file named “FIFA_World_Cup_2022” in our desktop directory. Let’s search for ‘FIFA’ in the file.

grep FIFA FIFA_World_Cup_2022

Searching pattern using the grep command.Now, if we want to just know about the occurrence number, we have to use the -c option.

grep -c FIFA FIFA_World_Cup_2022

Counting the occurence of a pattern.

14. head Command

The head command prints the first(by default 10 lines) few lines of a file.

Syntax:

head [OPTION]... [FILE]...

Options:

  • -n (Prints the first n lines.)
  • -v, –verbose (Prints message of what is being performed.)

Example:

We want to print the first 5 lines of the FIFA_World_Cup_2022 text file. It can be simply done using the head command with -n5 option.

head -n5 FIFA_World_Cup_2022

Displaying first five lines.

15. tail Command

The tail command prints the last(by default 10 lines) few lines of a file.

Syntax:

tail [OPTION]... [FILE]...

Options:

  • -n (Prints the last n lines.)
  • -v, –verbose (Prints message of what is being performed.)

Example:

We want to print the first 5 lines of the FIFA_World_Cup_2022 text file. It can be simply done using the tail command with -n3 option.

tail -n3 FIFA_World_Cup_2022

Displaying last three lines.

16. man Command

You are whether a beginner or a professional Linux CLI(command line interface) user, the command you will interact with the most is certainly the man command. The man command enables the user to learn more about a specific command i.e. syntax, options and arguments of that command.

Synopsis:

Syntax, available options and required arguments for the man command.

Options:

  • -k, –apropos (Displays the short manual page on the terminal)
  • -I, –match-case (Performs case-sensitive manual page search)
  • /pattern (It is a useful search shortcut built-in inside the man page.)

Example:

You can navigate through the man page using arrow keys and other specific keys. To know more about the man page navigation try pressing h on the man page of any command.

softeko@ubuntu:~/Desktop> man man

Manual page for man command.You can print short information from the man page using option -k.Shortd manual page for a specific command.

17. history Command

Executing this command one can view the previously used commands in the terminal.

Synopsis:

Syntax, available options and required arguments for the history command.

Example:

let’s view some of our previously executed commands using the history command.Previously executed commands.

18. chmod Command

chmod is the abbreviation for change mode. The chmod command can be used to alter the permission attributes of system contents.

Synopsis:

Syntax, available options and required arguments for the chmod command.

Options:

  • u represents user (u+x will empower the user with executable permission.)
  • g represents groups (g-w will revoke the modification power of members of the group.)
  • o represents others (o+r will empower others to read the contents.)
  • a represents all (a=r will grant everyone accessing power however it will revoke everyone from write and execution permissions.)
  • -c, –change (reports the occurrence of the change.)

Example:

The modification permission represented by character w of groups for a file named “file.txt” can be revoked using the command:

chmod g-w file.txt

Changing the group permission.Now, for the directory named “Folder”, we want that everyone only is able to read the file. This can simply be done by using the command:

chmod a=r Folder/

changing permission for all.

19. chown Command

The chown (change owner) command can be used to alter the owner of system files & directories.

Synopsis:

Syntax, available options and required arguments for the chown command.

Options:

  • -c, –change (reports the occurrence of the change.)
  • -R, –recursive (operates recursively on the desired files & directories)

Example:

We want to change the ownership of a directory named “Folder”. It can be easily done using the chown command. However, we need to use sudo as a prefix of chown as only the root user has permission to do so.

sudo chown sowad Folder/

Changing the ownership of a directory.

20. echo Command

The echo common is one of the simplest commands, it prints whatever we give to it.

Synopsis:

Syntax, available options and required arguments for the echo command.

Example:

Let’s print “whatever we want!”.Printing texts.Let’s print today’s date. However, if we feed ‘date’ to echo it will just literally print ‘date’ so we have to use special syntax $(command).Running commands and displaying them using echo and expansion characters.

21. alias Command

The alias command can be used to replace a command with user-modified instructions while running the command.

Synopsis:

Syntax, available options and required arguments for the alias command.

Note: Shell built-in commands don’t have man pages. The help command can be used here.

Example:

If we want to remove directories/files with the rm command while adding a confirmation prompt we need to run rm -ri. Now, we can make just rm sufficient enough to do the task of rm -ri, using the alias command.

alias rm='rm -ri'

rm Folder/

Creating our own defined command.

22. passwd Command

The passwd command can be used to change the password of a specific user.

Synopsis:

Syntax, available options and required arguments for the passwd command.

Options:

  • -d –delete User’s password can be deleted.
  • -e –expire Immediately makes the password expire.
  • -i –inactive INACTIVE  makes the password inactivate after a specific INACTIVATE period.

Example:

We can simply change our password for the current user with passwd command.Changing password of a user.

23. less Command

The less command is used to display the contents of a file on the terminal screen in page by page manner.

Synopsis:

Syntax, available options and required arguments for the less command.

Options:

  • -n –line-numbers (when enabled it stops showing line numbers)
  • -N –LINE-NUMBERS (displays line numbers at starting points of each line.)

Example:

We want to view the file named “World_Cup” with line numbers. This can be done by using the less -N  command.

less -N World-Cup

Arrow keys can be used to navigate through the less view.A sample less page.Now remember that you have to press q to exit the less display.

24. whoami Command

The whoami command simply displays the currently logged-in user.

Syntax:

whoami [OPTION]...

Example:

The whomai command displays the current user in our case which is softeko.Finding the user using whoami command.

25. kill Command

Kill is a built-in command that terminates currently running processes. This is a manual command that can forcefully kill a single process or all current processes using the terminal.

Syntax:

kill [options] <pid> [...]

Example:

top

The top command can be referred to as the task manager of Linux. It shows information regarding CPU and memory optimization.Output after running top command.The process ID(PID) of the terminal is 4178 in this case. Now using the kill command with the PID of the terminal as its argument we can close the terminal.

kill 4178

26. zip Command

zip command is used to compress files or folders into a .zip file in UNIX and UNIX-like operating systems. This allows for reducing the size of files and disk usage. Converting many files, and folders into a .zip file allows sharing and maintaining disk location by reducing file zie without any loss.

Synopsis:

Syntax of zip command

Options:

  • -e, –encrypt (encrypt a file with a password that is entered through the prompt)
  • -i \*.txt (include the only files with some conditions)
  • -m  (moves the files into the zip files, deletes the original files after compression)
  • -r, –recurse-paths (compression throughout all the files and folders recursively)
  • -s, –split-size SIZE (the zip file is split into many different files in a specific size) 

Example:

Use zip command to compress a single file.

zip COMPRESSED.zip file_1

Compressing a single file using zip commandYou can also compress multiple files.

zip COMPRESSED.zip file_1 file_2 file_3

Using zip command to compress multiple filesEncrypt a file with a password with -e option.

zip -e COMPRESSED.zip file_1

Using zip command -e option to encrypt a fileWe can move the file into a .zip file and delete the original with -m option.

zip -m COMPRESSED.zip file_1

Using zip command -m option to move original file

27. unzip Command

unzip command is used to extract files from a .zip file. This command creates a new folder in the current directory where the field inside the zip files is extracted.

Synopsis:

Synopsis of unzip command

Options:

  • -u (update existing files inside the folder and create new ones if required)
  • -i (shows the files or folders inside the compressed document)

Example:

To simply extract files from a compressed folder, we use unzip command.

unzip COMPRESSED.zip

Unizip a compressed file using unzip commandUse -l option to view the files inside the compressed files.

unzip -l COMPRESSED.zip

Usin unzip command -l option to view files inside a zip file

28. wget Command

wget is a download command that downloads files or webpages non-interactively from the network.

Syntax:

wget [option]... [URL]...

Options:

  • -b (downloads a file in the background)
  • -c (continues a partially downloaded file)

Example:

To download a webpage, we can use the wget command.

wget www.linuxsimply.com

Downloading a webpage using wget commandTo download a webpage in the background requires -b option.

wget -b www.linuxsimply.com

Downloading in the background using -b option wget command

29. df command

df (disk free) command shows the size, used, available space, and mounted on the information of the filesystem.

Syntax:

df [OPTION]... [FILE]...

Options:

  • -a, –all (displays all file systems including inaccessible or hidden files)
  • -h, –human-readable (displays information in human-readable format)
  • -t, –type=file_type (displays files of a certain file type)
  • -l, –local (displays local file system)

Example:

Using only df command shows default information.

Using df commandUsing df -h shows us the file size in a human-readable format.Using df command -h option to see file size in human readable formatUsing df file_name shows information about only the file_name.

df COMPRESSED.zip

Using df command to see information about a single file

30. ping command

ping (Packet Internet Groper) command shows the information about the network information about the host and the server. It can check the internet connection and show the latency between the host and server.

Synopsis:

Synopsis of ping command

Options:

  • -c COUNT (sends COUNT number of ECHO_REQUEST)
  • -i COUNT (sends a packet in every COUNT second interval)
  • -f (flood ping with rapid display, sudo permission is needed)

Example:

ping localhost

It finds information about the localhost, exiting the command needed, using ctrl+c.Finding ping information about local host using ping command Finds ping information about a website exiting the command needed, using ctrl+c.

ping -c 3 localhost

Finding ping information about a website using ping commandWe can add -c NUM option to limit the number of packets using ping.

ping www.linuxsimply.com

Limits the number of packets using ping command and -c NUM option

31. diff command

diff command finds checks 2 files and shows the difference between 2 files. Normally, it does not change the content of files, but it can generate a script.

Syntax:

diff [OPTION]... FILES

Options:

  • -c (shows the differences between the 2 files in context mode)
  • -u, -U, –unified (shows the unified context of the 2 files)
  • -r, –recursive (compares files inside any subdirectories)
  • -i, –ignore-case (ignore cases)

Example:

diff file_1.txt file_2.txt

Using diff command to view the difference between 2 filesWe can use -u option to see the difference in the unified context of 2 files.

diff -u file_1.txt file_2.txt

Using diff command -u option to view the difference in unified contextOption -c shows both files in context mode.

diff -c file_1.txt file_2.txt

Using diff command -c option to view both file in context mode

32. ps command

ps (Process Status) command shows the process status and information about that process.

Syntax:

ps [OPTIONS]

Options:

  • -a, –all (shows all the processes including hidden processes)
  • -r (shows all the running processes)
  • –pid PID (shows the specific process according to PID)

Example:

ps -r

Using ps commandOption <strong>-a</strong> shows all the processes including hidden processes.

ps -a

Using ps command -a option to view all hidden processesTo look into a specific process, --pid command is used.

ps --pid 8794

Using ps command --pid option to set PID

33. apt command

apt (Advanced Package Tool) command manages different packages including install, remove, update, etc.

Synopsis:

Synopsis of apt command

Options:

  • apt [install, update, upgrade] (downloads package information and install, update or upgrade the package, sudo permission is required)
  • apt full-upgrade ( upgrade all installed packages, even remove some if required)
  • apt remove Package_Name (removes a specific package)
  • apt autoremove (removes unneeded dependencies)
  • apt –only-upgrade install Package_Name (installs or upgrades a specific package)

Example:

sudo apt update command updates all packages.using apt command update option to update systemYou can use sudo apt upgrade command to upgrade all available packages.Using apt command upgrade option to upgrade all available packagesThe autoremove option removes all unneeded dependencies.

sudo apt autoremove

Using apt command autoremove option to remove unnecessary packagesThe --only-upgrade <Package_name> option updates a specific package.

sudo apt --only-upgrade install google-chrome-stable

Using apt command --only-upgrade option to upgrade a specific package

34. dd command

dd command converts and copies a file to another directory. This command can be used to create a backup inside the hard drive or an external hard drive.

Syntax:

dd [OPERAND]...

dd OPTION

Options:

  • if (read the file instead of standard input)
  • of (write the file instead of standard output)

Example:

sudo dd if=/dev/sda of=~/backup.img

This command is used to back up a folder into another directory as backup.img file

Using dd command to create a backup

35. top command

top (Table Of Processes) command shows the currently running process inside Linux. It gives a dynamic but not interactive view of the process.

Synopsis:

Synopsis of top command

Options:

  • -n NUM (shows the top NUM number of processes)
  • -u PARAS (shows the processes according to PID or User as given as PARAS)
  • -d TIME (shows a dynamic view which updates in TIME tenth of seconds)

Example:

Simply running top shows the processes dynamically.Using top commandWe can use option -n 10 to find the top 10 running processes according to CPU usage.Using top command -n NUM option to view top NUM number of processes

36. htop command

htop process is quite similar to the top process but in htop, the user can have interactive control over the top running processes in Linux. htop may need to be installed in the terminal first for usage.

Synopsis:

There is no manual page for htop, but help, there are different commands and options shown. But before using this command, htop command maye need to be installed using sudo snap install command.htop command install

htop command -help option

Example:

Simply running htop shows the prompt where each process can be analyzed interactively.Using htop command to view running process interactively

37. useradd command

useradd command is used to add a user to the Linux system. sudo command is needed to create a new user. The superuser sudo command is required to use this command.

Syntax:

useradd [options] LOGIN

useradd -D

useradd -D [options]

Options:

  • -d DIRECTORY USER_NAME (creates a user in DIRECTORY)
  • -u, –uid  ID (creates a user with the user id of ID)
  • -g –gid ID (creates a user with a group id of ID)
  • -M USER (creates a USER without any home directory)
  • -e DATE USER (creates a USER with an expiry DATE)

Example:

Creating a simple user is possible with useradd command.

sudo useradd linuxsimply

Creating a simple user using useradd commandOption -d creates a user inside a specific directory.

sudo useradd -d ~/home/softeko_LS

Using useradd command -d option to create a user in a specific directoryWe can also use -u NUM to create a user with a specific user id as NUM.

sudo useradd -u 999 LinuxSimply

Using useradd command -u option to create a user with a specific user id

38. unalias command

unalias command removes alias created before.

Options:

  • -a (removes all alias)

Example:

Removes an alias can be done using unalias command.

using unalias command to remove an aliasRemoving all alias requires using -a option.

unalias -a

Using unalias command -a option to remove all alias

39. uname command

uname command shows information about the system. Without any option it prints Linux.

Syntax:

uname [OPTION]...

Options:

  • -a (displays all information about the system)
  • -o (displays the operating system name)
  • -s (displays the kernel name)
  • -p (displays the processor type)

Example:

Option -s displays kernel name.

uname -s

Using uname command -s option to view kernel nameOption -o displays the operating system name.

uname -o

Using uname command -o option to view the operating system nameWe can use -a to display all information about the system.

uname -a

Using uname command -a option to view all information about the system

40. ssh command

ssh (Secured Shell) command is used for securely connecting to a remote server.

Synopsis:

Synopsis of ssh

41. traceroute command

traceroute command displays the packet route to reach the host. This command can be used to see the different hops or routes it takes to connect with a particular hostname.

Synopsis:

Synopsis of traceroute command

Options:

  • -g Host_name (Routing the packet through a gate or IP address)
  • -m Host_name (Fixing the maximum number of packets)

Example:

Simply typing traceroute shows the maximum number of hops and the routes.

traceroute www.linuxsimply.com

Using traceroute commandTo fix a gate for routing -g option is used.

traceroute -g 192.168.43.45 google.com

Using traceroute command -g option to fix a gateTo fix the maximum number of hops, -m option is used.

traceroute -m 5 google.com

Using traceroute command -m option to fix the maximum number of hops

42. groups command

Groups are used to manage multiple users and permissions. Several users can be members of a group and then the group can have permission for some files or folders to manage permissions.

Syntax:

groups [OPTION]... [USERNAME]...

Example:

Simply typing groups will display all the available groups in the machine.Using groups commandWe can use id command to find the group’s id.

id softeko

Using id command to fix a group id

43. shutdown command

shutdown command is used to shut down the system with some conditions. This command can schedule a shutdown at a specific time or cancel an already scheduled shutdown. The superuser sudo permission is required for this command.

Syntax:

shutdown [OPTIONS...] [TIME] [WALL...]

Options:

  • –halt Time/Delay (Schedule a shutdown at a specific time or after a certain delay)
  • -c (Cancel any shutdown command scheduled beforehand)
  • -r Time/Delay (Schedule a restart at a specific Time or after a certain Delay)

Example:

Option --halt can schedule a shutdown at 2:00 PM. The display will also show the date and the region.

sudo shutdown --halt 14:00

Using shutdown command --halt option to schedule a specific time for shutdownWe can also schedule a shutdown after a 5 minutes delay –halt option.

sudo shutdown --halt +5

Using shutdown command --halt option to schedule shutdown by a specific delayOption -c cancels a shutdown.

sudo shutdown -c

Using shutdown command -c option to cancel a scheduled shutdown

44. exit command

The exit command exits the terminal. It is a shell command, which means it doesn’t have any man page.

Synopsis:

--help option of exit command

Example:

exit command terminates or exits a terminal. Now that terminal is not available anymore.Using exit command 1

Using exit command 2The command exit is also used to exit a script. First, a demo script is created and exit 0 is present at the end. Create a demo script using:

nano demo.sh

Using exit command in scriptsNow running the script using bash command, the script will exit at the end.

exit command to stop exit the process of script

45. wc command

wc (Word count) command is used to count the number of characters or the number of lines in a file.

Synopsis:

wc [OPTION]... [FILE]...

wc [OPTION]... --files0-from=F

Options:

  • -l File.txt (shows the number of lines)
  • -w File.txt (shows the number of words)
  • -c File.txt (shows the number of characters)

Example:

Run wc <filename> shows the line, word, and character count of the file.

Using wc commandUsing -l option shows the number of lines of that file.

wc -l Frankenstein.txt

Using wc command -l option to view the number of linesUsing -w option shows the number of words in that file.

wc -w Frankenstein.txt

Using wc command -w option to view the number of wordsUsing -c options shows the number of characters in the file.

wc -c Frankenstein.txt

Using wc command -c option to view the number of characters,

46. sort command

sort command sorts the content inside a file and shows it in the display. By default sort command sort alphabetically. But different conditions can be applied for flexibility.

Synopsis:

sort [OPTION]... [FILE]...

sort [OPTION]... --files0-from=F

Options:

  • -o Main_file Sorted_File (sort and create a new sorted file)
  • -r, –reverse File (sort in reverse order for a specific line, sort in horizontal order)
  • -n, –numeric-sort File (sort in numeric order)
  • -kNUM (sort by using a key NUM, sorting by NUM column is possible using this option)

Example:

Simply running this command sorts the contents inside a file alphabetically.Actual file before sorting

Using sort commandWe can use the -o command to sort the content inside a file and create a new sorted file.Using sort command -o option to create a new sorted file-nk3 option sorts the using the third column numerically.

sort -nk3 purchases.txt

Using sort command and -n, -k options to sort in a specific key

47. cal command

cal command stands for the calendar. It shows calendars in many different formats according to the condition.

Synopsis:

Synopsis of cal command

Options:

  • -y (shows the whole calendar of the current year)
  • cal MM YYYY (shows the calendar of the MM month of YYYY year)
  • cal YYYY (shows the calendar of the YYYY year)
  • -j (shows the Julian calendar)

Example:

Simply typing cal shows the current month’s calendar.Using cal commandUsing cal -y command shows the whole year calendar.Using cal command -y option to view calender of a whole yearTyping the month MM and year YYYY shows the calendar of that specific month of a year.Using cal command to view the calendar of a specific monthUsing <strong>-3 </strong>option shows the calendar of the current, previous, and next month.Using cal command to view calendar of the current, previous and past monthUsing cal -j command shows the calendar of the current month in Julian format.Using cal command to view the calendar in julian format

48. nano command

Nano is another text editor. It is a simple and intuitive text editor that has many different shortcuts and is very light. It comes with the basic Ubuntu install.

Synopsis:Synopsis of nano command

Example:

Use nano <filename> to create and open a file with nano.
Using nano commandMany shortcuts of nano are available at the bottom of the terminal.Shortcuts of nano command

49. du command

du command means disk usage. Using this command the total usage of the disk and the disk usage of the different files are shown in the terminal.

Synopsis:

du [OPTION]... [FILE]...

du [OPTION]... --files0-from=F

Options:

  • -a (shows the total disk usage)
  • -ah (shows all files disk usage)
  • –time (shows the last modification time)

Example:

du displays the disk usage of the current directory.using du commanddu -a can be used to find disk usage of individual files inside the current directory.Using du command -a option to view individual disk usage of files in the current directorydu -ah shows all individual files’ disk usage in a human-readable format.Using du command -ah option to view individual file disk usage in human readable formatdu --time  shows the last modification of the directory.Using du command --time option to view last accessed time of the folder

50. apt-get command

apt-get command is quite similar to the apt command. But in apt-get common is generally used in the back-end and has backward compatibility. The apt-get (Advanced Packaging Tool) command is used for retrieving the package and managing (install, upgrade, update, remove) the package.

Synopsis:

Synopsis of apt-get

Options:

apt-get [install, update, upgrade, remove] (retrieve the package and install, update, upgrade or remove the package from the system)

  • –download-only (downloads a package without installing or updating)
  • –autoremove, –auto-remove (removes unnecessary packages from the system)
  • –version (shows the version)

Example:

We can use update command to update packages in the system.apt-get command update option used to update system packagesOption autoremove removes unnecessary packages from the system.apt-get command autoremove option used to remove unnecessary packagesOption --version shows the version of the apt-get. Moreover, this option is available for many other commands.apt-get command --version command used to view apt version and other package informaiton.

Conclusion

In this article, I have covered the 50 most used Linux commands that a regular user will encounter most of the time. Of course, there are many more of these commands and each of these commands has many more options and functionality available for the user.

You don’t need to memorize every one of them and a free pdf document is available that covers all these commands.

Rate this post
Md. Ashakul Islam Sowad

Hi, I am Md. Ashakul Islam Sowad from Dhaka, Bangladesh. I have completed my undergraduate degree in Biomedical Engineering from the Bangladesh University of Engineering and Technology (BUET). I love to watch football and play video games in my free time. Here, I am working as a Linux Content Developer Executive. Furthermore, as a Linux enthusiast, I am always learning new things about Linux-based systems and I’ll be sharing them here. Read Full Bio

Leave a Comment