What do the `--disabled-login` and `--gecos` options of `adduser` command stand for?
Running Ubuntu 12.04, I setup a private git server and created a group called git some time ago. Now I am following a guide to install gitlab and when it came to adding a user to the git group and create it, I saw that I already had it.
The command is this:
sudo adduser --disabled-login --gecos 'GitLab' git
taken from Gitlab installation Tutorial.
I would like to understand that command correctly. For me I thought I add a user to a group like this:
adduser user group
So what do --disabled-login
and --gecos
stand for?
It's all written in the manual page!
You don't need to install something, to search on google or to have an internet connection. Just open your terminal and first of all you must to run the following command:
man adduser
to open the manual page for adduser
command.
Then, in that manual page type: /--disabled-login
followed by Enter then press repetitively n to find all occurrences containing --disabled-login
. Do the same for --gecos
.
With a little bit of luck you will find out that:
--disabled-login Do not run passwd to set the password. The user won't be able to use her account until the password is set.
and:
--gecos GECOS Set the gecos field for the new entry generated. adduser will not ask for finger information if this option is given.
For those wondering what gecos actually is, wikipedia defines it as follows:
The gecos field, or GECOS field is an entry in the /etc/passwd file on Unix, and similar operating systems. It is typically used to record general information about the account or its user(s) such as their real name and phone number.
--disabled-login
, which is similar to --disabled-password
, is used to create the user account without any password and to avoid prompting for it. This is to avoid any attempt to log in as git
on your Git server. The reason for this is that you're not supposed to log in to it directly, you're supposed to interact with it via git
commands only.
--gecos
sets additional information about the user you're creating (and doesn't have anything particular with git to do). It's not in much use these days. If you set gecos values for an account, other users can read that information using the finger
command so they can get more information about him/her/it. You can also set it separately with the chfn
command. The --gecos
switch is intended to be followed by five comma-separated values which serves as additional comments about the user. The values are:
- Full name
- Room number
- Work phone
- Home phone
- Other
You can leave out any value and skip the ends, for example --gecos 'Donald Trump,3'
would work, as would 'Donald Trump,3,,,President'
.
The main reasons why you're asked to use the --gecos
option is, I guess, to avoid prompts for these values, they are just annoying and don't make much sense these days, and may actually be a security risk. Never put your personal data here!