Amazon Web Services Feed
Top 20 Basic Linux Commands You Should Know

Are you a beginner, aspiring to start a career in Linux? Check out these most common basic Linux commands that will help you get started with Linux.

The world of IT is more vibrant than ever, with many new tools and uniquely diverse development environments emerging every day. Among the many foundational aspects of the IT world, Linux always holds a formidable place. The open-source operating system framework has helped many applications and servers come to life.

Most of the enterprises and technology enthusiasts use Linux as their first preference while many of us are still using Windows in our computers. Learning the basic Linux commands becomes important because you cannot just depend on the GUI alone for using Linux. The various advantages of Linux make it one of the top preferences in the computing world.

Enroll Now: Linux Certification Training Courses

First of all, it is open-source with the facility of complete customization. However, if you learn how to use basic Linux commands, then you would have complete control over Linux. You can use Linux directly from the terminal with the help of basic commands. In addition, specific commands are essential for organization, troubleshooting, and optimization of applications.

Understanding Top Basic Linux Commands

Many readers might be doubtful about the applicability of Linux commands in all Linux distributions. However, the following basic Linux commands are applicable in all distributions of Linux. And in case, if anything goes wrong, Linux commands can provide significant triage information for sysadmins and operators.

The following discussion would serve as a Linux commands tutorial in which you can learn about 20 important Linux commands. Each of the commands in the following discussion would help you understand your applications better. You would also find the applications of these commands in Linux development environments, bare-metal infrastructure, containers and virtual machines (VMs).

1. Curl

‘Curl’ is the ideal entry among basic Linux commands for transferring an URL. You can use the ‘curl’ command for testing the endpoint of an application or its connectivity to upstream service endpoints. In addition, ‘curl’ could be ideally useful for finding out whether your application can reach another service or the check the health of your service. For example, if your application throws an HTTP 500 error implying that it cannot reach a MongoDB database, then you can find the following code.

$ curl –I –s myapplication:5000 HTTP/1.0 500 INTERNAL SERVER ERROR

In this case, the ‘-I’ option dictates the header information while the ‘-s’ option ensures silencing the response body. Users can check the database endpoint from a local desktop by the following example code.

$ curl –I –s database:27017 HTTP/1.0 200 OK

Now, you would have to check whether the application can reach other places other than the database from the application host.

$ curl –I –s https://opensource.com HTTP/1.0 200 OK

After this, try to reach the database from the application by trying the database hostname first.

$ curl database:27017 Curl: (6) Couldn’t resolve host ‘database’

As a result, you can clearly notice that your application could not resolve the database due to the unavailability of the database URL. On the other hand, it is possible that the host does not have a nameserver for resolving the hostname.

2. Sudo

‘Sudo’ is undoubtedly one of the prominent additions among basic Linux commands. You can use this command for executing commands with root or superuser privileges. The syntax for the command is “$ sudo <command>”. Some of the functionalities of the ‘sudo’ command could be evident in the following examples.

“$ sudo useradd <username>” for adding a new user “$ passwd <username>” for setting a password for the new user “$ sudo userdel <username>” for deleting the user “sudo groupdel <groupname>” for deleting a group

RHCE Online Course

3. Pwd Command

Sometimes, users want to know the location of the directory in which they are working. In this case, the best option among basic Linux commands for beginners would be the ‘pwd’ command. The ‘pwd’ command helps candidates find out the absolute location of the existing working directory. Here is an example of using ‘pwd’ command.

root@kali : ~/Desktop/Programming# pwd

The output would be /root/Desktop/Programming

You can clearly notice here how typing ‘pwd’ in the terminal helps in accessing the absolute location of the working directory.

4. Is Command

Another notable addition among basic Linux commands is the ‘Is’ command. It helps in listing files in a directory. Sysadmins and developers can use this command frequently. In the case of containers, the ‘Is’ command helps in determining the directory and files of the container image. Furthermore, the ‘Is’ command helps in the evaluation of your permissions. Here is an example of using ‘Is’ command.

$ ./myapp Bash: ./myapp: Permission denied $ -Is –I myapp -rw-r--r--. 1 root root 33 Jul 21 18:36 myapp

In the above example, you can find that you cannot run ‘myapp’ due to an issue with permissions. Upon checking the permissions with “Is –I”, users can find out that the permissions don’t include an “x” or a read and write-only permission.

5. Cat

One of the common additions in almost every basic Linux commands cheat sheet is the ‘cat’ command. The ‘cat’ command is ideal for concatenation and printing files. Users can also issue ‘cat’ command for checking the contents of dependencies files. In addition, it can also help in confirming the application version you have already built locally. Here is an example of using the ‘cat’ command.

$ cat requirements.txt flask flask_pymongo

The example presented above helps in checking if your Python Flask application lists Flask as a dependency.

Linux blogs are a good source of information about the latest news, trends, technology, and more. Here are the top Linux blogs that you should follow in 2020 to enhance your knowledge.

6. Grep

The ‘grep’ command is ideal for searching file patterns. In addition, ‘grep’ helps in highlighting relevant lines while looking for specific patterns in the output of another command. You can utilize ‘grep’ for searching log files and specific processes.

For example, if you want to check whether the Apache Tomcat starts up, the number of lines can be pretty overwhelming.

In this case, you can pipe the output to the ‘grep’ command for isolating the lines indicating server startup. Here is the code example to provide additional clarity on the example.

$ cat tomcat.log | grep org.apache.catalina.startup.Catalina.start 01-Jul-2017 18:03:47.542 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 681 ms

7. IP Address Command

The next important addition among basic Linux commands is the “IP address” command. If it does not work on your host, then you must have installed the host with iproute2 package. “IP address” command helps in viewing interfaces and IP addresses of an application’s host.

