AKGuidebooks Home Server Admin

Linux commands

Permissions: chmod, chown, sudo#

Every file has an owner, a group, and permissions for owner / group / everyone else.

Reading ls -l#

-rw-r----- 1 root ai  2147023008 Nov  3 10:12 model.gguf
│└┬┘└┬┘└┬┘   │    │
│ │  │  │    │    └── group
│ │  │  │    └─────── owner
│ │  │  └──────────── everyone else: nothing
│ │  └─────────────── group (ai): read
│ └────────────────── owner (root): read + write
└──────────────────── - = file, d = folder, l = link
Letter On a file On a folder
r read it list what's inside
w change it add / delete files inside
x run it as a program go into it (cd)

chmod with numbers#

Add up: r = 4, w = 2, x = 1. Three digits = owner, group, others.

Number Letters Typical use
600 rw------- Private file: SSH keys, passwords, authorized_keys, backups
644 rw-r--r-- Normal file anyone may read
640 rw-r----- Owner writes, group reads, others nothing
440 r--r----- Read-only for owner and group (the AI model files)
700 rwx------ Private folder: ~/.ssh, ~/secure-backups
750 rwxr-x--- Folder the group may enter (/srv/ai)
755 rwxr-xr-x Normal folder or program
chmod 600 ~/.ssh/authorized_keys
chmod 700 ~/.ssh
sudo chmod 0440 /srv/ai/models/model.gguf
chmod +x ~/bin/ask-pages          # make a script runnable
chmod -R u=rwX,g=rX,o= FOLDER     # whole folder: owner rw, group r, others none

(X capital = "x only on folders and things that are already programs".)

chown: change owner#

sudo chown alex:alex /srv/files            # owner alex, group alex
sudo chown root:ai /srv/ai/models/*.gguf   # owner root, group ai
sudo chown -R alex:alex FOLDER             # whole folder

sudo: do it as administrator#

Command Does
sudo COMMAND Run one command as root (asks your password)
sudo -v Just check you're allowed (and refresh the password timer)
sudo -u ai COMMAND Run as another account, e.g. to test what ai can do
sudo -i A full root shell. Avoid it; exit to leave

SSH is picky about permissions

If ~/.ssh or authorized_keys can be written by others, SSH ignores your key and says Permission denied (publickey). Fix with chmod 700 ~/.ssh and chmod 600 ~/.ssh/authorized_keys.

Who am I, what can I do#

Command Shows
whoami Your username
id Your user, group and all groups (look for sudo)
id ai Same for another account
stat FILE Owner, permissions as numbers, dates
namei -l /srv/ai/models/model.gguf Permissions of every folder on the way, handy when "Permission denied" makes no sense
Made by Anish · 2026