Explain the difference between how umask and the chmod comma

Explain the difference between how umask and the chmod command affect your permissions?

A. There is no difference

B. The umask command only affects files that already exist, while chmod changes your default permissions

C. The chmod command only affects files that already exist, while umask changes your default permissions

D. The umask command only works in symbolic mode, while chmod only works in binary mode

E. The umask command sets permissions for directories, while the chmod command sets file permissions.

Solution

Hi please inform if you need any clarification

Answer is C: The chmod command only affects files that already exist, while umask changes your default permissions


In linux File permissions define which user or system accounts have permissions to read, write, and execute specific files.
when you give ls -ltr in a directory
u will see like
-rw-r----- 1 t t 5760 Oct 18 06:43 60022454.txt
-rwxr-x--- 1 t t 5760 Oct 18 08:16 60022454.txt
-rwxr-xr-x 1 t t 424 Oct 24 07:00 NETMART_BPPData_T1T3Order.ref


you have seen this rwx, now r mans read w means write and x means execution permission

and first three bit is for user, after that next three bits reserverd for group and last three bit is for others.
chmod can help to change the permission of existing file.
permissions and there representation

Permissions Symbolic       Binary       Octal
read, write, and execute rwx 111 7
read and write rw- 110 6
read and execute r-x 101 5
read r-- 100 4
write and execute -wx 011 3
write -w- 010 2
execute --x 001       1
no permissions --- 000       0

now how to change permission of a file, you can use octal mode to change permission of a file
suppose you want to give permission to a file called my.txt like this rwxr-xr-x (previously suppose my.txt is like rw-r------)
chmod 755 my.txt
explaination here 7 means rwx 5 means r-x
now suppose you want to change permission of my.txt using symbolic mode
suppose you want to give rwxrwxrwx permission to my.txt using symbolic mode
chmod a=rwx my.txt
or you can use
chmod ugo=rwx my.txt
here u means user g means group o means others

suppose you want to remove read permission from every one
chmod a-r my.txt
suppose you want to give permission to user
you can use
chmod u+r my.txt
================
Now comming to umask
when you create a file default permission is set based on umask value
type umask in your terminal and you will come to know its value


You\'ll see something like 0002 displayed, however octal
numbers are preceded by a 0 (in the same way hex would be preceded by 0x), so the umask value itself is actually 002.

This value is an octal (base 8, digits 0-7) value which is subtracted from a base value of 777 for directories,
or subtracted from a base value of 666 for files.

The file permissions for this new file will be 666-002 = 664 here 6 means rw- and 4 menas r-- so default will be like rw-rw-r--

The file permissions for the directory newDir will be 777-002 = 775, i.e. drwxrwxr-x

Thanks

Explain the difference between how umask and the chmod command affect your permissions? A. There is no difference B. The umask command only affects files that a
Explain the difference between how umask and the chmod command affect your permissions? A. There is no difference B. The umask command only affects files that a

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site