•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Shell Scripting section within the Software Development category of DaniWeb, a massive community of 456,441 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,607 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Shell Scripting advertiser: Programming Forums
Views: 7738 | Replies: 0 | Solved
![]() |
•
•
Join Date: Oct 2007
Posts: 31
Reputation:
Rep Power: 2
Solved Threads: 0
This is my first time writing a bash script in Linux, basically I want to create a user but not use adduser or useradd.
So, in the /etc/passwd folder I need to put data in, in this way.
login:encrypted passwd:UID:GID:gecos:home directory:login shell
I'm going to leave the gecos blank.
Then I need to do something with the /etc/shadow folder, something with the encrypted password, adding it to it.
And finally, giving the person the startup files and doing a chmod to them, maybe 700 or 711, I'm not sure the difference. Also I know cp copies in Linux, but I don't know what startup files should be given to the user.
I'm at a standstill, I need to find the last used UID and add 1 to it, and I guess I'll make that the GID too. I've got the home directory made in the script, and the login shell. I'm sure you can also see I don't really know how to use crypt, I couldn't find a nice easy example anywhere, anytime I found an example I couldn't even see where they were encrypting something.
To add these things to /etc/passwd and etc/shadow would I just pipe it?
Something like that?
So, in the /etc/passwd folder I need to put data in, in this way.
login:encrypted passwd:UID:GID:gecos:home directory:login shell
I'm going to leave the gecos blank.
Then I need to do something with the /etc/shadow folder, something with the encrypted password, adding it to it.
And finally, giving the person the startup files and doing a chmod to them, maybe 700 or 711, I'm not sure the difference. Also I know cp copies in Linux, but I don't know what startup files should be given to the user.
#!/bin/bash # This script will set up a user account. echo "What do you want your account name to be?" read login echo "What do you want your password to be?" read password char *crypt(const char *password, const char *salt); hdirectory = mkdir /home/$login shell = /bin/bash
I'm at a standstill, I need to find the last used UID and add 1 to it, and I guess I'll make that the GID too. I've got the home directory made in the script, and the login shell. I'm sure you can also see I don't really know how to use crypt, I couldn't find a nice easy example anywhere, anytime I found an example I couldn't even see where they were encrypting something.
To add these things to /etc/passwd and etc/shadow would I just pipe it?
user = login:password:UID:GID::hdirectory:shell user | /etc/passwd shadow = password shadow | /etc/shadow
![]() |
•
•
•
•
•
•
•
•
DaniWeb Shell Scripting Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
apple bbc cd cellphone choose computer core debian dell desktop development enterprise fedora games garnet gentoo gpl hardware ibm infrastructure install kernel laptop linux microsoft mobile news novell open open source openbsd openoffice operating os palm palmos red hat scripting security server source sun suse system ubuntu unix vista web web development windows
- Puppy Linux Live multi-session cd (Getting Started and Choosing a Distro)
- The 10 Minute Linux Firewall (Linux Tutorials)
- Creating XP User Groups (C#)
- Linux for my PC (Getting Started and Choosing a Distro)
- need help creating user defined SQL statement (ASP.NET)
- Need help on what linux to get. (Getting Started and Choosing a Distro)
- Windows vs Linux (Linux Users Lounge)
Other Threads in the Shell Scripting Forum
- Previous Thread: script to query records from mysql and send emails?
- Next Thread: Compare two dates using Shell Programming


Linear Mode