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

5 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.

5 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.

More posts

Introducing Two-Factor Authentication [Plus Additional Security Features]

We're pleased to announce that you can now enabled Two-Factor Authentication (2FA) in your Domain Monitor account. Enable it today to take advantage of additional account security.

Read more
Setting Your Time Zone [New Feature]

Time Zones, they're a pain. Recently, here in the UK the clocks have gone forward, and for many of you, you’ve probably forgotten a few clocks or watches around the house right?

Read more
Introducing Slack Notifications [Third-party Integration]

I'm pleased to announce that we've just launched our Slack Integration as a new Notification Type, and you can enable it today!

Read more

Get our FREE downloadable PDF revealing The Top 3 Benefits Of A Website Monitoring Tool!

Plus, more great content, product news and updates