when I try using a command with sudo everything works fine, however, if I want to log in as the superuser using su it doesn't let me. Why?
19264
I am having problems with the su command. I know my password and I am typing it correctly but su indicates authentication failure.  So I checked on the internet and then went into recovery mode and changed my username's password to what I was entering before.  Even now entering the same password on su gives me authentication failure.  Please suggest what am I doing wrong??
108545
I know about "not using sudo su -" etc. But let's be honest, almost all of us do it.   So, here is the issue. We can't have root logins enabled, so we have to ssh in as our user then su to root.  Here is the process tree:       1  7897  7826  7826 ?           -1 S     1000   0:00 sshd: josh@pts/0  7897  7898  7898  7898 pts/0     8182 Ss    1000   0:00  \_ -bash  7898  7990  7990  7898 pts/0     8182 S        0   0:00      \_ sudo su -  7990  7991  7990  7898 pts/0     8182 S        0   0:00          \_ su -  7991  7992  7992  7898 pts/0     8182 S        0   0:00              \_  -su  7992  8182  8182  7898 pts/0     8182 R+       0   0:00                  \_ ps axjf   I would like to exit from root, then from my user with one command. Is there a way to do this?  BTW exit &amp;&amp; exit does not work because it exits the shell and doesnt process the rest of the command  josh@ubuntu:~$ sudo su - root@ubuntu:~# exit &amp;&amp; exit logout josh@ubuntu:~$
107417
I have a long and long-running bash script where a handful of commands need to be run as root while the majority of commands need to be run as the regular user before sudo, because it would mess up file ownership and such.  I came up with some methods, but each of them have some problems  Method 1: Using sudo inside the file  #!/bin/bash sudo echo "I must be run by root" touch needsToBeOwnedByUser1 echo "needs to be run by user" sleep 1000 sudo echo "I, again, must be run by root"   This would look good, from the way the code is written. sudo is written before the few statements that actually need to be run by root, but if the time between each sudo call is too long sudo again asks for a password. Also, if the first execution of sudo fails, e.g. due to an invalid password, the rest of the script is still executed.  Method 2: using sudo to call the file and then change back to the original user when needed  #!/bin/bash echo "I must be run by root" su username -c 'touch needsToBeOwnedByUser1' su username -c 'echo "needs to be run by user"' su username -c 'sleep 1000' echo "I, again, must be run by root"   This also sucks, because I need to add su username -c in front of almost every line. Also finding the original username after sudo is possible, but cumbersome.  Is there a better way?  Edit: I only posted small, nonsensical scripts here to show what I am talking about. In the actual script I have some lines that need sudo (starting and stopping services), some lines where it does not matter if there is sudo and quite a lot of lines that really need to be run without sudo.
16623
I have the su executable with the following permissions:  bash-4.2# ls -la /bin/su -rws--s--- 1 root wheel 59930 Sep 14  2012 ./su   When I am logged in as a user, not in the wheel group and try to run su, I get an error, which is correct:  bash-4.2$ su bash: /bin/su: Permission denied   After that I add this user to wheel group from root:  bash-4.2# usermod -a -G wheel user   But for the same terminal session I still can't run su:  bash-4.2$ su bash: /bin/su: Permission denied   For the new sessions I can run su. How to allow to run su instantly after I added the user to the appropriate group?
16006
When installing Ubuntu I can create a user with an encrypted folder, what I always do. Now after the installation the login password for this user is also the sudo password. Is that how it should be? I actually would like to have a different user login and sudo password, does is make sense? Should I do that, how?
59930
How do I change from user to superuser (root)? What command do I use in the Terminal to switch to root? I have tried --help but I get lost with all the listed help. I'm looking for a recent download/install so I can use it.
53235
I would like to know what is the difference between    su - sudo bash sudo sh   I cannot login as root while doing su - because I do not have the root password - I mean I have my user password with which I can sudo "command"  but this password does not work for su - I can log in as root with sudo bash with my user password and I can login while doing sudo sh but then I get a command prompt in this form #
74123
Whenever I issue command sudo apt-get install foo it does not ask for password. is it because of user groups?  How to make it prompt for password?  Edit: My sudoers file   apple@Ascension:~$ sudo cat /etc/sudoers # # This file MUST be edited with the 'visudo' command as root. # # Please consider adding local content in /etc/sudoers.d/ instead of # directly modifying this file. # # See the man page for details on how to write a sudoers file. # Defaults    env_reset  # Host alias specification  # User alias specification  # Cmnd alias specification  # User privilege specification root    ALL=(ALL:ALL) ALL  # Members of the admin group may gain root privileges %admin ALL=(ALL) ALL  # Allow members of group sudo to execute any command %sudo   ALL=(ALL:ALL) ALL  #includedir /etc/sudoers.d ALL ALL=(ALL) NOPASSWD:ALL ALL ALL=(ALL) NOPASSWD:ALL ALL ALL=(ALL) NOPASSWD:ALL
98180
Is it possible to make the password visible as asterisks (or any other character) on using sudo command?  Currently, it does not display anything, thus making it difficult to count the number of keystrokes pressed..
95185
A sample script can be as below:  #!/bin/bash sudo su ls /root   When using ./test.sh as the normal user, instead run ls as super user and exit, it switches to root; and when I logout, it executes ls /root as the normal user.  Can anybody tell me about the mechanism about it?
1058
I don't understand why su - is preferred over su to login as root.
14250
What is the difference between the following commands:  su sudo -s sudo -i sudo bash   I know for su I need to know the root password, and for sudo I have to be in the sudoers file, but once executed what is difference?  I know there is a difference between su and sudo -s because my home directory is /root after I execute su, but my home directory is still /home/myname after sudo -s. But I suspect this is just a symptom of an underlying difference that I'm missing.
34963
It is company policy for admins to login to the servers via a personal username, and then run sudo -i to become root.  Upon running sudo -i, sudo will create an environmental variable called SUDO_USER, which contains the original user's username.  Is there a way to log ALL commands within syslog with something akin to the following syntax:  ${TIME/DATE STAMP}: [${REAL_USER}|${SUDO_USER}]: ${CMD}   An example entry would be:  Sat Jan 19 22:28:46 CST 2013: [root|ksoviero]: yum install random-pkg   Obviously it doesn't have to be exactly the above syntax, it just has to include a minimum of the real user (eg. root), the sudo user (eg. ksoviero), and the full command that was run (eg. yum install random-pkg).  I've already tried snoopy, but it did not include the SUDO_USER variable.
18626
I already read it from manual but I can't see difference..  su - change user ID or become superuser  sudo -s [command]   The -s (shell) option runs the shell specified by the SHELL environment variable if it is set or the shell as specified in passwd(5).  If a                    command is specified, it is passed to the shell for execution.  Otherwise, an interactive shell is executed.  sudo -i disappear description in manual
43186
I'm using sudo su to start mysql and do some homework with it.  When I finish with mysql (or any other command), then I'm still in sudo.   How do I "log out", so my prompt changes back from # to $?
105305
why should root access be disabled for ssh? I always hear that's for security reasons. But I don't get it. What's different to login as non-root and then sudo su -? What's the preferred way to handle tasks that need privileged permissions?  Thanks  Thomas
1809
In /etc/sudoers I see this:  # Allow members of group sudo to execute any command after they have # provided their password # (Note that later entries override this, so you might need to move # it further down) %sudo ALL=(ALL) ALL   So how do I add a user to that sudo group?