The Next Chapter in Our Story has Started — Stay with Us!

15 Basic Linux Commands Every User Should Know🔑

Starting from $7.95/month. Check it Out Linux operating system seems to be too complicated to use, command lines might remind you of a programming process that needs expertise or talent to know what to do. I should say that don’t worry. We want to start with 15 basic Linux commands for beginners to easily become familiar with this popular open-source interface. Before getting to the list of the 15 commands every Linux user should know, you may want to get a perspective on the importance of commands in most distros. That’s why the first section deals with some basic definitions and explanations. There is also a 16th command I think should be here, or maybe the 0th command because it’s probably even more important than the others: apt. It’s basically used to install and remove packages in many Linux distros, including Debian and Ubuntu. If your OS comes with a GUI, you can just replace most of these 15 commands by clicking on a few screens. What you can’t change, however, is that most packages need to be installed from the terminal, and to that, you need apt. Does your Linux not have a GUI desktop? Not a problem: just take a look at my guide on how to install GUI on Ubuntu Server, and you’ll also see how important apt is! Linux Hosting Simplified Want a better way to host your websites and web apps? Developing something new? Simply don’t like Windows? That’s why we have Linux VPS. Get your Linux VPS The Most Basic Linux Commands You Should Know Most people imagine Linux as a complicated operating system that is used by programmers. But it is not as difficult as in their thoughts. As you get more familiar with this open-source operating system and its distributions, you will find out Linux commands as an easy-to-use interface for helping users in managing, troubleshooting, or even optimizing the OS and its applications. As you may know, this command-line interface (CLI) is a text-based user interface (UI) in your device that can run nearly all required tasks (A typically black box with white text that is also known as a command-line processor or command-line interpreter). One of the most popular types of command-line interface for Linux is bash (Bourne Again Shell) shell that supports all the commands of the original Bourne Shell, as well as many others. It was written as a free and open-source replacement for the Bourne shell that includes features such as command-line editing, command history, and command substitution syntax from the Korn shell (KSH), and C shell (CSH). It can also support brace expansion that is used for generating text strings. Also Read: Install Linux bash on Windows 10! Having the open nature of bash, most Linux distributions, all releases of Apple’s macOS, Windows Subsystem for Linux, and Solaris Operating system use that as a default user shell. To open the bash shell in Linux, just launch a terminal from your desktop’s application menu and start shell scripting. (Remember that, depending on how your system administrator has set things up, you can change your default shell). When a terminal opens, it will present a prompt to write the code. ✅Now, it’s time to learn some Linux codes. In the following, a list of some Linux basic commands with examples will be presented that every Linux user should know: Note 1: the typical syntax of a command can be something like this: command [-argument] [ - - long-argument] file Note 2: commands, files, and directory names in a Linux shell are case sensitive, meaning that PWD will print the current working directory but PWD will return the following error: Bash: PWD: command not found Note 3: file extension doesn’t matter which means in Linux CLI, the file type will automatically determine. Note 4: the / (forward-slash) is a special character used for directory separating? Note 5: nearly all Linux commands support the argument to help you during the journey with the Command-line interface. - - help Note 6: the sign is a prompt that shows us that the shell is waiting for input and comes before every syntax in this article. $

Also Read: Find OS version with Command Line

1- ls command

If you wish to list files or directories within the file system of Linux OS, then the ls command (short for List) is the solution. Using this command, you have a variety of options such as the following table:

 Option Description ls ~ It gives the contents of the home directory ls ../ It gives the contents of the parent directory ls –version It checks the version of the ls command ls -a list all files including hidden files starting with ‘.’ ls –color Colored list [=always/never/auto] ls -d list directories – with ‘ */’ ls -F Shows file types (“/” = directory, “*” = executable) ls -li If the file is the first column, then this command prints the index number ls -l list with long format (permissions, size, ownership, and modification date) ls -laF list long format including hidden files ls -lh list long format list with size displayed using human-readable file units (KB, MB, GB) ls -ls list with long format with the file size (descending) ls -r list in reverse order ls -R list recursively directory tree ls -s list file size ls -S sort by file size ls -t sort by modification time & date – it will open the last file you edited ls -X sort by extension name

As we mentioned,

7- cp command

The cp command stands for COPY. This command can copy a single or a group of files or directories. It requires at least two filenames in its argument. Syntax of this command can be something like the following:

cp [option] Source Destination
cp [option] Source Directory
cp [option] Source-1 Source-2 Source-3 Source-n Directory

The first and second syntax is used for copying the source file to the destination or directory. The third syntax is used for copying multiple files (sources) to the directory.

Example 1:

cp file file-backup

This code will copy a file named file.txt to file-backup.txt.

Example 2:

cp file1.txt dir file2.txt dir

This code will copy multiple files and directories at once. In this case, the destination must be a directory.

CentOS vs Ubuntu 2022: Choose Your Destiny 👨‍💻

8- mkdir command

This Linux command allows users to make new directories. With mkdir command, you can also set permissions, and create multiple folders at once. The syntax of this command for making a single directory is something like this:

mkdir [option] dir-name

Example:

mkdir test-dir

This command will create a new directory named test. If you wish to create multiple directories at once, use the following syntax:

