You manage an AlmaLinux or Rocky Linux server by typing commands over SSH. You do not need many: the ones on this page cover almost all daily work. Each table is one kind of task, and the links lead to the guides that explain a topic in full. The examples use AlmaLinux 10 and Rocky Linux 9.
How to connect: How to Connect to a Linux Server via SSH.
Four Keys That Save the Most Time
| Key | What it does |
| Tab | Completes the name of a command, file or folder you started to type. Press it twice to see all matches. |
| Arrow up | Brings back the previous command, so that you can run it again or correct it. |
| Ctrl+C | Stops the command that is running. |
| Ctrl+R | Searches the commands you typed before: press it and type a part of the command. |
Files and Folders
| Command | What it does |
pwd | Shows the folder you are in. |
ls -la | Lists the files of the folder with size, owner and date, hidden files too. |
cd /var/www | Goes to a folder. cd .. goes one level up, cd alone goes to your home folder. |
mkdir -p data/photos | Creates a folder, with the folders above it if they are missing. |
cp notes.txt copy.txt | Copies a file. For a folder: cp -r photos photos-copy. |
mv old.txt new.txt | Renames a file or folder, or moves it to another folder. |
rm notes.txt | Deletes a file. For a folder with everything in it: rm -r photos. There is no recycle bin. |
ln -s /data/photos photos | Creates a link named photos that leads to the folder /data/photos. |
tar czf photos.tar.gz photos | Packs a folder into one file. Unpack it with tar xzf photos.tar.gz. |
More: File Permissions on Linux: Who May Read, Change and Run a File.
Read and Search
| Command | What it does |
cat notes.txt | Prints a short file. |
less /var/log/messages | Opens a long file to read: arrows and Page Down move, /word searches, q closes. |
tail -n 20 /var/log/messages | Shows the last 20 lines. tail -f keeps showing new lines until you press Ctrl+C. |
nano notes.txt | Opens a file in a simple editor: Ctrl+O and Enter save, Ctrl+X closes. If the command is missing, install it with dnf install nano. |
grep -ri "error" /var/log | Finds a word in all files of a folder; -i ignores capital letters. |
find /etc -name "sshd_config" | Finds a file by its name: Find Files on Your Linux Server by Name, Size, Date or Content. |
Disk, Memory and Programs
| Command | What it does |
df -h | Shows how full each disk is. |
du -sh /var/log | Shows how much space one folder takes. |
lsblk | Lists the disks and their partitions. |
free -h | Shows the memory: total, used and available. |
top | Shows the running programs with their processor and memory use. q closes it. The more comfortable htop comes from EPEL: Install and Update Software on AlmaLinux and Rocky Linux: dnf and EPEL. |
ps aux | grep nginx | Shows whether a program runs, and its number (PID) in the second column. |
kill 1234 | Asks the program with this number to stop. kill -9 1234 stops it by force. |
uptime | Shows how long the server has been running and how busy it is. |
Services and Logs
| Command | What it does |
systemctl status sshd | Shows whether a service runs, with its last messages. |
systemctl restart nginx | Restarts a service. start and stop work the same way. |
systemctl enable --now nginx | Starts a service now and after every restart of the server. Most services are not started by the installation; you do it with this command. |
journalctl -u sshd -n 50 | Shows the last 50 log lines of a service. |
reboot | Restarts the server. |
More: A Service Does Not Start: Find Out Why. When a service runs but is blocked: SELinux on AlmaLinux and Rocky Linux: When Something Is Blocked.
Software
| Command | What it does |
dnf check-update | Lists the updates that are available. |
dnf upgrade | Installs all available updates. |
dnf install nano | Installs a program. dnf remove nano removes it. |
More: Install and Update Software on AlmaLinux and Rocky Linux: dnf and EPEL, Automatic Updates on AlmaLinux and Rocky Linux.
Network
| Command | What it does |
ip -br a | Shows the network cards and the addresses of the server. |
ping -c 3 1.1.1.1 | Tests whether the server reaches the Internet. |
ss -tlnp | Lists the programs that wait for connections, with their ports. |
curl -I https://example.org | Asks a website for its answer, without the page itself. |
curl -O https://example.org/file.zip | Downloads a file from a link into the current folder. |
More: Protect Your AlmaLinux or Rocky Linux Server With firewalld and Fail2ban.
Users and Rights
| Command | What it does |
whoami | Shows the user you are logged in as. |
sudo dnf upgrade | Runs one command as administrator when you are not root. |
passwd | Changes your password. |
w -f | Shows who is logged in right now and from where: Who Logged In to Your AlmaLinux or Rocky Linux Server? Check Logins and Failed Attempts. |
chmod 600 notes.txt | Sets who may read and change a file; 600 means only the owner. |
chown alex:alex notes.txt | Gives a file to another user and group. |
Help
ls --help prints a short list of the options of a command.
man ls opens the full manual of a command; q closes it.
history lists the commands you typed.
exit ends the SSH session.
Good to Know
- Names are case sensitive.
Notes.txt and notes.txt are two different files.
- Put names with spaces between quotes:
cd "My Folder".
- Some service names differ from Ubuntu and Debian: the SSH service is
sshd, cron is crond.
- New here? Start with AlmaLinux and Rocky Linux Server: Quick Start Guide.