hey /g/
so im pretty new into the whole Linux/shell script thing. and so ive been practicing making shell scripts. now im trying to create a shell script that adds new user. ive done most of the script and it all runs fine except the password part. whenever a new user is created i cant login in with the password, it always returns with incorrect password error. any thoughts and help?
also no bully pls
and stop anything else please do tell xo
>>52018881
I think #bash (the bash channel) on freenode is a better place to ask cuz they know bash inside out and they have good documentation. You can use Xchat to get on freenode.
also the code if you want it or want to add something to it
clear
if [ "$EUID" -ne 0 ]
then echo "Please run as root"
exit
fi
while [ x$username = "x" ]; do
read -p "Please enter the username you wish to create: " username
read -s -p "Enter password: " password
if id -u $username >/dev/null 2>&1; then
echo "User already exists"
username=""
fi
done
while [ x$group = "x" ]; do
read -p "Please enter the group you would like to be in. If that group doesn't exist it will be made: " group
if id -g $group >/dev/null 2>&1; then
echo "Group exist"
else
groupadd $group
fi
done
read -p "Please confirm [y/n] " confirm
if [ "$confirm" = "y" ]; then
useradd -g $group -m $username
chage -d 0 $username
fi
exit
>>52018957
ill try that too. thanks
>>52018881
To see if the password is being inputted correctly, add in a:echo $password >> $HOME/Password
See if there's an extra space being added in or something.
>>52018881
You need -r with read to read in the password and username otherwise backslashes will get mangled. Also you should quote the variable names to prevent word splitting. Please visit #bash if you are serious about shell.
https://github.com/koalaman/shellcheck/wiki/SC2034
shellcheck.net
no one is helping m3 :(
>>52019158
Are you fucking blind?
>>52019158
My negro friend, please look at this post >>52019131
>>52019212
>>52019168
>>52019158
im sorry guys the internet is being a little weird :) ;( :)()(:( :):D
>>52019275
It's okay anon.
>>52019021
can you post on pastebin where to put it?
>>52018957
>You can use Xchat to get on freenode.
Weechat or issr is better because it's like a command line interface. Which is more good looking.
>>52019293
>not same fag
Really? You're just going to output that fucking password to a file so you can read it, after running the fucking script.
If that doesn't make sense, go read a book.
>>52019312
>Weechat
i just need help desu
>>52019312
Yeah, weechat is nice.
>>52019293
You can put it at the end of the script.
>>52019561
ill try that now brother
>>52019343
Don't worry, we can probably help you. but you might check out IRC. Tried it out recently again for first time in like 15-17 years and people still use it. mostly tech people, programmers, hackers and that sort of thing, but great for real time tech help.
>>52018881
https://fixubuntu.com
thanks for all the new resources brothers and sisters
why are you putting x in front of the variables for the condition check?
>>52019757
honestly, i dont know. i found some of the code online.
>>52018881
>using nano unironically
>>52019867
thanks senpai
>>52019312
>not using ERC
ive fixed it. thank you bros :)