Get ready for your next interview with our comprehensive question library
The Linux file system follows the Filesystem Hierarchy Standard (FHS). Key directories include:
/
- Root directory, the top-level directory/bin
- Essential user binaries (commands)/boot
- Boot loader files and kernel/dev
- Device files/etc
- System configuration files/home
- User home directories/lib
- Essential shared libraries/media
- Mount points for removable media/mnt
- Temporary mount points/opt
- Optional software packages/proc
- Virtual filesystem with process information/root
- Root user's home directory/run
- Runtime data/sbin
- System administration binaries/tmp
- Temporary files/usr
- User programs and data/var
- Variable data (logs, databases, etc.)Linux uses a three-tier permission system:
rwxr-xr--
means owner has read/write/execute, group has read/execute, others have read only.# Change permissions using chmod
chmod 755 file.txt # rwxr-xr-x
chmod u+x script.sh # Add execute for owner
chmod g-w file.txt # Remove write for group
chmod o=r file.txt # Set others to read only
# Change ownership
chown user:group file.txt
chgrp newgroup file.txt
Multiple commands are available for finding files:
find command (most powerful):
# Find by name
find /path -name "filename"
find . -name "*.txt"
# Find by type
find /home -type f # Files only
find /home -type d # Directories only
# Find by size
find /var -size +100M # Files larger than 100MB
find . -size -1k # Files smaller than 1KB
# Find by permissions
find . -perm 755
find . -perm -u+x # Files executable by owner
# Find and execute action
find /tmp -name "*.tmp" -delete
find . -name "*.log" -exec rm {} \;
locate command (faster, uses database):
locate filename
updatedb # Update locate database
which/whereis commands:
which python # Find executable in PATH
whereis python # Find binary, source, manual
Several commands help manage processes:
# View processes
ps aux # All processes with details
ps -ef # Full format listing
ps -u username # Processes for specific user
pstree # Process tree view
# Real-time process monitoring
top # Interactive process viewer
htop # Enhanced version of top
atop # Advanced system monitor
# Process information
jobs # Current shell jobs
pgrep process_name # Find process IDs by name
pidof process_name # Get PID of running process
Process states:
# Kill by PID
kill PID # Send TERM signal (15)
kill -9 PID # Send KILL signal (forceful)
kill -15 PID # Send TERM signal (graceful)
# Kill by name
killall process_name # Kill all processes with name
pkill pattern # Kill processes matching pattern
# Common signals
kill -l # List all signals
kill -HUP PID # Reload configuration (1)
kill -INT PID # Interrupt (2)
kill -QUIT PID # Quit (3)
kill -KILL PID # Force kill (9)
kill -TERM PID # Terminate (15)
kill -STOP PID # Stop process (19)
kill -CONT PID # Continue process (18)
Foreground processes: Run in the terminal and accept input
Background processes: Run independently without blocking terminal
# Run command in background
command & # Start in background
nohup command & # Continue after logout
# Job control
jobs # List current jobs
fg %1 # Bring job 1 to foreground
bg %1 # Send job 1 to background
Ctrl+Z # Suspend current process
Ctrl+C # Terminate current process
# Detach from terminal
nohup long_command > output.log 2>&1 &
disown %1 # Remove job from shell
# User management
useradd username # Add new user
useradd -m -s /bin/bash username # Create with home directory
userdel username # Delete user
userdel -r username # Delete user and home directory
usermod -aG groupname username # Add user to group
passwd username # Change user password
chage -l username # View password aging info
# Group management
groupadd groupname # Create new group
groupdel groupname # Delete group
gpasswd -a username groupname # Add user to group
gpasswd -d username groupname # Remove user from group
# View user/group information
id username # Show user ID and groups
groups username # Show user's groups
getent passwd username # Get user info from database
getent group groupname # Get group info
Upgrade to Premium to see the answer
Upgrade to PremiumUpgrade to Premium to see the answer
Upgrade to PremiumUpgrade to Premium to see the answer
Upgrade to PremiumUpgrade to Premium to see the answer
Upgrade to PremiumUpgrade to Premium to see the answer
Upgrade to PremiumUpgrade to Premium to see the answer
Upgrade to PremiumUpgrade to Premium to see the answer
Upgrade to PremiumUpgrade to Premium to see the answer
Upgrade to PremiumUpgrade to Premium to see the answer
Upgrade to PremiumUpgrade to Premium to see the answer
Upgrade to PremiumUpgrade to Premium to see the answer
Upgrade to PremiumUpgrade to Premium to see the answer
Upgrade to PremiumUpgrade to Premium to see the answer
Upgrade to PremiumAccess all premium content - interview questions, and other learning resources
We regularly update our features and content, to ensure you get the most relevant and updated premium content.
1000 monthly credits
Cancel anytime