0

I am installing Linux on laptops of my friend's family. I want to create their accounts, with their names, log in to them to set a few things, then delete the password and have them be asked to set one when they first click their name.

I tried chage -d0 username, but that still asks for an original password.

I will need to repeat this process 2 more times on their other laptops, so I'd rather if it could be a shell script.

4
  • 2
    what is the 0S? and those accounts are standard ones are administrator ones? – UnKNOWn Dec 11 '19 at 20:08
  • At least on Ubuntu 19.10 you have that option when you create auser from the GUI. – schrodigerscatcuriosity Dec 11 '19 at 20:08
  • Found a dirty way, but as I'm not sure if it can have unnintentional consecuences (my gut says no), I'll just leave it in the comments. Once you created the user, set the password and change configs, etc, edit the file /etc/shadow, and in the user selected change the line to youruser::0:0:99999:7:::. The next login the user will be prompted to create a password instead of change it. Would be a good question IMO. – schrodigerscatcuriosity Dec 12 '19 at 20:08
  • Adressing my concerns: Why should you NEVER edit the /etc/shadow file directly?. Take a look at the answers and see if you will take the risks involved. – schrodigerscatcuriosity Dec 12 '19 at 20:20
1

From man passwd

   -e, --expire
       Immediately expire an account's password. This in effect can force
       a user to change his/her password at the user's next login.

so

 passwd -e user

On the next login the user will see :

Password: 
You are required to change your password immediately (administrator enforced)
Changing password for <user>.
Current password: 

The user must then enter their current password to create a new password that conforms with the password rules of the host.

3
  • Quote from my question: then delete the password and have them be asked to set one. I do not want to have to set any passwords for them and then have to tell them. I want them to set a password without entering the previous one – Tomáš Zato - Reinstate Monica Dec 12 '19 at 9:12
  • @TomášZato-ReinstateMonica Ah yes. That would be nice, I agree. Have you ever seen this on a Linux system? I have been entered to a number of unix systems through the years and always been given an initial password that expires -- my username or something simple like 'password' or 'admin'. that immediatly expires as above. – Stephen Boston Dec 12 '19 at 14:06
  • I haven't seen it, true. But I don't know as much about linux, so to me it looks as if everything was possible. I'll wait if maybe someone knows a trick, if not I'll keep the current solution, which is passwords same as usernames. – Tomáš Zato - Reinstate Monica Dec 12 '19 at 15:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.