Master Linux Fundamentals: Directory Structure, Permissions, Users, and Essential Commands
This comprehensive guide explains Linux's core directory hierarchy, file attributes and permission bits, user and group management commands, disk utilities such as df, du, fdisk, and essential file operations like copying, moving, archiving, and compression, providing practical examples for system administrators and developers.
Linux System Basics
Linux Directory Structure
The Linux root directory contains many standard sub‑directories, each serving a specific purpose:
/bin : Frequently used executable commands.
/boot : Kernel images and boot loader files.
/dev : Device files representing hardware and virtual devices.
/etc : System configuration files and sub‑directories.
/home : Home directories for regular users.
/lib : Essential shared libraries (similar to Windows DLLs).
/lost+found : Recovered files after an improper shutdown.
/media : Auto‑mounted removable media such as USB drives.
/mnt : Temporary mount points for manual mounting.
/opt : Optional third‑party software packages.
/proc : Virtual filesystem exposing kernel and process information.
/root : Home directory of the super‑user.
/sbin : System administration binaries for the super‑user.
/selinux : Security‑Enhanced Linux configuration files.
/srv : Data for services provided by the system.
/sys : Sysfs virtual filesystem representing kernel objects.
/tmp : Temporary files.
/usr : Secondary hierarchy for user applications and data.
/usr/bin : General user commands.
/usr/sbin : Advanced system administration commands.
/usr/src : Kernel source tree.
/var : Variable data such as logs and caches.
Linux File Basic Attributes
Linux is a multi‑user system; each file has an owner, a group, and permission bits that control read (r), write (w), and execute (x) access for the owner, the group, and others. The first character indicates the file type: "d" for directories, "-" for regular files, "l" for symbolic links, "b" for block devices, and "c" for character devices.
# Example of ls -l output
[root@host /]# ls -l
total 64
dr-xr-xr-x 2 root root 4096 Dec 14 2012 bin
... (additional entries omitted for brevity)Permission bits are displayed as a ten‑character string (e.g., "-rwxr-xr--"). The three groups of three characters represent owner, group, and others respectively. Numeric notation converts the bits to a three‑digit octal number (e.g., 754 = rwx r-x r--).
Changing File Ownership and Permissions
Common commands: chgrp: Change the group ownership of a file or directory. chown: Change the owner (and optionally the group) of a file or directory. chmod: Modify the nine permission bits using symbolic (u,g,o) or numeric (e.g., 777) notation.
# Change group to "users"
chgrp users install.log
# Change owner to "bin"
chown bin install.log
# Set permissions to 777
chmod 777 .bashrc
# Set permissions to 754 using symbolic mode
chmod u=rwx,g=rx,o=r .bashrcUser and Group Management
Linux manages users and groups through files such as /etc/passwd, /etc/shadow, and /etc/group. Key commands include: useradd: Add a new user account. userdel: Delete an existing user (option -r also removes the home directory). usermod: Modify user attributes (e.g., login shell, home directory, primary group). passwd: Set or change a user's password. groupadd, groupdel, groupmod: Manage groups. newusers: Bulk import of users from a formatted file. chpasswd: Set passwords for many users from a simple "user:password" list.
Disk Management Utilities
Key tools for monitoring and managing storage: df: Show overall filesystem usage (options -h, -a, -T, etc.). du: Estimate file and directory space usage (options -h, -s, -a, etc.). fdisk: Partition table manipulation (option -l lists partitions). mkfs: Create a filesystem on a partition (e.g., mkfs -t ext3 /dev/sda1). fsck: Check and repair filesystem consistency (use on unmounted filesystems). mount / umount: Mount and unmount filesystems. resize2fs: Resize an ext2/3/4 filesystem after expanding a partition.
Common File Operations
Basic commands for handling files and directories: ls, cd, pwd, mkdir, rmdir, rm, mv, cp – standard navigation and manipulation. cat, tac, nl, more, less, head, tail – view file contents with various options. scp: Securely copy files between hosts over SSH. tar: Archive and compress files (e.g., tar -czvf archive.tar.gz dir/). zip / unzip: Create and extract ZIP archives. chattr: Change extended file attributes (e.g., immutable flag).
Shell Scripting Basics
A simple Bash script starts with a shebang ( #!/bin/bash) and can use variables, conditionals ( if … then … elif … else … fi), loops ( for, while), and functions. Parameters are accessed as $1, $2, …, with special variables like $# (argument count) and $@ (all arguments).
#!/bin/bash
# Example: greet a user
if [ "$#" -eq 0 ]; then
echo "Usage: $0 name"
exit 1
fi
name=$1
echo "Hello, $name!"Additional Utilities
Other useful commands covered include chattr (file attribute manipulation), zipinfo (inspect ZIP contents), and various options for chmod, chown, and chgrp to fine‑tune permissions.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
