简体   繁体   English

如何在Shell脚本中以非root用户身份登录(同时使用用户名和密码)?

[英]How to login (using both username and password) as a non root user in linux in a shell script?

I have a non root user euser with a certain password. 我有一个具有特定密码的非root用户euser。

I am also writting a shell script thru which first I need to login thru euser and then run a installer. 我还要编写一个shell脚本,首先需要通过euser登录,然后运行安装程序。

Shell script contents - Shell脚本内容-

/bin/bash
su - newuser
cd installdir
./install.sh

When this script executes it gives error as - 执行此脚本时,错误为-

Password:
su: Authentication failure**

How I can avoid this error and make my script work? 如何避免此错误并使脚本正常工作?

su is for human interaction. su用于人类互动。 try sudo for single commands. 对于单个命令,请尝试sudo。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 linux 和 windows 上的 shell 脚本询问用户名和密码 - how to ask for username and password with a shell script on linux and windows linux bash shell:如何使用文件中的用户名和密码创建用户? - linux bash shell: how to create user with username and password from file? 如何在脚本中使用密码从shell脚本登录用户帐户? - how to login to user account from shell script with password in the script? SHELL SCRIPT LINUX 使用用户输入设置密码 - SHELL SCRIPT LINUX set password using user input 如何使用Shell脚本将用户名和密码传递给应用程序? - How to pass Username and password to an application using shell script? 运行shell脚本时如何提示用户以root用户身份登录 - how to prompt user to login as root when running a shell script 以没有 sudo 权限的非 root 用户身份连接时,使用 Ansible playbook 脚本更改 linux 密码 - Change linux password with Ansible playbook script when connecting as a non-root user without sudo privileges 在Shell脚本中与非root用户连接后更改root - Changing root after connecting with a non-root user in shell script 如何使用Linux root用户访问服务器登录drupal admin? - how to login in drupal admin using Linux root user access to the server? 如何使用ruby脚本以ROOT用户身份登录linux终端 - How to log in into the linux terminal as ROOT user using ruby script
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM