Linux command for switching user with password as parameter
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
I want to write the Linux shell script that switches the user without asking for password, i.e. password can be specified as the parameter.
I have my script like this startService.sh
sudo su hduser -p mypassword
but this is not working.
Can anyone tell how to specify the password in the command itself?
shell-script sudo users
add a comment |Â
up vote
1
down vote
favorite
I want to write the Linux shell script that switches the user without asking for password, i.e. password can be specified as the parameter.
I have my script like this startService.sh
sudo su hduser -p mypassword
but this is not working.
Can anyone tell how to specify the password in the command itself?
shell-script sudo users
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I want to write the Linux shell script that switches the user without asking for password, i.e. password can be specified as the parameter.
I have my script like this startService.sh
sudo su hduser -p mypassword
but this is not working.
Can anyone tell how to specify the password in the command itself?
shell-script sudo users
I want to write the Linux shell script that switches the user without asking for password, i.e. password can be specified as the parameter.
I have my script like this startService.sh
sudo su hduser -p mypassword
but this is not working.
Can anyone tell how to specify the password in the command itself?
shell-script sudo users
shell-script sudo users
edited Jun 14 at 14:22
Vlastimil
6,4861148121
6,4861148121
asked Sep 26 '17 at 4:21
Akash Sethi
130116
130116
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
You could use the -S
switch which reads the password from standard input like this:
echo 'password' | sudo -S command
From the man page:
-S
(stdin) option causessudo
to read the password from the standard input instead of the terminal device. The password must be followed by a newline character.
But there's a catch. It works for the current user only. I can't find a way around it, at least.
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
You could use the -S
switch which reads the password from standard input like this:
echo 'password' | sudo -S command
From the man page:
-S
(stdin) option causessudo
to read the password from the standard input instead of the terminal device. The password must be followed by a newline character.
But there's a catch. It works for the current user only. I can't find a way around it, at least.
add a comment |Â
up vote
0
down vote
accepted
You could use the -S
switch which reads the password from standard input like this:
echo 'password' | sudo -S command
From the man page:
-S
(stdin) option causessudo
to read the password from the standard input instead of the terminal device. The password must be followed by a newline character.
But there's a catch. It works for the current user only. I can't find a way around it, at least.
add a comment |Â
up vote
0
down vote
accepted
up vote
0
down vote
accepted
You could use the -S
switch which reads the password from standard input like this:
echo 'password' | sudo -S command
From the man page:
-S
(stdin) option causessudo
to read the password from the standard input instead of the terminal device. The password must be followed by a newline character.
But there's a catch. It works for the current user only. I can't find a way around it, at least.
You could use the -S
switch which reads the password from standard input like this:
echo 'password' | sudo -S command
From the man page:
-S
(stdin) option causessudo
to read the password from the standard input instead of the terminal device. The password must be followed by a newline character.
But there's a catch. It works for the current user only. I can't find a way around it, at least.
edited Jun 14 at 15:32
answered Sep 26 '17 at 4:53
Vlastimil
6,4861148121
6,4861148121
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f394455%2flinux-command-for-switching-user-with-password-as-parameter%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password