Just Enough CLI · Step 7 Free
Permissions, sudo, archives, and shortcuts
The last set of essentials: who can touch a file, how to act as the administrator, and how files travel between servers.
File modes and permissions
ls -l shows each file’s permissions as a string like -rw-r--r--:
r— readablew— writablex— executable (can run as a program)-— permission not granted
The string holds three sets: user (owner), group, other. So -rw-r--r-- means: the owner can read and write; everyone else can only read.
chmod — change permissions
chmod 644 file
The common numeric modes to memorize:
| Mode | Meaning | Used for |
|---|---|---|
644 | user: read/write; others: read | files |
600 | user: read/write; others: nothing | secrets, SSH keys |
755 | user: all; others: read/execute | directories, programs |
700 | user: all; others: nothing | private directories |
You will meet this the first time SSH refuses your key with “permissions are too open” — the fix is chmod 600 ~/.ssh/your-key.pem.
sudo — run as the superuser
sudo runs one command as root. Installing system packages, editing system configs, restarting services — all need it:
sudo apt-get install htop
sudo systemctl restart my-service
Use it deliberately. sudo rm -r on the wrong path has no undo.
Symbolic links
A symbolic link is a file that points to another file or directory — an alias, like a Windows shortcut. Quick access to long paths:
ln -s /very/long/path/to/data ~/data
Archiving: tar and gzip
gzip compresses a single file (file.gz; unpack with gunzip). It does not bundle directories — that is tar’s job:
tar cvf archive.tar file1 file2 ... # create an archive
tar xvf archive.tar # extract it
In practice you will mostly meet the combined form .tar.gz — tar czf to create, tar xzf to extract. Every dataset download and every software release uses it.
Keyboard shortcuts
Editing commands with arrow keys is slow. These work in every shell:
| Shortcut | Action |
|---|---|
| CTRL-A | jump to the beginning of the line |
| CTRL-E | jump to the end of the line |
| CTRL-W | erase the previous word |
| CTRL-U | erase to the beginning of the line |
| CTRL-K | erase to the end of the line |
| CTRL-Y | paste back what you erased |
| CTRL-P / CTRL-N | previous / next command |
For editing files in the terminal: nano is the simple choice; vim and emacs are the powerful ones. Learn nano now, vim later.
Practice in your terminal:
- Run
ls -l ~and read the permission strings on three files. - Create a file and lock it down:
touch secret.txt && chmod 600 secret.txt && ls -l secret.txt. - Pack and unpack:
tar czf test.tar.gz secret.txt, delete the original, thentar xzf test.tar.gz. - Type a long command, then practice CTRL-A, CTRL-E, and CTRL-W. Clean up with
rm secret.txt test.tar.gz.