linux - How can I apply password to sudo in one line command and execute su root? -
i've created user named samx root privilege (have appended "samx all=(all:all) all" in visudo
).
i'm trying apply password sudo
, su root
, execute whoami
sequentially in 1 line command. current command follows, complains error: sudo: su root; whoami: command not found
echo 'cbeykfkt' | sudo -s 'su root; whoami'
in which, 'cbeykfkt' password user samx.
is there anyway solve problem? lot.
you should add line sudoers file such as
samx all=(all:all) nopasswd: /sbin/su
instead of saving password in bash history or other file. that, there no need enter password @ all.
if want perform different command, add that.
Comments
Post a Comment