Best Linux Commands that everyone should know

Best Linux Command
Table of contents

What is Linux??

  • Just like Windows, iOS, and Mac, LNIX is the OS too. One of the most common Operating Systems on the planet, Android, is powered by the UNIX OS.
  • The OS is software that oversees all of the hardware resources associated with the screen or laptop. To put it simply, the OS oversees the connection between the software and the hardware. Without the Operating System (OS), Software cannot communicate with the hardware.
    This article speaks mostly about linux commands and their advantages

Also Read: Linux Tutorial

History of Linux

  • History of UNIX In 1969, a team of developers of Bell Labs started a project to create a customary code for all the computers and named it ‘UNIX’.
  • It was straightforward and chic, used ‘C’ language rather than programing language, and its code was valid. As it was useful, a vicinity of its code currently referred to as ‘kernel’ was wont to develop the software system and alternative functions and be used completely. Also, its ASCII text file was open supply.

Why use Linux??

  • High Security

Linux is safer in contrast with other working frameworks like Windows. Linux isn’t secure as there is some malware for it; additionally, however, it is less helpless than others. In either an application or an infection, each program in Linux needs approval from the director as a secret phrase. Except if the secret key is composed, infection will not execute.

  • Linux is everywhere

It is amazingly adaptable because of its open-source nature, so anybody can go through Linux’s code and change it in any way they need.

  • Stability (Reliability)

It is beneficial, suggesting that it might be easily used on fundamentally all CPU structures.

  • The resurrection of older computer computers.

The prerequisites for running Linux are a lot lesser than other operating systems. So old computers can run Linux too.

  • Linux is also used by many tech giants like NASA, Google, Amazon, Twitter, ISRO.
  • Privacy & freedom

privacy is a major issue; Linux consistently deals with client protection as it never takes a lot of private information from the client.

  • Linux is free to use.

Linux is liberal to use. The ASCII text file could also be used, modified, and distributed commercially or 

non-commercially by anybody under the particulars of its licenses.

  • Software Updates

Dissimilar to Windows that patches show up over months, Linux generally gives update once a week.

  • Linux Customization

Linux Distributions are also known as a flavour. Unlike other operating systems like windows, there is no flavour, but on the other hand, Linux has many flavours available like parrot OS, Zorin OS. Elementary OS, Gentoo Linux, Manjiro, etc., all are very popular distro.

What is Linux Command?

A command is just plain text which you write in the terminal. When you hit enter your airport, the text’s meaning will be interpreted by a computer program known as the shell.

  • The terminal is the window to the shell.
  • Different Shells can interpret the exact text differently.

For example, Linux is just a plain text; the shell interprets its meaning.

Why bother learning Linux Command ??

Or Why in this world learning Linux command is so important?

(This question is frequently asked by beginners.)

Whether you want to become a hacker or a programmer, Linux will boost your carrier. According to Stack Overflow’s Developer Survey, those how have Linux command Line skills have a lot more chance of getting a job.

Advantage of using command-line

  • Less Resource-Intensive.
  • Unix Shell is Available Everywhere.
  • Command-Line is faster than GUI(Graphical User Interface).
  • Loading GUI will make your pc slower where CLI does not require many resources to work.

Command Synopsis 

Synopsis means a summary, 

In Linux, there are thousands of commands and not every command can be memorized.

So there are many patterns of writing commands which you will encounter in your journey. But there is no easy. 

The table given below explains how the synopsis commands are used: 

SectionMeaning
[THINGS]Thing is optional
<THING >is mandatory
THING …Can be repeated(eternity)
THING 1 | THING 2Use THING 1 or THING 2
  • Everything inside of square brackets [] is optional.
  • Everything inside of <> is required.
  • (…) means things can be repeated(endlessly).

Let’s see how you can open and close a terminal before typing a command

Go to your search box and type terminal and you will see an application called terminal like so.

For closing terminal, you can type exit inside of your terminal and hit enter.

Note: I am using kali Linux; you can use any Linux distro you want

Best Linux Command Linux that everyone should know

  1.  ls command

   SYNTAX =>    

  • ls stands for list.
  • ls command will show the list of contents inside of a directory.
  • By default, the current directory is selected.

In the above example, we are inside of download folder. When you type ls command, it shows the list of a file inside of a directory.

ls command has more features, out of which some are listed below

  • ls -a command to show hidden files. 
  • ls -l command uses a long listing format, where you will see detailed information like file size, owner info, permissions, date of modification, time of creation. 

Other variations when using the ls command are:

-a, –alldo not ignore entries starting with
-F, –classifyappend indicator (one of */=>@|) to entries
-d, –directorylist directories themselves, not their contents
-fdo not sort
-s, –sizeprint the allocated size of each file in blocks
-Ssort by file size, largest first
  1. cd command

       syntax 

  • cd command stands for change directory.
  • Navigate through the Linux file and directories. 

Let’s say we want to go inside of Document Folder so we type cd and path for the folder. In this, we want to go inside of Document folder, so we type cd Documents.

Another scenario is if you want to go back one folder up so just type “cd ..”.

  1.   PWD command

