In this post we will learn how to customize the nologin shell message for user on linux/unix system. This is very useful when you want to display your company strict legal security message to users who are trying to login into your servers. As we know that , nologin shell won’t allow user to login and shows a message to user on terminal.
Now lets start making our customize nologin message for users.
Set nologin shell
For setting the user in nologin shell you can use either of given below command.
usermod -s /sbin/nologin user_name
chsh -s /sbin/nologin user_name
When you do ‘
su -l user_name‘ after changing the user bash shell to nologin shell, by default you will get the message “This account is currently not available ” .
Customize nologin shell message
Step 1: Create a user and change to nologin shell
We have created a user called test. And changed its shell to nologinshell. As expected, we will get the by default message as given below –
[root@localhost /]# grep test /etc/passwd test:x:500:500::/home/test:/sbin/nologin [root@localhost /]# su -l test This account is currently not available. [root@localhost /]#
Step 2: Write custom message in /etc/nologin.txt file
Now for changing the nologin message, create a new file called nologin.txt in /etc . Write your customized message in /etc/nologin.txt file.
## Using vi editor for editing vi /etc/nologin.txt
## Writing custom message in file Your account is disabled because of security breach. contact to- Linux System Administrator sharadchhetri.com extension: +747
Step 3: Verify custom nologin message
Now verify the nolgin customize message if it works.
[root@localhost /]# [root@localhost /]# su -l test Your account is disabled because of security breach. contact to- Linux System Administrator sharadchhetri.com extension: +747 [root@localhost /]#
Note: To revert back to old message settings, just remove the /etc/nologin.txt file (
sudo rm /etc/nologin.txt).
Yes it is working now .And this message will be applicable to all account which has nologin shell.