Shell security in Linux is a critical aspect of system administration and helps protect the system from unauthorized access and attacks. Here are several key points and practices related to shell security in Linux:
chmod
, chown
, and chgrp
commands to set proper permissions.sudo
to grant temporary elevated privileges. Configure /etc/sudoers
carefully to control which commands users can execute.rbash
) for users who need limited access. Modify users’ default shell in /etc/passwd
..bashrc
, .bash_profile
, and .profile
to prevent unauthorized command execution on login.PATH
. Ensure they don’t include directories writable by unprivileged users to avoid privilege escalation.secure_path
in /etc/sudoers
to enforce a secure PATH
for sudo
commands.HISTCONTROL
to ignore duplicate commands and commands that start with space (HISTCONTROL=ignoredups:ignorespace
). Secure the command history file (.bash_history
) to restrict access.auditd
to log shell commands and monitor user activities. Regularly check logs for suspicious activities.set +m
) or disabling the ability to execute certain commands through shell options.rbash
: The restricted bash shell (rbash
) limits certain operations, such as changing directories or setting the PATH
.iptables
or firewalld
) to restrict access to the shell over the network.OSSEC
or AIDE
to monitor for unauthorized changes and suspicious activities.