8

For example, hot to set-up the system for john.smith and jsmith to be synonyms?

UPDATE: the reason is than I want a user to be registered in the system as jsmith and to have [email protected] email address.

4
  • To what end? Do you want both john.smith and jsmith to have the same permissions?
    – Tyler K
    Jul 9, 2010 at 4:29
  • Look into postfix aliases then (Or whatever mail server you're using). You don't need to mess around with OS level users to have a mail alias. If you want to share what mail server you're using, we can get you an actual answer with what you need to do.
    – csgeek
    Jul 13, 2014 at 15:38
  • SSH users: If you were doing this because you are annoyed at having to type the username when connecting to an ssh host... there is a renaming config for that stackoverflow.com/questions/10197559/…
    – Ray Foss
    Jul 6, 2017 at 15:19
  • Now a very old question, but I'm just going to add that in Linux two user accounts with the same UIDs are indeed the same accounts as the OS only cares about UIDs (e.g. in checking ownerships), but you CAN add multiple accounts with the same UIDs giving them different account names, specific passwords, specific home directories, specific shells, and also distinguish them in logs and audit trails, however, since it's an unsupported feature, it's risky/unpredictable to be used in a serious scenario. Read more about it in part 4.1.2 here: docstore.mik.ua/orelly/networking/puis/ch04_01.htm
    – aderchox
    Nov 27, 2021 at 5:53

4 Answers 4

9

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.

3
  • Yes yes, what I actually need is an email alias (but I have never heard of them before as I am just starting my Linux admin career). I need a user login as jsmith and have [email protected] email address.
    – Ivan
    Jul 9, 2010 at 4:50
  • So then add john.smith: jsmith. Jul 9, 2010 at 4:56
  • 1
    Not all MTA support /etc/aliases.
    – Warner
    Jul 9, 2010 at 13:16
4

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

3
  • 3
    I tried this approach. Not a good idea. It only served to completely confuse my OS
    – csgeek
    Dec 4, 2012 at 21:40
  • 2
    It may confuse the OS becuase it's against POSIX. It may or may not work.
    – Nowaker
    Dec 5, 2012 at 1:35
  • 3
    It works. If you try Bitnami's WordPress for Ubuntu 14.04 you can login using usernames ubuntu or bitnami. Basically in /etc/passwd you will find these lines bitnami:x:1000:1000:Ubuntu:/home/bitnami:/bin/bash and ubuntu:x:1000:1000::/home/bitnami:/bin/bash May 27, 2015 at 12:12
3

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.

2

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .