Most basic Linux commands

Nidhisharma
6 min readMay 3, 2023

--

Photo by Gabriel Heinzer on Unsplash

Linux is a powerful operating system that is widely used in the tech industry, but for many beginners, the command line interface can seem daunting.
Fortunately, learning the most basic Linux commands is not difficult, and can help you to navigate the command line with ease. In this guide, we will explore the most essential Linux commands that every beginner should know.

whoami Command

The whoami command in Linux is used to display the username of the current user who is logged in to the system.

sudo Command

The sudo command in Linux is used to execute commands with administrative or "root" privileges. In Linux, the root user has full access to the system and can perform any operation, such as installing software, modifying system files, or running system-level commands.

man Command

Man pages provide detailed information about how to use a command, its syntax, options, and examples.

ls Command

The ls command in Linux is used to list the files and directories in the current working directory or in a specified directory. It is a basic and essential command that allows users to view the contents of directories and navigate the file system.

cd Command

The cd command in Linux is used to change the current working directory. It is one of the most frequently used commands in Linux, as it allows users to navigate the file system and access different directories.

Some examples of using the cd command are:

  • cd /usr/bin: Changes the current working directory to /usr/bin.
  • cd ..: Changes the current working directory to the parent directory of the current directory.
  • cd ~: Changes the current working directory to the user's home directory.
  • cd -: Changes the current working directory to the previous working directory.

cd /usr/bin: Changes the current working directory to /usr/bin.

mkdir Command

The mkdir command in Linux is used to create a new directory (also known as a folder) in the file system. It is a simple but essential command that allows users to organize their files and directories in a logical and hierarchical manner.

  • mkdir new_directory: Creates a new directory called new_directory in the current working directory.
  • mkdir /path/to/new_directory: Creates a new directory called new_directory in the /path/to directory.
  • mkdir -p /path/to/new/directory: Creates a new directory called directory within the new folder, and will create the to, path, and path/to directories if they do not already exist.

rmdir Command

The rmdir command in Linux is used to remove an empty directory from the file system. It is a simple but essential command that allows users to delete unwanted or unused directories.

Some examples of using the rmdir command are:

  • rmdir empty_directory: Removes the directory called empty_directory from the current working directory.
  • rmdir /path/to/empty_directory: Removes the directory called empty_directory from the /path/to directory.
  • rmdir -pv /path/to/empty_directory: Removes the directory called empty_directory from the /path/to directory, and displays a message for each directory that is removed.

mv Command

The mv command in Linux is used to move or rename files and directories in the file system. It is a versatile command that can be used to perform a variety of file management tasks.

  • mv file.txt /path/to/destination: Moves the file file.txt to the /path/to directory.
  • mv directory /path/to/destination: Moves the directory directory to the /path/to directory.
  • mv /path/to/source/* /path/to/destination: Moves all files and subdirectories in the /path/to/source directory to the /path/to/destination directory.

cp Command

The cp command in Linux is used to copy files and directories from one location to another in the file system. It is a basic but essential command for file management.

touch Command

You can create an empty file using the touch command

cat Command

The cat command in Linux is used to concatenate and display files in the terminal. It is a basic but versatile command that can be used for a variety of file management tasks.

Some examples of using the cat command are:

  • cat file.txt: Displays the contents of the file file.txt in the terminal.
  • cat file1.txt file2.txt > output.txt: Concatenates the files file1.txt and file2.txt into a single file named output.txt.
  • cat -n file.txt: Displays the contents of the file file.txt with line numbers.

echo Command

The echo command in Linux is used to display text or variables in the terminal. It is a simple but useful command that can be used for a variety of tasks, such as printing messages, creating scripts, or displaying system information.

  • echo "Hello, world!": Displays the message "Hello, world!" in the terminal.

We can append the output to a file:

clear Command

The clear command in Linux is used to clear the terminal screen. It is a simple but useful command that can be used to keep the terminal screen organized and easy to read.

history Command

The history command in Linux is used to display a list of recently executed commands in the terminal. It is a useful command for quickly accessing and re-running commands that you have used in the past.

Some examples of using the history command are:

  • history: Displays the 500 most recent commands in the history buffer.
  • history 10: Displays the 10 most recent commands in the history buffer.
  • history -c: Clears the history buffer.
  • history -d 123: Deletes command number 123 from the history buffer.

nano Command

The nano command in Linux is a text editor that is used to create and edit text files in the terminal. It is a user-friendly and intuitive editor that is particularly useful for beginners who are not familiar with other text editors like Vim or Emacs.

open Command

In Linux, the open command is used to launch a file or directory using the default application associated with the file type. The open command can also be used to launch a web page or URL in the default web browser.

Here are some examples of how to use the open command in Linux:

I hope you find it helpful.

Happy coding!

want to give suggestions:-

find me on LinkedIn Twitter

Email me at nidhisharma639593@gmail.com

--

--

Nidhisharma
Nidhisharma

Written by Nidhisharma

Self-taught front-end web developer! Js | React.js | Git. Find me on LinkedIn: https://shorturl.at/oTX04 open to work

No responses yet