How to create an alias for a user name on Linux?

You can't, reliably. Not all auth mechanisms allow for this, either natively or hacked-in.

Now if you don't mind it being an email alias, then just add a line to /etc/aliases and rebuild the alias DB.


What you looking for is an email alias, not an alias for the user name. Each user in Linux has one and only one name. However, setting up an email server is an entirely different matter. You can set up as many email accounts, with as many aliases to those accounts, as you like. Specifics of doing that are dependent on what your email package is.


Add john.smith user to /etc/passwd and set the same home and UID.


If you REALLY want to do this. Keep in mind that it's not natively supported nor is it a supported feature.

This is my suggestion:

create a new user and set his $HOME to point to the same directory, then use acl to make him the owner of that folder as well.

something along these lines:

given that user1 exists and userAlias is the new user I'm creating.

sudo useradd userAlias sudo setfacl -m u:userAlias:rwx -R /home/user1

so now userAlias can create files in user1's $HOME. This isn't a perfect solution.. you might have to run a cron to fix the permissions (ie make sure that all files have user and userAlias as the user).

You still have the problem of passwords not being in sync and other silliness to watch out for... but it's theoretically feasible with some ugly hacks.

note: facl is not always standard in all distributions and all kernels. It's been supported by the Linux kernel for ages.. but has been mostly ignored for a long time.