- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Useradd script
Categories
Company
Local Language
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
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
Community
Resources
Forums
Blogs
- 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
04-26-2007 07:34 AM
04-26-2007 07:34 AM
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2007 07:45 AM
04-26-2007 07:45 AM
Re: Useradd script
2) Is it safe to assume that a user's UID is unique?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2007 07:51 AM
04-26-2007 07:51 AM
Re: Useradd script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2007 08:11 AM
04-26-2007 08:11 AM
Re: Useradd script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2007 08:25 AM
04-26-2007 08:25 AM
Solutionfirst make sure, that no new UID is already present in /etc/passwd of the new server.
Now extract the lines of the requested users from the original passwd to a file e.g. pw2add.
If the HOME will be different, modify pw2add.
Having transformed the file to the new system, it depends on whether you use plain passwd authentication or the tcb (trusted system).
For plain passwd this is enough:
cp /etc/passwd /etc/passwd.1
cat pw2add >>/etc/passwd
awk -F: '{print $3,$4,$6}' pw2add |
while read uid gid dir
do
mkdir -p $dir && chown $uid:$gid $dir
done
If your system is trusted, let us know.
Just appending to /etc/passwd is not enough in that case.
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2007 09:35 AM
04-26-2007 09:35 AM
Re: Useradd script
cat /etc/passwd |awk -F":" '$3 >= 1100 && $3 <= 2999 {print $1 ":" $2 ":" $3 ":"$4 ":" $5 ":" $6 ":" $7}' > pw2add
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2007 08:48 PM
04-26-2007 08:48 PM
Re: Useradd script
the command you want to use is possible ...
>> cat /etc/passwd |awk -F":" '$3 >= 1100 && $3 <= 2999 {print $1 ":" $2 ":" $3 ":"$4 ":" $5 ":" $6 ":" $7}' > pw2add
<<
... but I want to add some comments:
- No need for the 'cat' - awk can open files by itself:
awk -F":" '$3 >= 1100 && $3 <= 2999 {print $1 ":" $2 ":" $3 ":"$4 ":" $5 ":" $6 ":" $7}' /etc/passwd >pw2add
- Having exactly seven fields in the input file, there is no need to numerate the all explictly - the action can be simplified to
... {print $0} ...
wjich is identical to
... {print} ...
which is the default, so this is equivalent:
awk -F: '$3 >= 1100 && $3 <= 2999' /etc/passwd >pw2add
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2007 11:30 PM
04-26-2007 11:30 PM
Re: Useradd script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2007 01:48 AM
05-01-2007 01:48 AM
Re: Useradd script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2007 01:49 AM
05-01-2007 01:49 AM