Adduser user mail
A simple one!
To add a new user with a mail alias in Linux, you can use the useradd
command followed by the name of the new user and the -m
option to create the user's home directory and set the mail alias.
Here's the syntax:
useradd -m -d /path/to/home/directory -s /bin/false -a /etc/aliases/user mail
Let me break it down:
useradd
: The command to add a new user.-m
: Create the user's home directory and set the mail alias.-d /path/to/home/directory
: Specify the path to the user's home directory.-s /bin/false
: Set the user's shell to/bin/false
(this is a common practice for mail-only accounts).-a /etc/aliases/user
: Set the mail alias to/etc/aliases/user
.
For example, to add a new user named "john" with a mail alias "john" and a home directory /home/john
, you would run:
useradd -m -d /home/john -s /bin/false -a /etc/aliases/john john
This will create a new user named "john" with a mail alias "john" and a home directory /home/john
. The -s /bin/false
option sets the user's shell to /bin/false
, which means they won't be able to log in interactively.
Note that you'll need to create the /etc/aliases
file and add the necessary entries for the mail alias to work.