For instance, if a container associated with two networks, then the ‘IP address’ command can showcase the interface connecting with different networks. The most general application of “IP address” command would be to identify the host’s IP address.

8. History Command

A prominent addition in basic Linux commands cheat sheet is the “history” command. You can find unique variants of the ‘history’ command for different shells. The command can help you find the history of commands that you have used since the beginning of the session. The most promising application of ‘history’ command is for logging the commands used for troubleshooting an application.

9. MV

The “mv” command is also one of the notable basic Linux commands. It helps in moving files and directories from one directory to another. After moving the file/directory, it is deleted from the working directory. The syntax of the ‘mv’ command is as follows,

$ mv <flag> {filename} /pathname/

10. RM

Exploring the list of basic Linux commands, you are most likely to come across the ‘rm’ command. The ‘rm’ command is important for removing files from a directory. The ‘rm’ command does not facilitate removal of directories by default. However, you cannot restore the content of a file after removal. The syntax of the ‘rm’ command is as follows,

$ rm <flag> {filename}

CompTIA Linux+ LPI LX0-103 Practice Tests

11. Sort Command

A basic Linux commands cheat sheet can help you uncover the significance of ‘sort’ command also. The ‘sort’ command helps in alphabetic or numeric sorting of search results. You can sort files, directories and file contents with the ‘sort’ command. The syntax for the command is as follows,

$ sort <flag> {filename}

12. SSH Command

The next important addition among top 20 basic Linux commands refers directly to the ‘ssh’ command. It actually presents indications towards a cryptographic network protocol for secure operations of network services on an unsecured network. The general use-cases refer to remote command-line execution. On the other hand, SSH command can also help in securing any network service. Here is the syntax of ‘ssh’ command running on a slave node for remote access to the master.

$ ssh <master’s ip>

The syntax for ‘ssh’ command running at the master for remote access to the slave node is as follows.

$ ssh <slave’s ip>

13. Echo

One of the most basic Linux commands is the ‘echo’ command. It helps in writing the arguments into the standard output format. The syntax for the ‘echo’ command is as follows,

$ echo “<text>”

14. Clear

Talking of basics, it is practically impossible to skip the ‘clear’ command in any Linux commands tutorial. The ‘clear’ command helps in clearing the terminal screen. Actually, the command does not delete the contents and only scrolls them down. Users can clear the screen by just pressing “Ctrl+L” on the keyboard. The syntax for the ‘clear’ command is as follows,

$ clear

15. CP Command

This is obviously one of the important basic Linux commands for beginners to learn working with files on Linux terminal. The ‘cp’ command helps in copying files and directories. One copy of the copied file or directory would still be present in the working directory. The syntax for the ‘cp’ command is as follows,

$ cp <flag> {filename} /pathname/

Preparing for CompTIA Linux+ LX0-104 Certification? Here’s how to prepare for CompTIA Linux+ LX0-104 Certification.

16. MKDIR Command

The most important addition among basic Linux commands is undoubtedly the ‘mkdir’ command. The ‘mkdir’ command is ideal for the creation of new directories. The syntax for the ‘mkdir’ command is as follows,

$ mkdir <flag> {directoryname} /pathname/

17. RMDIR Command

After a look at the above entries among Linux commands, the ‘rmdir’ command might be very clear to understand. The ‘rmdir’ command helps in removing specific directories. The command can remove only an empty directory albeit with certain flags that could be deployed only for deleting non-empty directories. The syntax of the ‘rmdir’ command is as follows.

$ rmdir <flag> {directoryname}

18. CHMOD Command

The ‘chmod’ command is ideal for changing the access permissions for directories and files. Take the following example into consideration,

[xyz@localhost ~]$ cat chmodtest.sh #!/bin/sh Echo “This file is to test file permissions.” [xyz@localhost ~]$

When you try to run the newly created file ‘chmodtest.sh’, you will encounter an error. It can be executable only after modification of permissions of the file through using ‘chmod’ command. Here is the syntax of the ‘chmod’ command.

$ chmod <permissions of user, group, others> {filename}

19. MAN Command

The unique addition among basic Linux commands is the ‘man’ command. It helps in obtaining the complete documentation or manual for any command or tool in Linux. The syntax for the ‘man’ command is as follows.

$ man command_name

For example, if you want the documentation for ‘mkdir’ command, then you can use the command “man mkdir” for obtaining the same.

20. Passwd Command

The final addition among the top 20 basic Linux commands refers to the ‘passwd’ command. The ‘passwd’ command is ideal for changing the user account password in Linux.

Therefore, you can just type in the ‘passwd’ command for changing the password of an existing running account. On the other hand, if you are a root user, then you have to use “sudo passwd username” for changing the password of another user.

Preparing for a Linux interview? Go through this definitive set of top 60 Linux Interview Questions Answers and get ready to ace the interview.

Bottom Line

Now, you must be feeling confident about starting your learning journey on the Linux platform. Awareness of basic Linux commands mentioned here can help you use the terminal effectively. In addition, you can be more confident and efficient in carrying out different tasks on Linux effortlessly. However, the 20 commands mentioned here are not the only commands for mastering Linux basics. There are many other commands which can strengthen your Linux expertise considerably.

On a concluding note, you can clearly note that basic commands improve the capabilities for troubleshooting. In addition, the basic commands can also help in identifying the ideal development environment for your applications. Furthermore, knowledge of basic commands improves your capabilities for effective collaboration to ensure promising resolution of issues with your application.

So, start learning the basic commands of Linux right now for a promising career ahead. If you’re aspiring to get certified in Linux, check out our Linux certification training courses and take the right step to boost your career!

The post Top 20 Basic Linux Commands You Should Know appeared first on Whizlabs Blog.