24

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?

28

It's all written in the manual page!

enter image description here

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.

| improve this answer | |
  • 2
    damn never knew about that kind of manual. Thank you sir. – Private Feb 14 '14 at 13:32
  • 41
    Actually GECOS is really badly explained in the manpage. It's the part where it asks for real name, phone etc. en.wikipedia.org/wiki/Gecos_field – benjaoming Jan 11 '16 at 14:55
  • 14
    This answers does not explain what gecos is. I came here looking for this info too. Nor does it explain that --disabled-login does not actually disable login as the man implies. it just disables login via password. It is usually used when you set the certificate for cert based ssh login. – John Little May 22 '18 at 17:59
  • I actually used GCOS systems way back in the day, so seeing this field brings back memories of being a carefree if very geeky high school senior. :-) – fool4jesus Oct 25 '18 at 20:47
  • What a terrible answer. I specifically came here because the format for the GECOS option was not sufficiently explained in the manpage. – Rörd Sep 3 '19 at 13:41
2

--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:

  1. Full name
  2. Room number
  3. Work phone
  4. Home phone
  5. 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!

| improve this answer | |
  • has anyone got a good way of making that the default? Ah it was simple: alias adduser='adduser --gecos ""' – wuxmedia Jun 26 at 10:14
  • Sure. Another way to do it would be to just download Linux source code, update adduser and recompile. Both alternatives are probably equally bad. My point is, adduser should behave in a standard way since it heavily affects security. And aliases are typically set individually by each user. Which user should set this alias? – Rein Jun 27 at 16:20
  • root should, being the only user who can create users? Yes aliases are not the best answer, slightly better than recompiling or mashing enter 5 times. – wuxmedia Jun 28 at 14:55
  • I hope you caught my irony about recompilation! If you add just a few users I think those extra presses on the same key (enter) still is quicker than adding an alias to /root/.bashrc. If in fact you have tons of users to add regularly, I guess you have their names in some file anyway so you could write a short bash script that feeds them to adduser or maybe even better useradd (perhaps you need to tweak a bit with awk and sed). This way you avoid confusing other administrators who runs adduser. Still, I doubt this is a big issue, off topic and doesn't add any value to the original question. – Rein Jun 29 at 17:42

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.