Linux red hat удалить пользователя

3.4. Managing Users via Command-Line Tools

When managing users via command line, the following commands are used: useradd , usermod , userdel , or passwd . The files affected include /etc/passwd which stores user accounts information and /etc/shadow , which stores secure user account information.

3.4.1. Creating Users

The useradd utility creates new users and adds them to the system. Following the short procedure below, you will create a default user account with its UID, automatically create a home directory where default user settings will be stored, /home/username/ , and set the default shell to /bin/bash .

Run the following command at a shell prompt as root substituting username with the name of your choice:

By setting a password unlock the account to make it accessible. Type the password twice when the program prompts you to.

Example 3.1. Creating a User with Default Settings

~]# useradd robert ~]# passwd robert Changing password for user robert New password: Re-type new password: passwd: all authentication tokens updated successfully.

Running the useradd robert command creates an account named robert . If you run cat /etc/passwd to view the content of the /etc/passwd file, you can learn more about the new user from the line displayed to you:

robert:x:502:502::/home/robert:/bin/bash

robert has been assigned a UID of 502, which reflects the rule that the default UID values from 0 to 499 are typically reserved for system accounts. GID, group ID of User Private Group , equals to UID. The home directory is set to /home/robert and login shell to /bin/bash . The letter x signals that shadow passwords are used and that the hashed password is stored in /etc/shadow .

If you want to change the basic default setup for the user while creating the account, you can choose from a list of command-line options modifying the behavior of useradd (see the useradd (8) man page for the whole list of options). As you can see from the basic syntax of the command, you can add one or more options:

Читайте также:  Альт линукс менеджер пакетов

As a system administrator, you can use the -c option to specify, for example, the full name of the user when creating them. Use -c followed by a string, which adds a comment to the user:

useradd -c "string" username

Example 3.2. Specifying a User’s Full Name when Creating a User

~]# useradd -c "Robert Smith" robert ~]# cat /etc/passwd robert:x:502:502:Robert Smith:/home/robert:/bin/bash

A user account has been created with user name robert , sometimes called the login name, and full name Robert Smith.

If you do not want to create the default /home/username/ directory for the user account, set a different one instead of it. Execute the command below:

Example 3.3. Adding a User with non-default Home Directory

~]# useradd -d /home/dir_1 robert

If you do not want to create the home directory for the user at all, you can do so by running useradd with the -M option. However, when such a user logs into a system that has just booted and their home directory does not exist, their login directory will be the root directory. If such a user logs into a system using the su command, their login directory will be the current directory of the previous user.

If you need to copy a directory content to the /home directory while creating a new user, make use of the -m and -k options together followed by the path.

Example 3.4. Creating a User while Copying Contents to the Home Directory

The following command copies the contents of a directory named /dir_1 to /home/jane , which is the default home directory of a new user jane :

As a system administrator, you may need to create a temporary account. Using the useradd command, this means creating an account for a certain amount of time only and disabling it at a certain date. This is a particularly useful setting as there is no security risk resulting from forgetting to delete a certain account. For this, the -e option is used with the specified expire_date in the YYYY-MM-DD format.

Читайте также:  Запуск си файла через консоль линукс

Do not confuse account expiration and password expiration. Account expiration is a particular date, after which it is impossible to log in to the account in any way, as the account no longer exists. Password expiration, the maximum password age and date of password creation or last password change, is the date, when it is not possible to log in using the password (but other ways exist, such as logging in using an SSH key).

useradd -e YYYY-MM-DD username

Example 3.5. Setting the Account Expiration Date

User’s login shell defaults to /bin/bash , but can be changed by the -s option to any other shell different from bash, ksh, csh, tsh, for example.

useradd -s login_shell username

Example 3.6. Adding a User with Non-default Shell

The -r option creates a system account, which is an account for administrative use that has some, but not all, root privileges. Such accounts have a UID lower than the value of UID_MIN defined in /etc/login.defs , typically 500 and above for ordinary users.

Источник

Добавить и удалить пользователя в Redhat/Fedora/Centos

Добавить и удалить пользователя в Redhat/Fedora/Centos

Данную тему решил написать для новичков, кто не знает как пользоваться теми или иными командами и нужно например, добавить и удалить пользователя в Redhat/Fedora/Centos. Данная тема очень простая, я долго думал стоит ли ее вообще писать и озвучивать. Но решил помочь юным админам.