Syntax 

  • The PWD stands for the print working directory
  • the command will return an absolute (full) path that starts with a forward slash(/).
  • The PWD command prints the name of the current/working directory.

As you can see PWD command returns a full path concerning your current directory.

Other variations when using the PWD command are:

-L, –logicaluse PWD from the environment
-P, –physicalavoid symlinks
–helpdisplay help menu
–versionoutput version information
  1. cat command


Syntax

  • The cat command stands for concatenating files.
  • It is used to show the content of the file on the standard output.
  • The cat command is also one of the most popular commands.

For instance, we have file cat.txt, where inside of this file, there is a text that says I love Linux. Using the cat command, we can see the content of this file without leaving the terminal, as shown above.

Another way to use the cat command

  • Creating a new file using the cat command.

Type cat then [>] greater than an operator and the name of your file.

Syntax   

Other variations when using the cat command are:

-E, –show-endsdisplay $ at the end of each line
-n, –numbernumber all output lines
-u(ignored)
–versionversion information
–helpdisplay help menu
  1. cp command
  • The cp order represents duplicate files and directories. 

    syntax

For instance, we want to copy the file learn.txt to the desktop.

Then we type the following command name: cp and then the name of the file and the path you want to copy.

Other variations when using the cp command are:

–i, –interactiveprompt before overwrite
-l, –linkhard link files instead of copying
-n, –no-clobber  do not overwrite an existing file
–versionoutput version information
–helpdisplay help menu
  1.  mkdir command

syntax

  • mkdir stands for make directories.
  • This command will create a new folder inside of your current directory.

For instance, you want to create a new folder inside your current directory and type the following command mkdir and name of the folder.

Other variations when using the mkdir command are:

-v, –verboseprint a message for each made registry
-p, –parentsmake parent directories as needed
–versionversion information
–helpdisplay help menu
  1. rmdir command

        syntax

  • If you want to delete an empty directory, then rmdir command is used.
  1.  rm command
  • rm command used to remove files or directories.

Let’s try to delete a file using the rm command.

Type rm and then the name of a file. In this case, we want to delete the deleteMe.txt file.

Also, you can delete multiple files at once. 

Other variations when using the rm command are:

-f, –forceignore nonexistent files and arguments, never prompt
-iprompt before every removal
-d, –dirremove empty directories
–versiondisplay version information
–helpdisplay help menu
  1.  Touch Command
  • Touch command allows us to create a file with the desire formate.

For creating a new file type the touch command and then the name of the file.

Also, you can create multiple files at once.

Type touch and then type the name of the files and give space between the different file names.

Other variations when using the touch command are:

-f(ignored)
-mchange only the modification time
-d, –dirremove empty directories
-achange access time  only
–helpdisplay help menu
  1. Locate Command
  • Just like windows search or mac finder, locate command works in the same way. The locate command find files by name.

syntax

  • For instance, let’s locate chrome for doing this using locate command, type locate, and the file’s name.

You can also pass an optional argument which is -c which counts no. of the result.

Other variations when using the locate command are:

-f(ignored)
-mchange only the modification time
-d, –dirremove empty directories
-achange access time  only
–helpdisplay help menu
  1. find command

syntax

  • Just like locate command find works the same way, but it searches for files in a directory hierarchy.
  • In simple terms, it will search files on the current directory.

For instance, let’s try to find file1.txt using the find command. For using the find command, type ‘find’ and then the name of the file you are searching.

Other variations when using the find command are:

-PNever  follow symbolic links
–helpdisplay help menu
  1. man command

syntax

  • The man command stands for manual, Which gives manual.
  • The man command is also known as man pages because it gives a manual for commands and tools.

Other variations when using the man command are:

-d, –debugPrint debugging information.
-I, –match-caseSearch for manual pages case-sensitively
-u, –updateThis  option  will update its database caches which are installed by manual pages
–help, -?display help menu
  1. history command

    syntax 

  • As the name says history command will show the history of your commands.

Let’s say you want to run command history no. 5 rather than typing hole command; here is one shortcut for this

!n  Refer to command line n.

Type ! and then no. of command.

Other variations when using the man command are:

!!Refer to the previous command
!#The entire command line typed so far.
  1. apt command
  • Like the play store in android and the App Store in IOS helps update our local application, the same goes for it to update and upgrade repositories and other tools.
  • The apt is a command-line interface for the package management system.
  • The ‘apt’ stands for an aptitude package manager.
  • There are many more package manager available

    some of the themes are as follows:

  • RPM (Red Hat Package Manager).
  • DNF – Dandified Yum.
  • Zypper Package Manager – openSUSE.
  • Portage Package Manager – Gentoo.
  1.  apt-update

Syntax 

  • This command will update the list of available packages and their versions.

Let’s try to update for Linux machine using the command line.

For updating, type apt and then update.

Some users also type apt-get update. Both statements are correct.

Other variations when using the apt command are:

Listlist package names
Showshow package details
reinstallreinstall packages
updateupdate list of available packages
autoremoveautomatically Remove all unused packages
full-upgradeupgrade the system by removing/installing/upgrading packages.
  1. apt-upgrade

syntax   

  • For installing the update package, type apt upgrade.

