4

I have raspberry pi 2 with the latest raspian and I am trying to set up an FTP server using this guide.

I am stuck at the part of

useradd ftpuser -g ftpgroup -s /sbin/nologin –d
/dev/null

when I hit enter (as sudo or as pi) it prints me the usage:

Usage: useradd [options] LOGIN
       useradd -D
       useradd -D [options]

Options:
  -b, --base-dir BASE_DIR       base directory for the home directory of the
                                new account
  -c, --comment COMMENT         GECOS field of the new account
  -d, --home-dir HOME_DIR       home directory of the new account
  -D, --defaults                print or change default useradd configuration
  -e, --expiredate EXPIRE_DATE  expiration date of the new account
  -f, --inactive INACTIVE       password inactivity period of the new account
  -g, --gid GROUP               name or ID of the primary group of the new
                                account
  -G, --groups GROUPS           list of supplementary groups of the new
                                account
  -h, --help                    display this help message and exit
  -k, --skel SKEL_DIR           use this alternative skeleton directory
  -K, --key KEY=VALUE           override /etc/login.defs defaults
  -l, --no-log-init             do not add the user to the lastlog and
                                faillog databases
  -m, --create-home             create the user's home directory
  -M, --no-create-home          do not create the user's home directory
  -N, --no-user-group           do not create a group with the same name as
                                the user
  -o, --non-unique              allow to create users with duplicate
                                (non-unique) UID
  -p, --password PASSWORD       encrypted password of the new account
  -r, --system                  create a system account
  -R, --root CHROOT_DIR         directory to chroot into
  -s, --shell SHELL             login shell of the new account
  -u, --uid UID                 user ID of the new account
  -U, --user-group              create a group with the same name as the user
  -Z, --selinux-user SEUSER     use a specific SEUSER for the SELinux user mapping

I gave the whereis nologin and it printed

nologin: /usr/sbin/nologin /usr/share/man/man5/nologin.5.gz /usr/share/man/man8/nologin.8.gz

When I tried with /usr/sbin/nologin it gives me the same output.

What do I miss? How to check if the user created?

  • You can check if the user was created by doing the following cat /etc/passwd | grep ftpuser – Steve Robillard Dec 31 '15 at 13:52
  • 2
    Have you tried useradd -g ftpgroup -s /sbin/nologin –d /dev/null ftpuser? You might need to use sudo as well as useradd typically needs root priviliges. – Phil B. Dec 31 '15 at 13:52
  • to add to what @PhilB.posted the if you look at the usage details the first line the options all come before the username (i.e.LOGIN) – Steve Robillard Dec 31 '15 at 13:54
  • @PhilB. I just tried with both /sbin/nologin and /etc/sbin/nologin but I have the same problem. I checked with the cat /etc/passwd | grep ftpuser if the user created but it failed – trelozakinthinos Dec 31 '15 at 14:06
  • Ok but did you put the username at the end of the useradd statement as I suggested? Useradd will be successful even if the login shell location is incorrect (you'll just have a boatload of trouble trying to login as the user :) ) – Phil B. Dec 31 '15 at 14:43
1

Maybe you didn't notice (and I did have the same problem) but

useradd ftpuser -g ftpgroup -s /sbin/nologin –d /dev/null

has the - incorrectly before the d. I was able to notice this when trying it myself with my own raspberry pi (yes very annoying to notice that typo in an official help post of the raspberrypi page) so once you copy and paste it, replace that – before the d by the real -.

Problem side to side

–d | -d

If you change that it should work now. (or if you are too lazy just copy paste the fixed version that I placed below). I forgot to mention, in the raspberry you need sudo (root action) to create another user.

sudo useradd -g ftpgroup -s /sbin/nologin -d /dev/null ftpuser

OR

sudo useradd ftpuser -g ftpgroup -s /sbin/nologin -d /dev/null
  • 1
    For real??? Thank you man. That just work! Indeed it is annoying to find that kind of typo in official resource! – trelozakinthinos Jan 15 '16 at 21:55

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.