Knowledgebase

Basic Linux commands every server owner needs

This guide collects the basic Linux commands every server owner needs to manage a VPS or dedicated server over SSH: moving around folders, working with files, checking services and reading logs. All examples work on AlmaLinux and most other distributions. First connect to your server (see How to connect to your VPS or server via SSH).

Golden rule: read a command before you press Enter, especially when you are logged in as root. Linux does not ask "are you sure?" and has no recycle bin.

1. Moving around

CommandWhat it does
pwdShows the folder you are in
ls -lahLists files with sizes, owners, permissions and hidden files
cd /home/user/public_htmlGoes into a folder
cd .. / cd ~Goes up one level / goes to your home folder

2. Working with files

cp file.txt file.bak            # copy
cp -a site/ site-copy/          # copy a folder, keep owners and permissions
mv old.txt new.txt              # rename or move
mkdir -p backups/2026           # create folders
nano wp-config.php              # edit a file (Ctrl+O save, Ctrl+X exit)
cat file.txt                    # print a small file
less big.log                    # page through a big file (q to quit)

Deleting: rm file removes a file and rm -r folder removes a folder with everything inside. Double-check the path first; a wrong space or path can delete the wrong data permanently.

3. Searching

find /home/user -name "*.php" -mtime -2     # PHP files changed in the last 2 days
grep -rn "DB_NAME" /home/user/public_html   # search text inside files
tail -f /var/log/messages                   # follow a log live (Ctrl+C to stop)

4. Permissions and owners

chown -R user:user /home/user/public_html/newfolder
find /home/user/public_html -type d -exec chmod 755 {} \;
find /home/user/public_html -type f -exec chmod 644 {} \;

Folders should be 755 and files 644 on most sites. Never use 777: it lets anyone write to the files and is a common cause of hacks. Files you create as root inside a cPanel account must be given back to the account user with chown.

5. Services

systemctl status httpd          # is the web server running?
systemctl restart httpd         # restart a service
systemctl list-units --failed   # show services that failed
journalctl -u sshd --since "1 hour ago"

On a cPanel server you can also restart services with /scripts/restartsrv_httpd, /scripts/restartsrv_exim and similar scripts, or from WHM. If the server uses LiteSpeed, the web server service is lsws.

6. System information

cat /etc/os-release   # operating system version
hostname              # server name
uptime                # uptime and load
df -h                 # disk space
free -h               # memory
ip a                  # IP addresses

For deeper checks, see How to check server resource usage.

7. Archives and downloads

tar -czf site.tar.gz public_html/   # compress a folder
tar -xzf site.tar.gz                # extract
unzip file.zip
wget https://example.com/file.zip   # download a file

Useful habits

  • Press Tab to auto-complete file and folder names; it prevents typos.
  • Use the up arrow to repeat earlier commands, and history to see them.
  • Add --help or use man command to learn a command's options.
  • Copy a file to .bak before editing it.

Frequently asked questions

What is sudo?

It runs one command with root rights when you are logged in as a normal user, for example sudo systemctl restart httpd.

I ran a command by mistake. What now?

Stop and do not run more commands to "fix" it. Open a support ticket with the exact command you ran so we can help you recover, for example from a backup.

Need help? Open a support ticket or message us on WhatsApp +20 127 113 3655.

  • linux commands, basic commands, ssh, server management, almalinux, command line

Was this answer helpful?

0 Users Found This Useful