mkdir {test1, test2, test3}

9- rmdir command

Another command of our provided Linux basic commands list is rmdir which allows you to remove empty directories from the filesystem in Linux. The syntax of this command is shown in the following:

rmdir [-p] [-v ǀ -verbose] [-ignore – fail – on – non – empty] directories …

Options:

In the

rmdir –p

each of directories

Example:

rmdir mydir1 mydir2 mydir3

In this example, mydir1, mydir2, and mydir3 will be removed, if they are empty. If any of these directories are not empty, then an error message will be printed for that directory and other directories will not be removed.

Options:

• rmdir –p: Each of the directory arguments is treated as a pathname that will be removed, in this option. If they are empty, the last component will start.
• rmdir –v, -verbose: this option can display verbose information for each directory that is being processed.
• rmdir -ignore – fail – on – non – empty: if a directory isn’t empty, this option will not report an error message for occurred failure.
• rmdir –version: this option is used for displaying the version information and exit.

Also Read: How to delete a directory in Linux?

10- rm command

When you are going to remove directories and the contents within them, the rm command is the solution. But, if you only want to delete the directory, use rm –r. The syntax is something like the following short-code:

rm [option] FILE

Example:

rm test.txt

This command will permanently remove the test.txt directory.

11- Touch command

The touch command is known as another Linux basic command that lets you create a new blank file.

Syntax: touch file_name

touch

This command creates a single text file in the destination address (documents). If you want to create multiple files in a particular destination.

Syntax: touch File1_name File2_name File3_name

Options:

touch –a: This command can change access time to a specific file. It is recommended to  modify or update the last access times of a file

12- Locate command

Locate command acts as a search command in windows. It is the easiest way to search the files by names or even not know the exact name.

Syntax: locate [filename]

locate

Example:

Locate{ -i Book*note}

This command finds files with the words “book” and “note,” whether uppercase or lowercase.

List Running Services on Linux:(Ubuntu,Debian,CentOS)

13- df command

The Df command stands for “Disk Free,” which gives you the system detail as a report, such as the amount of disk, space, and usage.

To view the readable disk space summary, you can receive it in bytes, megabytes, and gigabyte format.

E.g.: MegaBytes:

df -m

Syntax:

• df
• df /dir
• df [option] [/dev/DEVICE]

14- Kill command

Kill command helps you to collapse unresponsive programs; however, it is possible to terminate programs manually.

Syntax:

kill [signal option]
kill PID

Example:

There are two common signals with kill command that users most use:

SIGKILL: This signal forces all programs to be terminated as soon as possible, and this sudden stop won’t save program changes

SIGTERM: This type of signal causes a program to stop running, but unlike SIGKILL, it lets the program save all of the changes.

Multi-users operating system(Linux) provides multiple user access simultaneously. Thus creating multiple users is necessary to interact with the system.

Useradd: This command creates a new user, and Passwd is used to set the password for this user account.

Example:

useradd JohnSmith

Userdl: deleting a user account means removing the user and its files. This command acts the same as creating a user with a little change.

Example:

userdel JohnSmith

Options:

userdel –f: This option will force the user removal

userdel –r: This command deletes a user with the home directory and its files plus the user’s mail spool.

Example:

• userdel -f Jack
• userdel -r John

How to Practice Basic Linux Commands?

No matter you want to test /analyze your shell scripts online or want to practice basic Linux commands, you should first understand them well. To practice them, you can install Linux inside Windows using Windows Subsystem for Linux. You can also use online Linux terminals. Some websites provide you with online Linux terminals to run regular Linux commands in a web browser so that you can test them or practice them.

Conclusion

Linux includes a large number of commands but we’ve chosen the most frequently needed commands for you. In this article, we explained some of the basic Linux commands with examples of coding. However, the steps may differ based on the distributions that you’re using; you can use the help of the Linux, or even comment us to help you.

FAQ

What Is the Difference Between pwd and /bin/pwd?

The pwd is a built-in command in the shell while /bin/pwd is a tool that comes with your Linux distribution. To specify that you want to run the stand-alone program instead of the shell built-in command, use /bin/pwd.

How Do I Run Commands in Linux?

First, launch a terminal from your desktop’s application menu. Then try to find the bash shell that is the default shell in most Linux distributions. Now, type a command and press enter to run it.

What Does CLI mean?

A Command Line Interface (CLI) is a text-based interface used for typing and running commands. Before the Mouse, it was the standard way to interact with a computer. Every CLI has a command prompt for accepting a command.

What Is the Use of Command-Line?

The best use of the command line is that it takes a lot of commands. This interface helps you to enter a command that can pass on to the operating system of your computer and run. Using the command line, you can also navigate through the files and folders of your device.

What Is a Linux Cheat Sheet?

There are hundreds of Linux commands that you may need to know. A Linux Cheat Sheet can help you to easily find and remember them. Such a sheet can show you commands related to the following information:

• System information
• Hardware information
• Performance monitoring and statistics
• User information and management
• File and directory commands
• Process management
• File permissions
An SEO-Specialist who loves digital marketing and has a background in creating content. Matt loves teamwork and enjoys working with professional people. He always tries to bring more things to the team.