Learn to Code
All tracks
Learn to Code

Free lessons from scratch to pro — every language, databases and DevOps.

AboutContactPrivacy PolicyTerms of Use

Your progress is saved in this browser. © 2026 Learn to Code

>_
Terminal & Command Line
0/10 completed
Beginner
What is the terminal?Navigating foldersWorking with files and foldersViewing files
Intermediate
Wildcards and finding filesPipes and redirectionText processing: grep, sort, cut and friends
Advanced
Environment variables and PATHPermissions and processes
Pro
Shell productivity: aliases, scripts and dotfiles
Tracks / Terminal & Command Line / Advanced

Permissions and processes

Linux is a multi-user system: many users and programs share one machine. Permissions control who can read, change or run each file, and processes are the programs currently running. Both matter the moment you work on a server.

Reading permissions

Linux terminal (simulator) · editable
-rw-r--r--  1 you  staff  65 Nov 19 09:00 notes.txt
│└┬┘└┬┘└┬┘     │    │
│ │  │  │      │    └── group
│ │  │  │      └─────── owner
│ │  │  └── others (everyone else): r--  read only
│ │  └───── group:                  r--  read only
│ └──────── owner (user):           rw-  read + write
└────────── type: - file, d directory, l link
Letter On a file On a directory
r read View its contents List what's inside
w write Change it Create or delete files inside
x execute Run it as a program Enter it with cd

Changing permissions: chmod

Symbolic mode

Linux terminal (simulator) · editable

The script couldn't run until it was made executable (+x). This is the most common chmod you'll ever type.

Example Meaning
chmod +x file Everyone may execute
chmod u+x file Only the owner (user) may execute
chmod g-w file Remove write permission from the group
chmod o-r file Others may not read

Numeric (octal) mode

Each permission has a value: r = 4, w = 2, x = 1. Add them up for each of user, group and others:

Number Permissions Typical use
755 rwx r-x r-x Scripts, programs, directories
644 rw- r-- r-- Normal files
600 rw- --- --- Private files: SSH keys, secrets
700 rwx --- --- Private directories
Linux terminal (simulator) · editable

⚠️ Never chmod 777 (everyone can do everything) to "fix" a permission error. It's a security hole. Find out who needs access and grant just that. SSH refuses to use private keys that aren't 600.

Users, root and sudo

  • Each file has an owner and a group (change them with chown user:group file).
  • root is the all-powerful administrator account.
  • sudo command runs a single command as root, after asking for your password. It's needed for installing software (sudo apt install …) and editing system files.

Use sudo sparingly, and never just because "it didn't work". Understand why first.

Processes

Every running program is a process, with a unique PID (process ID).

Linux terminal (simulator) · editable
Command Shows
ps Your processes in this terminal
ps aux All processes on the system, with their user, CPU and memory
top / htop A live, updating view (press q to quit)
pgrep node PIDs of processes matching a name

Stopping processes

Linux terminal (simulator) · editable
  • Ctrl + C stops the program running in the foreground of your terminal.
  • kill PID politely asks a process to stop (the SIGTERM signal).
  • kill -9 PID forces it to die immediately (SIGKILL). This is a last resort: the process can't clean up.
  • pkill node kills processes by name.
  • You can only kill your own processes unless you use sudo.

Background jobs (real terminals)

bash
python server.py &      # & runs it in the background
jobs                    # list background jobs
fg %1                   # bring job 1 back to the foreground
# Ctrl + Z suspends the foreground job; `bg` resumes it in the background

For servers that must keep running after you log out, use a process manager: systemd services, pm2 for Node, Docker containers, or tmux/screen sessions.

"Port already in use"

A classic developer problem: you start a server and get EADDRINUSE: port 3000. Something is already running on that port:

bash
lsof -i :3000           # which process is using port 3000?
kill <PID>              # stop it

Practice

  1. Make projects/scripts/hello.sh executable and run it with two names as arguments.
  2. Create ~/.ssh-key-demo and give it permissions so only you can read and write it. Check with ls -l.
  3. Find the PID of the python worker.py process and stop it. Confirm it's gone.
Linux terminal (simulator) · editable
✎ Check your understanding

1.What permissions does chmod 644 notes.txt give?

2.A script fails with "Permission denied" when you run ./deploy.sh. What's the usual fix?

← Environment variables and PATH