 |
|
| |
| Introduction
| |
You don’t need to become a Unix guru to run your VPS — a few dozen commands cover almost
everything you will do day to day. This page is a working reference to those commands, grouped by task
and explained in plain language. It applies to both FreeBSD 15 and
Rocky Linux 10; where the two systems use different commands for the same job (managing
users, installing software, controlling services, configuring the firewall) the difference is noted
inline.
A few conventions used throughout: a line beginning with $ is run as your ordinary user, and one
beginning with # is run as root; text in <angle brackets> is a placeholder you
replace. Filenames are case-sensitive, and most commands take single-letter -options that
can be combined (ls -la is ls -l -a). For the bigger picture see
The Unix Shell and
The Unix File System; every
command below also has a manual page (see Documentation at the foot of this page).
| |
| Files and Navigation
| |
These are the commands you will reach for constantly. pwd tells you where you are; cd
moves you around (cd ~ jumps to your home directory, cd .. goes up one level); and
ls lists what is there — add -l for details (permissions, owner, size, date),
-a to include hidden dot-files, and -F to flag directories with a trailing slash. You
create directories with mkdir (-p makes intermediate parents as needed), copy with
cp (-r for a whole directory), rename or move with mv, and delete with rm
(-r for a directory). There is no undo on rm — be sure before you press return.
| Command |
Effect |
| pwd | Print the current (working) directory |
| ls, ls -la | List files (all, including hidden, with details) |
| cd <dir>, cd .., cd ~ | Change directory (up one level; to your home) |
| cp, cp -r | Copy a file (recursively, for a directory) |
| mv | Move or rename a file or directory |
| rm, rm -r | Remove a file (recursively, for a directory — careful!) |
| mkdir, mkdir -p | Make a directory (and parents as needed) |
| rmdir | Remove an empty directory |
| |
| Viewing and Searching File Contents
| |
To read a file, less <file> pages through it one screen at a time (press q to
quit, / to search); cat <file> dumps the whole thing at once; and
tail -f <file> follows a file as it grows — the standard way to watch a
log live. To find text,
grep <pattern> <file> prints every matching line (add -r to search a whole
directory tree, -i to ignore case); to find files by name, use find.
| Command |
Effect |
| cat <file> | Print a file’s contents |
| less <file> | View a file one screen at a time (q to quit) |
| tail -f <file> | Follow a growing file (e.g. a log) in real time |
| grep <pattern> <file> | Search a file for lines matching a pattern (-r recursive, -i ignore case) |
| find <dir> -name <pattern> | Find files by name beneath a directory |
| |
| Archiving and Compression
| |
The classic way to bundle many files into one is tar: tar czf backup.tgz <dir>
creates a gzip-compressed archive of a directory, and tar xzf backup.tgz extracts it (drop the
z for an uncompressed .tar). To compress a single file in place use gzip <file>
(undo with gunzip); for cross-platform Windows-compatible archives use zip and
unzip. These work identically on FreeBSD 15 and Rocky Linux 10. (The old
compress/uncompress and their .Z files still exist but gzip has long since
replaced them.)
| Command |
Effect |
| tar czf <archive.tgz> <dir> | Create a gzip-compressed archive of a directory |
| tar xzf <archive.tgz> | Extract a compressed archive into the current directory |
| tar tzf <archive.tgz> | List an archive’s contents without extracting |
| gzip <file>, gunzip <file.gz> | Compress / decompress a single file in place |
| zip -r <archive.zip> <files>, unzip <archive.zip> | Create / extract a Windows-compatible zip archive |
| |
| Permissions and Ownership
| |
Every file has an owner, a group, and read/write/execute permissions. chmod sets the
permissions numerically — read (4) + write (2) + execute (1) for each of owner /
group / other — so 644 is the usual setting for a web page and 755 for a script or a
directory. chown changes ownership and is root only. The
file-system page explains all of
this in depth.
| Command |
Effect |
| chmod 644 <file> | Owner read/write, others read-only (typical for a web page) |
| chmod 755 <file> | Owner read/write/execute, others read/execute (script or directory) |
| chmod -R <mode> <dir> | Apply permissions recursively |
| chown <user>:<group> <file> | Change owner and group (root only) |
| id <user> | Show a user’s UID, GID, and group memberships |
| ls -Z, restorecon -Rv <dir> | Rocky Linux only: show / reset SELinux file contexts |
| |
| Users and Privileges
| |
This is the first place the two systems part ways. On FreeBSD 15 you create accounts
interactively with adduser (or scriptably with pw useradd), remove them with rmuser,
and become root with su or run a single command as root with doas. On
Rocky Linux 10 you use useradd / userdel / usermod, and privilege is
granted through sudo rather than a root login. Either way, passwd changes a password. See
the User Accounts page for the
full treatment.
| Task |
FreeBSD 15 |
Rocky Linux 10 |
| Create an account | adduser / pw useradd | useradd -m -s /bin/bash <user> |
| Remove an account | rmuser <user> | userdel -r <user> |
| Add to a group | pw groupmod <group> -m <user> | usermod -aG <group> <user> |
| Lock / unlock | pw lock / pw unlock <user> | usermod -L / -U <user> |
| Change a password | passwd [user] | passwd [user] |
| Run a command as root | su / doas <command> | sudo <command> / sudo -i |
| |
| Processes and Resource Usage
| |
When the server feels slow, these tell you why. top is a live, self-updating view of processes
and load (press q to quit); ps aux is a one-time snapshot of everything running;
uptime shows the load averages; df -h shows free disk space per file system; and
du -sh <dir> shows how much space a directory is using. To stop a misbehaving program,
kill <pid> asks it to exit and kill -9 <pid> forces it. These are the same on
both systems; Server Maintenance
goes deeper.
| Command |
Effect |
| top | Live process / resource monitor (q to quit) |
| ps aux | List all running processes |
| kill <pid>, kill -9 <pid> | Terminate a process (forcefully) |
| uptime | Load averages and how long the server has been up |
| df -h, du -sh <dir> | Disk space per file system; space used by a directory |
| vmstat 1 | Live memory / CPU statistics |
| |
| Networking
| |
You reach the server with ssh user@host for a shell and sftp user@host (or
scp <src> <dst>) to transfer files; rsync -avz copies efficiently and is ideal
for backups. For diagnostics, ping tests basic reachability and dig queries DNS. The one
difference worth remembering: on FreeBSD 15 you inspect interfaces with ifconfig,
while on Rocky Linux 10 the modern equivalents are ip addr (addresses) and
ss -tulpn (listening ports). See
Connecting with SSH for more.
| Command |
Effect |
| ssh user@host | Open a shell on a remote host |
| sftp user@host | Open an interactive file-transfer session |
| scp <src> <dst> | Copy a file over SSH |
| rsync -avz <src> <dst> | Efficiently sync files (transfers only the changes) |
| ifconfig (FreeBSD) | Show network interfaces and addresses |
| ip addr, ss -tulpn (Rocky) | Show addresses; show listening ports and their programs |
| dig <domain>, ping <host> | Query DNS records; test basic connectivity |
| |
| Packages and Services
| |
Installing software and controlling background services is the other big FreeBSD / Rocky difference.
On FreeBSD 15 you install with pkg, control services with service, and enable
them at boot with sysrc. On Rocky Linux 10 the package manager is dnf and
services are managed by systemd through systemctl, with logs read via journalctl. The
Installing Software page covers
package management in full.
| Task |
FreeBSD 15 |
Rocky Linux 10 |
| Install / remove software | pkg install / delete <name> | dnf install / remove <name> |
| Search / show info | pkg search / info <name> | dnf search / info <name> |
| Apply updates | pkg upgrade; pkg audit -F | dnf upgrade; dnf updateinfo list --security |
| Start / stop a service | service <name> start|stop|restart|status | systemctl start|stop|restart|status <name> |
| Enable at boot | sysrc <name>_enable=YES | systemctl enable --now <name> |
| Read a service’s logs | tail -f /var/log/<name>.log | journalctl -u <name> |
| Test Apache config | apachectl configtest | apachectl configtest |
| |
| Firewall and SELinux
| |
Both systems ship a firewall, configured differently. On FreeBSD 15 the packet filter is
pf, edited in /etc/pf.conf and controlled with pfctl (pfctl -sr lists the
active rules). On Rocky Linux 10 the firewall is firewalld, driven by
firewall-cmd, and the system additionally enforces SELinux — mandatory access control
that can deny an action even when ordinary permissions allow it. The commands below are the ones you will
use most; Securing Your VPS
explains both in depth.
| Command |
Effect |
| pfctl -sr (FreeBSD) | Show the active pf firewall ruleset |
| firewall-cmd --list-all (Rocky) | Show what the firewall currently allows |
| firewall-cmd --permanent --add-service=https (Rocky) | Open a service (then --reload to apply) |
| getenforce (Rocky) | Show the SELinux mode (Enforcing / Permissive / Disabled) |
| setsebool -P <boolean> on (Rocky) | Turn an SELinux boolean on permanently |
| ausearch -m avc -ts recent (Rocky) | Show recent SELinux denials when something is unexpectedly blocked |
| |
| Mail
| |
A few commands come up when running the mail
server. After editing the aliases file, newaliases rebuilds its database;
mailq shows messages waiting in the queue; and tail -f /var/log/maillog watches mail
activity as it happens. These are the same on both systems — only the path to the aliases file
differs (/etc/mail/aliases on FreeBSD, /etc/aliases on Rocky Linux).
| Command |
Effect |
| newaliases | Rebuild the mail aliases database after editing the aliases file |
| make -C /etc/mail | Rebuild Sendmail’s tables and configuration |
| mailq | List messages stuck in the mail queue |
| tail -f /var/log/maillog | Watch mail activity in real time |
| |
| Documentation
| |
To learn more about any command, read its manual page: man <command> on the VPS is always
the authoritative copy for the exact version you have installed, and the same pages are published online
at www.gsp.com/support/man/. Most commands
also accept --help for a quick summary of their options.
|
Toll Free 1-866-GSP-4400 • 1-301-464-9363 • service@gsp.com
Copyright © 1994-2026 GSP Services, Inc.
|