Linux SSH commands are typed instructions you send to a remote server after logging in with SSH (Secure Shell), an encrypted connection to the server's command line. You connect with ssh username@server_ip, then use commands like ls, cd, chmod, and systemctl to manage files, permissions, and services.
ssh username@server_ip.rm -rf and sudo with care, and keep backups before you change anything important.SSH stands for Secure Shell. It is an encrypted way to log into and control a remote server from your own computer's terminal. Instead of clicking buttons in a control panel, you type commands and the server runs them and sends the results back. Because the connection is encrypted, no one on the network in between can read your password or the commands you send.
If you have moved past shared hosting to your own machine, this is how you will do most of your work. A quick primer on that kind of server lives in our guide to what VPS hosting is. A terminal is simply the text window on your computer where you type these commands. On Linux and macOS it is built in; on Windows you can use the built-in Windows Terminal or a small free program called PuTTY.
You only need four steps to reach the command line of your server. Have your username and server IP address (a set of numbers like 203.0.113.10) ready before you start; your host shows both in your account dashboard.
ssh username@server_ip and press Enter. For example: ssh root@203.0.113.10. Replace username with your login name and server_ip with your server's address.yes to continue.$ or #). Every command you type from here runs on the server. Type exit when you want to log out.SSH keys vs passwords. A password is something you type each time, and a weak one can be guessed by automated attacks. An SSH key is a pair of long, matched files: a public key you place on the server and a private key that stays on your computer. When they match, you are let in without typing a password. Keys are far harder to guess and are the recommended method. You generate a key pair with ssh-keygen and copy the public half to the server with ssh-copy-id username@server_ip.
These are the commands you will use most. They let you move around the server, look at files, and create, copy, move, or remove them. Think of the server as a set of folders (called directories) you walk through by name.
| Command | What it does | Example |
|---|---|---|
pwd | Prints the working directory: shows where you are right now. | pwd |
ls | Lists the files and folders in the current directory. | ls |
ls -la | Lists everything, including hidden files, with permissions, owner, size, and date. | ls -la /var/www |
cd | Changes directory: moves you into another folder. | cd /var/www/html |
mkdir | Makes a new, empty directory. | mkdir backups |
rm | Removes (deletes) a file. There is no recycle bin. | rm old.log |
rm -r | Removes a directory and everything inside it. Use with care. | rm -r old-site/ |
cp | Copies a file or folder to a new location. | cp config.php config.php.bak |
mv | Moves or renames a file or folder. | mv draft.html index.html |
touch | Creates a new empty file, or updates a file's timestamp. | touch index.html |
cat | Prints a file's whole contents to the screen. | cat notes.txt |
less | Opens a long file one screen at a time. Press q to quit. | less access.log |
tail -f | Shows the end of a file and keeps following new lines as they arrive. Great for live logs. | tail -f error.log |
nano | Opens a simple, friendly text editor. Save with Ctrl+O, exit with Ctrl+X. | nano config.php |
Every file on a Linux server has permissions (who may read, write, or run it) and an owner. Getting these right is often the fix for "permission denied" errors on a website.
| Command | What it does | Example |
|---|---|---|
chmod | Changes a file's permissions using a three-digit code. 644 is typical for files (owner can edit, others can read); 755 is typical for folders and scripts (owner can edit, others can read and enter). | chmod 644 index.php |
chown | Changes who owns a file or folder. Add -R to apply it to everything inside. | chown -R www-data:www-data /var/www/html |
sudo | Runs a single command with administrator rights. You put it in front of a command that needs elevated access. | sudo systemctl restart nginx |
When you cannot remember where a file is, or you need to find a line inside many files, these two commands do the work for you.
| Command | What it does | Example |
|---|---|---|
find | Searches for files and folders by name, type, size, or age, starting from a folder you name. | find /var/www -name "*.php" |
grep | Searches inside files for a word or phrase. Add -r to search a whole folder. | grep -r "database_name" /var/www |
These commands tell you how healthy the server is: what is running, how busy it is, and whether it is running low on memory or disk space. They are the first place to look when a site feels slow.
| Command | What it does | Example |
|---|---|---|
top | Shows live running programs and how much processor and memory each one uses. Press q to quit. | top |
htop | A friendlier, colourful version of top. You may need to install it first. | htop |
ps aux | Lists every process running right now, with its owner and ID. | ps aux | grep nginx |
kill | Stops a stuck process by its ID number (shown by ps or top). | kill 4821 |
df -h | Shows how much disk space is used and free, in easy-to-read sizes. | df -h |
free -m | Shows how much memory (RAM) is used and free, in megabytes. | free -m |
uptime | Shows how long the server has been running and how busy it has been. | uptime |
whoami | Prints the username you are currently logged in as. | whoami |
On Debian and Ubuntu servers, apt is the tool that installs and updates software from trusted sources. Run these with sudo because they change the whole system. (On other systems such as CentOS or AlmaLinux the equivalent tool is dnf or yum.)
| Command | What it does | Example |
|---|---|---|
apt update | Refreshes the list of available software and versions. It does not change anything yet. | sudo apt update |
apt upgrade | Installs the newer versions found by apt update. | sudo apt upgrade |
apt install | Installs a named program and anything it needs to run. | sudo apt install htop |
When something cannot be reached, these commands help you tell whether the problem is the network, a domain name, or a program that is not listening. Domain names are covered in more depth on our VPS hosting guide.
| Command | What it does | Example |
|---|---|---|
ping | Checks whether another machine answers, and how fast. Press Ctrl+C to stop. | ping google.com |
curl | Fetches a web address from the command line, useful for testing a site or an API. | curl -I https://example.com |
wget | Downloads a file from a web address and saves it to disk. | wget https://example.com/file.zip |
ss | Shows which network ports are open and which programs are listening. | ss -tulpn |
netstat | An older tool that does much the same as ss; still common on many servers. | netstat -tulpn |
dig | Looks up a domain's DNS records so you can confirm where a name points. | dig example.com |
nslookup | A simpler DNS lookup tool for checking the IP behind a domain. | nslookup example.com |
These commands bundle files together, shrink them, and move them between your computer and the server. They are the backbone of backups and deployments.
| Command | What it does | Example |
|---|---|---|
tar | Bundles many files into one archive (a .tar file). Add z to also compress it. | tar -czf site.tar.gz /var/www/html |
gzip | Compresses a single file to save space. | gzip access.log |
unzip | Extracts the contents of a .zip file. | unzip theme.zip |
scp | Securely copies a file between your computer and the server over SSH. | scp backup.tar.gz root@203.0.113.10:/root/ |
rsync | Copies and syncs folders, transferring only what changed. Ideal for repeat backups. | rsync -av /var/www/ /backup/www/ |
A service is a program that runs in the background, such as your web server or database. systemctl starts and stops them, and journalctl shows you their logs when something goes wrong.
| Command | What it does | Example |
|---|---|---|
systemctl status | Shows whether a service is running, and its recent activity. | systemctl status nginx |
systemctl start | Starts a stopped service. | sudo systemctl start nginx |
systemctl stop | Stops a running service. | sudo systemctl stop nginx |
systemctl restart | Stops and starts a service, often needed after a config change. | sudo systemctl restart nginx |
journalctl | Reads the system and service logs. Add -u to focus on one service. | journalctl -u nginx |
The command line is powerful because it does exactly what you tell it, at once, with no confirmation. A few habits keep you out of trouble.
Be extremely careful with rm -rf. This deletes a folder and everything inside it, permanently, with no recycle bin and no undo. Read the path twice before you press Enter, and never run it against / or a path you are unsure of.
Use sudo deliberately. It gives a command full control of the server. Run only commands you understand with it, and never paste a sudo command from a source you do not trust.
Keep backups. Before you edit a config file or delete anything, make a copy first, for example cp config.php config.php.bak. A snapshot from your host is even better.
Double-check before deleting or overwriting. Confirm you are in the right directory with pwd, and list the files with ls, before you remove or move them.
SSH stands for Secure Shell. It is an encrypted way to log into and control a remote server from your own computer's terminal. Because the connection is encrypted, your password and commands cannot be read by anyone else on the network. It is the standard way system administrators manage Linux servers.
Open your terminal (or an SSH client such as PuTTY on Windows), then type ssh username@server_ip and press Enter, for example ssh root@203.0.113.10. Authenticate with your password or an SSH key. You will then see the server's command prompt, where every command you type runs on the server.
A password is text you type each time, and a weak one can be guessed by automated attacks. An SSH key is a matched pair of files: a public key stored on the server and a private key kept on your computer. When they match, you are let in without typing a password. Keys are much harder to break, so they are the recommended login method.
Start with the ones you use constantly: ls, cd, and pwd to move around; cat, less, and nano to read and edit files; cp, mv, and rm to manage them; and systemctl to control services. These cover most everyday server work.
Yes, as long as you go slowly and think before you press Enter. Most commands, such as ls, pwd, and df -h, only read information and change nothing. The commands that can cause harm are the deleting and overwriting ones, so double-check the path with those and keep a backup.
The file, permission, process, and networking commands here work on almost every Linux system. The package commands (apt) are specific to Debian and Ubuntu; on CentOS, AlmaLinux, or Rocky Linux you would use dnf or yum instead. The service commands (systemctl) work on any modern system that uses systemd, which is most of them.
Type exit and press Enter, or use the shortcut Ctrl+D. This closes your session and returns you to your own computer's terminal. Your server keeps running everything you started in the background, so logging out does not stop your website.
SSH gives you a secure, encrypted line to your server's command line, and a small set of Linux commands covers nearly everything you will do there: moving through files, setting permissions, checking system health, installing software, and managing services. Learn the connect step and a dozen everyday commands, keep backups, and treat rm -rf and sudo with respect, and you can run a server with confidence. Ready to put this into practice on your own machine? Follow our step-by-step walkthrough on how to set up a VPS, or browse more guides in the Hosting Help Center.
ssh, ssh-keygen, and scp (openssh.com/manual.html).apt package management (help.ubuntu.com).ls, chmod, find, grep, and rsync (man7.org/linux/man-pages).systemctl and journalctl (freedesktop.org/wiki/Software/systemd).The editorial team behind the Bitrich777 Hosting Help Center — practical, tested guides on web hosting, WordPress, servers, DNS, SSL, email, security and migration. Every walkthrough is reproduced on a live host before it is published.
View all guides by the Hosting Team Spotted an error? Tell us