Difference between revisions of "Linux-Ubuntu/C2/Linux-File-Ownership-and-Permissions/English"

From Script | Spoken-Tutorial
Jump to: navigation, search
 
(2 intermediate revisions by the same user not shown)
Line 4: Line 4:
  
 
'''Keywords:''' Linux, File Ownership, File Permissions, chown, chmod, chgrp, Inodes, Hard link, Soft link, Symbolic link, Terminal commands, Linux file system, edupyramids, video tutorial.
 
'''Keywords:''' Linux, File Ownership, File Permissions, chown, chmod, chgrp, Inodes, Hard link, Soft link, Symbolic link, Terminal commands, Linux file system, edupyramids, video tutorial.
 +
  
 
{|border=1
 
{|border=1
Line 21: Line 22:
 
* Manage file ownership and permissions using '''c h own''' and '''c h mod''' commands.
 
* Manage file ownership and permissions using '''c h own''' and '''c h mod''' commands.
 
* Change file group ownership using '''chgrp''' command.
 
* Change file group ownership using '''chgrp''' command.
* Describe '''i nodes '''and view '''i node''' numbers of the files.
+
* Describe '''inodes '''and view '''inode''' numbers of the files.
 
* Create and verify '''hard links '''and '''symbolic links''' in Linux.
 
* Create and verify '''hard links '''and '''symbolic links''' in Linux.
 
|-  
 
|-  
Line 60: Line 61:
  
 
'''File-attributes.png'''
 
'''File-attributes.png'''
|| File attributes are properties linked to a file. Attributes define ownership and permissions.
+
|| File attributes are properties linked to a file.  
  
They include file type, size, and time details. They show who owns the file and who can access it.
+
Attributes define ownership and permissions.
 +
 
 +
They include file type, size, and time details.  
 +
 
 +
They show who owns the file and who can access it.
  
 
File attributes are viewed using the '''l s hyphen l '''command.
 
File attributes are viewed using the '''l s hyphen l '''command.
Line 83: Line 88:
 
Now switch to the terminal.
 
Now switch to the terminal.
  
Type '''c d space Desktop slash file hyphen a t t r '''and press Enter. Notice that the prompt path has changed.
+
Type '''c d space Desktop slash file hyphen a t t r '''and press Enter.  
 +
 
 +
Notice that the prompt path has changed.
 
|-  
 
|-  
 
|| Type
 
|| Type
Line 106: Line 113:
 
If it is a '''hyphen''', it denotes a regular file.
 
If it is a '''hyphen''', it denotes a regular file.
  
If it is '''l,''' it denotes a '''symbolic link'''.
+
If it is '''l ''', it denotes a '''symbolic link'''.
  
 
If it is '''d''', it denotes a '''directory.'''
 
If it is '''d''', it denotes a '''directory.'''
Line 119: Line 126:
 
Next three denote '''group''' permissions,
 
Next three denote '''group''' permissions,
  
Last three denote '''others''' permissions
+
Last three denote '''others''' permissions.
  
Here each set contains '''r, '''and''' w,''' means '''read, '''and''' write'''.
+
Here '''r, w, x''' means '''read''', '''write''' and '''execute'''.
 
|-  
 
|-  
 
|| Highlight '''example1'''
 
|| Highlight '''example1'''
Line 131: Line 138:
  
 
'''chown command'''
 
'''chown command'''
* The''' chown''' command changes the ownership of a file or directory.  
+
* The ''' chown''' command changes the ownership of a file or directory.  
 
* This is an admin command.
 
* This is an admin command.
 
* Only the root user can change the owner of a file or directory.
 
* Only the root user can change the owner of a file or directory.
  
'''chown [options] ownername filename or directoryname'''
 
 
|| * The''' c h own''' command changes the ownership of a file or directory.  
 
|| * The''' c h own''' command changes the ownership of a file or directory.  
 
* This is an admin command.
 
* This is an admin command.
 
* Only the root user can change the ownership of a file or directory.
 
* Only the root user can change the ownership of a file or directory.
* Here is the syntax of the '''c h own''' command.
+
|-
+
|| '''Slide 8'''
+
 
+
'''chown options'''
+
* -R: change permissions for all files in the current directory and its sub-directories.
+
* -c: report changes made to files.
+
* -f: prevent chown from displaying error messages.
+
|| The '''c h own''' command comes with various options like '''hyphen R, hyphen c, hyphen f''' and others.
+
 
|-  
 
|-  
 
||  
 
||  
Line 164: Line 162:
 
|-  
 
|-  
 
|| Type the sudo password if prompted.
 
|| Type the sudo password if prompted.
|| Type the password if prompted again.
+
|| Type the sudo password if prompted again.
 
|-  
 
|-  
 
|| Type
 
|| Type
Line 182: Line 180:
  
 
Otherwise we will get an '''invalid user''' error.
 
Otherwise we will get an '''invalid user''' error.
 
Recall that we have given you an assignment in an earlier tutorial to create a user named''' demo'''.
 
  
 
If the user does not exist, please create the user.
 
If the user does not exist, please create the user.
Line 202: Line 198:
  
 
highlight examples 1 to 5.  
 
highlight examples 1 to 5.  
|| Now, we will see how to change the owner''' '''of a '''directory.'''
+
|| Now, we will see how to change the owner of a '''directory.'''
  
 
For that we will create a directory first.
 
For that we will create a directory first.
  
Type '''m k dir space pond '''and press Enter.
+
Type '''m k dir space pond ''' and press Enter.
  
To check, type '''l s space hyphen l '''and press Enter.
+
To check, type '''l s space hyphen l ''' and press Enter.
  
 
It displays a directory named''' pond''' and all the existing files examples.  
 
It displays a directory named''' pond''' and all the existing files examples.  
Line 228: Line 224:
 
|| I will clear the screen by pressing '''Ctrl + L''' keys together for our convenience.  
 
|| I will clear the screen by pressing '''Ctrl + L''' keys together for our convenience.  
  
Now type,'''l s space hyphen l '''and press '''Enter'''
+
Now type,'''l s space hyphen l ''' and press '''Enter'''.
  
 
Here we can see the new owner of the directory '''pond''' is '''demo'''.
 
Here we can see the new owner of the directory '''pond''' is '''demo'''.
 
|-  
 
|-  
|| '''Slide 9'''
 
  
'''Changing File Permissions'''
 
  
ch mod command is used to change the permissions of a file or directory.
 
 
The name chmod stands for change mode.
 
 
Using chmod we can grant or remove permissions for owner, group and others.
 
 
read (r)
 
 
write (w)
 
 
execute (x)
 
 
The command modifies only the permissions, not the file contents or ownership.
 
|| '''ch mod''' command is used to change the permissions of a''' file '''or''' directory'''.
 
 
The name''' c h mod '''stands for change mode.
 
 
Using '''chmod '''we can add or remove permissions such as: '''read, write, execute'''.
 
 
These permissions can be changed''' '''for '''owner, group '''and '''others.'''
 
 
It does not modify the file contents or change ownership.
 
|-
 
|| '''Slide 10'''
 
 
'''Syntax of chmod command'''
 
 
chmod [ugoa][+-=][rwx] file-or-directory
 
|| This is the syntax of the '''c h mod''' command.
 
|-
 
|| '''Slide 11'''
 
 
'''Permissions using three-digit octal number'''
 
 
chmod [0-7][0-7][0-7] file_or_directory
 
 
Each digit represents:
 
 
1st digit → owner permissions
 
 
2nd digit → group permissions
 
 
3rd digit → others permissions
 
 
Permission values:
 
 
r = 4 (read)
 
 
w = 2 (write)
 
 
x = 1 (execute)
 
|| Alternatively, we can set permissions using a three digit octal number.
 
|-
 
 
|| Press Clear and press Enter.
 
|| Press Clear and press Enter.
 
|| Now, we will look at some examples of '''ch mod'''.  
 
|| Now, we will look at some examples of '''ch mod'''.  
  
Let me clear the screen
+
Let me clear the screen.
 
|-  
 
|-  
 
|| Type'''chmod u+x example2'''
 
|| Type'''chmod u+x example2'''
  
 
press Enter
 
press Enter
|| To add execute permission to the '''owner''' of the file '''example2''' type:'''ch mod space u plus x space example2 '''and''' '''press '''Enter.'''
+
|| To add execute permission to the '''owner''' of the file '''example2''' type:'''ch mod space u plus x space example2 ''' and press '''Enter.'''
  
 
This will add the execute permission to the owner of the file example2.
 
This will add the execute permission to the owner of the file example2.
Line 312: Line 253:
 
'''l s space hyphen l space example2'''
 
'''l s space hyphen l space example2'''
  
and press '''Enter''' to see the changes
+
and press '''Enter''' to see the changes.
  
It has assigned''' read, write''', and''' execute '''permissions to the '''owner.  
+
It has assigned ''' read, write''', and''' execute '''permissions to the '''owner.  
  
 
'''read-only''' permissions to the '''group'''.
 
'''read-only''' permissions to the '''group'''.
Line 331: Line 272:
  
 
Highlight the output
 
Highlight the output
|| Now type the command
+
|| Now type the command,
  
 
'''ch mod space 751 space example2
 
'''ch mod space 751 space example2
  
'''press '''Enter'''
+
'''press '''Enter'''.
  
This command gives the''' owner read, write''', and '''execute '''permissions.
+
This command gives the ''' owner read, write''', and '''execute '''permissions.
  
To check type, '''ls space hyphen l space example2''' and press Enter.
 
  
 
'''Read''' and '''execute''' permissions to the '''group'''.
 
'''Read''' and '''execute''' permissions to the '''group'''.
  
 
And '''execute-only '''permission to '''others '''for the file '''example2'''.
 
And '''execute-only '''permission to '''others '''for the file '''example2'''.
 +
 +
To check type, '''ls space hyphen l space example2''' and press Enter.
 
|-  
 
|-  
 
|| type '''chmod a<nowiki>=</nowiki>r example2'''
 
|| type '''chmod a<nowiki>=</nowiki>r example2'''
Line 370: Line 312:
 
|| Let’s add the write permissions to the group for file '''example3'''.  
 
|| Let’s add the write permissions to the group for file '''example3'''.  
  
Type the command'''ch mod space g plus w space example3 '''
+
Type the command '''ch mod space g plus w space example3 ''' and press '''Enter'''.
 
+
and press '''Enter'''.
+
 
|-  
 
|-  
 
|| Type'''ls -l example3'''  
 
|| Type'''ls -l example3'''  
Line 388: Line 328:
  
 
press '''Enter'''
 
press '''Enter'''
|| To remove the write permissions for all,type the command'''ch mod space a hyphen w space example3'''
+
|| To remove the write permissions for all, type the command '''ch mod space a hyphen w space example3'''
  
 
press '''Enter.'''
 
press '''Enter.'''
Line 405: Line 345:
 
Observe that write permission for all has been removed
 
Observe that write permission for all has been removed
 
|-  
 
|-  
|| '''Slide 12 '''
 
  
'''chgrp command'''
+
||type  
 
+
'''Ch-grp.png'''
+
||  
+
* '''ch grp''' command changes the '''group ownership''' of a file or directory.
+
* Group members can then access it based on the set permissions'''.'''
+
* Only the owner of a file or a privileged user can change the group.
+
|-
+
|| '''Slide 13'''
+
 
+
'''Syntax of chgrp command'''
+
* The basic syntax of the ch grp command is:'''chgrp [options] group file'''
+
* To change the group of a directory and all its contents recursively:'''chgrp -R group directory'''
+
* Here, '''group''' is the new group name, and '''file''' or '''directory''' is the target.
+
||
+
* The basic syntax of the''' ch g r p''' command is:'''ch grp options group file.'''
+
* To change the group of a directory and all its contents recursively type:'''ch grp hyphen R group directory.'''
+
* Here, '''group''' is the new group name, and '''file''' or '''directory''' is the target.
+
|-
+
|| Switch to terminal
+
 
+
Press Clear and press Enter.
+
 
+
type  
+
  
 
'''ls -l example4'''
 
'''ls -l example4'''
Line 450: Line 366:
  
 
press Enter
 
press Enter
|| To change the group permission, type the command'''sudo space ch grp space demo space example4 '''press Enter. Enter the sudo password, if required.
+
|| To change the group permission, type the command '''sudo space ch grp space demo space example4 ''' press Enter.  
 +
 
 +
Enter the sudo password, if required.
 
|-  
 
|-  
 
|| Type  
 
|| Type  
Line 459: Line 377:
  
 
Highlight the permissions in the output
 
Highlight the permissions in the output
|| Now type the command'''l s space hyphen l space example4'''
+
|| Now type the command '''l s space hyphen l space example4'''
  
 
press '''Enter'''
 
press '''Enter'''
  
 
Observe that the group has changed from '''spoken''' to '''demo'''
 
Observe that the group has changed from '''spoken''' to '''demo'''
|-
 
|| '''Slide 14'''
 
 
'''Inode'''
 
|| An '''i node''' is a unique number that stores file or directory information.
 
  
Files are hard links to i nodes, which the system uses to access data.
 
 
|-  
 
|-  
 
|| Switch to the terminal
 
|| Switch to the terminal
Line 481: Line 393:
  
 
Highlight the number in the output
 
Highlight the number in the output
|| We can use''' l s space hyphen i''' command to see the '''i node '''number of a file.
+
|| We can use ''' l s space hyphen i''' command to see the '''i node '''number of a file.
  
 
type the command,''' l s space hyphen i space example5'''
 
type the command,''' l s space hyphen i space example5'''
 +
 +
An '''inode''' is a unique number that stores file or directory information.
 +
  
 
press '''Enter.'''
 
press '''Enter.'''
  
The number written before the file is the i node number of the file.
+
The number written before the file is the inode number of the file.
  
 
The '''i node''' number may vary for the users.
 
The '''i node''' number may vary for the users.
|-
 
|| '''Slide 15'''
 
  
'''Hard Links'''
 
|| A hard link is another name for an existing file.
 
  
Both files point to the same '''i node.'''
 
 
Since they share the same i node, they share the same data on disk.
 
 
The file is not copied, only a new filename is created.
 
 
|-  
 
|-  
|| '''Slide 16'''
+
|| Type: clear
  
'''Inode and Hard Links'''
+
and press enter
|| An i node can have multiple directory entries through hard links.
+
  
Hard links let multiple filenames point to the same i node.
+
'''ln example2 exampleln'''
  
To create links in Linux, we use the '''ln''' command.
+
press Enter
|-
+
|| '''Slide 17'''
+
  
'''Syntax of ln'''
+
Point to the command.
 +
|| Now we will look at some examples of hard links.
  
'''ln source link'''
+
Let me clear the screen again.
|| The syntax of '''ln''' command to create a hard link is:
+
  
'''ln space source space link'''
+
To create links in Linux, we use the '''ln''' command.
  
The source is an existing file, and the link is the new filename.
+
Type the command,
  
 +
'''l n space example2 space example l n'''.
 +
 
Both files point to the same i node and share the same data.
 
Both files point to the same i node and share the same data.
  
 
Any change made to one file will reflect in the other file.
 
Any change made to one file will reflect in the other file.
|-
 
|| Type: clear
 
  
and press enter
+
A hard link is another name for an existing file.
  
'''ln example2 exampleln'''
+
Both files point to the same '''inode.'''
  
press Enter
+
Since they share the same inode, they share the same data on disk.
  
Point to the command.
+
The file is not copied, only a new filename is created.
|| Now we will look at some examples of hard links
+
 
+
Let me clear the screen again.
+
 
+
Type the command,
+
 
+
'''l n space example2 space example l n'''
+
  
 
press Enter.
 
press Enter.
  
This command creates a hard link named '''exampleln''' to the file '''example2.'''
+
This command creates a hard link named '''exampleln''' to the file '''example2 '''.
 
|-  
 
|-  
 
|| Type '''ls -i example2 exampleln'''
 
|| Type '''ls -i example2 exampleln'''
Line 552: Line 448:
  
 
Highlight to the output
 
Highlight to the output
||  
+
|| To display the inode number of both the files, type the command'''l s space hyphen i space example2 space exampleln'''
 
+
To display the i node number of both the files, type the command'''l s space hyphen i space example2 space exampleln'''
+
  
 
and press '''Enter.'''
 
and press '''Enter.'''
  
The output shows that both files have the same i node number.
+
The output shows that both files have the same inode number.
  
File '''exampleln''' is the hard link for file example2
+
File '''exampleln''' is the hard link for file example2.
|-
+
|| '''Slide 18'''
+
  
'''Soft Link'''
 
|| A soft link or a symbolic link is a special type of file.
 
 
It holds a reference to another file or directory.
 
 
This reference is an absolute or relative path.
 
|-
 
|| '''ln -s target-filename symbolic-filename'''
 
|| The syntax of''' l n command''' to create soft links is'''l n space hyphen s space target filename space symbolic filename.'''
 
 
|-  
 
|-  
 
||  
 
||  
 
|| Now we will look at some examples of soft links.
 
|| Now we will look at some examples of soft links.
 
|-  
 
|-  
||  
+
|| type '''ln -s example2 examplesoft''' press Enter
 
+
type '''ln -s example2 examplesoft''' press Enter
+
 
|| To create a soft link, type the command
 
|| To create a soft link, type the command
  
'''l n space hyphen s space example2 space examplesoft '''and press Enter.
+
'''l n space hyphen s space example2 space examplesoft '''  
 +
 
 +
A soft link or a symbolic link is a special type of file.
 +
 
 +
It holds a reference to another file or directory.
 +
 
 +
This reference is an absolute or relative path
 +
 
 +
and press Enter.
 +
 
 
|-  
 
|-  
 
|| type the command
 
|| type the command
  
 
''' ls -li example2 examplesoft '''press Enter
 
''' ls -li example2 examplesoft '''press Enter
|| Now, let us display the i node number and list both the files.
+
|| Now, let us display the inode number and list both the files.
  
 
Type the command,
 
Type the command,
  
'''l s space hyphen l i space example2 space examplesoft'''
+
'''l s space hyphen l i space example2 space examplesoft''' and
  
 
press '''Enter.'''
 
press '''Enter.'''
  
Observe that the '''i node''' number of both the files is different.
+
Observe that the '''inode''' number of both the files is different.
  
 
'''examplesoft''' is a''' soft link''' of''' example2'''.
 
'''examplesoft''' is a''' soft link''' of''' example2'''.
 
|-  
 
|-  
|| '''Slide 19'''
+
|| '''Slide 8'''
  
 
'''Summary'''
 
'''Summary'''
Line 612: Line 502:
 
Let us summarise.
 
Let us summarise.
 
|-  
 
|-  
|| '''Slide 20'''
+
|| '''Slide 9'''
  
 
'''Assignment'''
 
'''Assignment'''
Line 621: Line 511:
 
|| As an Assignment, please do the following.
 
|| As an Assignment, please do the following.
 
|-  
 
|-  
|| '''Slide 21'''
+
|| '''Slide 10'''
  
 
'''Thank you'''
 
'''Thank you'''
|| This '''Spoken Tutorial''' is brought to you by '''EduPyramids Educational Services Private Limited SINE IIT Bombay.'''Thank you.
+
|| This '''Spoken Tutorial''' is brought to you by '''EduPyramids Educational Services Private Limited, SINE, IIT Bombay.'''Thank you.
 
|-
 
|-
 
|}
 
|}

