当前位置: 技术问答>linux和unix
root登录脚本
来源: 互联网 发布时间:2015-12-16
本文导语: 在非root用户状态下,已知root用户的密码为“password”。 现在需要写一个脚本,该脚本的功能就是不需要用户的交互从非root用户转入到root用户,也就是说密码在脚本中写定,不需要用户在终端里输入任何信息。 有办...
在非root用户状态下,已知root用户的密码为“password”。
现在需要写一个脚本,该脚本的功能就是不需要用户的交互从非root用户转入到root用户,也就是说密码在脚本中写定,不需要用户在终端里输入任何信息。
有办法解决吗,如果可以,帮忙写个脚本或者给出思路。
现在需要写一个脚本,该脚本的功能就是不需要用户的交互从非root用户转入到root用户,也就是说密码在脚本中写定,不需要用户在终端里输入任何信息。
有办法解决吗,如果可以,帮忙写个脚本或者给出思路。
|
There is a group of commands that make use of super user commands
safer. They allow better logging, user-based restrictions and usage
of individual passwords. Most widely used is sudo.
$ sudo env
executes command env as super user (if it is configured to allow it).
sudo command has again a different approach to path handling. It
modifies the search path so that the current directory is always the
last one. However, it does not modify PATH environment variable.
just couple of environment variables like SUDO_USER.
safer. They allow better logging, user-based restrictions and usage
of individual passwords. Most widely used is sudo.
$ sudo env
executes command env as super user (if it is configured to allow it).
sudo command has again a different approach to path handling. It
modifies the search path so that the current directory is always the
last one. However, it does not modify PATH environment variable.
just couple of environment variables like SUDO_USER.
|
这样很不安全啊。
|
su
password
password
|
写个脚本
在脚本里面su一下
在脚本里面su一下