Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 75a39ab

Browse files
useradd
1 parent 3223772 commit 75a39ab

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

‎linux/users.md‎

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# User Account Management:
2+
## Table of Contents:
3+
## Intro:
4+
- This chapter is
5+
6+
## Creating User Accounts:
7+
### `useradd`:
8+
- Managing user accounts through CLI have multiple advantages over doing the same thing in a GUI. GUIs are nottt always available, especially in the case of servers. CLI also allows you to automate user account management so you can add , remove, mod users in bulk and automatically if needed.
9+
- The **`useradd`** command which requires root privileges adds a new user to the system. It has one required parameter, the username, and the rest is optional:
10+
```sh
11+
sudo useradd somebody1
12+
```
13+
- `useradd` also takes a variety of options which include:
14+
15+
| Option | Description |
16+
| --- | --- |
17+
| **`-c "Mustapha K3ik3a"`** | Used to provide a description of the accountt. Used mostly for user full name. |
18+
| **`-d "somewhre/user123"`** | Provides a custom home directory. Instead of `/home/somebody1`, the home directory is what you specify as an argument to this option. |
19+
| **`-D`** | When invoked by itself, it displays default values for all newly created accounts. If invoked with other options, it changes such default values. |
20+
| **`-e 2222年12月22日`** | Expiry date of the account. |
21+
| **`-f -1`** | Set number of days after password expiry until account is permanently deleted. The default is `-1` which probably means the system will use some default value stored in some `/etc/default/useradd` file. If you set this to `0` the account is disabled as soon as the password expires. Setting this t `2` disables the account 2 days after the expiry of the password. |
22+
| **`-g somegroup`** | Sets the an existing group as the primary group of the new user. If not set a new group with the user's name is created. |
23+
| **`-G wheel,sales,tech`** | Add the user to a list of additional groups |
24+
| **`-k skel_dir`** | Sets/copies an initial directory skeleton to the new user's home directory containing initial configuration files. If not set, **`/etc/skel/`**. This must be used with the `-m` option |
25+
| **`-m`** | Automatically creates a home directory for the new user and optionally copies `/etc/skel` to it. This is the default in Fedora but not in Ubuntu. |
26+
| **`-M`** | Do not create a new user home directory even if the default states so! |
27+
| **`-p passwd`** | Allows you to enter a password for the account. |
28+
| **`-s /bin/bash`** | Specifies the default shell of the new account |
29+
| **`-u user_id`** | Specifies a user id (UID) instead of having it generated automatically. |
30+
31+
- If you haven't provided a password to the new user at the time of account creation, you can do so with the following command:
32+
```sh
33+
sudo passwd somebody1
34+
```
35+
- When you run `useradd` a lot of things happen which have to do with a lot of configuration files we have seen earlier:
36+
1. Reads configuration files `/etc/logins.defs` and `/etc/useradd` to get default values for creating new user accounts.
37+
2. Run through command options and arguments to find which default values to override.
38+
3. Create a new user entry in `/etc/passwd` (users) and `/etc/shadow` (passwords) based on default values and provided parameters.
39+
4. Might create new group entries in `/etc/group`.
40+
5. Creates user home directory, by default in `/home`.
41+
6. Copies some skeleton to the user's home directory which is `/etc/skel` if no alternative is provided.
42+
- Ubuntu actually offers an easier way to add a new user. It is an interactive and more user-friendly and spares you the need to enter a lengthy blob of options. It is **`adduser`**.
43+
- ***I have also begun to realize a few things about all the configuration business and how it works!! I used to hate having to reconfigure stuff, but I kinda started liking it. I seems to me like I can just add user by simply modifying some of configuration files like `/etc/passwd` although I'm aware that is not the recommended.***
44+
45+
### User Defaults:
46+
- `usermod` can also be used to inspect and modify user creation defaults. This is done by the very special option we've seen in the table above **`-D`**:
47+
```sh
48+
useradd -D
49+
```
50+
- The command above displays the current `useradd` defaults which are stored in `/etc/default/useradd`. With other options, you can change these default. Let's change the default home directory with the following command:
51+
```sh
52+
useradd -D -b /home/users
53+
```
54+
- This command change the base directory where user home directories are placed from `/home` to `/home/users`.
55+
- You can also change some other defaults by modifying the `/etc/logins.defs` which also control age of passwords, their minimum lengths and many other things.
56+
- As an admin, you can also create default files that you want added to new user accounts and whatnot.s
57+
58+
59+
### `usermod`:
60+
### `userdel`:
61+
62+
## Group Accouns:
63+
## Managing User Accounts in a Complex Environment:
64+
## Centralizing User Accounts:

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /