I want to automate the login process with sudo su
.
I have seen lot of questions on these, but none of them are working for me.
Automate login with sudo and su
Here's my what I tried so far
echo "mypassword" | sudo -S su - user
echo "mypassword\n" | sudo -S su - user
echo mypassword | sudo -S su - user
echo "mypassword" | sudo -S su user
echo mypassword | sudo -S su user
I am just getting the below response
-bash: line 1: mypassword: command not found
My Bash version
GNU bash, version 4.1.2(1)-release (x86_64-redhat-linux-gnu)
Copyright (C) 2009 Free Software Foundation, Inc.
As a note, my password contains special character @
@ sudo
usage: sudo [-D level] -h | -K | -k | -V
usage: sudo -v [-AknS] [-D level] [-g groupname|#gid] [-p prompt] [-u user name|#uid]
usage: sudo -l[l] [-AknS] [-D level] [-g groupname|#gid] [-p prompt] [-U user name] [-u user name|#uid] [-g groupname|#gid] [command]
usage: sudo [-AbEHknPS] [-r role] [-t type] [-C fd] [-D level] [-g groupname|#gid] [-p prompt] [-u user name|#uid] [-g groupname|#gid] [VAR=value] [-i|-s] [<command>]
usage: sudo -e [-AknS] [-r role] [-t type] [-C fd] [-D level] [-g groupname|#gid] [-p prompt] [-u user name|#uid] file ...
sudo su
. That's pointless and needlessly complex. Just usesudo -i
to start a root shell, or if your system has an activeroot
account, usesu -
. To log in as another user, usesudo -iu user
. I have no idea whysudo su
is so popular.