Disk Partition Analysis
To identify which partition a specific directory resides on, utilize the df command with the -h flag for human-readable output. For example, to determine the partition containing the /var directory:
[root@server ~]# df -h /var Filesystem Size Used Avail Use% Mounted on /dev/mapper/vg_system-lv_root 50G 3.1G 44G 7% /
The 'Mounted on' column indicates the partition location.
For a comprehensive view of all disk partitions, employ the fdisk command with the -l option:
[root@server ~]# fdisk -l
System Management Operations
Several commands are essential for system administration:
- sync: Writes all buffered data to disk
- ps -ef: Displays running processes
- netstat -tuln: Shows active network services
- shutdown: Powers down the system
- reboot: Restarts the system (use -h now for immediate restart)
- poweroff: Halts system and powers off
- init: Changes system runlevel
Text File Editing
The nano editor provides a simple interface for file manipulation:
- To save modifications: Press Ctrl+O
- To exit: Press Ctrl+X
File Permission Management
Modify file access permissions using chmod:
chmod 777 filename chmod a+w filename
Additionally, change file ownership with:
- chgrp: Modifies group ownership
- chown: Changes user ownership
File Operations
Copy files with the cp command:
cp source_file destination_file
User Account Management
Create and manage user accounts with these commands:
useradd newuser passwd newuser
Notes: New user accounts automatically create home directories in /home. Additional usermod options are available via usermod --help. Remove users with:
userdel newuser rm -rf /home/newuser
Environment Variables
Display system or user environment variables:
echo $PATH
File Viewing Utilities
Various commands allow direct file content viewing:
- cat: Displays file content from beginning to end
- tac: Shows file content in reverse order
- nl: Numbers lines while displaying content
Storage Analysis
Monitor disk and directory usage with:
- df: Shows disk space utilization
- du: Displays directory space consumption
File Link Types
Understand the difference between link types:
- Hard links: Function as additional names for the same inode. Deleting one doesn't affect others as they share identical inode numbers.
- Soft links (symbolic links): Act as shortcuts to original files. If the target file is deleted, the soft link becomes a dangling link and unusable.
Important: Removing a soft link doesn't impact the original file, but deleting the original file creates a dangling link. If the original file is recreated with the same path, the dangling link can be restored.