Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Vivesh
Vivesh

Posted on

     

Linux Administration Tasks 2

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:

  1. Edit crontab:
   crontab-e
Enter fullscreen modeExit fullscreen mode
  1. Add the job:
   0 0*** /path/to/backup.sh
Enter fullscreen modeExit fullscreen mode
  1. Verify:
   crontab-l
Enter fullscreen modeExit fullscreen mode

2. Linux Banner

Display a custom message on login using/etc/motd.

Steps:

  1. Edit/etc/motd:
echo"Welcome to Linux Server" |sudo tee /etc/motd
Enter fullscreen modeExit fullscreen mode

3. Linux Collaborative Directories

Set up a shared directory with proper permissions.

Steps:

  1. Create directory:
mkdir /shared
Enter fullscreen modeExit fullscreen mode
  1. Set group ownership and permissions:
chgrpdevelopers /sharedchmod2775 /shared
Enter fullscreen modeExit fullscreen mode

4. Linux String Substitute (sed)

Modify files usingsed. Example: Replace "error" with "warning".

Command:

sed-i's/error/warning/g' logfile.txt
Enter fullscreen modeExit fullscreen mode

5. Linux SSH Authentication

Set up key-based authentication for secure remote access.

Steps:

  1. Generate keys:
   ssh-keygen
Enter fullscreen modeExit fullscreen mode
  1. Copy the public key to the server:
   ssh-copy-id user@server
Enter fullscreen modeExit fullscreen mode

6. Linux Find Command

Locate files quickly. Example: Find.log files larger than 10MB.

Command:

find /path-type f-name"*.log"-size +10M
Enter fullscreen modeExit fullscreen mode

7. Install a Package

Installhtop as an example.

Command:

sudoaptinstallhtop
Enter fullscreen modeExit fullscreen mode

8. Install Ansible

Automate IT tasks with Ansible.

Steps:

  1. Install Ansible:
sudoaptinstallansible
Enter fullscreen modeExit fullscreen mode
  1. Verify:
   ansible--version
Enter fullscreen modeExit fullscreen mode

9. Configure Local Yum Repos

Set up a local YUM repository.

Steps:

  1. Create a repo file:
sudovi /etc/yum.repos.d/local.repo
Enter fullscreen modeExit fullscreen mode
  1. Add content:
   [local-repo]   name=Local Repository   baseurl=file:///mnt/repo   enabled=1   gpgcheck=0
Enter fullscreen modeExit fullscreen mode

10. Linux Services

Manage services. Example: Start and enable Apache.

Commands:

sudosystemctl start httpdsudosystemctlenablehttpd
Enter fullscreen modeExit fullscreen mode

11. Linux Configure sudo

Grant sudo privileges.

Steps:

  1. Edit sudoers file:
sudovisudo
Enter fullscreen modeExit fullscreen mode
  1. Add user:
   username ALL=(ALL) NOPASSWD:ALL
Enter fullscreen modeExit fullscreen mode

12. DNS Troubleshooting

Diagnose DNS issues.

Commands:

nslookup domain.comdig domain.com
Enter fullscreen modeExit fullscreen mode

13. Linux Firewalld Setup

Set up and manage firewalld.

Commands:

sudofirewall-cmd--add-port=80/tcp--permanentsudofirewall-cmd--reload
Enter fullscreen modeExit fullscreen mode

14. Linux Postfix Mail Server

Set up Postfix for email delivery.

Steps:

  1. Install:
sudoaptinstallpostfix
Enter fullscreen modeExit fullscreen mode
  1. Configure via/etc/postfix/main.cf.

15. Linux Postfix Troubleshooting

Check logs:

sudo tail-f /var/log/mail.log
Enter fullscreen modeExit fullscreen mode

16. Install and Configure HAProxy LBR

Load balance traffic with HAProxy.

Steps:

  1. Install HAProxy:
sudoaptinstallhaproxy
Enter fullscreen modeExit fullscreen mode
  1. Configure/etc/haproxy/haproxy.cfg.

17. HAProxy LBR Troubleshooting

Check status:

sudosystemctl status haproxy
Enter fullscreen modeExit fullscreen mode

Debug logs:

sudojournalctl-u haproxy
Enter fullscreen modeExit fullscreen mode

18. MariaDB Troubleshooting

Check MariaDB logs:

sudo tail-f /var/log/mysql/error.log
Enter fullscreen modeExit fullscreen mode

19. Linux Bash Scripts

Automate tasks. Example: Disk usage report.

#!/bin/bashdf-h> disk_report.txt
Enter fullscreen modeExit fullscreen mode

20. Add Response Headers in Apache

Enhance security by adding headers.

Steps:

  1. Edit.htaccess or/etc/httpd/conf/httpd.conf:
   Header set X-Frame-Options "DENY"
Enter fullscreen modeExit fullscreen mode
  1. Restart Apache:
sudosystemctl restart httpd
Enter fullscreen modeExit fullscreen mode

21. Apache Troubleshooting

Check configuration:

sudoapachectl configtest
Enter fullscreen modeExit fullscreen mode

View logs:

sudo tail-f /var/log/httpd/error_log
Enter fullscreen modeExit fullscreen mode

22. Linux GPG Encryption

Encrypt files with GPG.

Commands:

gpg--encrypt--recipient email@example.com file.txtgpg--decrypt file.txt.gpg
Enter fullscreen modeExit fullscreen mode

23. Linux Log Rotate

Automate log rotation.

Steps:

  1. Configure/etc/logrotate.conf.
  2. Test:
   logrotate-d /etc/logrotate.conf
Enter fullscreen modeExit fullscreen mode

24. Application Security

Implement security measures like SELinux, AppArmor, or Fail2Ban.

Commands:

sudoaptinstallfail2bansudosystemctlenablefail2ban
Enter fullscreen modeExit fullscreen mode

Happy Learning !!!

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

####
  • Education
    ☘️
  • Work
    👨‍💻
  • Joined

More fromVivesh

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp