Introduction
This comprehensive guide covers everything you need to know about Linux user management, file permissions, system navigation, and file operations. Whether you’re a beginner or an experienced user, this reference will help you master Linux system administration. Also a good application that you can use after you grasp the basics is Midnight Commander - https://midnight-commander.org
A highly regarded tool to make file management easier and more like working within a regular desktop environment.
Part 1: Linux Users, Groups, and Permissions
User Management
Viewing User Information
# Current user information
whoami
id
# All logged-in users
who
w
# User account information
cat /etc/passwd
getent passwd username
# User password/account status
sudo cat /etc/shadow
chage -l username
Creating and Modifying Users
# Create user with home directory and specific shell
sudo useradd -m -c "John Doe" -s /bin/bash johndoe
# Add user to supplementary groups
sudo useradd -m -g developers -G sudo,docker johndoe
# Modify user properties
sudo usermod -aG sudo johndoe # Add to sudo group
sudo usermod -s /bin/zsh johndoe # Change shell
sudo usermod -L johndoe # Lock account
Group Management
Viewing and Managing Groups
# Current user's groups
groups
id -Gn
# Group management
sudo groupadd developers
sudo usermod -aG developers johndoe
sudo gpasswd -a johndoe developers
File Permissions Basics
Understanding Permission Types
- Read (r) = 4: View file contents or list directory
- Write (w) = 2: Modify file or directory contents
- Execute (x) = 1: Run file or traverse directory
Permission Classes
- User (u): File owner
- Group (g): Group owner
- Others (o): All other users
Viewing Permissions
ls -l file.txt
# -rw-r--r-- 1 johndoe developers 1024 Dec 10 14:30 file.txt
# With numeric permissions
stat -c "%a %n" file.txt
Permission Modification
Changing Permissions with chmod
# Symbolic notation
chmod u+x file.txt # Add execute for user
chmod g-w file.txt # Remove write for group
# Numeric notation
chmod 755 file.txt # rwxr-xr-x
chmod 644 file.txt # rw-r--r--
# Recursive changes
chmod -R 755 directory/
Changing Ownership
# Change owner and group
sudo chown johndoe:developers file.txt
# Change group only
sudo chgrp developers file.txt
# Recursive ownership changes
sudo chown -R johndoe:developers directory/
Special Permissions
SetUID, SetGID, and Sticky Bit
# SetUID - executes with owner's privileges
chmod u+s file
chmod 4755 file
# SetGID - executes with group's privileges, directories inherit group
chmod g+s directory/
chmod 2755 directory/
# Sticky Bit - users can only delete their own files
chmod +t directory/
chmod 1777 directory/
Access Control Lists (ACL)
Advanced Permission Management
# Install ACL tools
sudo apt install acl # Debian/Ubuntu
# View and set ACLs
getfacl file.txt
setfacl -m u:username:permissions file.txt
setfacl -m g:groupname:permissions file.txt
# Examples
setfacl -m u:bob:rw file.txt
setfacl -m g:developers:rx directory/
# Default ACLs for directories
setfacl -m d:u:bob:rwx shared_directory/
Sudo and Privilege Escalation
Sudo Configuration
# Edit sudoers file safely
sudo visudo
# Test sudo access
sudo -l
Sudoers File Examples
# User specifications
username ALL=(ALL:ALL) ALL
%groupname ALL=(ALL:ALL) ALL
# Specific command permissions
johndoe ALL=(root) /usr/bin/apt, /usr/bin/systemctl
%developers ALL=(ALL) NOPASSWD: /usr/bin/docker
Part 2: Linux Navigation and File Location
Basic Navigation
Directory Operations
# Current directory
pwd
pwd -P # Physical location (resolve symlinks)
# Changing directories
cd /path/to/directory # Absolute path
cd ~ # Home directory
cd - # Previous directory
cd .. # Parent directory
# Directory history
pushd /path/to/directory # Save current and change
popd # Return to saved directory
dirs # Show directory stack
Linux Filesystem Hierarchy
Essential Directory Structure
/
├── bin/ # Essential user binaries
├── etc/ # System configuration files
├── home/ # User home directories
├── opt/ # Optional application software
├── tmp/ # Temporary files
├── usr/ # User utilities and applications
└── var/ # Variable data (logs, cache)
File System Navigation
Listing Files and Directories
# Basic listing with details
ls -la # Long format with hidden files
ls -lh # Human readable sizes
ls -ltr # Sorted by time (oldest first)
# Tree structure view
tree -L 2 # Limit depth to 2 levels
tree -d # Directories only
File Information Commands
# File type and information
file filename
stat filename # Detailed file statistics
# Path resolution
realpath filename
basename /path/to/file # Extract filename
dirname /path/to/file # Extract directory path
Searching for Files
Using find Command
# Basic find syntax
find [path] [options] [expression]
# By name and type
find /home -name "*.txt"
find /etc -iname "*.conf" # Case insensitive
find /var -type f # Files only
# By size and time
find /var -size +10M # Larger than 10MB
find /var/log -mtime -7 # Modified in last 7 days
# By permissions and owner
find /home -perm 644
find /var -user root
# Actions on found files
find /tmp -name "*.tmp" -delete
find . -name "*.old" -exec rm {} \;
Fast Search with locate
# Update file database
sudo updatedb
# Fast filename search
locate filename
locate -i "readme" # Case insensitive
locate -l 20 "*.jpg" # Limit to 20 results
Finding Commands
# Find executables
which ls
which -a python3 # Show all instances
# Locate binaries and manuals
whereis bash
whereis -b ls # Only binaries
# Command documentation
whatis ls
Finding File Content
grep for Text Search
# Basic text search
grep "pattern" file.txt
grep -i "pattern" file.txt # Case insensitive
grep -n "pattern" file.txt # Show line numbers
# Recursive search
grep -r "pattern" /path/
grep -r --include="*.py" "import" . # Specific file types
# Context around matches
grep -A 3 -B 2 "pattern" file.txt # 3 lines after, 2 lines before
Modern Alternatives
# ripgrep (faster)
rg "pattern"
rg -t py "import" # Python files only
# Silver Searcher
ag "pattern"
ag -G "\.js$" "function" # JavaScript files
File Compression and Archiving
tar Commands
# Create archives
tar -czvf archive.tar.gz files/ # Create gzip compressed
tar -cjvf archive.tar.bz2 files/ # Create bzip2 compressed
# Extract archives
tar -xzvf archive.tar.gz # Extract gzip
tar -xjvf archive.tar.bz2 # Extract bzip2
# List contents
tar -tzf archive.tar.gz # List gzip archive
Other Compression Tools
# Individual file compression
gzip file.txt # Creates file.txt.gz
gunzip file.txt.gz # Decompress
bzip2 file.txt # Creates file.txt.bz2
xz file.txt # Creates file.txt.xz
Disk Usage Analysis
Analyzing Space Usage
# Disk usage by directory
du -sh directory/ # Summary total
du -h --max-depth=1 /var # One level deep
# Sorting by size
du -h /var/* | sort -hr # Sort by size (largest first)
# Free space
df -h # Human readable filesystem usage
df -i # Inode usage
Interactive Analysis
# NCurses disk usage
ncdu /path
ncdu -x / # Stay on filesystem
# Find large files
find / -type f -size +100M -exec ls -lh {} \; 2>/dev/null
File Operations
Copying and Moving
# Copy with preservation
cp -p file1 file2 # Preserve attributes
cp -a dir1/ dir2/ # Archive mode (preserve all)
# Safe moves
mv -i file* dest/ # Prompt before overwrite
mv --backup=numbered file1 file2 # Numbered backups
Creating Files and Directories
# Create nested directories
mkdir -p path/to/nested/dirs # Create parent directories
# Create files with content
cat > file.txt << EOF
line 1
line 2
EOF
# Create large files
dd if=/dev/zero of=largefile.bin bs=1M count=100 # 100MB file
Text File Operations
# View files
cat file.txt
less file.txt # Interactive pager
head -20 file.txt # First 20 lines
tail -f logfile.txt # Follow (real-time)
# File comparison
diff file1.txt file2.txt
vimdiff file1.txt file2.txt # Visual diff
# Text processing
sort file.txt
sort -n file.txt # Numerical sort
uniq -c file.txt # Count occurrences
Part 3: Essential Applications and Tools
Terminal File Managers
Midnight Commander (mc)
# Installation
sudo apt install mc # Debian/Ubuntu
sudo yum install mc # RHEL/CentOS
# Features: Two-pane interface, built-in FTP, file operations
Ranger
# Installation
sudo apt install ranger
# Features: Vim-like navigation, three-pane layout, file previews
Other Terminal Managers
- Vifm: Dual-pane with Vim keybindings
- nnn: Fast and minimalistic
- Yazi: Modern, asynchronous (Rust-based)
Enhanced Search Tools
ripgrep (rg)
# Installation
sudo apt install ripgrep
# Usage: Faster than grep, better default experience
rg "pattern"
rg -t js "function" # JavaScript files only
fd-find
# Installation
sudo apt install fd-find
# Usage: Simpler alternative to find
fd "*.txt"
fd -e py # Python files
Disk Analysis Tools
ncdu
# Installation
sudo apt install ncdu
# Usage: Interactive disk usage analyzer
ncdu /path/to/scan
dust
# Installation (via cargo)
cargo install du-dust
# Usage: More intuitive disk usage
dust /var
Permission Management Tools
ACL Tools
# Installation
sudo apt install acl
# Essential commands
getfacl /path/to/file
setfacl -m u:user:perms /path/to/file
Best Practices and Security
Security Guidelines
Principle of Least Privilege
chmod 750 sensitive_directory/
chown root:root /etc/shadow
chmod 600 /etc/shadow
Regular Audits
# Find world-writable files
find / -perm -o+w ! -type l 2>/dev/null
# Find SetUID/SetGID files
find / -perm /6000 2>/dev/null
Secure Defaults
# Set secure umask
umask 027
Navigation Efficiency
# Directory shortcuts
export CDPATH=.:~:/var/www:/opt
alias proj='cd /home/user/projects/current'
alias logs='cd /var/log/apache2'
# Enhanced prompt showing path
PS1='\u@\h:\w\$ '
File Management Tips
# Safe operations
cp -i file* dest/ # Always prompt before overwrite
rm -I file* # Prompt if deleting >3 files
# Efficient archiving
tar -czf backup.tar.gz --exclude='*.tmp' /important/data/
# Regular cleanup
find /tmp -type f -atime +7 -delete
find ~/.cache -type f -mtime +30 -delete
Conclusion
Mastering Linux user management, permissions, and file navigation is essential for effective system administration. This guide provides comprehensive coverage of:
- User and group management for multi-user systems
- File permissions for security and access control
- Efficient navigation techniques and shortcuts
- Powerful search tools for locating files and content
- Essential applications that enhance productivity
Regular practice with these commands and tools will significantly improve your efficiency as a Linux system administrator.

