Linux powers a significant portion of the world’s web servers, cloud infrastructure, and enterprise systems. Whether you’re managing a VPS, dedicated server, or cloud instance, understanding Linux server basic commands is essential for maintaining, troubleshooting, and securing your environment.
While Linux may appear intimidating to beginners, most daily server management tasks can be accomplished with a relatively small set of commands. Learning these commands can help you navigate directories, manage files, monitor system resources, administer users, and maintain server performance.
This guide covers the most important Linux server basic commands that every administrator, developer, and hosting customer should know.
Why Learn Linux Server Commands?
Most Linux servers operate primarily through a command-line interface (CLI). Unlike desktop operating systems that rely heavily on graphical interfaces, Linux servers are designed for efficiency and remote administration.
Learning Linux commands allows you to:
- Manage servers remotely
- Troubleshoot issues quickly
- Monitor server performance
- Manage files and directories
- Control users and permissions
- Improve security
- Automate administrative tasks
Checking Your Current Directory
One of the first commands every Linux user should learn is pwd, which stands for “print working directory.”
pwd
This command displays your current location within the file system.
Listing Files and Directories
The ls command displays files and folders within the current directory.
ls
To view detailed information:
ls -la
This displays file permissions, ownership, sizes, and hidden files.
Changing Directories
The cd command allows you to move between directories.
cd /var/www/html
Useful variations include:
cd ~
cd ..
cd /
cd ~returns to your home directory.cd ..moves up one directory level.cd /takes you to the root directory.
Creating Directories
Create new folders using the mkdir command.
mkdir backups
Create nested directories:
mkdir -p projects/website/files
Creating Files
You can quickly create empty files using the touch command.
touch test.txt
This command is commonly used when creating configuration files or testing file permissions.
Viewing File Contents
The cat command displays file contents.
cat filename.txt
For larger files, use:
less filename.txt
The less command allows you to scroll through files one page at a time.
Copying Files and Directories
The cp command copies files.
cp file.txt backup.txt
To copy directories:
cp -r website/ backup/
The -r option copies directories recursively.
Moving and Renaming Files
The mv command moves or renames files.
mv oldname.txt newname.txt
Move a file to another directory:
mv file.txt /home/user/documents/
Deleting Files and Directories
Delete files using:
rm file.txt
Delete directories and their contents:
rm -rf foldername
Warning: Use this command carefully as deleted files cannot be easily recovered.
Viewing Running Processes
The ps command displays active processes.
ps aux
For real-time monitoring:
top
Many administrators also prefer:
htop
which provides a more user-friendly interface.
Checking Server Resource Usage
Monitor memory usage with:
free -h
Check disk usage:
df -h
View directory sizes:
du -sh *
These commands are useful when troubleshooting performance issues.
Managing Services
Most modern Linux distributions use systemd for service management.
Check service status:
systemctl status nginx
Start a service:
systemctl start nginx
Stop a service:
systemctl stop nginx
Restart a service:
systemctl restart nginx
Enable automatic startup:
systemctl enable nginx
Managing Software Packages
Ubuntu and Debian servers use APT.
Update package lists:
sudo apt update
Upgrade installed packages:
sudo apt upgrade
Install software:
sudo apt install nginx
CentOS, AlmaLinux, and Rocky Linux often use DNF:
sudo dnf update
User Management Commands
Create a new user:
sudo adduser username
Delete a user:
sudo userdel username
Change a password:
passwd username
User management is an important part of Linux server security.
Managing File Permissions
Linux uses permissions to control access to files and directories.
Change ownership:
chown user:user file.txt
Change permissions:
chmod 644 file.txt
Common permission settings include:
- 644 for files
- 755 for directories
- 600 for sensitive files
Network Troubleshooting Commands
Check network connectivity:
ping google.com
View IP addresses:
ip addr
Check open ports:
ss -tulpn
Display DNS information:
nslookup example.com
These commands help diagnose network and connectivity problems.
Viewing Log Files
Logs provide valuable information when troubleshooting issues.
View system logs:
journalctl -xe
View Nginx logs:
tail -f /var/log/nginx/error.log
Monitor logs in real time:
tail -f logfile.log
Updating and Securing Your Server
Keeping software updated is one of the simplest ways to improve security.
sudo apt update && sudo apt upgrade -y
Additional security best practices include:
- Using strong passwords
- Implementing SSH key authentication
- Configuring a firewall
- Installing security updates regularly
- Monitoring logs for suspicious activity
- Using a Web Application Firewall (WAF)
You may also find these resources helpful:
- Linux Hosting vs Windows Hosting
- When to Upgrade to VPS Hosting
- VPS Performance Optimization That Works
- Guide to Website Uptime Monitoring
Conclusion
Learning Linux server basic commands is one of the most valuable skills for anyone managing a website, VPS, dedicated server, or cloud environment. While Linux offers thousands of commands, mastering the fundamentals covered in this guide will allow you to perform most daily administration tasks confidently.
As your experience grows, you’ll discover more advanced tools and automation techniques, but these basic Linux commands provide the foundation for effective server management, troubleshooting, performance optimization, and security.