Skip to main content

Command Palette

Search for a command to run...

Basic concepts of linux

Updated
5 min read
Basic concepts of linux

Day 3

Hello everyone welcome back !!!

Myself Swanik Santosh Gudekar and I am back with my blog. This is the third blog of Linux series. Today I attended the third session conducted by Master Pranav Jambare. It was a fun and exciting session.

Points Covered in This Session :

  • Hardlink

  • Softlink

  • Permission

  • Special Permission

  • HardLink is also a type of file that points to the same data as another file.

  • HardLink creates a separate copy of a file's data.

  • This means if the main file is renamed, relocated, or removed from the system it does not bother the copy created by HardLink it still works smoothly.

  • HardLinks cannot be created for directories, if does then it may cause circular reference or loop, which causes issues with file system operations and can lead to data corruption.

  • SYNTAX : ln [main_file][link_file]

  • It is a type of file that points to another file or directory is said to be SoftLink in Linux.

  • It is also called a Symbolic Link.

  • When we open a SoftLink it redirects us to the original or main file or directory.

  • It is similar to the shortcuts in Windows.

  • SoftLink makes it easier to access files that are stored in different directories.

  • They do not take more additional space on your hard disk.

  • Softlink is a powerful tool that can be used to simplify file management in Linux.

  • SoftLink can't work or be accessed If the original file is removed or Deleted.

  • SYNTAX : ln -s [main_file][link_file]

Permission :

  • Linux is a multi-user operating system, so it has security to prevent people from accessing each other’s confidential files.

  • Permission is the set of access rights that determine what actions can be performed on a file or directory.

  • The permissions are primarily associated with three entites : Owner of the file, the group to which they belong, and others.

  • Eg. -rwxrwxrwx

LettersDefinition
rread the content of the files
wwrite or modify the content of the files
xexecute the file

Calculate the permission :

Read - 2^2 = 4

Write - 2^1 = 2

Execute - 2^0 = 1

Eg. A file might have read, write, and execute permission for owner and read, write permission for group and only read permission for other user.

  • Owner : rwx = 4+2+1 = 7

  • Group : rw- = 4+2+0 = 6

Other : r-- = 4+0+0 = 4

Hence the permission is 764.

Root User Permission :

FileDirectories
Max666777
Default644755

Normal User permission :

FileDirectories
Max666777
Default664775

Umask :

  • Umask stands for user file creation mask

  • The umask command specifies the permissions that the user does not want to be given out to the newly created file or directory.

  • We can provide the default permission to the file or directory using the command.

  • the umask command is used to set the default permission file permission for the newly created file and directory.

  • SYNTAX : umask <umasknumber>

  • eg. umask 766

Special Permission :

  • Linux uses some special permissions to allow certain capabilities that go beyond the basic rwx.

  • Special permissions allow for additional privileges over the standard permission sets.

  • Special permissions make up a fourth access level in addition to user, group, and other.

    1) Sticky Bit :

  • Skicky bit works in directories.

  • This permission does not affect individual files.

  • However, at the directory level, it restricts file deletion.

  • Only the file owner, directory owner, and root user can delete or rename its files when a sticky bit is set to the directory.

  • To avoid such scenarios sticky bit is applied to the directory where you can create the files, and check someone else's file but can't rename and delete it.

  • SYNTAX :

To enable - chmod +t <dir name>

To disable - chmod -t <dir name>

2)SGID :

  • SGID stands for Set Group Identification.

  • If set on a file, it allows the file to be executed as the group that owns the file (similar to SUID).

  • If set on a directory, any files created in the directory will have their group ownership set to that of the directory owner.

  • SYNTAX :

    To enable - chmod g+s <dir name>

    To disable - chmod g-s<dir name>

    3) SUID :

  • SUID stands for set Set Owner User Id.

  • A file with SUID always executes as the user who owns the file, regardless of the user passing the command.

  • When the SUID bit on an executable file is set, it signifies that the file will be executed with the same permissions as the executable's owner.

  • SYNTAX :

    To enable : chmod u+s <dir name>

    To disable : chmod u-s <dir name>

These were the topics covered by Master Pranav Jambare in the third session of Linux.

More from this blog

Swanik

9 posts