-
Notifications
You must be signed in to change notification settings - Fork 0
/
filePermissions
84 lines (55 loc) · 3.05 KB
/
filePermissions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
file permissions
suid ,sgid give priveleges of owner , group respectively when file is executed .
It is denoted by s .
to set it
chmod u+s filename or chmod 4755 //set suid
chmod g+s filename or chmod 2755 //set sgid
diff between s and S
if file is executable and suid is set then small s else S
sticky bit
to set it chmod o+t or chmod 1755
Sticky Bit is mainly used on folders in to avoid deletion of a folder and its
content by other users though they having write permissions on the folder contents.
If Sticky bit is enabled on a folder, the folder contents are deleted by only owner who created them and the root user
hardlink
to create
ln filename linkname
both filename and linkname are linked to same inode .
so even filename is moved , deleted or renamed , linkname is valid
an inode exist as long as long as a link to it exist
so for deleting file we have to delete all the links to it .
hardlink refers to same inode so they can be used within a filesystem
softlink
to create
ln -s filename linkname
linkname is linked to different inode
linkname points to filename
when filename is deleted ,renamed or moved , linkname becomes unusable
on executing ls -l softlinks are represented as
linkname > filename
Advantage of hardlink
The main advantage of hard links is that, compared to soft links, there is no size or speed penalty.
Soft links are an extra layer of indirection on top of normal file access; the kernel has to dereference the link when you open the file,
and this takes a small amount of time. The link also takes a small amount of space on the disk,
to hold the text of the link. These penalties do not exist with hard links because they are built into the very structure of the filesystem.
http://unix.stackexchange.com/questions/20670/why-do-hard-links-exist
in unix . and .. are real entries . actually they are hardlinks .
even root has both . and .. entry and they point to same inode .
to view inode ls-i
inodes do not contain file names, only other file metadata.
files are listed as
numerals first
uppercase
lowercase
umask() sets the calling process's file mode creation mask (umask) to
mask & 0777 (i.e., only the file permission bits of mask are used), and
returns the previous value of the mask.
Special Execute
X - This is a slightly more restrictive version of "x".
It applies execute permissions to directories in all cases,
and to files only if at least one execute permission bit is already set.
It is typically used with the "+" operator and the "-R" option,
to give group and/or other access to a large directory tree, without setting execute permissions on normal (non-executable) files (e.g., text files).
For example, "chmod -R go+rx bigdir" would set read and execute permissions on every file (including text files) and directory in the bigdir directory,
recursively, for group and other. The command "chmod -R go+rX bigdir" would set read and execute permissions on every directory,
and would set group and other read and execute permissions on files that were already executable by the owner.