In: Computer Science
SOLUTION:
1. CREATE A FILE NAMED PERMS01 WITH PERMISSIONS rwxrw-r--1
Ans: -rwxrw-r--1 jsmith student 365 feb 22 15:31 lab1.c
This is the normal file named "lab1.c" owned by user jsmith and associated with the student group. This file is readable, writable, and executable by the owner, readable and writable by members in the student group, and only readable by all other users. Of course, there would be no point in actually trying to execute a.c file.
2. Create a file named perms02 with permissions rwxr-xr-x.
Ans: $ls - l
drwxr-xr-x 3 dd users 4096 Jun 8:01 pictures
The first ten characters in the format drwxrwxrwx, represents the permissions for all the three classes of users. Let's try to understand what each of these letters means. The first character, d, signifies that the file is a directory. This position can be blank (-) or any of the following characters.
c: character device
b: Block device
s: socket
p: pipe
D:Door
l: Symbolic link etc.,
Then the next three characters(drwxr-xr-x) represent the permission that have been assigned to the owners of the file. The owner dd can read, write, and execute to the folder pictures.
Moving on to the next three characters (drwxr-xr-x) which is r-x, represents the group permission. The users from users group can access the file according to the group permissions, which specify they can read and execute in the directory but cannot write into it. The hyphen signifies that the permission is not granted.
The last three characters xr-x represents the permissions for other groups who are neither the owner nor a member of the group users and the permissions are set to read and execute only.
The 11th character is a number that represents the number of hard links for the files and is not related to permission for a file.The two columns next to this number(drwxr-xr-x) 3 add users represents the owner and group of the file.
To find the permission for a particular file or directory, specify the name of the file in the ls command like below.
$ ls -l filename