Сначала создадим пользователя и назначим мы ему пароль, делается это следующим образом:

# useradd captainua # passwd captainua

Чтобы удалить пользователя captainua (без удаления домашнего каталога) выполните команду:

Чтобы удалить пользователя captainua c удалением домашнего каталога выполните команду:

НО ПОМНИ! В директории могут храниться важные данные! Сделайте бэкапы.

Чтобы проверить реально ли мы удалили пользователя, можно выполнить команду:

# find / -user captainua -print

Надеюсь я помог юному поколению админов в моей статье «Добавить и удалить пользователя в Redhat/Fedora/Centos».

Добавить комментарий Отменить ответ

Этот сайт использует Akismet для борьбы со спамом. Узнайте, как обрабатываются ваши данные комментариев.

Читайте также:  Добавить виртуальный диск linux

Рубрики

  • Arch Linux (167)
  • Commands (36)
  • Debian’s (635)
    • Administration tools Ubuntu (37)
    • Backups Debian’s (7)
    • Database в Ubuntu (58)
    • Games (игры) (1)
    • Monitoring в Debian и Ubuntu (49)
    • Virtualization в Ubuntu / Debian/ Linux Mint (41)
      • Docker (22)
      • Kubernetes (6)
      • KVM (4)
      • OpenVZ (3)
      • Vagrant (5)
      • VirtualBox (6)
      • ArgoCD (1)
      • Concourse (1)
      • Gitlab (1)
      • Jenkinks (4)
      • Spinnaker (1)
      • Apache (32)
      • Cherokee (1)
      • FTP-services (5)
      • Lighttpd (1)
      • Nginx (26)
      • PHP (27)
      • Proxy для Debian’s (2)
      • Tomcat (4)
      • Панели управления в Ubuntu/Debian/Mint (24)
      • Установка и настройка почты на Ubuntu/Debian (12)
      • Хранилища (clouds) (2)
      • Administration tools freeBSD (19)
      • Database во FreeBSD (52)
      • Monitoring во freeBSD (37)
      • Virtualization во FreeBSD (22)
      • VoIP (1)
      • Установка Web сервисов (91)
      • Установка и настройка почты (6)
      • Установка из ports (пакетов) (19)
      • Установка из sorce code (исходников) (23)
      • Непрерывная интеграция (CI) (27)
      • Database в MacOS (36)
      • Monitoring в Mac OS (31)
      • Security (безопасность) (12)
      • Virtualization в Mac OS (30)
        • Docker (19)
        • Kubernetes (6)
        • Vagrant (5)
        • VirtualBox (5)
        • ArgoCD (1)
        • CircleCI (1)
        • Concourse (1)
        • Gitlab (1)
        • Jenkinks (4)
        • Spinnaker (1)
        • Administration tools CentOS (49)
        • Backups RPM’s (4)
        • Database в CentOS (68)
        • Monitoring в CentOS (67)
        • Virtualization в CentOS/ Red Hat/ Fedora (42)
          • Docker (23)
          • Kubernetes (6)
          • KVM (5)
          • OpenVZ (2)
          • Vagrant (5)
          • VirtualBox (6)
          • VMWare (3)
          • ArgoCD (1)
          • Concourse (1)
          • Gitlab (1)
          • Jenkinks (4)
          • Spinnaker (1)
          • Apache (35)
          • Cherokee (1)
          • DNS (3)
          • FTP (10)
          • Nginx (33)
          • PHP (34)
          • Proxy для RedHat’s (2)
          • Tomcat (2)
          • Voice (2)
          • Панели управления в CentOS/Red Hat/Fedora (27)
          • Прокси сервер на CentOS/RHEL/Fedora (4)
          • Установка и настройка почты на CentOS/RHEL/Fedora (14)
          • Хранилища (clouds) (1)

          соц сети

          Unix-Linux- в примерах

          Unix-Linux- в примерах

          Unix-Linux- в примерах

          Архив новостей

          Свежие записи

          Свежие комментарии

          • Глеб к записи Установка Adobe Flash Player в Debian/Ubuntu/Mint
          • Максим к записи Заблокировать User Agents используя Nginx
          • Денис к записи Как включить EPEL репозиторий на CentOS
          • Гость к записи Закомментировать/Раскомментировать строки vi/vim в Unix/Linux
          • Sergey к записи Установка и настройка OpenVPN сервера на Debian/Ubuntu/Linux Mint

          Источник

Оцените статью
Adblock
detector