Creating users and groups and forcing users to change them on the next login
One of the most common things you are going to do on Linux machines is create a lot of users. There is a way to avoid this by using a centralized database for user authentication, but in reality, this is used only on machines in large deployments, so local users are still prevalent in most cases.
Having a way to deploy users and assign them passwords is something every admin needs whenever deploying a new server or desktop.
Getting ready
This recipe calls for two things.
The script
has to be used with administrative privileges since it changes users on the system. Also, we need to prepare a file containing a user list in advance.
Before we show you our script, we must also mention that there is more than one way to read and parse a file when getting values for our scripts. It makes sense to try to understand different ways of doing this in order to up your scripting game. For this exact...