As a Linux administrator, managing systems effectively involves a variety of tasks, from automating jobs with Cron to securing applications. This guide walks you through 24 essential tasks with practical use cases and instructions.
1. Create a Cron Job
Cron automates repetitive tasks. Example: Schedule a backup every day at midnight.
Steps:
- Edit crontab:
crontab -e
- Add the job:
0 0 * * * /path/to/backup.sh
- Verify:
crontab -l
2. Linux Banner
Display a custom message on login using /etc/motd.
Steps:
- Edit
/etc/motd
:
echo "Welcome to Linux Server" | sudo tee /etc/motd
3. Linux Collaborative Directories
Set up a shared directory with proper permissions.
Steps:
- Create directory:
mkdir /shared
- Set group ownership and permissions:
chgrp developers /shared
chmod 2775 /shared
4. Linux String Substitute (sed)
Modify files using sed. Example: Replace "error" with "warning".
Command:
sed -i 's/error/warning/g' logfile.txt
5. Linux SSH Authentication
Set up key-based authentication for secure remote access.
Steps:
- Generate keys:
ssh-keygen
- Copy the public key to the server:
ssh-copy-id user@server
6. Linux Find Command
Locate files quickly. Example: Find .log
files larger than 10MB.
Command:
find /path -type f -name "*.log" -size +10M
7. Install a Package
Install htop as an example.
Command:
sudo apt install htop
8. Install Ansible
Automate IT tasks with Ansible.
Steps:
- Install Ansible:
sudo apt install ansible
- Verify:
ansible --version
9. Configure Local Yum Repos
Set up a local YUM repository.
Steps:
- Create a repo file:
sudo vi /etc/yum.repos.d/local.repo
- Add content:
[local-repo]
name=Local Repository
baseurl=file:///mnt/repo
enabled=1
gpgcheck=0
10. Linux Services
Manage services. Example: Start and enable Apache.
Commands:
sudo systemctl start httpd
sudo systemctl enable httpd
11. Linux Configure sudo
Grant sudo privileges.
Steps:
- Edit sudoers file:
sudo visudo
- Add user:
username ALL=(ALL) NOPASSWD:ALL
12. DNS Troubleshooting
Diagnose DNS issues.
Commands:
nslookup domain.com
dig domain.com
13. Linux Firewalld Setup
Set up and manage firewalld.
Commands:
sudo firewall-cmd --add-port=80/tcp --permanent
sudo firewall-cmd --reload
14. Linux Postfix Mail Server
Set up Postfix for email delivery.
Steps:
- Install:
sudo apt install postfix
- Configure via
/etc/postfix/main.cf
.
15. Linux Postfix Troubleshooting
Check logs:
sudo tail -f /var/log/mail.log
16. Install and Configure HAProxy LBR
Load balance traffic with HAProxy.
Steps:
- Install HAProxy:
sudo apt install haproxy
- Configure
/etc/haproxy/haproxy.cfg
.
17. HAProxy LBR Troubleshooting
Check status:
sudo systemctl status haproxy
Debug logs:
sudo journalctl -u haproxy
18. MariaDB Troubleshooting
Check MariaDB logs:
sudo tail -f /var/log/mysql/error.log
19. Linux Bash Scripts
Automate tasks. Example: Disk usage report.
#!/bin/bash
df -h > disk_report.txt
20. Add Response Headers in Apache
Enhance security by adding headers.
Steps:
- Edit
.htaccess
or/etc/httpd/conf/httpd.conf
:
Header set X-Frame-Options "DENY"
- Restart Apache:
sudo systemctl restart httpd
21. Apache Troubleshooting
Check configuration:
sudo apachectl configtest
View logs:
sudo tail -f /var/log/httpd/error_log
22. Linux GPG Encryption
Encrypt files with GPG.
Commands:
gpg --encrypt --recipient email@example.com file.txt
gpg --decrypt file.txt.gpg
23. Linux Log Rotate
Automate log rotation.
Steps:
- Configure
/etc/logrotate.conf
. - Test:
logrotate -d /etc/logrotate.conf
24. Application Security
Implement security measures like SELinux, AppArmor, or Fail2Ban.
Commands:
sudo apt install fail2ban
sudo systemctl enable fail2ban
Happy Learning !!!
Top comments (0)