reworking content
All checks were successful
learn org at code.softwareshinobi.com/linux.softwareshinobi.com/pipeline/head This commit looks good
All checks were successful
learn org at code.softwareshinobi.com/linux.softwareshinobi.com/pipeline/head This commit looks good
This commit is contained in:
67
landing/docs/Commands/users/chmod.md
Normal file
67
landing/docs/Commands/users/chmod.md
Normal file
@@ -0,0 +1,67 @@
|
||||
# The `chmod` command
|
||||
|
||||
The `chmod` command allows you to change the permissions on a file using either a symbolic or numeric mode or a reference file.
|
||||
|
||||
### Examples:
|
||||
|
||||
1. Change the permission of a file using symbolic mode:
|
||||
|
||||
```
|
||||
chmod u=rwx,g=rx,o=r myfile
|
||||
```
|
||||
|
||||
The command above means :
|
||||
|
||||
- user can read, write, execute `myfile`
|
||||
- group can read, execute `myfile`
|
||||
- other can read `myfile`
|
||||
|
||||
2. Change the permission of a file using numeric mode
|
||||
|
||||
```
|
||||
chmod 754 myfile user:group file.txt
|
||||
```
|
||||
|
||||
The command above means :
|
||||
|
||||
- user can read, write, execute `myfile`
|
||||
- group can read, execute `myfile`
|
||||
- other can read `myfile`
|
||||
|
||||
3. Change the permission of a folder recursively
|
||||
|
||||
```
|
||||
chmod -R 754 folder
|
||||
```
|
||||
|
||||
### Syntax:
|
||||
|
||||
```
|
||||
chmod [OPTIONS] MODE FILE(s)
|
||||
```
|
||||
|
||||
- `[OPTIONS]` :
|
||||
`-R`: recursive, mean all file inside directory
|
||||
|
||||
- `MODE`: different way to set permissions:
|
||||
|
||||
- **Symbolic mode explained**
|
||||
|
||||
- u: user
|
||||
- g: group
|
||||
- o: other
|
||||
- =: set the permission
|
||||
- r: read
|
||||
- w: write
|
||||
- x: execute
|
||||
- example `u=rwx` means user can read write and execute
|
||||
|
||||
- **Numeric mode explained**:
|
||||
|
||||
The **numeric mode** is based off of a binary representation of the permissions for user, group, and others, for more information please look at this [explanation](https://www.digitalocean.com/community/tutorials/linux-permissions-basics-and-how-to-use-umask-on-a-vps#types-of-permissions) from Digital Ocean's community section:
|
||||
|
||||
- 4 stands for "read",
|
||||
- 2 stands for "write",
|
||||
- 1 stands for "execute", and
|
||||
- 0 stands for "no permission."
|
||||
- example 7 mean read + write + execute
|
||||
36
landing/docs/Commands/users/chown.md
Normal file
36
landing/docs/Commands/users/chown.md
Normal file
@@ -0,0 +1,36 @@
|
||||
# The `chown` command
|
||||
|
||||
The `chown` command makes it possible to change the ownership of a file or directory. Users and groups are fundamental in Linux, with `chown` you can
|
||||
change the owner of a file or directory. It's also possible to change ownership on folders recursively
|
||||
|
||||
### Examples:
|
||||
|
||||
1. Change the owner of a file
|
||||
|
||||
```
|
||||
chown user file.txt
|
||||
```
|
||||
|
||||
2. Change the group of a file
|
||||
|
||||
```
|
||||
chown :group file.txt
|
||||
```
|
||||
|
||||
3. Change the user and group in one line
|
||||
|
||||
```
|
||||
chown user:group file.txt
|
||||
```
|
||||
|
||||
4. Change to ownership on a folder recursively
|
||||
|
||||
```
|
||||
chown -R user:group folder
|
||||
```
|
||||
|
||||
### Syntax:
|
||||
|
||||
```
|
||||
chown [-OPTION] [DIRECTORY_PATH]
|
||||
```
|
||||
40
landing/docs/Commands/users/deluser.md
Normal file
40
landing/docs/Commands/users/deluser.md
Normal file
@@ -0,0 +1,40 @@
|
||||
# The `deluser` command
|
||||
|
||||
The `deluser` command is used to delete a user account and related files
|
||||
|
||||
## Command Demo
|
||||
|
||||
<video src="/videos/commands/the-deluser-command.mp4" width="640" height="480" controls></video>
|
||||
|
||||
## Delete User
|
||||
|
||||
To delete a user with the `deluser` command the syntax would be the following:
|
||||
|
||||
```
|
||||
deluser userName
|
||||
```
|
||||
|
||||
## Delete User & Home Directory
|
||||
|
||||
To delete a user along with the files in the user’s home directory using the `deluser` command the syntax would be the following:
|
||||
|
||||
```
|
||||
deluser --remove-home userName
|
||||
```
|
||||
|
||||
## Basic Syntax:
|
||||
|
||||
```
|
||||
deluser [options] [--force] [--remove-home] [--remove-all-files]
|
||||
[--backup] [--backup-to DIR] user
|
||||
|
||||
```
|
||||
|
||||
## Possible Options:
|
||||
|
||||
|**Flag** |**Description** |
|
||||
|:---|:---|
|
||||
|`-f`|Force the removal of the specified user account even if the user is logged in|
|
||||
|`-r`|Remove the files in the user’s home directory along with the home directory itself and the user’s mail spool|
|
||||
|`-Z`|Remove any SELinux(Security-Enhanced Linux) user mapping for the user’s login.|
|
||||
|
||||
45
landing/docs/Commands/users/groups.md
Normal file
45
landing/docs/Commands/users/groups.md
Normal file
@@ -0,0 +1,45 @@
|
||||
# The `groups` command
|
||||
|
||||
In Linux, there can be multiple users (those who use/operate the system), and groups (a collection of users).
|
||||
Groups make it easy to manage users with the same security and access privileges. A user can be part of different groups.
|
||||
|
||||
Important Points:
|
||||
|
||||
The `groups` command prints the names of the primary and any supplementary groups for each given username, or the current process if no names are given.
|
||||
If more than one name is given, the name of each user is printed before the list of that user’s groups and the username is separated from the group list by a colon.
|
||||
|
||||
### Syntax:
|
||||
|
||||
```
|
||||
groups [username]
|
||||
```
|
||||
|
||||
#### Example 1
|
||||
|
||||
Provided with a username
|
||||
|
||||
```
|
||||
groups demon
|
||||
```
|
||||
|
||||
In this example, username demon is passed with groups command and the output shows the groups in which the user demon is present, separated by a colon.
|
||||
|
||||
#### Example 2
|
||||
|
||||
When no username is passed then this will display the group membership for the current user:
|
||||
|
||||
```
|
||||
groups
|
||||
```
|
||||
|
||||
Here the current user is demon . So when we run the `groups` command without arguments we get the groups in which demon is a user.
|
||||
|
||||
#### Example 3
|
||||
|
||||
Passing root with groups command:
|
||||
|
||||
```
|
||||
$demon# groups
|
||||
```
|
||||
|
||||
> Note: Primary and supplementary groups for a process are normally inherited from its parent and are usually unchanged since login. This means that if you change the group database after logging in, groups will not reflect your changes within your existing login session. The only options are –help and –version.
|
||||
55
landing/docs/Commands/users/passwd.md
Normal file
55
landing/docs/Commands/users/passwd.md
Normal file
@@ -0,0 +1,55 @@
|
||||
|
||||
# The `passwd` command
|
||||
|
||||
In Linux, `passwd` command changes the password of user accounts. A normal user may only change the password for their own account, but a superuser may change the password for any account.
|
||||
`passwd` also changes the account or associated password validity period.
|
||||
|
||||
|
||||
## Example
|
||||
|
||||
```bash
|
||||
$ passwd
|
||||
|
||||
```
|
||||
|
||||
|
||||
## The syntax of the `passwd` command is :
|
||||
|
||||
```bash
|
||||
$ passwd [options] [LOGIN]
|
||||
|
||||
```
|
||||
## options
|
||||
|
||||
```bash
|
||||
-a, --all
|
||||
This option can be used only with -S and causes show status for all users.
|
||||
|
||||
-d, --delete
|
||||
Delete a user's password.
|
||||
|
||||
-e, --expire
|
||||
Immediately expire an account's password.
|
||||
|
||||
-h, --help
|
||||
Display help message and exit.
|
||||
|
||||
-i, --inactive
|
||||
This option is used to disable an account after the password has been expired for a number of days.
|
||||
|
||||
-k, --keep-tokens
|
||||
Indicate password change should be performed only for expired authentication tokens (passwords).
|
||||
|
||||
-l, --lock
|
||||
Lock the password of the named account.
|
||||
|
||||
-q, --quiet
|
||||
Quiet mode.
|
||||
|
||||
-r, --repository
|
||||
change password in repository.
|
||||
|
||||
-S, --status
|
||||
Display account status information.
|
||||
|
||||
```
|
||||
43
landing/docs/Commands/users/useradd.md
Normal file
43
landing/docs/Commands/users/useradd.md
Normal file
@@ -0,0 +1,43 @@
|
||||
# The `useradd` command
|
||||
|
||||
The `useradd` command is used to add or update user accounts to the system.
|
||||
|
||||
### Examples:
|
||||
|
||||
To add a new user with the `useradd` command the syntax would be the following:
|
||||
|
||||
```
|
||||
useradd NewUser
|
||||
```
|
||||
|
||||
To add a new user with the `useradd` command and give a home directory path for this new user the syntax would be the following:
|
||||
|
||||
```
|
||||
useradd -d /home/NewUser NewUser
|
||||
```
|
||||
|
||||
To add a new user with the `useradd` command and give it a specific id the syntax would be the following:
|
||||
|
||||
```
|
||||
useradd -u 1234 NewUser
|
||||
```
|
||||
|
||||
### Syntax:
|
||||
|
||||
```
|
||||
useradd [OPTIONS] NameOfUser
|
||||
```
|
||||
|
||||
### Possible options:
|
||||
|
||||
|**Flag** |**Description** |**Params** |
|
||||
|:---|:---|:---|
|
||||
|`-d`|The new user will be created using /path/to/directory as the value for the user's login directory|/path/to/directory|
|
||||
|`-u`|The numerical value of the user's ID|ID|
|
||||
|`-g`|Create a user with specific group id|GroupID|
|
||||
|`-M`|Create a user without home directory|-|
|
||||
|`-e`|Create a user with expiry date|DATE (format: YYYY-MM-DD)|
|
||||
|`-c`|Create a user with a comment|COMMENT|
|
||||
|`-s`|Create a user with changed login shell|/path/to/shell|
|
||||
|`-p`|Set an unencrypted password for the user|PASSWORD|
|
||||
|
||||
80
landing/docs/Commands/users/usermod.md
Normal file
80
landing/docs/Commands/users/usermod.md
Normal file
@@ -0,0 +1,80 @@
|
||||
# The `usermod` command
|
||||
|
||||
The `usermod` command lets you change the properties of a user in Linux through the command line. After creating a user we sometimes have to change their attributes, like their password or login directory etc. So in order to do that we use the `usermod` command.
|
||||
|
||||
### Syntax:
|
||||
|
||||
```
|
||||
usermod [options] USER
|
||||
```
|
||||
|
||||
#### Note : Only superuser (root) is allowed to execute `usermod` command
|
||||
|
||||
### Options and their Functionalities:
|
||||
|
||||
|**Option** |**Description** |
|
||||
|:---|:---|
|
||||
|`-a`|to add anyone of the group to a secondary group|
|
||||
|`-c`|to add comment field for the useraccount|
|
||||
|`-d`|to modify the directory for any existing user account|
|
||||
|`-g`|change the primary group for a User|
|
||||
|`-G`|to add supplementary groups|
|
||||
|`-l`|to change existing user login name|
|
||||
|`-L`|to lock system user account|
|
||||
|`-m`|to move the contents of the home directory from existing home dir to new dir|
|
||||
|`-p`|to create an un-encrypted password|
|
||||
|`-s`|to create a specified shell for new accounts|
|
||||
|`-u`|to assigned UID for the user account|
|
||||
|`-U`|to unlock any locked user|
|
||||
|
||||
### Examples:
|
||||
|
||||
1. To add a comment/description for a user:
|
||||
```
|
||||
sudo usermod -c "This is test user" test_user
|
||||
```
|
||||
|
||||
2. To change the home directory of a user:
|
||||
```
|
||||
sudo usermod -d /home/sam test_user
|
||||
```
|
||||
|
||||
3. To change the expiry date of a user:
|
||||
```
|
||||
sudo usermod -e 2021-10-05 test_user
|
||||
```
|
||||
|
||||
4. To change the group of a user:
|
||||
```
|
||||
sudo usermod -g sam test_user
|
||||
```
|
||||
|
||||
5. To change user login name:
|
||||
```
|
||||
sudo usermod -l test_account test_user
|
||||
```
|
||||
|
||||
6. To lock a user:
|
||||
```
|
||||
sudo usermod -L test_user
|
||||
```
|
||||
|
||||
7. To unlock a user:
|
||||
```
|
||||
sudo usermod -U test_user
|
||||
```
|
||||
|
||||
8. To set an unencrypted password for the user:
|
||||
```
|
||||
sudo usermod -p test_password test_user
|
||||
```
|
||||
|
||||
9. To create a shell for the user:
|
||||
```
|
||||
sudo usermod -s /bin/sh test_user
|
||||
```
|
||||
|
||||
10. To change the user id of a user:
|
||||
```
|
||||
sudo usermod -u 1234 test_user
|
||||
```
|
||||
58
landing/docs/Commands/users/whoami.md
Normal file
58
landing/docs/Commands/users/whoami.md
Normal file
@@ -0,0 +1,58 @@
|
||||
# The `whoami` command
|
||||
---
|
||||
The `whoami` command displays the username of the current effective user. In other words it just prints the username of the currently logged-in user when executed.
|
||||
|
||||
To display your effective user id just type `whoami` in your terminal:
|
||||
|
||||
```
|
||||
manish@godsmack:~$ whoami
|
||||
# Output:
|
||||
manish
|
||||
```
|
||||
|
||||
Syntax:
|
||||
|
||||
```
|
||||
whoami [-OPTION]
|
||||
```
|
||||
|
||||
There are only two options which can be passed to it :
|
||||
|
||||
`--help`: Used to display the help and exit
|
||||
|
||||
Example:
|
||||
|
||||
```
|
||||
whoami --help
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```
|
||||
Usage: whoami [OPTION]...
|
||||
Print the user name associated with the current effective user ID.
|
||||
Same as id -un.
|
||||
|
||||
--help display this help and exit
|
||||
--version output version information and exit
|
||||
```
|
||||
|
||||
`--version`: Output version information and exit
|
||||
|
||||
Example:
|
||||
|
||||
```
|
||||
whoami --version
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```
|
||||
whoami (GNU coreutils) 8.32
|
||||
Copyright (C) 2020 Free Software Foundation, Inc.
|
||||
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
|
||||
This is free software: you are free to change and redistribute it.
|
||||
There is NO WARRANTY, to the extent permitted by law.
|
||||
|
||||
Written by Richard Mlynarik.
|
||||
```
|
||||
Reference in New Issue
Block a user