Latest revision as of 17:23, 11 March 2026

Title of the Script: Linux File Ownership and Permissions

Authors: Edupyramids

Keywords: Linux, File Ownership, File Permissions, chown, chmod, chgrp, Inodes, Hard link, Soft link, Symbolic link, Terminal commands, Linux file system, edupyramids, video tutorial.


Visual Cue Narration
Slide 1

Title Slide

Welcome to this spoken tutorial on Linux File Ownership and Permissions.
Slide 2

Learning Objectives

In this tutorial, we will learn to:
  • Manage file ownership and permissions using c h own and c h mod commands.
  • Change file group ownership using chgrp command.
  • Describe inodes and view inode numbers of the files.
  • Create and verify hard links and symbolic links in Linux.
Slide 3

System Requirements

To record this tutorial, I am using:

Ubuntu O S version 24 point 04

Slide 4

Pre-requisites

https://EduPyramids.org </u>

To follow this tutorial,

learners should have Ubuntu version 24 point 04.

For the prerequisite Linux tutorials please visit this website.

Slide 5

Code Files

The following code file is required to practice this tutorial.

  1. file-attr.zip
  2. fa-commands.txt

This file is provided in the Code Files link of this tutorial page.

The following code files are required to practice this tutorial.

These files are provided in the Code Files link of this tutorial page.

