os_cp:users_permissions
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| os_cp:users_permissions [2024/03/11 17:59] – jkonczak | os_cp:users_permissions [2026/03/18 20:56] (current) – [Changing permissions, group and owner of a file] jkonczak | ||
|---|---|---|---|
| Line 4: | Line 4: | ||
| A user is identified by a numerical __u__ser __id__entifier – **uid**. Uids are mapped to usernames. | A user is identified by a numerical __u__ser __id__entifier – **uid**. Uids are mapped to usernames. | ||
| \\ | \\ | ||
| - | A group is identified by a numerical __g__roup __id__entifier – **uid**, that are likewise mapped to group names. | + | A group is identified by a numerical __g__roup __id__entifier – **gid**, that are likewise mapped to group names. |
| A user must be in one primary group and can be in multiple supplementary groups. | A user must be in one primary group and can be in multiple supplementary groups. | ||
| Line 65: | Line 65: | ||
| < | < | ||
| | | ||
| + | ++++ Examples: | {{section> | ||
| + | |||
| ==== [extra] Logged on users, logon history, messaging others ==== | ==== [extra] Logged on users, logon history, messaging others ==== | ||
| Line 79: | Line 81: | ||
| < | < | ||
| - | ~~Exercise.# | + | ~~Exercise.# |
| < | < | ||
| Line 98: | Line 100: | ||
| < | < | ||
| + | |||
| + | ++++ Examples: | {{section> | ||
| ==== Switching to another user ==== | ==== Switching to another user ==== | ||
| Line 103: | Line 107: | ||
| One can run commands (including a shell) as another user, provided one has sufficient privileges and/or knows the right password (depending on system configuration). | One can run commands (including a shell) as another user, provided one has sufficient privileges and/or knows the right password (depending on system configuration). | ||
| - | The '' | + | The '' |
| + | authenticated, starts as the target user (or root, if no user is specified) | ||
| + | the users default shell. | ||
| \\ | \\ | ||
| - | < | + | < |
| + | runs as the target user the provided command inside the users default shell.</ | ||
| '' | '' | ||
| In most Linux systems the '' | In most Linux systems the '' | ||
| Line 112: | Line 119: | ||
| Some distributions abuse '' | Some distributions abuse '' | ||
| - | ~~Exercise.# | + | ~~Exercise.# |
| + | during classes; most likely it's going to be '' | ||
| + | where //N// needs to be substituted with your computer number). | ||
| + | Switch user to '' | ||
| < | < | ||
| Line 119: | Line 129: | ||
| < | < | ||
| + | |||
| + | ++++ Examples: | {{section> | ||
| ===== File permissions ===== | ===== File permissions ===== | ||
| Line 175: | Line 187: | ||
| \\ | \\ | ||
| and '' | and '' | ||
| + | |||
| + | ++++ Illustration on which chunk of permissions to look at | | ||
| + | < | ||
| + | < | ||
| + | .wP{margin: | ||
| + | .wS{border-radius: | ||
| + | .wN{border-radius: | ||
| + | linear-gradient(to left top, transparent 47%, #aaa 47%, #aaa 53%, transparent 53%)} | ||
| + | .wG{border-radius: | ||
| + | linear-gradient(to right top, transparent 47%, #aaa 47%, #aaa 53%, transparent 53%)} | ||
| + | p{margin-top: | ||
| + | </ | ||
| + | </ | ||
| + | Keep in mind that programs such as '' | ||
| + | exactly the same regardless if the user that ran them is the owner or not, | ||
| + | belongs to the group whose the file is or not. One has to tell apart manually | ||
| + | which chunk of permissions to look at. | ||
| + | < | ||
| + | <pre> | ||
| + | <span class=" | ||
| + | <span class=" | ||
| + | <span class=" | ||
| + | bipedal jumping | ||
| + | <span class=" | ||
| + | total 4 | ||
| + | d<span class=" | ||
| + | -<span class=" | ||
| + | <span class=" | ||
| + | File: myDir | ||
| + | Size: 160 | ||
| + | Device: 0,30 Inode: 90 | ||
| + | Access: (0<span class=" | ||
| + | <span class=" | ||
| + | File: someFile | ||
| + | Size: 249 | ||
| + | Device: 0,30 Inode: 91 | ||
| + | Access: (0<span class=" | ||
| + | </ | ||
| + | </ | ||
| + | The user '' | ||
| + | |||
| + | < | ||
| + | <pre> | ||
| + | <span class=" | ||
| + | <span class=" | ||
| + | <span class=" | ||
| + | <span class=" | ||
| + | <span class=" | ||
| + | total 4 | ||
| + | drwx< | ||
| + | -rw-< | ||
| + | <span class=" | ||
| + | File: myDir | ||
| + | Size: 160 | ||
| + | Device: 0,30 Inode: 90 | ||
| + | Access: (07<span class=" | ||
| + | <span class=" | ||
| + | File: someFile | ||
| + | Size: 249 | ||
| + | Device: 0,30 Inode: 91 | ||
| + | Access: (06<span class=" | ||
| + | </ | ||
| + | </ | ||
| + | The user '' | ||
| + | but is in group '' | ||
| + | so for the user **only** the middle chunk matters. | ||
| + | |||
| + | < | ||
| + | <pre> | ||
| + | <span class=" | ||
| + | <span class=" | ||
| + | <span class=" | ||
| + | <span class=" | ||
| + | <span class=" | ||
| + | total 4 | ||
| + | drwxr-x< | ||
| + | -rw----< | ||
| + | <span class=" | ||
| + | File: myDir | ||
| + | Size: 160 | ||
| + | Device: 0,30 Inode: 90 | ||
| + | Access: (075< | ||
| + | <span class=" | ||
| + | File: someFile | ||
| + | Size: 249 | ||
| + | Device: 0,30 Inode: 91 | ||
| + | Access: (060< | ||
| + | </ | ||
| + | </ | ||
| + | The user '' | ||
| + | **neither** he is in group '' | ||
| + | so for the user **only** the last chunk matters. | ||
| + | |||
| + | ++++ | ||
| To see detailed information about a file (this includes permissions), | To see detailed information about a file (this includes permissions), | ||
| \\ | \\ | ||
| - | Permissions are also presented in the results of '' | + | Permissions are also presented in the results of '' |
| + | (or, the '' | ||
| \\ | \\ | ||
| All these commands precede file permissions with a character indicating the file type. | All these commands precede file permissions with a character indicating the file type. | ||
| Line 227: | Line 334: | ||
| The '' | The '' | ||
| - | //Do the exercises on the SSH server indicated during classes. \\ To create files, you may use e.g., the // '' | + | //Do the exercises on the SSH server indicated during classes |
| + | \\ To create files, you may use e.g., the // '' | ||
| + | |||
| + | < | ||
| + | ++++ Instructions for using your own Linux box to do the exercises | | ||
| + | To do the exercises on your own computer, you may either: | ||
| + | - Use the following commands to add sample groups and users to your system:< | ||
| + | groupadd even | ||
| + | groupadd odd | ||
| + | groupadd low | ||
| + | groupadd high | ||
| + | useradd -g odd -G low -m user1 | ||
| + | useradd -g even -G low -m user2 | ||
| + | useradd -g odd -G high -m user3 | ||
| + | useradd -g even -G high -m user4 | ||
| + | passwd -d user1 | ||
| + | passwd -d user2 | ||
| + | passwd -d user3 | ||
| + | passwd -d user4</ | ||
| + | - Build & use {{so: | ||
| + | curl -s https:// | ||
| + | docker build --tag container-for-file-permission-labs container-for-file-permission-labs | ||
| + | docker run --network=none --rm -ti container-for-file-permission-labs</ | ||
| + | ++++ | ||
| + | </ | ||
| ~~Exercise.# | ~~Exercise.# | ||
| Line 244: | Line 375: | ||
| ~~Exercise.# | ~~Exercise.# | ||
| - | ~~Exercise.# | + | ~~Exercise.# |
| ~~Exercise.# | ~~Exercise.# | ||
| Line 261: | Line 392: | ||
| </ | </ | ||
| + | |||
| + | < | ||
| + | <WRAP nomargin> | ||
| + | Examples: | ||
| + | ++++ umask | {{section> | ||
| + | ++++ manipulating mode bits | {{section> | ||
| + | ++++ user, group or others | {{section> | ||
| + | ++++ write-only and read-only files | {{section> | ||
| + | ++++ creating/ | ||
| + | </ | ||
| + | ++++ suid and sgid | {{section> | ||
| + | |||
| ===== Change, modify and access date ===== | ===== Change, modify and access date ===== | ||
| Line 285: | Line 428: | ||
| < | < | ||
| + | |||
| + | ++++ Examples: | {{section> | ||
os_cp/users_permissions.1710179947.txt.gz · Last modified: (external edit)