Avoid common pitfalls in Linux administration by following these practical tips. Learn how to handle permissions, troubleshoot errors, and secure your system effectively.
1. Avoid Running Commands That Change Multiple Properties
Instead of running commands that change a large number of properties, focus on specific files or directories related to the issue you are troubleshooting.
Example:
Avoid using:
chmod 777 everything
This can cause security issues and break applications such as SSH or sudo
. Instead, identify why you need to run these commands and explore more secure alternatives.
2. Don’t Use Root as a Daily Driver
Unlike the Administrator account in Windows, the Linux root user bypasses security warnings and checks. Using sudo
to run privileged commands is safer and provides an audit trail for tracking purposes.
3. Understand the rm
Command Flags
The -r
(recursive) and -f
(force) flags in the rm
command are permanent. Using them can delete files or directories without confirmation.
Example:
rm -rf /folder
This command will permanently delete the specified folder and all its contents without asking, “Are you sure?”
4. Troubleshooting Permission Denials
When troubleshooting access issues, consider both DAC (Discretionary Access Control) and MAC (Mandatory Access Control).
- DAC: File permissions (e.g.,
chmod
,chown
). - MAC: Tools like SELinux or AppArmor enforce additional security layers.
Example:
Check SELinux logs:
cat /var/log/audit/audit.log
5. Networking: Check Software Firewalls
Don’t assume networking issues are related to hardware alone. Software firewalls like iptables
or SELinux might be blocking connections.
Example:
Use iptables
commands to inspect rules:
iptables -L -v -n
If no rules are specified, SELinux might be configured at the IP layer.
6. Use SSH Key-Based Authentication
Avoid using password authentication in SSH. Passwords are prone to brute-force attacks, especially dictionary-based ones.
Exception:
Users who are part of a directory service might require passwords.
7. Always Identify the Time Zone
When checking timestamps, don’t assume the server time is local or UTC. Use the below command to confirm the timezone.
Example:
date
cat /etc/timezone
timedatectl
8. Troubleshoot Kernel Errors Effectively
When troubleshooting kernel errors, search the error message online along with the kernel and software version.
Example:
Use Bing or Google to search for:
<error message> <kernel version>
9. Handle Read-Only Filesystems
If you cannot modify a file even as root, check if the filesystem is mounted as read-only.
Steps:
- Run:
dmesg
Look for errors indicating filesystem integrity issues. - Check file attributes using:
lsattr
Files with the+i
attribute are immutable and cannot be modified, even by root.
10. Don’t Guess When Unsure
If you’re unsure how to proceed, don’t guess! Reach out to Linux experts or consult the documentation. Guessing can worsen the issue and make recovery more difficult.
Conclusion
By avoiding these common pitfalls, you can improve your Linux administration skills and ensure a more secure and efficient environment. Always prioritize understanding the commands you use and consult experts when necessary.