The 10 Most Commonly Used Linux Commands

What Is a Linux Command?

A Linux command is a program or utility that runs on the command line interface (CLI) – a console that interacts with the system via texts and processes. It’s similar to the Command Prompt application in Windows.

Linux commands are executed on Terminal by pressing Enter at the end of the line. You can run commands to perform various tasks, from package installation to user management and file manipulation.

Here’s what a Linux command’s general syntax looks like:

bash CommandName [option(s)] [parameter(s)]

A command may contain an option or a parameter. In some cases, it can still run without them. These are the three most common parts of a command:

  • CommandName is the rule that you want to perform.

  • Option or flag modifies a command’s operation. To invoke it, use hyphens (-) or double hyphens (--).

  • Parameter or argument specifies any necessary information for the command.

Keep in mind that all Linux commands are case-sensitive.

Here is the list of basic Linux commands:

  1. sudo command Short for superuser do, sudo is one of the most popular basic Linux commands that lets you perform tasks that require administrative or root permissions. When using sudo, the system will prompt users to authenticate themselves with a password. Then, the Linux system will log a timestamp as a tracker.

Example:

sudo apt update

This command updates your system’s package list using administrative privileges.

  1. pwd command Use the pwd command to find the path of your current working directory. Simply entering pwd will return something like this:

This command is useful when you want to know where you are in the file system.

  1. cd command The cd command stands for change directory. It allows you to navigate through different directories in the file system.

Example:

This command changes your current working directory to Documents.

To go back to the previous directory, use this command:

To go back to your home directory, use this command:

To go to any directory from anywhere, use an absolute path:

  1. ls command The ls command lists all files and directories in your current working directory.

Example:

This command will return something like this:

You can also use some options with this command, such as:

  • -a to show all files, including hidden ones.

  • -l to show detailed information, such as permissions, size, and modification date.

  • -h to show human-readable file sizes.

  • -t to sort files by modification time.

Example:

This command will return something like this:

  1. mkdir command The mkdir command creates a new directory in your current working directory or a specified path.

Example:

This command creates a new directory named NewFolder in your current working directory.

To create multiple directories at once, use this command:

To create a nested directory structure, use this command:

This command creates a new directory named NewFolder with two subdirectories named Subfolder and Subsubfolder.

  1. touch command

The touch command creates a new empty file in your current working directory or a specified path.

Example:

This command creates a new empty file named NewFile.txt in your current working directory.

To create multiple files at once, use this command:

This command creates three new empty files named NewFile1.txt, NewFile2.txt, and NewFile3.txt in your current working directory.

The touch command can also be used to change the access and modification times of existing files.

Example:

This command updates the access time of ExistingFile.txt to the current time.

  1. cp command

The cp command copies files or directories from one location to another.

Example:

This command copies SourceFile.txt from your current working directory to DestinationFolder.

To copy multiple files at once, use this command:

This command copies SourceFile1.txt and SourceFile2.txt from your current working directory to DestinationFolder.

To copy a directory and its contents recursively, use this command:

This command copies SourceFolder and all its subdirectories and files to DestinationFolder.

  1. mv command

The mv command moves files or directories from one location to another.

Example:

This command moves SourceFile.txt from your current working directory to DestinationFolder.

To move multiple files at once, use this command:

This command moves SourceFile1.txt and SourceFile2.txt from your current working directory to DestinationFolder.

To move a directory and its contents recursively, use this command:

This command moves SourceFolder and all its subdirectories and files to DestinationFolder.

The mv command can also be used to rename files or directories.

Example:

This command renames OldName.txt to NewName.txt in your current working directory.

  1. rmcommand

The rmcommand removes files or directories from your file system.

Example:

This command deletes FileToDelete.txt from your current working directory.

To delete multiple files at once, use this command:

This command deletes FileToDelete1.txt, FileToDelete2.txt, and FileToDelete3.txt from your current working directory.

To delete a directory and its contents recursively, use this command:

This command deletes FolderToDelete and all its subdirectories and files from your file system.

  1. catcommand

The catcommand concatenates files and prints them on the standard output (usually the terminal).

Example:

This command prints the contents of FileToRead.txt on the terminal.

To concatenate multiple files and print them on the standard output, use this command: