10 Essential Linux Commands That Every User Should Know!
# tutorial# how to

10 Essential Linux Commands That Every User Should Know!

When you're interfacing with a Linux, CentOS or any other type of server remotely or through a screen attached to the server, it's always a good time investment to know some basic Linux commands to run through the terminal.

Whether you're new to servers or are more experienced with server commands, sometimes we simply forget commands, or just can't remember the order in which to type command line arguments.

When connecting to a Linux server remotely through what's called the shell, you're going to need to know some basic commands to perform actions such as navigation, creating directories and files and how to remove items (the equivalent of a delete via a GUI)

It's not always possible to have a screen connected to a computer, so in this post, I'm going to give you the essential commands that every user should know...

Ready? Let's dive right in...

How to run Linux commands on a server

how to run commands on a server

When you're running commands on a server, you're going to need to run them through a command-line interface.

Accessing this is going to be different based on what server you're connecting to and how you connect to them, but the most basic way of accessing a server remotely and running commands is to use a popular tool for the OS you're on:

  • OSX / Mac - you can use the built-in terminal which can be located in: Applications -> Utilities -> Terminal
  • Windows - if you're a windows user, you could either download Git Bash or use the command prompt found in: Start Menu -> Windows System -> Command Prompt

If you're on a Linux machine, chances are you already know where to find the terminal, so I won't be covering that here.

How to connect to a server remotely

If you're trying to run Linux commands on a remote server, you're going to need to connect to it first through the terminal within your OS as described above.

Typically you can access a remote server if you know the server's IP address and the username and password of the server, in your terminal, run:

ssh [username]@[server_ip]

Of course, replace username and server_ip with the relevant fields. Depending upon what server you're trying to connect to and what commands you need to run, you might need to connect as a root user for your username.

10 Essential Linux Commands

Now that I've covered how to find your terminal and connect to the server, let's now go through the essential commands that every user should know.

If I miss some commands in this list, chances are it's because I'll be coming back to this post to add more! So check back soon if the command you're trying to find isn't here yet!

1: pwd command

The pwd command can be used to find what directory you're in and the path to that particular directory. It's useful for when you're trying to navigate through directories on your server and then you forget what directory you're in.

The command will return an absolute path which is essentially a path that starts with a trailing slash.

2: ls command

Whenever you're connected to a server and are interfacing with it through a terminal, you're going to need to list out all of the directories and files within a folder on your server.

Unlike being able to see all of the directories and files on your computer such as on a Windows machine through the explorer, you don't have this when connected through shell.

There are variations of the command, so here's a few of the basics:

  • ls -al - this command will list out all of the files, directories along with information about the size, owner and permissions of the file/folder. It's the command I tend to opt for a lot of the time
  • ls -a - will show you your hidden files/folders, useful for finding
  • ls -R - would list out all of the files and sub-directories

This command is likely going to be one of the most used commands that you'll use on a Linux server.

3: cd command

Unlike a system that has a fancy GUI to navigate between directories on a computer, the cd command will allow you to move between folders on your server.

Let's say for instance you're inside a directory located at: /var/www/myfolder and then you wanted to move up one level to: /var/www then you'd need to use this command for that:

cd ..

By specifying the two dots, you're going to be moving up one level

If you wanted to move back into that specific folder, you could then run:

cd myfolder

And it would put you into that folder.

Some other uses of the cd command include:

  • cd - on it's own which would take you straight to the home folder
  • cd- - (note the hyphen) which would simply move you back to the previous folder that you were in had you actually moved a directory

As a note with this command, it is case-sensitive, so be careful to type the folder path and command in just right as per the example above.

4: mkdir command

You can use the mkdir command to make a new directory on your server in the same way that you would "right-click" and select "New Folder" on most computers.

It's an essential command to know since making directories and files within directories are likely going to be consuming another large chunk of your time when working with a Linux or CentOS server.

There's a few variations of this command, here's a few ways that you can go about using it:

  • mkdir Photos - this will create a Photos folder in whatever directory you're currently in.
  • mkdir -p Photos/2021 - this command has the optional flag that will create a 2021 folder within the Photos folder

5: touch command

If you're creating directories on your server, chances are you're going to need to create files within them.

This is where the touch command comes in handy, and it's incredibly simple to use.

All you need to do is run: touch index.html

And this would create a file called index.html in whichever directory you're currently in.

6: cat command

Ever wanted to simply find out what's inside of a file without actually running the risk of modifying the file?

That's where the cat command can come in handy, and I've used it many times.

All you need to do to use this command is to run: cat filename.txt, and of course, replace the filename part with whatever file you'd like to read.

7: history command

This command works wonders!

Have you ever wanted to find out all of the commands you've recently ran on a server?

If you're like me, then you probably log into a server and tap the up arrow multiple times until you come across the command that you're loking for.

I recently found out about the history command, and it's saved me hours of manual work trying to find a specific command that I might've ran many days ago.

To use it, simply run: history in your terminal and it'll output all of the past commands that have been ran.

8: mv command

Sometimes you need to rename a file, there could be many reasons that you want to rename a file on a Linuxx server, some of these reasons might include:

  • prefixing or appending the date/time to a file name
  • moving a file to a different directory
  • changing the filename due to a typo that's been made (it's all too easy to make typos these days)

Using the mv command is pretty simple, and this is how to use it:

run: mv filename.txt filenameNEW.txt

9: clear command

By far the simplest and most basic Linux command that you can run on a server is clear.

And it does exactly that, it clears out everything in the terminal so that you can start typing out a clean set of commands without the bloat from all of the other commands listed on screen.

10: man command

Need to get help information for a command?

Run the man command to do that.

More posts

The role of website uptime monitoring in ensuring customer satisfaction

As a business owner, ensuring customer satisfaction should be a top priority. One key aspect of customer satisfaction is having a reliable and efficient online presence, which is where website uptime monitoring comes in.

Read more
Website uptime monitoring for e-commerce stores what you need to know

As an e-commerce store owner, you understand the importance of having a reliable and efficient online presence. Let's look at why website uptime monitoring is so important for e-commerce. Read more today.

Read more
Maximizing the efficiency of your website uptime monitoring strategy

As a website owner, uptime monitoring is crucial to ensure that your website is always available and functioning properly. In this article, we'll discuss how to maximize the efficiency of your website uptime monitoring strategy, including the use of tools, setting up alerts, and optimizing your website's performance.

Read more

Subscribe to our PRO plan.

Looking to monitor your website and domains? Join our platform and start today.