On Unix systems, you have your username, say "johnsmith", and your full name, "John Smith". That's it.

Now, suppose I want to use a nickname or two - something which isn't my username, but is in a lot of use. For example, "jsmith" may be a nickname/alias for "johnsmith".

Obviously, this information can't be saved in /etc/passwd. But - is there some idiomatic/commonly used method for indicating these nicknames?

  • 2
    Indicating them where & how? email? as sources/targets of cp or mv-type commands for files in home directories? As the output from 'list all users'? What about people who don't have "nicknames" set? – Jeff Schaller Jun 25 at 14:22
  • @JeffSchaller: The more context in which such nicknames can be used - the better. ~jsmith working instead of ~johnsmith; usernames to try or to suggest in apps, like email or IRC or other messaging; associations of artifacts labeled jsmith with johnsmith by other apps, I dunno... anything and everything. – einpoklum Jun 25 at 21:37
  • @JeffSchaller: About your latter questions: nicknames will not appear as additional users when listing all users; or rather - at most one name out of the set or "real" name and nicknames. As for people without nicknames - what about them? Of course no app and no utility requires you to have a nickname. – einpoklum Jun 25 at 21:39

Not very official but you could create a user with the other name but with the same settings (UID, GID, $HOME, password). That would allow you to use e.g. ~jsmith and ~johnsmith.

| improve this answer | |
  • 1. This would require root access; which is not a disqualifier, but not what I'm after . 2. It would be non-trivial (though quite doable) to lookup nicknames by user rather than user by nickname, with this approach. – einpoklum Jun 25 at 21:40
  • @einpoklum awk -F: '$6=="/home/johnsmith" { print $1; }' /etc/passwd seems trivial enough for me. Or awk -F: '$1!="johnsmith" && $6=="/home/johnsmith" { print $1; }' /etc/passwd if you want the aliases only without the main user. – Hauke Laging Jun 25 at 21:45
  • Well, I said "doable"... it's just that O(number of users) is non-trivial. Still, it's worth an upvote. – einpoklum Jun 25 at 22:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.