Snippets Collections
# When using a number mask for permission representation there are only a few basic permissions

4: Read
2: Write
1: Execute

# Combined you get this table

+-----+---+--------------------------+
| rwx | 7 | Read, write and execute  |
| rw- | 6 | Read, write              |
| r-x | 5 | Read, and execute        |
| r-- | 4 | Read,                    |
| -wx | 3 | Write and execute        |
| -w- | 2 | Write                    |
| --x | 1 | Execute                  |
| --- | 0 | no permissions           |
+------------------------------------+
  
# The permissions for user, group and other are listet after each other when looking them up

+------------+------+-------+
| Permission | Octal| Field |
+------------+------+-------+
| rwx------  | 700  | User  |
| ---rwx---  | 070  | Group |
| ------rwx  | 007  | Other |
+------------+------+-------+
  
# This boils down to this
  
  +------------------------+-----------+
| chmod u=rwx,g=rwx,o=rx | chmod 775 | For world readable directories
|                        |           |   Members of group can change files
| chmod u=rwx,g=rx,o=    | chmod 750 | For group readable directories
|                        |           |   Members of group can change files
| chmod u=rwx,go=        | chmod 700 | For private direcories
+------------------------+-----------+
# Check if 'webmasters' group exist

cat /etc/group | grep webmasters

# Create 'webmasters' group

sudo addgroup webmasters

# Add users to 'webmasters' group

sudo usermod -a -G webmasters username

# Group assignment changes won't take effect
# until the users log out and back in.


# Change group owner of the directory to webmaster user

sudo chgrp -R webmasters /etc/nginx/
  
# Give write permission to the group

sudo chmod -R g+w /etc/nginx/
  
# Create file as different user

sudo -u username touch /etc/nginx/test.txt
private fun askPermissions(){
        Dexter.withContext(this)
                .withPermissions(
                        Manifest.permission.ACCESS_FINE_LOCATION,
                        Manifest.permission.ACCESS_COARSE_LOCATION
                )
                .withListener(object : MultiplePermissionsListener {
                    override fun onPermissionsChecked(report: MultiplePermissionsReport?) {
                        if (report!!.areAllPermissionsGranted()) {
                            // TODO (STEP 7: Call the location request function here.)
                        }

                        if (report.isAnyPermissionPermanentlyDenied) {
                            Toast.makeText(
                                    this@MainActivity,
                                    "You have denied location permission. Please allow it is mandatory.",
                                    Toast.LENGTH_SHORT
                            ).show()
                        }
                    }

                    override fun onPermissionRationaleShouldBeShown(
                            permissions: MutableList<PermissionRequest>?,
                            token: PermissionToken?
                    ) {
                        showRationalDialogForPermissions()
                    }
                }).onSameThread()
                .check()

    }
star

Mon Jun 21 2021 20:45:00 GMT+0000 (UTC) https://www.grymoire.com/Unix/Permissions.html

#authentification #permissions
star

Mon Jun 21 2021 20:32:43 GMT+0000 (UTC) https://askubuntu.com/questions/488485/allowing-a-group-read-write-access-to-a-directory

#authentification #permissions

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension