sudo su后如何执行命令 [英] How to execute the command after sudo su

查看:159
本文介绍了sudo su后如何执行命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要执行monit restart haproxy"sudo su 之后的命令.

I need to execute "monit restart haproxy" command after sudo su.

这是我的脚本.sh

sudo su
monit restart haproxy.

在这里,如果我将执行 script.sh 文件,那么它会挂起并且不会执行 monit restart haproxy 命令.

Here if i will execute the script.sh file then it will hang and it is not executing the monit restart haproxy command.

有什么想法吗?

推荐答案

这里是关于 sudo su 的一些信息.您需要为 sudo 或 su 命令输入密码,这是我发布的链接的一些引用,可能是您的问题的根源:

Here comes some information about sudo su. You need to enter password for sudo or su command, here is some quote from link i posted that may be the source of your problem:

sudo - sudo 旨在以 root 权限运行单个命令.但与 su 不同的是,它会提示您输入当前用户的密码.此用户必须在 sudoers 文件中(或在 sudoers 文件中的组).默认情况下,Ubuntu 会记住"您的密码 15 分钟,这样您就不必每次都输入密码.

sudo - sudo is meant to run a single command with root privileges. But unlike su it prompts you for the password of the current user. This user must be in the sudoers file (or a group that is in the sudoers file). By default, Ubuntu "remembers" your password for 15 minutes, so that you don't have to type your password every time.

这篇关于sudo su后如何执行命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