dexterous
dexterous

Reputation: 6526

how to pass a password on a command line while using su

I am trying to switch the user in pC. I don't want to type the password after prompt. Instead I want to pass it while doing a login.

For example-

$su loolu oohlala

How to pass the password in the su command.

Upvotes: 0

Views: 871

Answers (1)

hildred
hildred

Reputation: 453

There are two approaches I would recommend: the easy way, and the hard way.

The hard way is a su wrapper, gsu or ksu. If you look at the source code of these applications, you can learn how to do this, but it is not easy.

The easy way is to use a tool that does not require a password in all configurations instead of su. I would recommend either sudo or super. I prefer super for scripts, but both work fine for this, and can be configured not to ask a password.

Upvotes: 1

Related Questions