Essential Linux Commands for Self-Hosting Beginners
You do not need to be a sysadmin to self-host. These 12 Linux commands cover 90 percent of what you will ever need to manage your server.
Self-hosting runs on Linux, and Linux runs on commands. But you do not need to know hundreds of them. Twelve commands cover the vast majority of server management tasks. If you learn these, you can handle basic server administration without calling for help.
Navigating the Filesystem
pwd — Print Working Directory
Shows you where you are. Always run this first if you are unsure of your location in the filesystem.
pwd
# Output: /opt/stacksls — List Directory Contents
Shows what is in a directory. The most commonly used options are:
ls # list files and directories
ls -l # long format: permissions, size, date, name
ls -la # long format, including hidden files (starting with .)
ls -lh # long format with human-readable file sizes (K, M, G)
ls -ltr # long format, sorted by time, newest lastThe long format shows permissions, owner, group, size, modification date, and name. This is the output you will use most often to check that files are where they should be and have the correct permissions.
cd — Change Directory
cd /opt/stacks # go to a specific directory
cd .. # go up one level
cd ~ # go to your home directory
cd - # go back to the previous directoryWorking with Files and Directories
mkdir — Make Directory
mkdir new-project # create a new directory
mkdir -p /opt/stacks/app # create parent directories as neededcp — Copy Files and Directories
cp file.txt backup.txt # copy a file
cp -r /opt/stacks/app /backups/ # copy a directory recursivelymv — Move or Rename Files
mv old-name.txt new-name.txt # rename a file
mv file.txt /opt/stacks/ # move a file to another directoryrm — Remove Files or Directories
rm file.txt # delete a file
rm -r old-project/ # delete a directory and its contents (be careful)
rm -rf old-project/ # force delete without prompts (very careful)Warning: rm is permanent. There is no trash bin on the command line. Always double-check before running rm, especially with -rf.
Viewing File Contents
cat — Concatenate and Write Files
cat docker-compose.yml # display a file's contents in the terminal
cat file1.txt file2.txt # display multiple files sequentiallyhead and tail — View the Beginning or End of a File
head -20 app.log # first 20 lines of a log file
tail -20 app.log # last 20 lines of a log file
tail -f app.log # follow a log file in real time (Ctrl+C to stop)tail -f is the most useful command for debugging. Run it while starting a Docker container to see live logs as the application initialises.
File Permissions
chmod — Change File Mode (Permissions)
chmod 600 private.key # owner can read/write, no one else
chmod 755 script.sh # owner can read/write/execute, others can read/execute
chmod -R 755 public/ # apply recursively to a directoryPermission numbers: 4 = read, 2 = write, 1 = execute. Add them: 7 = read+write+execute, 6 = read+write, 5 = read+execute.
chown — Change File Owner
chown user:group file.txt # set owner and group
chown -R 1000:1000 /opt/stacks/ # set owner by numeric ID (common for Docker)Disk and System
df — Report File System Disk Space Usage
df -h # human-readable: shows free and used space on all mounted filesystemsRun this when you need to know if a disk is filling up. Check before deploying large applications.
du — Estimate File Space Usage
du -sh /opt/stacks/ # total size of a directory
du -sh * # size of each subdirectory in the current directoryIf the command line is not your preferred interface, VPS1 manages your server for you. We handle the file permissions, the disk monitoring, and every command in this guide. You focus on your business.
More articles
How to Deploy BTCPay Server: Accept Bitcoin Payments with Zero Platform Fees
BTCPay Server lets you accept Bitcoin and Lightning payments with no platform fees. Only standard Bitcoin network fees apply. Here is how to deploy it with Docker Compose.
Self-Hosted Crypto Payment Processors: BTCPay Server, Bitcart, and SHKeeper Compared
Accept Bitcoin and cryptocurrency payments directly with no platform fees, no intermediaries, and no KYC. Here is how BTCPay Server, Bitcart, and SHKeeper compare.
How to Deploy SHKeeper: Accept Crypto Payments with WooCommerce in 30 Minutes
SHKeeper supports Bitcoin, Ethereum, USDT, USDC, and 19+ cryptocurrencies with a free WooCommerce plugin. Zero platform fees -- only standard network fees apply.