To make a directory named "my folder" that can only be accessed by userid john, go to the directory above "my folder" and type chown john direct. If you wish for only John to read and write in it, type chmod 700 my folder. If you wish to allow others to read these files you can type chmod a+rx my folder after typing the first command.
The above only works if you are john. If you are not, but john is in your group, ask us to make a new group for you and john, your2grp. Then you can chgrp your2grp my folder, and chmod g=rwx my folder. If you do not wish anyone else to be able to read these files, use chmod o-rx my folder.
To list the access permissions of a file, type ls -l file, and for a directory, ls -ld directory. r=read access, x=execute access, w=write access. After the first letter or hyphen (for file type), the first three letters apply to you, the second three letters apply to your group, the last three letters apply to everyone else. Execute access enables you to run programs or enter directories.
Examples of using chmod:
- PEOPLE = PERMISSIONS
- u = the file's user (or owner)
- r = read access
- g = the file's group
- x = execute access
- o = others
- w = write access
- a = the user, the group, and others.
- chmod a+w = let everyone write to the file
- chmod go-r = don't let people in the file's group or others to read the file
- chmod g+x = let people in the file's group execute the file