RMS Meta

RMS Meta

Code to cloud for people & nature

Blog · Dec 25, 2025

File Structure & User Management (With Paths Refresher)

This guide revisits Linux file structure, path basics, and core user management commands (including usermod) so you can navigate and administer systems with confidence.

Linux file structure (quick tour)

  • /: Root of the file system tree.
  • /home: User home directories (e.g., /home/alice).
  • /bin, /usr/bin: User binaries; /sbin, /usr/sbin for system binaries.
  • /etc: System configuration.
  • /var: Variable data (logs, spool, caches); /var/log for logs.
  • /tmp: Temporary files (often cleared on reboot).
  • /dev: Device nodes; /proc and /sys are virtual FS for kernel/process info.
  • /opt: Optional software; /srv for service data; /mnt//media for mounts.

Paths: absolute vs relative

  • Absolute path: Starts at / and points to a single location, e.g., /etc/ssh/sshd_config. Works from anywhere.
  • Relative path: Based on current directory, e.g., ../logs/app.log. Shorter for quick navigation.
  • Helpers: . (current dir), .. (parent), ~ (home).

Navigation essentials

pwd                     # show current directory
ls -la                  # list files (long, all)
cd /path/to/dir         # absolute
cd ../sibling           # relative

User management revision

  • Check a user: id alice · list users: getent passwd · list groups: getent group
  • Create group: sudo groupadd developers
  • Create user (low-level): sudo useradd -m -s /bin/bash -G developers alice then sudo passwd alice
  • Create user (interactive helper): sudo adduser bob then sudo usermod -aG developers bob

usermod and related commands

  • Add secondary groups: sudo usermod -aG docker alice
  • Change primary group: sudo usermod -g developers alice
  • Change shell: sudo chsh -s /bin/bash alice
  • Lock/unlock account: sudo usermod -L alice · sudo usermod -U alice
  • Change password: sudo passwd alice
  • Delete user: sudo userdel alice · with home removal: sudo userdel -r alice

Permissions refresher (tie-in with groups)

  • Ownership: user:group. Change with sudo chown user:group file.
  • Permissions: read/write/execute for owner, group, others. Change with chmod (e.g., chmod 640 file).
  • Use groups to grant shared access; avoid over-permissive “others.”

Good practices

  • Use absolute paths in scripts; relative paths for quick CLI work.
  • Keep one account per person/service; lock or remove unused accounts.
  • Set sane shells; use /usr/sbin/nologin for service accounts that shouldn’t log in.
  • Rely on groups for access control; keep .dockerignore/.gitignore clean to avoid leaking files into builds.

With a clear view of the file tree, path handling, and user/group commands (especially usermod), you can navigate, automate, and administer Linux systems confidently.