常用shell技巧整理

常用shell技巧整理

Posted by WW on April 6, 2021

自动输入密码运行sudo指令

For sudo there is a -S option for accepting the password from standard input. Here is the man entry:

    -S          The -S (stdin) option causes sudo to read the password from
                the standard input instead of the terminal device.

This will allow you to run a command like:

echo myPassword | sudo -S ls /tmp