Racks of weapons line the walls. Suits of armour stand at attention. But every sword and potion is locked behind a permission barrier β you must learn chmod before you can equip a single item.
ls -l output and interpret permission bitschmod to make scripts executable./potion to restore health./sword to equip your weaponls -F, cat, and file navigation| Command | What It Does |
|---|---|
ls -l |
Long listing β shows permissions, owner, size |
chmod +x file |
Add execute permission for everyone |
chmod 755 file |
rwxr-xr-x β owner can all; others can read+execute |
chmod 644 file |
rw-r--r-- β owner can read+write; others read only |
./script |
Execute a script in the current directory |
-rwxr-xr-x
βββββββββββββ
β u g o
β user group others
βββ file type: - = regular, d = dir, l = link
Each group: r = read (4), w = write (2), x = execute (1)
Octal shorthand: 755 = rwx r-x r-x, 644 = rw- r-- r--
ls -l
# -rw-r--r-- 1 user group 512 Jan 01 potion
# -rw-r--r-- 1 user group 1024 Jan 01 sword
# -rwxr-xr-x 1 user group 256 Jan 01 guardian*
potion and sword lack the x bit β they are not yet executable. You cannot run them.
./potion
# bash: ./potion: Permission denied
This is the expected result. Now fix it.
chmod +x potion
chmod +x sword
ls -l potion sword
# -rwxr-xr-x 1 user group 512 Jan 01 potion*
# -rwxr-xr-x 1 user group 1024 Jan 01 sword*
./potion
# HP restored: 50 β 100
./sword
# Sword of Echoes added to inventory.
./guardian
# A stone golem steps forward...
# You raise your sword...
# [combat sequence]
With the sword equipped, you should win. Health permitting, the guardian falls and the door to the Chamber opens.
| Octal | Symbolic | Who Can Do What |
|---|---|---|
777 |
rwxrwxrwx |
Everyone can read, write, execute β οΈ |
755 |
rwxr-xr-x |
Owner: all; others: read + execute β |
644 |
rw-r--r-- |
Owner: read + write; others: read only β |
600 |
rw------- |
Owner only β private files π |
400 |
r-------- |
Read-only, even for owner |
Security note: Never use
chmod 777on scripts or sensitive files. Use755for scripts and644for data.
| Problem | Cause | Fix |
|---|---|---|
Permission denied after chmod |
Not the file owner | Use ls -l to check owner |
| Script does nothing | Missing shebang line | Add #!/usr/bin/env bash as line 1 |
No such file: ./sword |
Wrong directory | pwd and ls first |
| Health still low after potion | Bug in game version | Run ./setup.sh --repair |
rwxr-xr-- without looking it up./ is needed to run a script./potion and ./sword successfullyContinue your terminal adventure with these resources:
Sword in hand, potion consumed. The Chamber awaits. βοΈ