
However, this will not work unless the superuser has already updated /etc/sudoers to grant you permission to use the sudo command.
UBUNTU SUDO SU PASSWORD
While this resembles doing su -c, it is quite different in that the user’s own password is required su requires the other user’s password (often that of root). Where in the second form, the implicit user is root. While this may be an acceptable day-to-day method on a system on which you are the only normal user and you are trying to respect good system hygiene by avoiding privilege escalation except when absolutely necessary, there is a better method involving the sudo command. Once you have made the root password known to a normal user, you have abandoned all notions of security. You can do that with the su command, but there is one obvious drawback the user needs to have the root password in order to do this. Suppose a normal user needs temporary root privilege to execute a command, say to put a file in a directory that requires root privilege. In the first case, this will be in the current working directory, in the second, in the root’s home directory. You execute only one command, in this case ls. There is a subtle difference you are signed into a login shell, which means your working directory will shift to the home directory of the account you are logging into, paths will change, etc. If you use a naked dash as an option, as in: The superuser session ends when you type exit in the shell. If you do not give a user name (as in the third example), root will be assumed. You will be prompted for the password of the user whose name was specified. In order to temporarily sign on as another user, you can use the su command, as in the following examples:

As a general rule, you should assume so-called root privileges only when absolutely necessary and for as short a time as necessary. It is possible to enter the system as the root user either for a series of operations or only for one.
