![]() I hope you like this handy Ubuntu tutorial. rw-rw-r- 1 abhishek abhishek 0 Aug 23 07:56 a.txt :/home/abhishek# su -c "touch a.txt" abhishek The command should be a single argument and hence you should keep it under quotes. You can use the -c and run the given command as another user: su -c command_to_run user_name If the entire idea of switching to another user is to run a command, you don't necessarily change the user accounts. :/home/abhi# Bonus tip: Run a command as another user ![]() When asked for the password, enter your account's password: :~$ sudo su If you don't know the root password but have sudo access (default sudo configuration that comes in most Ubuntu system), you can switch to the root user like this: sudo su When asked, enter the root password: :/root$ su If you know the root password, you can switch to root user simply with: su Since we are discussing the su command here, let's use that only. There are several ways to switch to the root user. You can switch back to your logged-in user by entering: exit The sudo command is to execute commands with root privileges: you tried to execute the command root, which was obviously not found. Now restart and login as root with the password you gave to root account. If you are running as the root user, you can simply switch to the other user with its name: su other_username You can now reset your lost root password by using the following command: passwd root Alternatively, you can change the password of the super user with the command: passwd username. You can list the users in Ubuntu with the following command and get the desired username from the bottom of its output: compgen -u Switching to a normal user from root user □️ You need to know the exact username to which you need to switch to. Intrigued? Let's see all the above in detail, along with a few additional tips and use cases on switching users in Ubuntu.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |