File Linking and Permission
Hello guys!! my self prathmesh ingawale and I'm back here with another blog about the Linux workshop.conducted by jambare sir.
CONTENTS :-
• Hardlink and Softlink
• Permission
• Special permissons
Hardlink:
In Linux, a hard link is a directory entry that points to the same inode as another directory entry. Essentially, it creates multiple names (links) for the same file. All hard links to a file are treated equally, and there is no distinction between the original file and its hard links. If you delete a hard link, the file itself remains until all hard links are removed. Hard links can only be created for files and not directories, and they cannot span across file systems.
Syntax:
ln <main_file> <hardlinkfile>
SoftLink:
A symbolic or SoftLink file is an actual link to the original file.If you delete the original file, the SoftLink has no value, because it points to a non-existent file.SoftLink acts as a Shortcut file as it points toward the original file.The creation timing and Link count number of the SoftLink file and the original file are different.The Link count number for the SoftLink file is 1.
Syntax:
ln -s <MainFile name> <SoftLinkFile name> #Example ln -s MainFile SoftLinkFile
PERMISSIONS:
File permissions are core to the security model used by Linux systems. They determine who can access files and directories on a system and howThere are three sorts of permissions in the Linux system. Read, write, and execute.
READ "r" :- it reads the contents of the file
WRITE 'w" :- it is used to write the contents of the file
EXECUTE "x" :- it is used to execute the file
TO DISPLAY THE PERMISSSON :-
ls -l [filename] -rw-r--r--.2 root root 40 July 14
Umask :-
In Linux, umask is a command that is used to set the default file permissions for new files and directories. It stands for "User Mask" and is a value that is subtracted from the maximum file permission value (777) to determine the default permissions for new files. The default umask value is usually 022, which means that the group and others permissions are set to read-only. Umask values can be changed to control the default file permissions to better suit your needs. Umask values can be set temporarily for the current session or permanently by adding them to the user's shell configuration file.
COPY
Checking the umask- #Syntax: umask setting the umask temporarily- #Syntax: umask <umask number
Special permissions:
Special permissions in Linux refer to additional settings that can be applied to files and directories to control their access and behavior beyond the standard read, write, and execute permissions. They include the setuid (Set User ID), setgid (Set Group ID), and sticky bit permissions.
Set User ID (SUID): When applied to an executable file, it allows the user running the program to temporarily gain the permissions of the file's owner, instead of their own, while executing it.
Syntax-
chmod 4777 [directory_name]
The first digit (4) sets the SUID bit, indicating that the file has the SUID permission set. However, this permission is typically not used on directories.
chmod 0000777 [directory_name]
The first 4 bits as (0) don't enable the SUID special permissions.
Set Group ID (SGID): Similar to SUID but applies to executable files as well as directories. When applied to a directory, any file created inside that directory will inherit the group ownership of the parent directory, rather than the group ownership of the user who created the file.
Syntax-
chmod 2777 [directory_name or file_name]
The first digit (2) represents that the SGID special permission is set.
chmod 00777 [directory_name or file_name]
The first 2 digits (0) are representing that the SGID special permissions are not set.
Sticky Bit: When applied to a directory, it ensures that only the owner of a file within that directory can delete or rename that file, even if other users have write permissions on the directory.
Syntax-
chmod 1777 [directory_name]
To set the sticky bit using octal notation, you add the value 1 to the existing permission bits for the directory as in the above syntax. The octal value for the sticky bit is 1000. The special permissions are set here.
chmod 0777 [directory_name]
The special permissions are not set here. Since the first bit is 0, there is not any special permission set.
These special permissions add an extra layer of control and security for specific scenarios in the Linux operating system.
Thank you!!