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:
chgrpdevelopers /sharedchmod2775 /shared
4. Linux String Substitute (sed)
Modify files usingsed. 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
Installhtop as an example.
Command:
sudoaptinstallhtop
8. Install Ansible
Automate IT tasks with Ansible.
Steps:
- Install Ansible:
sudoaptinstallansible
- Verify:
ansible--version
9. Configure Local Yum Repos
Set up a local YUM repository.
Steps:
- Create a repo file:
sudovi /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:
sudosystemctl start httpdsudosystemctlenablehttpd
11. Linux Configure sudo
Grant sudo privileges.
Steps:
- Edit sudoers file:
sudovisudo
- Add user:
username ALL=(ALL) NOPASSWD:ALL
12. DNS Troubleshooting
Diagnose DNS issues.
Commands:
nslookup domain.comdig domain.com
13. Linux Firewalld Setup
Set up and manage firewalld.
Commands:
sudofirewall-cmd--add-port=80/tcp--permanentsudofirewall-cmd--reload
14. Linux Postfix Mail Server
Set up Postfix for email delivery.
Steps:
- Install:
sudoaptinstallpostfix
- 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:
sudoaptinstallhaproxy
- Configure
/etc/haproxy/haproxy.cfg
.
17. HAProxy LBR Troubleshooting
Check status:
sudosystemctl status haproxy
Debug logs:
sudojournalctl-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/bashdf-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:
sudosystemctl restart httpd
21. Apache Troubleshooting
Check configuration:
sudoapachectl 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.txtgpg--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:
sudoaptinstallfail2bansudosystemctlenablefail2ban
Happy Learning !!!
Top comments(0)
For further actions, you may consider blocking this person and/orreporting abuse