Lesson 27 of 60 beginner

Linux Filesystem, Users & Permissions

Enough Linux to be useful on day one

Open interactive version (quiz + challenge)

Real-world analogy

Linux is like a well-organized warehouse. Every aisle (directory) has a purpose, every item (file) has an owner and rules about who can touch it. The loading dock (sudo) is supervised, and the logbook (permissions) never lies.

What is it?

Linux administration basics cover filesystem navigation, user/group management, permissions, package management, and the sudo/audit model. This is the starter pack that makes you useful on mixed-stack teams.

Real-world relevance

A developer says ‘my app can’t write logs.’ You check /var/log/myapp and find the directory owned by root:root, 755. The app runs as user ‘myapp.’ You chown to myapp:adm, chmod 750. App writes. Problem solved — without root passwords or dangerous shortcuts.

Key points

Code example

// Linux day-one essentials

who                   # who's logged in
id                    # your UID/GID and groups
groups                # your groups
pwd                   # where am I?
ls -la                # long list with hidden + perms
cd /etc

# Inspect a user and their groups
cat /etc/passwd | grep alice
id alice

# Add a user and group safely
sudo adduser dave                       # debian/ubuntu
sudo useradd -m -s /bin/bash dave       # portable
sudo usermod -aG sudo dave              # grant sudo

# Change permissions and ownership
chmod 640 /etc/myapp.conf
chown myapp:adm /var/log/myapp

# Edit sudoers safely
sudo visudo

Line-by-line walkthrough

  1. 1. Linux essentials script
  2. 2. who is logged in
  3. 3. user identity and groups
  4. 4. group membership
  5. 5. current directory
  6. 6. long listing with hidden files
  7. 7. change to /etc
  8. 8. Blank separator
  9. 9. Inspect a specific user
  10. 10. passwd grep
  11. 11. id command
  12. 12. Blank separator
  13. 13. Create user and group
  14. 14. adduser on Debian/Ubuntu
  15. 15. Portable useradd with home and shell
  16. 16. Grant sudo membership
  17. 17. Blank separator
  18. 18. Change permissions and ownership
  19. 19. chmod config
  20. 20. chown on log dir
  21. 21. Blank separator
  22. 22. Safe sudoers edit with visudo

Spot the bug

App fails to write to /var/log/myapp.
Junior runs: chmod -R 777 /var/log and proudly says ‘fixed’.
Need a hint?
Why is chmod 777 on /var/log a security disaster?
Show answer
That grants every user full read/write/execute on all log files — destroying integrity, enabling tampering, and likely violating multiple policies. Correct fix: chown the specific app directory to the app’s user/group (chown -R myapp:adm /var/log/myapp) and set 750 or 770 as appropriate. Never use recursive 777 as a troubleshooting shortcut.

Explain like I'm 5

Linux is a warehouse. Everyone has a badge (user), belongs to teams (groups), and every box (file) has a tag saying who can open, move, or destroy it. Root is the manager. Sudo is the rare time you borrow the manager’s badge — and everyone writes down when you did.

Fun fact

The concept of sudo came from Berkeley in the 1980s. It’s so deeply embedded in Unix culture that ‘sudo’ has become a verb — and a whole genre of internet jokes about root power.

Hands-on challenge

On Ubuntu in a VM: create a user ‘alice,’ add her to group ‘ops,’ create /srv/ops owned by root:ops with mode 2770 (setgid + rwx for owner+group). Test that new files in /srv/ops inherit group ops.

More resources

Open interactive version (quiz + challenge) ← Back to course: IT Jobs Bootcamp