Slide 6

File Attributes

File-attributes.png

File attributes are properties linked to a file.

Attributes define ownership and permissions.

They include file type, size, and time details.

They show who owns the file and who can access it.

File attributes are viewed using the l s hyphen l command.

Switch to terminal

Type cd Desktop/file-attr

Press Enter

Highlight the output

/Desktop/file-attr$d

Let us move to the code files folder file hyphen attr

provided along with the tutorial.

I have downloaded it to my Desktop.

Now switch to the terminal.

Type c d space Desktop slash file hyphen a t t r and press Enter.

Notice that the prompt path has changed.

Type

ls -l example1

and press Enter

Highlight the output

point to the first character

Let us type

l s space hyphen l space example1

and press Enter.

Observe the output.

The first character in the output shows the file type.

If it is a hyphen, it denotes a regular file.

If it is l , it denotes a symbolic link.

If it is d, it denotes a directory.

We see a hyphen here since example1 is a regular file.

highlight the next 9 characters The next nine characters show permissions.

First three denote owner permissions,

Next three denote group permissions,

Last three denote others permissions.

Here r, w, x means read, write and execute.

Highlight example1

highlight spoken

Here we can see that the owner of the file example1 is spoken.
Slide 7

chown command

  • The chown command changes the ownership of a file or directory.
  • This is an admin command.
  • Only the root user can change the owner of a file or directory.
