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 [2025/03/31 12:30] – jkonczak | os_cp:users_permissions [2026/03/18 20:56] (current) – [Changing permissions, group and owner of a file] jkonczak | ||
|---|---|---|---|
| Line 81: | Line 81: | ||
| < | < | ||
| - | ~~Exercise.# | + | ~~Exercise.# |
| < | < | ||
| Line 107: | 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 116: | 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 181: | 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 233: | 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 250: | Line 375: | ||
| ~~Exercise.# | ~~Exercise.# | ||
| - | ~~Exercise.# | + | ~~Exercise.# |
| ~~Exercise.# | ~~Exercise.# | ||
os_cp/users_permissions.1743424226.txt.gz · Last modified: (external edit)