大网数据广告活动
服务器运维问答

create user without password in ubuntu with su access?

· 52CE 我爱测

I am trying to create a user with su access on centos . I followed the instructions from this post . but NOTHING worked. I want to login using su test_user steps: sudo adduser test_user (No prompt to set up password) I tried su t…

问题原文

原帖链接 · brain storm · CC BY-SA 3.0

I am trying to create a user with su access on centos. I followed the instructions from this post. but NOTHING worked.

I want to login using su test_user

steps:

sudo adduser test_user (No prompt to set up password)

I tried su test_user (prompted for password) (pressed entered key - did not work)

then I deleted password

sudo passwd -d test_user
Removing password for user test_user.
passwd: Success

Then I tried

su test_user 
Password: (just enter key pressed)
su: Permission denied

NOTE: I also changed my sudoers file to reflect the following at the end of file /etc/sudoers as indicated in this post.

test_user ALL=(ALL) NOPASSWD:ALL

still nothing worked. Thanks

已采纳解答

原帖链接 · EEAA · CC BY-SA 3.0

OK, to be clear, su and sudo are completely different things. Adding test_user to your sudoers file is completely irrelevant for this use case.

su allows you to switch from one user to another, while sudo allow you to run a command as a different user. There's a subtle difference.

Having a passwordless account is horrible idea. Don't do it.

If you want to be able to switch from one account to another without affecting the other account's password, then just do:

$ sudo su - username

It goes without saying that your user account will need to be added to sudoers with the appropriate access to run the above command as root.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-01-06)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。