Skip to content

Lab04EXTRALinuxFilePerms

echadbourne edited this page Jan 23, 2024 · 1 revision

Making New and Adding to Groups

  • useradd [name] - adds a user with that username
  • passwd [username] - changes the password of that user
  • groupadd [name] - makes a group with that name
  • usermod -aG [groupname] [username] - adds the user specified to the specified group
  • mkdir /[name] - makes a directory with that name

Lab Notes

I made 3 new users, Fred, Bob, and Alice, and 2 new groups, Marketing and Management

  • Fred and Bob are in Marketing
  • Alice is in Management

After exploring the default permissions, I needed to change the /marketing directory to be in the Marketing group. To do this I used:

chgrp marketing /marketing - applies the "marketing" group to the "/marketing" directory

Then I needed to give write permission to the group for the directory, which I did with the following command: chmod g+w /marketing

To trim off the permissions of everyone else for this directory, I used the command: chmod o-rwx /marketing (the o means other)

To trim the read permissions of all the files in the current directory use: chmod o-r *

Specifics for Changing file and directory Permissions

Octal Permissions Table

  • r - 100 - 4
  • w - 010 - 2
  • x - 001 - 1

600 = rw-------

  • This is essentially 4+2+(0x7) because r represents 4 and w represents 2

777 = rwxrwxrwx

  • Bad Idea

666 = rw-rw-rw- 640 = rw-r-----

  • The one I used in the lab most commonly, rw for user, r for group, nothing for everyone

chmod -v 600 [filename] - filename permissions changed to rw-------

  • Syntax for using the Octal numbers to change file permissions (I like this better)

chmod u+rw,g-rwx,o-rwx [filename] - same as previous, assuming user did not already have x perms

Useful Resources

https://www.redhat.com/sysadmin/linux-file-permissions-explained

https://www.redhat.com/sysadmin/manage-permissions

Clone this wiki locally