Discovering the concepts of linux

Discovering the concepts of linux

LINUX WORKSHOP : Day -3

Hello everyone ;

I am Teertha Darekar Welcome to my day 3 blog of linux Workshop conducted by Pranav Jambare sir.

CONTENTS :-

  • Hardlink and Softlink

  • Permission

  • Special permissons

Lets Start ;

. In Linux operating system , a hardlink is equivalent to a file stored in the hard drive

. A hardlink is a minor copy of the original file

TO Create hard link the following command is used :

ln [mainfile] [HLfile]  
* Example
ln testuser test1

. Softlinks in Linux are a type of file that points to another file or directory.

. They're also known as symbolic links.

. The symbolic link contains the path to the original file or directory, so when you access the symbolic link, you're actually accessing the original file or directory.

To create softlink the following commands is used :-

ln -s [mainfile] [SL file]
* Example
ln -s testuser test2

--> 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 how

There 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 15:37 MF
  • - --> Type of file

  • rw- --> Permission for the owner of the file

  • r-- --> Permission for group owner of the file

  • r-- --> Permission for other users

  • . --> ACL

  • 2 --> Link Count

  • root --> Owner of the file

  • root --> Group owner of the file

  • 40 --> Size of the file

  • July 14 15:37 --> time spam

  • MF--> File name

OCTAL VALUES

three-digit value represents specific file permissions; These are called octal values. FOR EXAMPLE 755

. r (read): 2^2= 4

.w (write): 2^1= 2

.x (execute): 2^0= 1

To modify the file permissions the following command is used :-

chmod (change mode)

chmod [Permission] [nameofile/directory]
example :- chmod 554 file1

To change the owner name the following command is used :-

chown (change owner)

command:-
chown [username]:[groupname] [filename/directory]
Example :-
chown robot:classmate file1

To change the group name the following command is used :-

chgrp (change group )

command:-
chgrp [group/owneroffile] [filename/directory]
Example :-
chgrp classmate file1

--> UMASK

The umask (UNIX shorthand for "user file-creation mode mask").

The umask specifies the permissions you do not want given by default to newly created files and directories.

By default, most UNIX versions specify an octal mode of 666 in files

And in directories maximum permission is 777

TO SET THE UMASK VALUE

You can set the umask value using the " umask " command followed by "octal value" you want to set.

umask [umask number]

FOR EXAMPLE :-

to set the umask value to 002 you can use the command :-

" umask 002 "

--> SPECIAL PERMISSIONS

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

By using special permissions, users with less privilege are allowed to execute a file and assume the privileges of the file's owner or group.

1) Sticky bit :-

  • This permission does not affect individual files.

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

  • The permission set is noted by the lowercase t.

# to enable
chmod 1777 <dir name> 
# to disable
chmod 0777 <dir name>

2) SGID (set group user id)

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

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

  • This permission set is noted by a lowercase s.

# to enable
chmod 2777 <dir name>
# to disable
chmod 00777 <dir name>

3) SUID ( set owner user id )

  • The special permission for the user access level has a single function.

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

# to enable 
chmod 4777 <binary name>
# to disable
chmod 0000777 <binary name>

Thankyou....