12/15/2023 0 Comments Sudo user specific command![]() ![]() etc/sudoers.d/eliza: bad permissions, should be mode 0440 To check the validity of all sudoers config files visudo -c /etc/sudoers: parsed OK echo "john ALL=(root) /bin/systemctl restart apache2" > /etc/sudoers.d/johnĪlways be sure to confirm if the syntax of the sudo configs is okay when you echo commands visudo -c /etc/sudoers.d/johnĮnsure the output is Ok. Unless the root user is allowed to login, you can try to use echo. You can easily mess up and loose sudo access to your system. ![]() NOTE: Be extra cautions when echoing commands. Note that while adding sudo privileges for the user, it is more safer to put the user specific sudo configuration under the /etc/sudoers.d directory for example To run specific commands with sudo as any target user, for example to allow user john to restart only Apache service using sudo john ALL=(ALL) /bin/systemctl restart apache2 Next, add the line below john ALL=(root) /bin/systemctl restart NetworkManager To edit sudoers file, you need to be root user or have sudo privileges. ![]() This can be done by modifying the /etc/sudoers file or by adding user specific sudoers configuration file under the /etc/sudoers.d directory.įor example, to allow a user called john to restart Network Manager as user root on all hosts, edit the sudoers file and add the line below. So it is possible to enable a user to run only specific commands with sudo in Linux. Our previous guide covered how to add user to sudo group to enable them to execute the commands with elevated privileges. In this guide, you are going to learn how to run only specific commands with sudo in Linux. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |