Deep Dive into Linux Server Guides

2025-02-05

Linux servers are the backbone of modern IT infrastructure, powering everything from web applications to cloud services. Mastering Linux server administration is essential for DevOps engineers, system administrators, and IT professionals. This guide provides practical, verified commands and techniques to help you manage Linux servers effectively.

Essential Linux Server Commands

1. System Information

To check system information, use the following command:

uname -a

This displays the kernel version, hostname, and other system details.

2. Disk Usage

Monitor disk usage with:

df -h

The `-h` flag makes the output human-readable.

3. Memory Usage

Check memory usage using:

free -m

This shows memory usage in megabytes.

4. Process Management

List running processes:

top

To kill a process, use:

kill <PID>

Replace `` with the process ID.

5. Network Configuration

View network interfaces:

ip addr show

To restart the network service:

systemctl restart networking

6. User Management

Add a new user:

sudo adduser <username>

Grant sudo privileges:

sudo usermod -aG sudo <username>

7. File Permissions

Change file permissions:

chmod 755 <filename>

Modify ownership:

chown <user>:<group> <filename>

8. Package Management

Update package lists:

sudo apt update

Install a package:

sudo apt install <package-name>

9. Firewall Configuration

Allow a port through the firewall:

sudo ufw allow <port>

Enable the firewall:

sudo ufw enable

10. Log Monitoring

View system logs:

sudo journalctl -xe

Tail log files in real-time:

tail -f /var/log/syslog

What Undercode Say

Linux server administration is a critical skill for IT professionals, and mastering it requires hands-on practice with commands and tools. Here are some additional tips and commands to enhance your Linux server management skills:

  • Automate Tasks with Cron Jobs

Edit the crontab file:

crontab -e

Add a cron job to schedule tasks:

* * * * * /path/to/script.sh
  • Secure SSH Access

Disable root login:

sudo nano /etc/ssh/sshd_config

Change `PermitRootLogin` to `no`. Restart the SSH service:

sudo systemctl restart sshd
  • Backup and Restore

Create a backup using `tar`:

tar -czvf backup.tar.gz /path/to/directory

Restore from a backup:

tar -xzvf backup.tar.gz -C /path/to/restore
  • Monitor System Performance

Use `htop` for an interactive process viewer:

sudo apt install htop
htop
  • Network Troubleshooting

Test connectivity with `ping`:

ping google.com

Trace the route to a destination:

traceroute google.com
  • File System Checks

Check and repair the file system:

sudo fsck /dev/sdX

Replace `/dev/sdX` with the appropriate device.

  • Kernel Updates

List installed kernels:

dpkg --list | grep linux-image

Remove old kernels:

sudo apt remove linux-image-<version>
  • Service Management

Start a service:

sudo systemctl start <service-name>

Enable a service to start on boot:

sudo systemctl enable <service-name>
  • Disk Partitioning

List disk partitions:

sudo fdisk -l

Create a new partition:

sudo fdisk /dev/sdX
  • Environment Variables

Set an environment variable:

export VAR_NAME="value"

Make it persistent by adding it to `.bashrc`:

echo 'export VAR_NAME="value"' >> ~/.bashrc

For further reading, check out these resources:

By practicing these commands and techniques, you’ll become proficient in managing Linux servers, ensuring optimal performance and security for your IT infrastructure.

References:

Hackers Feeds, Undercode AIFeatured Image

Scroll to Top