Lab L-4 Creating Users and Folder Permissions in Linux

In order to allow regular users to create documents that save in the /var/www/html folder you’re going to need to modify the permissions. This is a good place to learn about permissions in Linux.

 

 

Do this

It’ll look like this

  1. First lets create a group named Webdesign. Go under the SystemàAdministrationàUsers and Groups
  2. Create a user for each of your partners.
  3. Click on the groups tab.
  4. Note that each person is a member of their own group. Did you ever think you’d be a group and a user at the same time?
  5. Create a group named web.
  6. Under the tab Group Users select all of the members of your team.
  7. Click OK.

 

How to: Change group ownership

  1. Chgrp (command) web (group to change to) html (name of folder)

 

Permissions on files

Below is an example of how a file may be listed when typing ( ls -l ) at the prompt as well as information on how to interpret it.

-rw-rw-r-- 1   hope  web  123   Feb 03 15:36   file.txt

-

rw

rw-

r--

1

hope

Web

123

Feb 03 15:36

file.txt

File

owner

group

everyone else

links

owner

group

size

mod date

file name

  • Owner can read and write
  • Group can read and write
  • Everyone else can just read

To change modes (chmod) use the following numbers. This seems hard, but it’s really not:

 

CHMOD can also to attributed by using Numeric Permissions:

400 read by owner
040 read by group
004 read by anybody (other)
200 write by owner
020 write by group
002 write by anybody
100 execute by owner
010 execute by group
001 execute by anybody

So if you want to change the mode of a file named fred so that the owner can read, write, and execute you add together the read (4) the write (2) and the execute (1) = 7 so the command would be

 

Chmod 7 fred

 

Or to make it easy

7=rwx

6=rw-

5=r-x

4=r--

3=-wx (which would be strange)

2=-w-

1=--x

0=deny all

 

So if I want to the folder, HTML owner=RWX, Group=RWX, and everyone else=R—

 

I would type the command chmod 774 html

 

Alternative I can do one type at a time. So if I wanted the owner to be RWX I could type

 

Chmod u=rwx html

 

That sets the first set. Then I could do chmod g=rwx html and finally o=r

Screenshot-Create New Group

Oops! It won’t let me put a space in, so we’ll just say web.

Screenshot-Group Properties

  1. Now go into terminal and log in as root.
  2. CD to /var/www/
  3. Do a listing with a –l
  4. You should see something that looks like this:
  5. We want to change the group membership to web.
  6. Use the chgrp command to change the group membership of html to web.
  7. Give the following permissions:
    1. Owner: rwx
    2. Group: rwx
    3. Others: r-x
  8. Use command chmod 774 html
  9. Let’s create another folder inside html. CD into html.
  10. Create a folder named intranet (mkdir intranet)
  11. Create a new group named “Employees”
  12. Create three new users
    1. Penny Pinkleton
    2. Tracy Turnbladt
    3. Link Hearthrob
  13. Add them and all of your partners to the employees group.
  14. Go into # and change the group ownership of the intranet folder to employees.
  15. Now give the intranet folder full permissions for the owner, read and execute for the group, and deny all for everyone.
  16. Do an ls –l and write in the box to the right what you see.

root

 

chmod

  1. To change all the folders in a folder (a folder and all its files and folders inside of it), use the –R (recursive) switch. CD so you’re in the /var/ folder.
  2. Change group ownership to web for all of the folders in www, including www
    1. Owner can have rwx
    2. Group can have at least rw
    3. Others need rx but not w
  3. Once you change the mode, then just type chmod –r www to set that mode to all files INSIDE the folder.

Before you do this…ask yourself “What numbers do I use to change the folder permissions in one command?”

www permissions