You need to rename a user from `jsmith` to `john.smith` on a server without breaking their files. How?
IntermediateScenarioUsers, groups and access control
Answer
Situation read → Change login name and home path, keep UID.
What I'd do →
- Make sure they are logged out:
pkill -u jsmith. - Run:
sudo usermod -l john.smith -d /home/john.smith -m jsmith
sudo groupmod -n john.smith jsmith
- Check crontabs (
/var/spool/cron/jsmithis renamed by some distros, not all), sudoers entries and any config referencing the old name.
Why → Files are owned by UID, not name, so keeping the UID means ownership stays correct.
Interview tip → Mention that NFS-shared homes need the same change on every host or the UID mapping breaks.
More on Users, groups and access control
You need to onboard 50 new developers onto a shared build server, each with their own account and SSH key. How do you do it?BeginnerThree teams share one server and each needs a project directory only its members can write to, with new files staying group-owned. How do you set it up?BeginnerA junior engineer needs to restart nginx but must not get full root. How do you grant that?BeginnerAn engineer leaves the company today. What do you do with their Linux account on 30 servers?BeginnerA service account for a backup tool must exist on every server but nobody should be able to log in as it. How do you create it?BeginnerYour security team requires passwords to expire every 90 days for human users only. How do you implement it?Beginner