Some users also type apt-get upgrade. Both statements are correct.

  1. apt-autoremove
  • the apt-autoremove command will remove all old and unnecessary packages which were installed during the update. 
  • For removing old files, type apt and then an option called auto-remove.
  1. git command
  • The ‘git’ stands for the version control system.
  • Git command helps us to clone repositories.
  • Before using the git command, we have to install git by using a package manager.

Syntax

Use the above command to install git. Let’s see the git command in action. 

Step 1: choose the repository you want to clone. In my case, I want to clone the freeCodeCamp repository.

Step 2: click on the button which says code.

Step 3: After that, you will see multiple methods for cloning repositories.

Step 4: we are going to use the HTTPS method, which is very easy to understand.

Step 5: Copy the link.

Step 6: Open your terminal.

    Syntax

Step 7: type git clone [url] for cloning repositories.

Step 8: your repositories are ready to use.

Other variations when using the nano command are:

git-initCreate an empty Git repository or reinitialize an existing one
git-cleanRemove untracked files from the working tree.
git-notesAdd or inspect object notes
git-rmRemove files from the working tree and the index
git-switchSwitch branches.

19. nano command

  • Nano is just a simple text editor inside of your terminal, inspired by Pico.
  • Nano is very lightweight and less resource-intensive compare to other editors.

Syntax 

Let’s see the nano command in actions, in this case, I want to read/write a file called readMe.txt using nano.

For reading and writing  type nano and name of the file, in my case 

It will pop up a window that will look something like this is where you can edit text.

Other variations when using the nano command are:

-H, –history logSave  the  last  hundred  search strings and replacement strings
-F, –multibufferRead a file into a new buffer by default.
-w, –nowrapDo not automatically hard-wrap
-N, –convertDisable automatic conversion of files from DOS/Mac
-h, –helpDisplay help menu
-V, –versionShow the current version number and exit

20. htop command

  • An interactive process viewer, just like a task manager in windows.

    syntax 

For using this command, type ‘htop’ and hit enter.

A window will pop up where you can see all of your resources and process.

Other variations when using the htop command are:

-C, –no-colourSingle-color mode.
-h –helpDisplay a help message.
-p Show only the given PIDs.
-V, –versionDisplay version information

21. clear command (CTRL + L)

    syntax

  • As the name suggests clear command clears the terminal.
  • You can use CTRL + L instead of typing the clear command.

Other variations when using the clear command are:

22. whoami command

  • Whoami command print effective username that is currently logged in.

    syntax

Other variations when using the htop command are:

-V, –versionversion information
-h, –help     Display a help menu

23. ifconfig

syntax 

  • Ifconfig command is used to configure a

             network interface.

Ifconfig command shows all types of network detail concerning your network card.

For example, ethernet is denoted by eth0, wifi is denoted by wlan0 and this is called an interface.

Other variations when using the ifconfig command are:

-a     display all interfaces even if down
–s     display a shortlist
-v     more verbose for some error conditions
up     Activate the interface
down   shut down this interface 
24. ping command

 
syntax
  • Send a request to the host for checking connectivity
  • Ping command also works on windows.
  • Let’s see the ping command in action. For using the ping command first choose a server where you want to ping. I am using google here.
  • Server response depends upon the number of packets transmitted, and the number of packets received.
If the server receives a packet, then the server is active.


syntax

Other variations when using the ifconfig command are:

-4Use IPv4 only.
-6Use IPv6 only.
-D     Print timestamp
-r    Bypass the normal routeing tables

25. chmod command

  • The ‘chmod’ command order is utilized to change/update record access authorizations like this.

       syntax

As you can see on the above image, the file I want to run is highlighted in red, which means we can not execute this file. For running this file, we type chmod +x, which will permit us to execute this file.

Other variations when using the chmod command are:

-c, –changesreport  only when a change is made
-f, –silent, –quiet         suppress most error messages.
–help display help menu.
–version              Display version information.

26. exit command

  • exit command is used to leave a shell.

Syntax 

The exit command can execute by typing exit like so.

This brings us to the end of the Linux Commands. Check out this free LINUX Course to get started with LINUX. If you wish to learn more such concepts, you can check out the Free Online Courses available on Great Learning Academy.

→ Explore this Curated Program for You ←

Avatar photo
Great Learning Editorial Team
The Great Learning Editorial Staff includes a dynamic team of subject matter experts, instructors, and education professionals who combine their deep industry knowledge with innovative teaching methods. Their mission is to provide learners with the skills and insights needed to excel in their careers, whether through upskilling, reskilling, or transitioning into new fields.

Full Stack Software Development Course from UT Austin

Learn full-stack development and build modern web applications through hands-on projects. Earn a certificate from UT Austin to enhance your career in tech.

4.8 ★ Ratings

Course Duration : 28 Weeks

Cloud Computing PG Program by Great Lakes

Enroll in India's top-rated Cloud Program for comprehensive learning. Earn a prestigious certificate and become proficient in 120+ cloud services. Access live mentorship and dedicated career support.

4.62 ★ (2,760 Ratings)

Course Duration : 8 months

Scroll to Top