Unix stores account information in 2 files. These files are the password file /etc/passwd, and the shadow file /etc/shadow. Each user belongs to a group with this information being stored in /etc/group. Refer to the man pages for the purpose and format of these files. To successfully add a user, a line must be added to the password and shadow files. Because of the importance of these files to the systems operation, any production quality script should ensure that they are not corrupted by any circumstances during an update.
Your script MUST take the following arguments:
-P to specify the name of the password file to update.
-S to specify the name of the shadow file to update.
-G to specify the group file to consult.
Such arguments MAY be followed with:
-p to specify the new entry to be added to the password file.
-s to specify the entry to be added to the shadow password file
Do assign the default password for all the users created. This may take a bit more time, but don’t give up, do explore. Good luck!
Do check for errors, for example, if the user name entered already exist, then it should state that “User Exist! Try another Name”. Lastly in some circumstances you will have to make decisions. For example let’s say a home directory is specified that already exists and belongs to another user. What should you do here? This is a design decision – normally you would terminate with an error. What if the home directory does not exist? You would have to create it right? but also ensure the permissions are correct…All directories should be under /home – this is the norm.
In other words think about what could go wrong and try to handle it nicely… You should put comments in your code justifying your actions.
To test your files simply examine them and try to log in with a user you created.
can someone just explain to me then i start to implementing?
not really understand the question~
It looks like you are to write a UNIX shell script to handle user accounts on UNIX. Your instructor wants your script to write to the /etc/password (or a file with the same format); /etc/shadow (or a file with the same format); and the /etc/group file (or a file with the same format.)
Your instructor suggests that you should run the "man" command on these files and other UNIX commands to get ideas on how to approach your script.
Your instructor has given you lots of ideas on how to check for errors, and what errors you need to handle.
the user will auto add to
1 2 3
so i not really understand at your script to write to the /etc/password (or a file with the same format); /etc/shadow (or a file with the same format); and the /etc/group file (or a file with the same format.)