The beginning of a Linux Story

Rihaab WadekarRihaab Wadekar
3 min read

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.

  • 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>
    
  • 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:

  1. "-" => Regular file.

  2. "d" => Directory.

  3. "l" => Link file.

  4. "b" => block file.

  5. "s" => Socket file.

  6. "c" => Character file.

  7. "p" => Pipe file.


Permissions

Every File can do Three actions. There are three sorts of permission established in Linux system.

  1. Read(r)

  2. Write(w)

  3. 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:

  1. Open /etc/bashrc

  2. search for umask

  3. change the mask number in the files

  4. save and exit from the files

  • umask 002 -> for root

  • umask 022 -> for other user.

Thank you!!

10
Subscribe to my newsletter

Read articles from Rihaab Wadekar directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Rihaab Wadekar
Rihaab Wadekar