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.
#!/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
Something like that?