However, in the case that the SHELL environment variable is set in the invoking user's environment (which it usually is, and it is typically /bin/bash), and that the target user has a login shell which differs from this (such as /usr/sbin/nologin), there is then a difference between which shell gets executed by these two commands, and this is what you are seeing. Execute the following command: sudo su -c env PATHPATH:/home/unitech/.nvm/versions/node/v14.3/bin. So the two commands look similar (largely coincidentally) and have a somewhat similar effect when the target user has the same login shell as that of the invoking user. pm2 startup PM2 You have to run this command as root. The su user command could be run without the use of sudo, but by running it as root it will not require the password of the target user. Running sudo -i is a cleaner (in my opinion) way of running sudo su. Running su as root is essentially a no-op, though it probably starts a new shell. sudo runs the specified command ( su) as root. su root (which can be shortened to just su) runs the su command as the user who invoked it. The su command will then invoke the login shell of the specified username. There's a subtle difference between the two. su - temporarily become the superuser sudo - temporarily become the superuser chown - change file ownership chgrp - change a files group ownership. The su utility requests appropriate user credentials via PAM and switches to that user ID (the default user is the superuser). What are the differences between 'su', 'sudo -s', 'sudo -i', 'sudo su' Ask Question Asked 11 years, 8 months ago Modified 1 year, 8 months ago Viewed 356k times 182 I already read it from manual but I can't see difference. 1) switches from the current directory to the home directory of the new user (e.g., to /root in the case of the root user) by. su takes the other users password since you are switching to that user. The difference between '-' and 'no hyphen' is that the latter keeps your existing environment (variables, etc) the former creates a new environment (with the settings of the actual user, not your own). Sudo su user will use sudo to run the command su user as the root user. Its called the substitute user identity tool. These options are documented under man sudo. One day, a typo meant I typed sudo su - instead - it seems to me that everything was the same as with a single hyphen, except that I was in the same folder as before I issued the command (with a single hyphen. When I am working on our RHEL machines, I use sudo su - to switch to being root. Not entirely accurate but close enough to remember. I find an easy way to remember which is which is su switch user (to root - yes, you can use it to switch to other users too), sudo switch user to root and do, and chroot as change root. The -u user option means to run the command as the specified user rather than root. What's the difference between sudo su - and sudo su -. almost confusingly, on ubuntu, visudo uses nano. The -s option means to run the shell specified in the environment variable SHELL if this has been set, or else the user's login shell. Sudo -su user is short for sudo -s -u user.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |