Don't Fear the Command Line: 15 Basic Linux Server Commands.
25 Aug 2025, 16:30:41
The fear of a "black screen with letters" is the main barrier for a new user of a Linux-based OS. However, an experienced user knows that the command line is the main advantage of Linux, which gives it the notorious flexibility, speed and huge automation capabilities. Most dedicated and virtual servers use systems on the Linux kernel for a reason. In this article, we will consider 15 of the most popular commands that will be useful for a new owner of a server on Debian, Ubuntu, AlmaLinux, CentOS or any other Linux distribution. All commands are executed on a virtual server, which can be connected to via a terminal using the SSH utility (MacOS, Linux) or an SSH client (Putty, Hyper, MobaXterm).1. cd - go to directory
By connecting to the server via SSH, you get to your user's home directory. However, this is rarely the same directory where the site's files are located. To go to a specific directory, use the cd command:cd /path/to/dir
In the example, this is the domain directory:
Useful examples:
- cd - - return to the previous directory;
- cd .. - go to the parent directory, the directory above;
- cd ~ - go to the user's home directory.
2. ls - view directory contents
The command displays the contents of the specified directory. If the directory is not specified, the contents of the current directory:ls -lahS
Popular flags:- -l - long list (rights, owner, group, size, creation time and the file/directory itself);
- -a - show hidden files (start with a dot .);
- -h - human-friendly display of file size;
- -S - sort by size (large files on top);
- -t - sort by time (new files on top).

3. pwd - where am I?
Sometimes scripts need to specify the full path to a directory. A simple command to display the full path of the current directory:pwd

4. mkdir - create directory
The command creates a new directory. In the example, this is the newPath directory in the modules directory, which we also create automatically:mkdir -p modules/newPath
Popular flags:- -p - create nested directories if they do not exist.

5. rm - delete
The command deletes files and directories. In the example, we delete the newPath directory that we created earlier:rm -rf modules/newPath
Popular flags:- -i - request confirmation for deletion (interactive);
- -r - recursive delete, directory delete;
- -f - forced deletion (no questions asked).

6. cp - copy files and directories
Basic command for copying files and directories, including recursively. In the example, we copy the wp-content directory to wp-content_backup while preserving all rights:cp -ar wp-content/ wp-content_backup/

Or we can copy only one index.php file to the wp-content_backup directory:
cp -av index.php wp-content_backup/

Popular flags:
- -a - preserve file attributes;
- -r - copy recursively (directory);
- -i - ask for confirmation when overwriting a file;
- -v - detailed output of information about the copying progress.
7. mv - move or rename
The command moves files and directories and changes their name. Let's rename the index.php file to index_old.php:mv -iv index.php index_old.php

We can also move the new file to the wp-content_backup directory:
mv -iv index_old.php wp-content_backup/

Popular flags:
- -i - ask for confirmation when rewriting;
- -v - detailed output of information about the progress of execution.
8. grep - find the required lines
We have previously used the grep utility to search for and highlight a specific word from the ls command output. However, the utility has many more capabilities and is very often used to recursively search for a specific string across multiple files and directories. As an example, let's find a file that contains the Nginx configuration for the domain.com domain:grep -ri "domain.com" /etc/nginx
The search was successful, we received the file and the entry string:
As we have seen before, grep works well not only with files, but also with command output. For example, let's filter the output of the ps command, showing only the Nginx and MariaDB processes, and also enable highlighting of matches:
ps aux | grep --color=auto -E "(nginx|mariadb)"

Popular flags:
- -i - ignore case when searching;
- -n - display line numbers;
- -r - recursive directory search;
- -v - inverse search (output of lines that do not match the search expression);
- -E - use extended regular expressions;
- --color=auto - turns on highlighting of matches.
9. tail - an indispensable tool for viewing log files
The utility is used to display the last lines of a file, as well as to view file changes in real time. Useful when working with log files:tail -5 dpkg.log
Outputs the last 5 lines of the specified file. In the dpkg.log example:
Popular flags:
- -n - output the specified number of lines at the end of the file. Analog -[NUM].
- -f - "monitor" the contents of a file in real time.
10. head - the reverse analogue of tail
The most current data is written to the end of the log file. However, sometimes we need to know when the log file began. The head utility outputs a specified number of lines from the beginning of the file. In the example, we output the first line of the dpkg.log log file:head -1 dpkg.log

- -n - output the specified number of lines from the beginning of the file. Analog -[NUM].
11. find - advanced file search
The find utility is used to search for files by mask, name, type, size, date. It is a powerful tool for automating many server management processes and deserves a separate article, but we will consider only the most popular parameters.For example, let's find all files with the .jpg extension in the current and child directories:
find . -type f -name "*.jpg"
Since the output will be huge, for convenience we will simply count the found files using the utility wc -l:
The team found 170 jpg files in the site directory. That's not bad, but the whole point of the find utility is in its various filters. We'll add a new condition to our search - the files must be larger than 300 kilobytes:
find . -type f -name "*.jpg" -size +300k
We get only 6 files and can view the output in full:
But that's not all. The most important function of find is the ability to execute a specified command on each file or directory found. For example, we will execute the ls -lh command on each file found, but in real tasks it can be anything, even your own scripts:
find . -type f -name "*.jpg" -size +300k -exec ls -lh {} \;

Popular flags:
- -type f - type of object to search for (f - file, d - directory);
- -name "*.jpg" - name, file name mask;
- -size +300k - search for files larger(+) or smaller(-) than the specified size(k, M, G);
- -print - output of search results;
- -delete - deleting found files;
- -exec [CMD] {} \; - run command [CMD] for each file found;
12. chmod - access rights management
Utility for managing access rights to files and directories. Most webmasters are accustomed to the digital designation of rights, where a three-digit number is used:- Owner (u)
- Group (g)
- Other (o)
- Read (r) = 4
- Write (w) = 2
- Execut (x) = 1
- 6 = 4 (r) + 2 (w). The owner has read and write (edit) rights to the file;
- 4 = 4 (r). Users in the file's group can only read the file;
- 4 = 4 (r). All others can only read the file.
chmod 644 index.php

Linux users are accustomed to a more convenient designation of rights and roles - letter (letter designations of rights are indicated in brackets). In it, setting rights 644 for a file looks like this:
chmod u+rw,g+r,o+r index.php
We literally added (+) to the user (u) read (r) and write (w) rights, to the group (g) read (r) rights, and to others (o) also read (r):
To remove (-) or set specific rights (=) you need to use the same logic. Remove the read right (r) for all others (o):
chmod o-r index.php

To set new specific rights for the user (u) to execute (x), read (r) and write (w):
chmod u=rwx index.php

Useful flags:
- -R - recursive application of rights for a directory and its contents.
13. chown - change user and group of file
When gaining root access to a new server, some users upload site files under the root user. However, running site scripts as the root user is dangerous for the entire server. Using a simple chown command, you can change the user and group for the entire site directory recursively:chown -R user01:user01 /path/to/dir
- -R - recursive execution of an operation.

14. df - free disk space
The df utility displays information about mounted partitions on the server and the space used on them.df -Th
- -T - output file system type;
- -h - human-friendly display of units of measurement.

15. du - find out the size of directories and files
Unlike df, which takes information from the file system, du takes measurements of the files being processed directly.Using du, we can find out the size of a specific directory:
du -sh /var/www

Or each directory and file in it separately:
du -sh /var/www/*

Popular flags:
- -h - human-friendly display of units of measurement;
- -s - only the total for each argument.

However, the latter should be used with caution if the server uses large amounts of disk space, since the utility automatically goes through all nested directories recursively.
We have reviewed 15 of the most popular commands for a server with an operating system based on the Linux kernel. This list can be fully called the minimum base that is necessary for a confident start in learning Linux administration. Master them at the level of muscle memory and you will never need a control panel on the server to work with your sites. If you have any difficulties with executing these commands on our VPS and dedicated servers, you can contact our technical support at any time through the ticket system or online chat on the site.