* The c h own command changes the ownership of a file or directory.
  • This is an admin command.
  • Only the root user can change the ownership of a file or directory.
Now we will look at some examples.
Type

sudo chown demo example1

press Enter.

Let us change the owner of the file example1.

Type sudo space ch own space demo space example1

press Enter.

Type the sudo password if prompted. Type the sudo password if prompted again.
Type

ls -l example1

press Enter

Highlight the output

Let us see the file attributes of example1.

Type l s space hyphen l space example1 and press Enter.

Observe that the new owner of the file is demo.

This works only if the user named demo exists.

Otherwise we will get an invalid user error.

If the user does not exist, please create the user.

Type

mkdir pond

and press Enter.

Type the command

ls -l

press Enter

Highlight the pond directory details

highlight examples 1 to 5.

Now, we will see how to change the owner of a directory.

For that we will create a directory first.

Type m k dir space pond and press Enter.

To check, type l s space hyphen l and press Enter.

It displays a directory named pond and all the existing files examples.

Here we can see the owner of the directory pond is spoken

Type

sudo chown -R demo pond

Let us change the owner of the directory pond to demo.

Type the following command and press Enter

Enter the sudo password, if required and press Enter again.

Press Ctrl+L keys together.

Type ls -l and press Enter.

I will clear the screen by pressing Ctrl + L keys together for our convenience.

