Master the Linux Terminal: Top 10 Most Essential Commands to Know

Master the Linux Terminal: Top 10 Most Essential Commands to Know

ยท

3 min read

ls: list directory contents

The ls command in Linux is used to list the contents of a directory. It stands for list and is one of the most commonly used commands in the Linux terminal.

Some of the basic options that can be used with ls include:

  • -l : This option displays the contents of a directory in a long format, showing details such as permissions, owner, size, and modification date for each file or directory.

  • -a : This option displays all files and directories, including hidden files.

  • * : This option lists the contents of the directory with its subdirectories.

cd: change directory

The cd command in Linux is used to change the current working directory. It stands for change directory and is used to navigate the file system.

Some examples of using the cd command include:

  • cd / : This changes the current working directory to the root directory.

  • cd ~/ : This changes the current working directory to the home directory of the current user.

  • cd ../ : This changes the current working directory to the parent directory.

  • cd <directory> : This changes the current working directory to the specified directory, relative to the current working directory.

pwd: print working directory

The pwd command in Linux stands for print working directory and is used to display the current working directory.

When you run the pwd command, the full path of the current working directory is displayed on the terminal. This is useful for determining your current location in the file system and for referencing other files and directories relative to the current working directory.

cp: copy files and directories

The cp command in Linux is used to copy files and directories from one location to another.

The most common options used with cp are:

  • -v : This option displays the progress of the copy operation.

  • -R : This option is used to copy directories recursively, including all files and subdirectories within them.

rm: remove files and directories

The rm command in Linux is used to remove files and directories.

The most common options used with rm are:

  • -r : This option is used to remove directories and their contents recursively.

  • -v : This option displays the name of each file as it is removed.

mv: move or rename files and directories

The mv command in Linux is used to move files and directories from one location to another.

touch: create a new file

The touch command in Linux is used to create new empty files.

mkdir: make a new directory

The mkdir command in Linux is used to create new directories.

echo: display a message or the value of a variable

The echo command in Linux is used to display text or the contents of variables on the screen.

The most common options used with echo is:

  • -e : This option enables the interpretation of backslash escapes.

cat: concatenate and display the contents of files

The cat command in Linux is used to concatenate and display the contents of files on the screen.

The most common options used with cat are:

  • -n : This option displays the line numbers for each line of the file.

  • -b : This option displays the line numbers only for non-empty lines of the file.

  • -e : This option displays a $ character at the end of each line of the file.

Did you find this article valuable?

Support Adesh Khanna by becoming a sponsor. Any amount is appreciated!

ย