

Next we add user bill to the netadmin group: sudo adduser bill netadmin The command tcpdump is under CAPTURE alias i.e. NETALL in turn include all commands under CAPTURE and SERVERS aliases. Users in the netadmin group can run commands specified in NETALL. What we have done in the above file is create a netadmin group. Use the following command to create the file: sudo visudo -f /etc/sudoers.d/networkingĪdd following text in the file: Cmnd_Alias CAPTURE = /usr/sbin/tcpdumpĬmnd_Alias SERVERS = /usr/sbin apache2ctl, /usr/bin/htpasswd To do so we create a configuration file in /etc/sudoers.d/ called networking. What if we want bill to be able to run only specific kinds of commands with sudo privileges, like networking? Use the Sudoers File to Grant Specific Privileges Now the user bill can no longer perform actions that require sudo privileges. The deluser command will remove bill from the sudo group. To remove a user from sudo: deluser bill sudo If you want to give anyone root privileges just add them to sudo. If we use the grep command to check who is in the group, we’ll see the username bill. To add a user called bill to the sudo group, we use the adduser command in the command line, like so: adduser bill sudo To see which users are in the sudo group we can use a grep command: grep ‘sudo’ /etc/group Visudo makes sure that sudoers is edited by one user at a time and provides necessary syntax checks. It is recommended to use visudo to edit the sudoers file. To edit /etc/sudoers file, use following command: sudo visudo -f /etc/sudoers

#SUDO LINUX PASSWORD#
The user does not need access to the root password when using the sudo commad the user can use his or her own password, and the access to the specified commands can be set to a limited amount of time. The sudo command allows selected non-root users to execute restricted commands.īy using this command, access to the root account can be controlled.

By allowing authorized users to execute specific commands with elevated privileges, the sudo command promotes a safer operating environment and minimizes the risks associated with direct root access. The sudo command in Red Hat Linux is an essential tool for managing system privileges and performing administrative tasks securely. However, it is recommended to use the 'visudo' command instead to safely edit the sudoers file: This command provides a root shell, allowing you to execute multiple commands with elevated privileges without having to prepend 'sudo' to each command.įor example, to edit the sudoers file using the 'vi' text editor, you would use:
#SUDO LINUX UPDATE#
Running a single command as the root user:įor example, to update the system package list, you would use:įor instance, to run a command as the user 'john', you would use:.Some common use cases for the sudo command in Red Hat Linux include: The 'options' can be used to modify the behavior of the sudo command, such as specifying the target user or preserving the environment variables. Here, 'command' represents the command to be executed with elevated privileges, and 'arguments' are any optional parameters for the command. Linux sudo CommandExplain the use of the sudo command in Red Hat Linux Lesson 10 sudo Objective Explain the use of the sudo command.