Now type,l s space hyphen l and press Enter.

Here we can see the new owner of the directory pond is demo.

Press Clear and press Enter. Now, we will look at some examples of ch mod.

Let me clear the screen.

Typechmod u+x example2

press Enter

To add execute permission to the owner of the file example2 type:ch mod space u plus x space example2 and press Enter.

This will add the execute permission to the owner of the file example2.

type

ls -l example2

press Enter

highlight the permissions in the output

To check that, type

l s space hyphen l space example2

and press Enter to see the changes.

It has assigned read, write, and execute permissions to the owner.

read-only permissions to the group.

And read-only permission to others, for the file example2.

Type

chmod 751 example2

press Enter

type ls -l example2

and press Enter

Highlight the output

Now type the command,

ch mod space 751 space example2

press Enter.

This command gives the owner read, write, and execute permissions.


Read and execute permissions to the group.

And execute-only permission to others for the file example2.

To check type, ls space hyphen l space example2 and press Enter.

type chmod a=r example2

and press Enter

To assign read-only permission to example2 for everyone, type the following command:

ch mod space a equal to r space example2 and press Enter.

type ls -l example2

press Enter

Highlight the output

Now type the command,

l s space hyphen l space example2

and press Enter.

Observe that the file example2 has read-only permission for all users.

