HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- useradd command
Operating System - HP-UX
1825721
Members
3134
Online
109687
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
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
Go to solution
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-01-2003 07:36 AM
10-01-2003 07:36 AM
I am trying to build a scrict that adds ftpusers. I am using the useradd command but I want to set the UID to use the next available over 1000. can this be done?
Solved! Go to Solution.
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2003 07:45 AM
10-01-2003 07:45 AM
Solution
do the following in your script.
useradd -u $(expr $(cat /etc/passwd|cut -d ':' -f3|sort -n|tail -1) + 1) ....
This will find the largest number in your /etc/passwd file and add one to it, then pass that value on to useradd. I do the same thing here. Of course this only does a one up. It will not fill in any empty spaces that are less then the max uid.
--Jim
useradd -u $(expr $(cat /etc/passwd|cut -d ':' -f3|sort -n|tail -1) + 1) ....
This will find the largest number in your /etc/passwd file and add one to it, then pass that value on to useradd. I do the same thing here. Of course this only does a one up. It will not fill in any empty spaces that are less then the max uid.
--Jim
"Everyone can be taught to sculpt: Michelangelo would have had to be taught how not to. So it is with the great programmers."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2003 07:51 AM
10-01-2003 07:51 AM
Re: useradd command
Add this line to your script:
cut -d: -f3 passwd | sort -n | awk -f nextuid.awk
nextuid.awk should contain:
-------------------------------------
BEGIN {previd=1000;}
$1>1000 {
if ($1-previd > 1)
{print previd+1; exit;}
previd=$1;
}
----------------------------------------
Best regards,
Kent M. Ostby
cut -d: -f3 passwd | sort -n | awk -f nextuid.awk
nextuid.awk should contain:
-------------------------------------
BEGIN {previd=1000;}
$1>1000 {
if ($1-previd > 1)
{print previd+1; exit;}
previd=$1;
}
----------------------------------------
Best regards,
Kent M. Ostby
"Well, actually, she is a rocket scientist" -- Steve Martin in "Roxanne"
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
Support
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP