Basic Linux Commands for Server Management
Introduction
Linux command-line tools are essential for server administration and daily operations. Understanding basic commands helps in managing files, monitoring system usage, and troubleshooting issues efficiently.
Prerequisites
Before using these commands, ensure:
- Access to a Linux server via SSH
- Basic familiarity with terminal usage
- Required permissions for executing commands
Common Linux Commands
1. Disk Usage
du -sch *
- Displays total disk usage of files and directories in the current location
df -h
- Shows overall disk space usage of all mounted filesystems
2. File & Directory Management
ls -la
- Lists all files (including hidden) with details
cd /path/to/directory
- Change directory
pwd
- Show current directory path
mkdir dirname
- Create a new directory
rm -rf dirname
- Remove directory or files (use with caution)
3. File Viewing & Editing
cat filename
- Display file contents
less filename
- View file page by page
nano filename
- Edit file using nano editor
vi filename
- Edit file using vi editor
4. File Permissions & Ownership
chmod 755 filename
- Change file permissions
chown user:user filename
- Change file ownership
5. Process Management
top
- View running processes in real-time
ps aux
- List all running processes
kill -9 PID
- Terminate a process
6. Network Commands
ping google.com
- Check network connectivity
ifconfig
- Display network interfaces (or use
ip a)
netstat -tulpn
- Show open ports and services
7. System Monitoring
uptime
- Show system uptime
free -m
- Display memory usage
who
- Show logged-in users
8. Archive & Compression
tar -czvf file.tar.gz folder/
- Compress files
tar -xzvf file.tar.gz
- Extract compressed files
9. Search & Find
find / -name filename
- Search for files
grep "text" filename
- Search text inside files
Notes
- Use
--helporman <command>to learn more about any command - Be cautious with commands like
rm -rfandkill -9 - Some commands require root privileges
Conclusion
Basic Linux commands are the foundation of server management. Mastering these commands will improve efficiency, troubleshooting capabilities, and overall system control.
