linux Basic

Linux Basic Useful Commands with Examples

October 8, 2022
Linux Basic

Linux is a free and open-source operating system that can be run with a variety of hardware, both mainframes, and devices. Millions of people use it, making it one of the most well-liked operating systems worldwide.

While Linux is very user-friendly. can be daunting for newcomers to learn all the different commands and options available. In this article, we’ll go through some of the most helpful commands for Linux beginners, along with some basic examples.

If you’re new to Linux Basic, there are a few basic commands that you should know. These commands will help you navigate the file system, install new software, and more.

Here is the list of Linux basic useful commands with examples :

1. ls – command

The ls command is used to list a directory’s contents. It has a few choices that it has the ability to change how it behaves. For example. The -l option will cause ls to list the contents of a directory in a long format.

2. Grep – command

To search for a specific word or phrase in a file, you can use the grep command. This command searches for the specified word or phrase in the specified file and returns any lines that contain it.

For example. To search for the word “test” in the file test.txt, you would use the following command:

grep test test.txt

3. PWD – command 

In computing, the PWD command is a command used to print the current working directory. To print the path to the current working directory, use this command often in a shell or command-line interface. The output of the PWD command is a string that specifies the path of the current working directory.

Here is an example of the PWD command in use:



4. Passwd – command

The passwd command is used to change the password for a user account. This command will prompt you for your current password, followed by a new password. It’s crucial to pick a secure password that is difficult to guess. You can modify your password using the example below:


Enter your current password:

Enter your new password:

Re-enter your new password:

Your password change was successful!

5. Mv – command

The mv command is a Linux Basic command that allows you to move files and directories. The basic syntax for the mv command is:

mv [options] source destination

For example, let’s say you have a file called file1.txt in your current directory. To move this file to the /tmp directory, you would use the following command:

mv file1.txt /tmp

6. Cp – command

The cp command is a Linux Basic command used to copy files and folders. The cp command is often use to copy a file from one directory to another.

H The cp command can be use to copy a directory and all of its contents as well as many files at once.

cp command with some examples. Recommended Reading: cp – Copy Files/Directories In Linux (RHEL 6/7 && CentOS 6/7)

7. Rm – command

In Unix-like and some other operating systems, the rm command is used to delete files or directories. It accepts multiple filenames or directory names as arguments. The rm command removes each specified file. By default, it does not remove directories.

Here is an example of the rm command in use:

$ rm test.txt

8. Mkdir – command

To make new folders, use the mkdir command. With this command, you can create one or more directories at the same time. the following command would create two new directories, “dir1” and “dir2”, in the current directory:

mkdir dir1 dir2

9. chown – command

The chown command is a Linux command that changes the owner of a file or directory. The owner is the user who has permission to modify, delete, or change the permissions of the file or directory.


To change the owner of the file test.txt to the user jane, you would use the following command:

chown jane test.txt

10. Cat – command

A Linux Basic tool for concatenating files and printing to standard output is the cat command. A file’s contents can be created, viewed, spliced, printed to the screen, or any combination of these actions can be done but use the command.

The -n option, for instance, is able to count the lines in a file. You can use the -b option to only number non-blank lines in a file. A file’s blank lines can be remove with the -s option.

11. Echo – command

An essential Linux command for displaying text or strings is an echo. You can print a message, a file’s contents, or the value of variables by using the echo command. Example:

cat file.txt | echo

This will print the contents of file.txt to the terminal.

12. WC – command

In Linux, the wc command is used to count the number of words, characters, and lines in a text file.

For example, to find out how many words are in the file “text.txt”, you would type:

WC text.txt

13. Man – command

The man command is used to display the manual pages of a given command. Manual pages contain detailed information about a command, including its syntax, options, and usage examples.

For example, to view the man page for the ls command. You would use the following command:

man ls

14. Clear – command

An imperative sentence gives a command. Using it to give instructions is common.

For example:

– Close the door.

– Turn off the lights.

– Take out the trash.

15. Apt-get – command

The `apt-get` command is typically used with the `sudo` command, allowing users to run commands with superuser privileges. For example, the command `Sudo apt-get install [package]` would install the specified package.

16. Diff – command

To use the diff command, you must specify the two files you want to compare. For example, let’s say you have a file named “file1.txt” and another file named “file2.txt”. To see the differences between these two files, you would run the following command:

diff file1.txt file2.txt

17. kill – command

The kill command is a command line utility that is used to terminate a running process. The kill command sends the SIGTERM signal to the process, which terminates the process. However. Using the -s option, you can additionally define which signals should be transmitted to the process.

Here is an example of how to use the kill command to terminate a process:

$ kill -s SIGTERM 1234

18. Exit – command 

To end a shell, shell script, or subshell, use the exit command. It is possible to stop an ongoing operation or exit with a specific exit code using a number of inputs.

For example. The following exit command would exit the shell with a status code of 0:

exit 0

19. Useradd – command

The useradd command is a simple way to create a new user. The username alone can be set as an input when running it. Here’s an example of how to use the useradd command to create a new user with custom settings:

useradd “John Doe” 


This article is all about Linux’s Basic Useful Commands. We will show you Linux basic commands and their usage. This command helps to create, copy, delete, rename, and even format the file in Linux. We will also show you how to create a directory in Linux with some examples.

Leave a Comment

Your email address will not be published.

Get 01 month free trial before buying. Click HERE to download the installation instructions.