BLP Unit 3.4
BLP Unit 3.4
- Each file has characteristics like file name, file type, date (on which file was created), etc.
- These characteristics are referred to as ‘File Attributes’.
- The OS associates these attributes with files.
- In different operating systems files may have different attributes.
- – l : known as a long format that displays detailed information about files and
directories(shows permissions).
- Example:
- ls – l
- Here, as you can see the list in long list format.
- Columns above indicate specific things:
- Column 1 indicates information regarding file permission.
- Column 2 indicates the number of links to the file.
- Column 3 & 4 indicates the owner and group information.
- Column 5 indicates size of the file in bytes.
- Column 6 shows the date and time on which the file was recently modified.
- Column 7 shows the file or directory name.
- ls –l can be used to get the details of directories content. But –d option can be used to
display the details of directories. With ls – ld command, we will see the permissions on the
directory itself, not on its contents.
- Example:
- ls – ld
- Different users in the operating system have ownership and permission to ensure that the
files are secure.
- In Linux, different users use the system:
i) Root User: It is a superuser who has access to all the directories and files in our system
and it can perform any operation. Only the root user can perform changing of permissions
or ownerships of the files that are not owned by them.
ii) Regular User: These users have limited access to files and directories and can only
modify the files that they own.
- Every file and directory in your Linux system has following 3 permissions.
i) Read: This permission gives the authority to open and read a file. Read permission on a
directory gives the ability to lists its content.
ii) Write: The write permission gives the authority to modify the contents of a file. The
write permission on a directory gives the authority to add, remove and rename files stored in
the directory.
iii) Execute: In Windows, an executable program usually has an extension “.exe” and which
you can easily run. In Linux, you cannot run a program unless the execute permission is set.
Syntax:
$chmod<Category><Operation><permission><filename>
Example 1:
$chmod ugo+x abc.txt
Above command assigns the execute permission for user, group and others.
Example 2:
$chmod ugo-r x1.txt
Above command removes read permission for user, group and others.
- This method uses a number to specify each set of permissions for the file.
- It assigns permission in three digits.
- First digit assign permission for owner, second digit for group and third for others.
- Digits range is 0 to 7.
- Syntax:
$chmod <Three digit octal number><Filename>
$chmod [u g o ] filename