Answer the question
In order to leave comments, you need to log in
How to execute a command as a simple user without sudo?
Let's say there is a simple user. I know the password of the superuser
I can do sudo rm something
I enter the password - voila.
I can configure it so that it does not ask for a password every time for a given command, but how can I make it so that a simple user can execute a certain set of commands (rm, ln, mv, start, stop, restart, status) without entering four characters s, u, d, o?
Really needed. There is a script that I will not change, it tries to execute commands without sudo, and shuts up on ln: Access denied. Tried manually, really denied access without sudo
Answer the question
In order to leave comments, you need to log in
You should not give permission to rm, ln, etc.
You should edit /etc/sudoers and allow one user to run your file with root privileges.
The file should definitely not be edited by this user
# Allow members of group sudo to execute any command
%sudo ALL=(ALL:ALL) ALL
john ALL = NOPASSWD: /home/john/Documents/script.sh
1. You can set the SUID flag on your executable script file to run the program as root (but this can be dangerous).
2. A set of valid commands for a user or group (for such purposes it is useful to create) is defined in /etc/sudoers.
Why don't you like sudo? ... each user enters the password there, not root.
PS This is the usual way for Linux ... and the invention of bicycles is always fraught with trouble ;-)
ln is a program just like any other program on the system. You can find an executable file like this:
... and then give the rights to the required user to run this file.
Run your script with sudo
Or sudo su - will switch the current console to the root user, from where you are already running your script
> rm, ln, mv, start, stop, restart, status
Issue Ruta to the user. These commands are enough to get root.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question