Bash script to get list of expired local users on Linux

Scenario: How to get the list of expired local users on Linux.
System :
CentOS/RHEL 6/7
IP address: 192.168.99.11
Hostname : horse

Steps:
1) Create the bash script file with file name listchageusers.sh
$ vi /home/bachem/listchageusers.sh

3) Make the file executable
$ chmod +x /home/bachem/listchageusers.sh

4) Finish,run the script as root or sudoers and the output should like below..

to save the listchageusers.sh output to a filename called hostname_chage.txt do below:
– Edit bash script that created above add red font in below
$ vi /home/bachem/listchageusers.sh

– Run the script the output will save into a filename $(hostname)_chage.txt

to save the listchageusers.sh output to a filename called ipaddress_chage.txt do below:
– Edit bash script that created above add red font in below
$ vi /home/bachem/listchageusers.sh

– Run the script the output will save into a filename “$ipaddress”_chage.txt


Related posts:

Leave a Reply

Your email address will not be published. Required fields are marked *