Bash script to get list of local users on Linux

Scenario: How to get the list of normal users and System users in Linux.
System : CentOS/RHEL 6/7

Steps:
1) Login as local users (work without login to root), example I login as bachem.
2) Create the bash script file with file name listusers.sh
$ vi /home/bachem/listusers.sh

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

4) Finish,running the script and see the output.

Here steps to save the listusers.sh output to a filename called hostname_users.txt.
1) Create the bash script file with file name listusers_host.sh
$ vi /home/bachem/listusers_host.sh

2) Make the file executable,
$ chmod +x /home/bachem/listusers_host.sh

3) Finish,running the script and see the output.

Here steps to save the listusers.sh output to a filename called ipaddress_users.txt.
1) Create the bash script file with file name listusers_ip.sh
$ vi /home/bachem/listusers_ip.sh

2) Make the file executable,
$ chmod +x /home/bachem/listusers_ip.sh

3) Finish,running the script and see the output.

Reference:
https://www.cyberciti.biz/faq/linux-list-users-command/


Related posts:

Leave a Reply

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