One liner for login using su


Answer: 1

33 hours ago

I know you can use su to switch users within the terminal. As the account I use is non-root (without superuser permissions), it brings up a password prompt for the user I log into.

Is there a way to use su or something similar to login using a one line command? For example,


Something like this could be used in a bash script for example.

Answer: 2

15 hours ago

While I wouldn't recommend it (unless the use case explicitly calls for it), you can use something like the following in a shell script:

"echo PASSWORD | sudo -S COMMAND"

Where PASSWORD is the user password, and COMMAND is the command to run at the elevated permissions level.

Note that the -S option is important, as it redirects input from term to standard input. See Sudo Manual for additional details.

Added by: Dr. Oda Crona IV

Popular Search

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 1 2 3 4 5 6 7 8 9