Managing a Linux system effectively requires proficiency in a wide range of administrative tasks. Below is a guide to key tasks with examples and use cases to streamline operations and ensure security.
1. Custom Apache User Setup
Objective: Create a dedicated Apache user for running the web server securely.
Commands:
sudo useradd -r -d /var/www -s /sbin/nologin apache
sudo chown -R apache:apache /var/www
Use Case: Secure a web server by running Apache as a non-privileged user.
2. Group Creation and User Assignment
Objective: Create a group for developers and assign users.
Commands:
sudo groupadd devteam
sudo usermod -aG devteam user1
Use Case: Facilitate collaboration by giving group-level permissions to project files.
3. Linux User Setup with Non-Interactive Shell
Objective: Create a user with no interactive shell to limit login access.
Commands:
sudo useradd -s /sbin/nologin backupuser
Use Case: Use for users who only require FTP or backup services.
4. Service User Creation without Home Directory
Objective: Add a service-specific user without a home directory.
Commands:
sudo useradd -M -r -s /bin/false serviceuser
Use Case: Securely run background services or daemons.
5. Temporary User Setup with Expiry
Objective: Create a user account with an expiration date.
Commands:
sudo useradd -e 2024-12-31 tempuser
Use Case: Allow temporary access for contractors or short-term projects.
6. Linux User Data Transfer
Objective: Transfer user data to another directory or server.
Commands:
sudo rsync -av /home/user1/ /backup/user1/
Use Case: Backup or migrate user data during system upgrades.
7. Secure Root SSH Access
Objective: Restrict SSH access for root users.
Steps:
- Edit the SSH configuration file:
sudo nano /etc/ssh/sshd_config
- Disable root login:
PermitRootLogin no
- Restart SSH:
sudo systemctl restart sshd
Use Case: Prevent unauthorized root access to the server.
8. Data Backup for Developer
Objective: Schedule regular backups for developers.
Commands:
crontab -e
# Add the following line:
0 2 * * * tar -czf /backup/dev_backup_$(date +\%F).tar.gz /home/dev
Use Case: Ensure developers' data is secure in case of accidental deletion.
9. Script Execution Permissions
Objective: Make a script executable.
Commands:
chmod +x script.sh
./script.sh
Use Case: Run custom scripts for automation or system management.
10. File Permission Correction
Objective: Correct permissions for shared directories.
Commands:
sudo chmod -R 775 /shared_folder
sudo chown -R user:group /shared_folder
Use Case: Prevent unauthorized access to sensitive shared files.
11. String Replacement
Objective: Replace strings in configuration files.
Commands:
sed -i 's/oldstring/newstring/g' config.txt
Use Case: Update URLs, paths, or configurations programmatically.
12. Secure Data Transfer
Objective: Transfer data securely between servers.
Commands:
scp file.tar.gz user@remote:/path/to/destination
Use Case: Migrate sensitive data between servers securely.
13. Restrict Cron Access
Objective: Restrict specific users from scheduling cron jobs.
Commands:
Add users to /etc/cron.deny
:
echo "user1" | sudo tee -a /etc/cron.deny
Use Case: Prevent misuse of system resources.
14. Default GUI Boot Configuration
Objective: Change default boot to GUI mode.
Commands:
sudo systemctl set-default graphical.target
sudo reboot
Use Case: Enable a desktop environment for easier management.
15. Timezone Alignment
Objective: Set the correct timezone for the server.
Commands:
sudo timedatectl set-timezone Asia/Kolkata
Use Case: Align logs and cron jobs with local time.
16. Firewall Configuration
Objective: Set up and enable a firewall.
Commands:
sudo ufw allow 22
sudo ufw enable
Use Case: Secure the server by controlling network access.
17. Process Limit Adjustment
Objective: Modify user process limits.
Steps:
- Edit limits file:
sudo nano /etc/security/limits.conf
- Add or modify:
user1 soft nproc 1024
Use Case: Prevent resource exhaustion due to excessive processes.
18. SELinux Installation and Configuration
Objective: Enable SELinux for enhanced security.
Commands:
sudo apt install selinux
sudo setenforce 1
sudo sestatus
Use Case: Enforce mandatory access controls on critical systems.
_By implementing these tasks, as a Linux administrators you can efficiently manage systems, ensure security, and optimize performance for varied use cases.
Happy Learning !!! _
Top comments (0)