How can I execute any command as a normal user without sudo?
If your account has sudo rights, then there’s no need to mess with the suid bit. The following assumes Bash as your interactive shell, so you may have to modify steps 2&3 depending on what you use.
1)Add these to the end of /etc/sudoers
1 2 |
USERNAME HOST_NAME = (root) NOPASSWD: /usr/bin/apt-get USERNAME HOST_NAME = (root) NOPASSWD: /usr/bin/shutdown |
2)Add these to your ~/.bashrc
1 2 |
alias shutdown='sudo shutdown' alias apt-get='sudo apt-get' |
3)Reload the startup config for the current session.
1 |
$ source ~/.bashrc |
4)Now you can run the commands as a normal user without being prompted for a root/sudo password (and therefore, eliminate the need to know the password altogether).
1 2 3 |
$ apt-get update $ apt-get upgrade $ shutdown -h now |