sábado, 8 de septiembre de 2012

Creación usuarios en Linux


Para la creacion de usuarios en linux se tienen 2 comandos.

adduser nombre_usuario: crea un usuario pidiendo los datos de este paso a paso

User ID: (por defecto tomo desde el 1001 en adelante siendo el 1000 el super usuario)
Initial group: (por defecto esta el grupo users)
Home directory: (por defecto crea una carpeta en /home/nombre_usuario)
Shell: (la manera de manejar la consola, por defecto usa el bash)
Expiry date: (se le asigna una fecha de ezpiracion al usuario)

despues viene la informacion personal del nuevo usuario

Full Name:
Room Number:
Work Phone:
Home Phone:
Other:
por ultimo viene la parte del Password, el cual debe ser robusto y se digita 2 veces por seguridad

useradd [Opciones]
este comando cuenta con unas opciones para personalizar mas el usuario, no lo crea
automaticamente pidiendo los datos como el adduser

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

ahora algunos ejemplos de este comando


  • useradd -s /bin/nologin hiox (se crea el usuario hiox al cual no se le permite acceder a la terminal gracias al comando nologin del shell)
  • useradd -M -e 2012-09-28 jose (se crea al usuario jose con la opcion Mse le restringe la creacion de la carpeta personal y se le asigna una fecha de caducidad al usuario)
  • useradd -g users -s /bin/bash  lore (se crea un usuario asignandole el grupousers dandole permiso a la consola con el bash)
  • useradd -g adminitradores -m /home/pepe pedro (se crea un usuario llamado pedroen el grupo administradores y se le crea un directorio personalizado llamado pepe)
  • passwd lore (con este comando le asignamos una contrase;a al usuario)


los usuario que emos creado se peuden ver en un archivo llamado passwd en la carpeta etc podemos usar el comando "nano /etc/passwd" para ver el archivo o el comando "who"

para eliminar un usuario del sistema se usa "dell user"
para modificar un suario se usa el comando ussermod [Opciones]

Options:
  -c, --comment COMMENT         new value of the GECOS field
  -d, --home HOME_DIR           new home directory for the user account
  -e, --expiredate EXPIRE_DATE  set account expiration date to EXPIRE_DATE
  -f, --inactive INACTIVE       set password inactive after expiration
                                to INACTIVE
  -g, --gid GROUP               force use GROUP as new primary group
  -G, --groups GROUPS           new list of supplementary GROUPS
  -a, --append                  append the user to the supplemental GROUPS
                                mentioned by the -G option without removing
                                him/her from other groups
  -h, --help                    display this help message and exit
  -l, --login NEW_LOGIN         new value of the login name
  -L, --lock                    lock the user account
  -m, --move-home               move contents of the home directory to the
                                new location (use only with -d)
  -o, --non-unique              allow using duplicate (non-unique) UID
  -p, --password PASSWORD       use encrypted password for the new password
  -s, --shell SHELL             new login shell for the user account
  -u, --uid UID                 new UID for the user account
  -U, --unlock                  unlock the user account

ejemplos

  • usermod -d -m /home/nuevodirectorio usuario (mueve la carpeta del usuario a un nuevo directorio)
  • usermod -s -s /bin/nologin lore (le quita el permiso para acceder a la consola al usuario lore)

No hay comentarios:

Publicar un comentario