If you’re delving into Linux, understanding its directory structure and key commands is critical for system configuration and management. This blog covers some of the most important aspects, focusing on high-utility directories, user management, permissions, and resource monitoring—all optimized with relevant keywords for Linux enthusiasts.
Understanding the /etc Directory
The /etc directory contains system-wide configuration files essential for managing Linux systems. It houses settings for services, applications, and networking.
Key files in /etc include:
/etc/passwd: User account information./etc/shadow: Encrypted passwords./etc/hosts: Maps hostnames to IP addresses./etc/resolv.conf: DNS configuration./etc/fstab: Filesystem mount points./etc/ssh/sshd_config: SSH server settings.
What Is the /bin Directory?
The /bin directory contains essential binary executables used by all users. These programs are critical for basic system functionality, including:
/bin/ls: List files in a directory./bin/cp: Copy files./bin/mv: Move or rename files./bin/rm: Remove files./bin/cat: View file contents./bin/bash: Default shell.
Difference Between /bin and /sbin:
/bin: Commands accessible to all users (e.g.,ls,cp)./sbin: Commands intended for system administrators (e.g.,fdisk,reboot).
User and Permission Management
How to Create a User and Manage Permissions
Create a New User
Using adduser (recommended):
sudo adduser usernameThis creates a user with a home directory and prompts for a password.
Using useradd (manual setup):
sudo useradd -m -s /bin/bash username
sudo passwd username-m: Creates a home directory.-s /bin/bash: Sets the default shell.
Add a User to a Group Groups simplify permission management for multiple users.
sudo usermod -aG groupname usernameExample: Grant sudo privileges:
sudo usermod -aG sudo usernameVerify group membership:
groups usernameFile and Directory Permissions
Linux permissions include:
Read (r): View file contents.
Write (w): Modify files.
Execute (x): Run scripts or executables.
View permissions:
ls -l filenameExample output:
-rwxr--r-- 1 user group 1234 Jan 1 12:00 file.txtrwx: Owner permissions.r--: Group permissions.r--: Others’ permissions.
Change permissions:
chmod 755 file.txt7: Owner (rwx).5: Group (r-x).5: Others (r-x).
Change ownership:
sudo chown username:groupname file.txtRecursive ownership change for directories:
sudo chown -R username:groupname /path/to/directoryProcess Management in Linux
A process is any running instance of a program. Efficient process management ensures optimal system performance.
Viewing Processes
Check running processes:
ps auxReal-time monitoring:
top htop # Enhanced UI
**Controlling Processes**
- Kill a process by PID:
```bash
kill PIDForce kill:
kill -9 PIDPause a process:
kill -STOP PIDResume a paused process:
kill -CONT PID
Adjusting Process Priorities
Start a process with lower priority:
nice -n 10 commandChange priority of a running process:
renice -n priority -p PID
Disk and Memory Management
Check Disk Space Usage
Use df to check disk space:
df -hOutput example:
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 100G 40G 60G 40% /Check directory sizes with du:
du -sh /path/to/directoryFind largest files:
du -ah / | sort -rh | head -10Check Memory Usage
Use the free command:
free -hReal-time monitoring:
top
htopConclusion
Mastering Linux commands and directory structures is essential for managing systems effectively. This guide covers everything from user management to resource monitoring, ensuring you’re equipped to handle Linux environments confidently.













Leave a Reply