GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: useradd script
Operating System - HP-UX
1846190
Members
2601
Online
110254
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2002 03:37 PM
10-29-2002 03:37 PM
useradd script
I found a script on one of the forums and have modified it to use a custom skel directoy and groups. What I would like to do is insert the persons full name and location into the ect/passwd file. I'm not sure how to do this and any help would be greatly appreciated. Also if I could insert a generic encrypted password in the /etc/passwd file. Please find a below the script I have so far. Thank you in advanced.
#!/usr/bin/sh
Usage() {
echo "Usage: $1"
exit
}
if test $# -ne 1
then
Usage $0
else
uid=`cut -d":" -f 3 /etc/passwd | sort +n | uniq | tail -1`
uid=`expr $uid + 1`
user=`echo $1 | tr -s '[A-Z]' '[a-z]'`
echo "The user $1 is given user id $uid."
echo "Ok to proceed (Y/n) ? :\c"
read choice
if test "$choice" = "Y" -o "$choice" = "y"
then
/usr/sbin/useradd -u $uid -g lawson -d /home/$user -m -k /etc/lawskel $user
case $? in
0) echo "User is successfully created.";;
9) echo "User id is not unique.";;
16) echo "Cannot add user into /etc/passwd.";;
esac
fi
fi
#!/usr/bin/sh
Usage() {
echo "Usage: $1
exit
}
if test $# -ne 1
then
Usage $0
else
uid=`cut -d":" -f 3 /etc/passwd | sort +n | uniq | tail -1`
uid=`expr $uid + 1`
user=`echo $1 | tr -s '[A-Z]' '[a-z]'`
echo "The user $1 is given user id $uid."
echo "Ok to proceed (Y/n) ? :\c"
read choice
if test "$choice" = "Y" -o "$choice" = "y"
then
/usr/sbin/useradd -u $uid -g lawson -d /home/$user -m -k /etc/lawskel $user
case $? in
0) echo "User is successfully created.";;
9) echo "User id is not unique.";;
16) echo "Cannot add user into /etc/passwd.";;
esac
fi
fi
1 REPLY 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2002 03:52 PM
10-29-2002 03:52 PM
Re: useradd script
add a little piece to your script that creates a text comment saved as a variable:
looks like you have a single argument that is run with your script at a command prompt.... then it chugs on through and creates your new user. Would it be a huge problem to add a second, third and fourth argument that is the Full name + location.... then modify the useradd as follows:
/usr/sbin/useradd -u $uid -g lawson -d /home/$user -m -c "$2 $3 located in $4" -k /etc/lawskel $user
sure there are more ways to skin this cat
Ted
looks like you have a single argument that is run with your script at a command prompt.... then it chugs on through and creates your new user. Would it be a huge problem to add a second, third and fourth argument that is the Full name + location.... then modify the useradd as follows:
/usr/sbin/useradd -u $uid -g lawson -d /home/$user -m -c "$2 $3 located in $4" -k /etc/lawskel $user
sure there are more ways to skin this cat
Ted
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2026 Hewlett Packard Enterprise Development LP