Type chmod g+w example3

and press Enter

Let’s add the write permissions to the group for file example3.

Type the command ch mod space g plus w space example3 and press Enter.

Typels -l example3

press Enter

Highlight the output

Now type,l s space hyphen l space example3

press Enter.

Note that the write permission has been added to the group.

Type chmod a-w example3

press Enter

To remove the write permissions for all, type the command ch mod space a hyphen w space example3

press Enter.

Type

ls -l example3

press Enter

Highlight the output

Now type, l s space hyphen l space example3

press Enter.

Observe that write permission for all has been removed

type

ls -l example4

press Enter

Highlight the permissions in the output

Let's look at some examples of ch grp commands.

Type the command,

l s space hyphen l space example4

and press Enter.

Here we can see the group permission is given for the user spoken.

Type sudo chgrp demo example4

press Enter

To change the group permission, type the command sudo space ch grp space demo space example4 press Enter.

Enter the sudo password, if required.

Type

ls -l example4

press Enter

Highlight the permissions in the output

Now type the command l s space hyphen l space example4

press Enter

Observe that the group has changed from spoken to demo

Switch to the terminal

type the command

ls -i example5

press Enter

Highlight the number in the output

We can use l s space hyphen i command to see the i node number of a file.

type the command, l s space hyphen i space example5

