Question Locked

Could any one be willing to help

0 helpful
4 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hi,
I'm totally new to Linux Bash scripting arena. I need to write a bash script to verify OS configuration. The purpose is to execute this script on a recently built Linux host to verify that the users/groups and settings required for WebSphere software have been configured correctly.

Any help would be appreciated. Thanks. Mehdi

4 replies

by tig2

I know one well enough to peer mail and send a link to your question. That way you question won't get lost.

Good luck!

by jmgarvin

You can just run a diff on passwd and see if it's correct or not...

It might be more difficult than that, but I like to keep it simple.

by deity_chooch

To find if the users and groups are correct, you can use grep on the /etc/passwd and /etc/group files. To see if a user exists, just grep the user on the /etc/passwd file:

`grep mehdisatter /etc/passwd`

To see if that user is in the correct group, grep the user on the /etc/group file and check the output for the group name:

`grep mehdisatter /etc/group`

If these commands output nothing, then the username is not in the file. I'm not sure what other settings you would need, but that should do it for the users/groups. You can just run these commands from the terminal or, if you'd prefer, you can make a script that would check whether it exists and check the group it's in. It'd look something like:

#!/bin/bash

USERS=(root mehdisatter anotheruser)
for USER in ${USERS[@]}; do
if [[ `grep $USER /etc/passwd` != "" ]]; then
GROUP=`grep $USER /etc/group | awk -F':' '{print $1}'`
echo "$USER exists and belongs to: $GROUP"
echo ""
else
echo "$USER does not exist."
fi
done

This discussion is closed to new replies.