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

KeyWhat it does
TabCompletes the name of a command, file or folder you started to type. Press it twice to see all matches.
Arrow upBrings back the previous command, so that you can run it again or correct it.
Ctrl+CStops the command that is running.
Ctrl+RSearches the commands you typed before: press it and type a part of the command.

Files and Folders

CommandWhat it does
pwdShows the folder you are in.
ls -laLists the files of the folder with size, owner and date, hidden files too.
cd /var/wwwGoes to a folder. cd .. goes one level up, cd alone goes to your home folder.
mkdir -p data/photosCreates a folder, with the folders above it if they are missing.
cp notes.txt copy.txtCopies a file. For a folder: cp -r photos photos-copy.
mv old.txt new.txtRenames a file or folder, or moves it to another folder.
rm notes.txtDeletes a file. For a folder with everything in it: rm -r photos. There is no recycle bin.
ln -s /data/photos photosCreates a link named photos that leads to the folder /data/photos.
tar czf photos.tar.gz photosPacks 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

CommandWhat it does
cat notes.txtPrints a short file.
less /var/log/messagesOpens a long file to read: arrows and Page Down move, /word searches, q closes.
tail -n 20 /var/log/messagesShows the last 20 lines. tail -f keeps showing new lines until you press Ctrl+C.
nano notes.txtOpens 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/logFinds 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

CommandWhat it does
df -hShows how full each disk is.
du -sh /var/logShows how much space one folder takes.
lsblkLists the disks and their partitions.
free -hShows the memory: total, used and available.
topShows 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 nginxShows whether a program runs, and its number (PID) in the second column.
kill 1234Asks the program with this number to stop. kill -9 1234 stops it by force.
uptimeShows how long the server has been running and how busy it is.

Services and Logs

CommandWhat it does
systemctl status sshdShows whether a service runs, with its last messages.
systemctl restart nginxRestarts a service. start and stop work the same way.
systemctl enable --now nginxStarts 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 50Shows the last 50 log lines of a service.
rebootRestarts 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

CommandWhat it does
dnf check-updateLists the updates that are available.
dnf upgradeInstalls all available updates.
dnf install nanoInstalls 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

CommandWhat it does
ip -br aShows the network cards and the addresses of the server.
ping -c 3 1.1.1.1Tests whether the server reaches the Internet.
ss -tlnpLists the programs that wait for connections, with their ports.
curl -I https://example.orgAsks a website for its answer, without the page itself.
curl -O https://example.org/file.zipDownloads a file from a link into the current folder.

More: Protect Your AlmaLinux or Rocky Linux Server With firewalld and Fail2ban.

Users and Rights

CommandWhat it does
whoamiShows the user you are logged in as.
sudo dnf upgradeRuns one command as administrator when you are not root.
passwdChanges your password.
w -fShows 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.txtSets who may read and change a file; 600 means only the owner.
chown alex:alex notes.txtGives 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.
Was this answer helpful? 0 Users Found This Useful (0 Votes)