An inode is a unique number that stores file or directory information.


press Enter.

The number written before the file is the inode number of the file.

The i node number may vary for the users.


Type: clear

and press enter

ln example2 exampleln

press Enter

Point to the command.

Now we will look at some examples of hard links.

Let me clear the screen again.

To create links in Linux, we use the ln command.

Type the command,

l n space example2 space example l n.

Both files point to the same i node and share the same data.

Any change made to one file will reflect in the other file.

A hard link is another name for an existing file.

Both files point to the same inode.

Since they share the same inode, they share the same data on disk.

The file is not copied, only a new filename is created.

press Enter.

This command creates a hard link named exampleln to the file example2 .

Type ls -i example2 exampleln

press Enter

Highlight to the output

To display the inode number of both the files, type the commandl s space hyphen i space example2 space exampleln

and press Enter.

The output shows that both files have the same inode number.

File exampleln is the hard link for file example2.

Now we will look at some examples of soft links.
type ln -s example2 examplesoft press Enter To create a soft link, type the command

l n space hyphen s space example2 space examplesoft

A soft link or a symbolic link is a special type of file.

It holds a reference to another file or directory.

This reference is an absolute or relative path

and press Enter.

type the command

ls -li example2 examplesoft press Enter

Now, let us display the inode number and list both the files.

Type the command,

l s space hyphen l i space example2 space examplesoft and

press Enter.

Observe that the inode number of both the files is different.

examplesoft is a soft link of example2.

Slide 8

Summary

In this tutorial, we have learnt to:

  • Manage file ownership and permissions using chown and chmod commands.
  • Change file group ownership using chgrp command.
  • Describe inodes and view inode numbers of the files.
  • Create and verify hard links and symbolic links in Linux.
With this we come to the end of this tutorial.

Let us summarise.

Slide 9

Assignment

  1. Create a file named sample.txt.
  2. Display its permissions using the ls -l command.
  3. Change the permissions so that only the owner can read and write the file.
  4. Display the inode number of sample.txt.
As an Assignment, please do the following.
Slide 10

Thank you

This Spoken Tutorial is brought to you by EduPyramids Educational Services Private Limited, SINE, IIT Bombay.Thank you.

Contributors and Content Editors

Ketkinaina, Madhurig