The beginning of a Linux Story
Welcome back to day-3 of understanding the power and importance of Linux in The programming world under the guidance of Pranav Jambare.
The 3rd day of the workshop included many important topics which are explained in detail below.
Hardlink and Softlink
In Unix, Link is a file pointer.
t is like making shortcuts for accessing files.
There are two types of links Hardlink, and Softlink.
1) Hardlink:
Hardlink always points to the source, even if it is moved or destroyed.
ls -l command displays all links.
Removing any link reduces the link count
We cannot build a hardlink for a directory.
If the original file is deleted the link will still display the files content.
command:-
ln <OriginalFile> <LinkFile>
2) Softlink:
Softlinks are not updated, they simply include a string containing the target's path name.
If the source file is removed or transferred, the softlink file will stop working.
Softlinks only retains the path to the original file, not its contents.
If we change the name of the original file, any softlink to that file become useless.
Command:
ln -s <OriginalFile> <LinkFile>
Types of files:
"-"
=> Regular file."d"
=> Directory."l"
=> Link file."b"
=> block file."s"
=> Socket file."c"
=> Character file."p"
=> Pipe file.
Permissions
Every File can do Three actions. There are three sorts of permission established in Linux system.
Read(r)
Write(w)
Execute(x)
Calculating The permission
The permission is calculated on the octal values.
Execute - 2^0 = 1
Write - 2^1 = 2
Read - 2^2 =4
Changing the permission
We can change the permission of a file or directory by using chmod command.
Syntax:
chmod <permission> <File/Dir name>
Changing the owner and group of the file
We can change the owner and group of the file with "chown" and "chgrp" commands.
Syntax:
chown <fileOwner>:<FileGroupOwner> <name of file/dir>
we can also change the owner and group individually.
Change owner of the file only:-
Syntax:
chown <fileOwner>: <file/directory name>
Change GroupOwner of the file only:-
Syntax:
chown :<groupowner_file> <nameofile/directory>
Default Permission in Linux:umask
We can provide default permission to the file or directory with umask
The max permission for
1)Directory - 777
2)File - 666
We don't provide file execute permission, we only provide it to executable files.
Check umask:
Syntax:
umask
Set umask:
Syntax:
umask 0033
Set umask Permanently:
Open /etc/bashrc
search for umask
change the mask number in the files
save and exit from the files
umask 002 -> for root
umask 022 -> for other user.
Thank you!!
Subscribe to my newsletter
Read articles from Rihaab Wadekar directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by