Package Management with YUM
On RPM-based distributions like CentOS or RHEL, the yum package manager is the standard tool for software management.
Installing Software:
yum install package_name
# Example:
yum install htop
Removing Software:
yum remove package_name
# Example:
yum remove htop
Searching for Packages: Supports fuzzy matching to find relevant packages.
yum search keyword
Additional Operations:
# Clear cached package data
yum clean packages
# List all installed packages
yum list
# Display detailed information about a package
yum info package_name
System Resource Monitoring
Monitoring hardware resources is crucial for maintaining server health.
Memory Usage: Use the -h flag for human-readable output or -m for megabytes.
free -m
Disk Space: View file system disk space usage.
df -h
System Load: Check load averages and uptime. A load average consistently above 0.7 may indicate performance issues.
w
# or
top
CPU Information: Detailed processor specifications can be found in the proc filesystem.
cat /proc/cpuinfo
File Operations and Text Editing
Key directories include /home for user files, /etc for system configurations, and /tmp for temporary data.
Vim Editor Basics: Vim is a powerful modal text editor.
- Navigation:
ggjumps to the first line;Gjumps to the last line. - Editing:
dddeletes the current line;uundoes the last action. - Clipboard:
yycopies (yanks) a line;ppastes it. - Search: In command mode, type
/keywordand press Enter. - Line Numbers: In command mode, type
:set numberto display line counts.
Content Search and Analysis:
# Search for 'error' in a file and show line numbers
grep -n 'error' server.log
# Count total lines in a file
cat server.log | wc -l
# Count occurrences of a specific pattern
grep -c '200 OK' server.log
File Searching: The find command locates files based on criteria.
# Find all C source files in the current directory
find . -name "*.c"
File Compression: The tar command is used for archiving.
# Create a gzip compressed archive
tar -czvf archive.tar.gz /path/to/directory
# List contents of an archive
tar -tzvf archive.tar.gz
# Extract an archive
tar -xzvf archive.tar.gz
User Management
Managing user accounts is a fundamental administrative task.
# Add a new user
useradd devuser
# Set or change the user's password
passwd devuser
# Remove a user and their home directory
userdel -r devuser
Firewall Configuration
The firewalld service manages network security.
Service Management:
# Check service status
ps -ef | grep firewalld
# Start, stop, or restart the service
systemctl start firewalld
systemctl stop firewalld
systemctl restart firewalld
Firewall-cmd Operations:
# Check runtime state
firewall-cmd --state
# List all open ports
firewall-cmd --list-ports
# Open a port permanently (requires reload)
firewall-cmd --add-port=8080/tcp --permanent
firewall-cmd --reload
# Allow a service
firewall-cmd --add-service=http
Privilege Escalation and File Transfer
Sudo Configuration: To grant a user administrative privileges, edit the sudoers file using visudo and add the user to the privilege specification section.
# Run as root
su -
visudo
# Add line:
devuser ALL=(ALL) ALL
File Download:
# Using wget
cd /tmp
wget http://example.com/file.zip
# Using curl
curl -O http://example.com/file.zip
Secure Copy (SCP):
# Upload local file to remote server
scp local_file.txt user@192.168.1.50:/tmp/
# Download remote file to local machine
scp user@192.168.1.50:/tmp/remote_file.txt ./
Terminal File Transfer (ZModem): Requires the lrzsz package.
# Install utility
yum install lrzsz
# Upload file (opens file dialog in secure CRT/Xshell)
rz
# Download file
sz file_name