There are basically two ways to look at this:
Never edit certain files without using the prescribed tools because you probably don't know what you're doing and that's ok because said tools know better and are always available.
More realistically, you might as well break it now while you're thinking about it so you can plan ahead with a backup copy and compare the differences after you do because basic knowledge about the ins and outs of your system's basic initial login
process is probably worth having for when you break it some other way later and said tools will not help you.
I guess you can probably tell which I recommend. I say that if a topic interests you even for a moment you might as well capitalize on that curiosity and gain a new skill while you're at it. Especially one such as this - the shadow
file is in a fairly basic format, and what little I know of it I learned after breaking it accidentally - and it wasn't the result of an edit I made to that file.
Rather my problem occurred after some other mistake with a package management database led the package manager to overwrite it without saving a backup and all users on the system were made kaput. Further ignorant bungling attempts at repairs only spread the damage to other related files and it wasn't long before I had to restore the majority of /etc
's text files from a (less recent than hoped-for) backup.
Once I had done so and verified I had it in workable state, I decided to deliberately, meticulously do it all again. And once more. This was all a few months ago, but today I remain confident that I can diagnose the source of a login
issue w/ a once-over of a single logfile on my system and address it with any basic editor (and provided, perhaps, a glance or two at man 5 problem_file
) provided only basic access to the root fs affected. It was not cheaply gained - it took me most of a day - and the related config files are spread all over the directory (and even some - such as Linux PAM's /var/run/no_login
- on other mounts) - but it was worth doing. And it could have been cheaper with a little forethought.
The moral of this story is that it is probably not a good thing that the format of mission-critical configs like shadow
, passwd
, groups
, shells
should be so opaque to us that we must employ special edit tools that may or may not correct our work in ways and for reasons we do not understand just to effect a simple change. At least, I think, it is worth our while to understand exactly what they would do differently than we might.
It probably is a good thing, however, that once we become familiar enough with editing said files that we run the risk of making within them and afterward saving to them typographical or simple syntactic errors that there are tools at our disposal which can double-check our work in ways and for reasons we already understand before applying our blase edits.
/etc/shadow
for over 20 years without a problem, ever. And please be so polite to read the two minute help→tour, especially the "no distractions", "no chit-chat". This is the first time I had to read through more non-relevant chit-chat in a question than read through question relevant "details".