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

How to use a bash script as a user's shell in centOS 7?

· 52CE 我爱测

I have user test and I want to provide a bash script as a login shell for this user. I was able to do it on centOS 6 easily by using the command usermod -s /pathtomyscript.sh . But in centOS 7 I am unable to do it like this. I co…

问题原文

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

I have user test and I want to provide a bash script as a login shell for this user. I was able to do it on centOS 6 easily by using the command usermod -s /pathtomyscript.sh. But in centOS 7 I am unable to do it like this. I copied the script to /usr/bin and added it to /etc/shells. But still no luck. My script is the following:

#!/bin/bash

PATH=$PATH:$HOME/.local/bin:$HOME/bin:/usr/bin:/bin
export PATH

whiptail --title "Example Dialog" --msgbox "You are logged in and now click ok to exit!" 8 78

I am able to login by running su, but when I login into console, it is saying that no shell, permission denied. I have already given the proper permission to the file like the following:

-rwxr-xr-x. 1 test test 240 Jan 19 15:57 /usr/bin/testshell.sh

已采纳解答

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

If you need, to some script or program acts as user's login shell - you must append it's full path to /etc/shells file.

pam_shells module checks for user login shell in this file.

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

资料来源与适用范围

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

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

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