- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- How to write a "useradd" bash program for me?
Operating System - Linux
1748198
Members
2580
Online
108759
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
Discussions
Discussions
Forums
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
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
тАО03-26-2008 11:58 PM
тАО03-26-2008 11:58 PM
How to write a "useradd" bash program for me?
don't use the standard command useradd.
thanks so much.
thanks so much.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-27-2008 01:04 AM
тАО03-27-2008 01:04 AM
Re: How to write a "useradd" bash program for me?
Hello,
why don't you want to use the standard program?? If you need to add useraccounts, but won't using "useradd", write a simple script. With a combination of "echo", "sed" and "awk" you can add or change lines to /etc/passwd and /etc/group. With "mkdir" you can create home directories, with "cp" you can copy files vom /etc/skel to the new created home directory. Don't forget to change the ownership and permission while using "chown" and "chmod".
Best regards,
Patrick
why don't you want to use the standard program?? If you need to add useraccounts, but won't using "useradd", write a simple script. With a combination of "echo", "sed" and "awk" you can add or change lines to /etc/passwd and /etc/group. With "mkdir" you can create home directories, with "cp" you can copy files vom /etc/skel to the new created home directory. Don't forget to change the ownership and permission while using "chown" and "chmod".
Best regards,
Patrick
Best regards,
Patrick
Patrick
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-27-2008 12:04 PM
тАО03-27-2008 12:04 PM
Re: How to write a "useradd" bash program for me?
This sounds suspiciously like a homework question one of my fellow instructors likes to assign to his scripting class.
Anyhow, the trick here to start is to build a script that will accept various arguments. Then take each argument and put them into an echo line something like this:
echo $1:x:$2:$3:$4:$5:$6 >> /etc/passwd
where 1 is the username, 2 is the UID, 3 is the GID, 4 is the LYCOS field, 5 is the root path, and 6 is the startup shell.
You would then enter something like this at your command line:
$ ./myscript username 222 333 stuff /home/username /sbin/sh
And, if everything works right (this example probably has a few tweaks in it that need fixing), the last line of the password file should look like this:
username:x:222:333:stuff:/:/sbin/sh
Anyhow, the trick here to start is to build a script that will accept various arguments. Then take each argument and put them into an echo line something like this:
echo $1:x:$2:$3:$4:$5:$6 >> /etc/passwd
where 1 is the username, 2 is the UID, 3 is the GID, 4 is the LYCOS field, 5 is the root path, and 6 is the startup shell.
You would then enter something like this at your command line:
$ ./myscript username 222 333 stuff /home/username /sbin/sh
And, if everything works right (this example probably has a few tweaks in it that need fixing), the last line of the password file should look like this:
username:x:222:333:stuff:/:/sbin/sh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-28-2008 02:26 AM
тАО03-28-2008 02:26 AM
Re: How to write a "useradd" bash program for me?
within redhat you can use a utility called
newusers
Go to the following link to see how it works
http://kbase.redhat.com/faq/FAQ_43_4400.shtm
newusers
Go to the following link to see how it works
http://kbase.redhat.com/faq/FAQ_43_4400.shtm
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.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP