0% found this document useful (0 votes)
72 views5 pages

Filesystems and Storage File Attributes

The document discusses file attributes in Linux, including permission levels for owner, group, and world. It also covers using ls -l to view file attributes, chmod to change permissions, and chown to change ownership. Examples provided demonstrate finding file attributes, representing permissions in octal, and changing permissions and ownership of files.

Uploaded by

Pepe Otero
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
72 views5 pages

Filesystems and Storage File Attributes

The document discusses file attributes in Linux, including permission levels for owner, group, and world. It also covers using ls -l to view file attributes, chmod to change permissions, and chown to change ownership. Examples provided demonstrate finding file attributes, representing permissions in octal, and changing permissions and ownership of files.

Uploaded by

Pepe Otero
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

File Attributes

A Linux Foundation Training Publication


www.training.linuxfoundation.org
(c) Copyright the Linux Foundation 2015. All rights reserved.
File Attributes

Overview
The Linux operating systems allows for a high degree of control over access to files and
directories. Each file and directory has attributes that determine access at the owner, group,
and world level. These attributes are used to determine whether a user or process can read,
write, and execute a file.

File access, or permission, is granted hierarchically. Group access overrides universal


access, and owner access overrides group access. The permissions on a given file or
directory are often represented numerically as an octal.

Key Ideas
Permission levels: Each file and directory has permissions set at three levels: owner, group,
and world. The permissions at each level can be represented together as an octal (three
digit number with one number each for owner, group, and world permissions).

Permission types: Permission is given to perform actions on files and directories: read,
write, and execute. To calculate the octal representation of what permissions are allowed
to group, each action is worth a certain number or points. Read permission = 4, Write
= 2, Execute = 1. For example, if permissions allow for read, write, and execute, that is
represented as a 7.

ls -l: The ls command for listing files in a directory has “-l” argument which gives the file
attributes of each file and directory. The first 10 characters of the ls -l command are file
attributes.

drwxr-xr-x. 3 root root 18 Feb 11 22:49 mnt


1st character: Type of file (d = directory, - = file)
2nd - 4th characters: Owner permissions (read, write, execute = 7)
5th - 7th characters: Group permissions (read and execute, but not write = 5)

2
File Attributes

8th - 10th characters: World permissions (read and execute, but not write = 5)
Owner: root
Group: root

chmod: The chmod command is for changing permissions of a file or directory.

chown: The chown command is for changing the ownership of a file or directory.

Example Scenario
The following series of examples shows different scenarios where you can discover and
change file attributes.

Now Do It
1. Find the file attributes of the /home directory.

2. Find the octal representation of the permissions of /etc/hosts

3. If a file’s permissions are represented by 755, what actions can members of the
owner group take?

4. Create a file in /root called star.txt, and change its ownership a different user.

5. Change the permissions of of star.txt so that the owner, owner group, and world
can read and execute.

If you remember nothing else...


Chmod 777 means that everyone can read, write, and execute the file.

3
File Attributes

Answer Key
1. Find the file attributes of the home directory
# ls -l /
drwxr-xr-x. 3 root root 21 Feb 8 13:09 home

2. Octal representation of /etc/hosts: 622

3. 755 means members of the owner’s group can read and execute

4. Create a file and change it’s ownership:


# touch /root/star.txt
# chown USER /root/start.txt
No output on successful execution of command

5. Change permissions so everyone can read, write execute:


# chmod 555 /root/star.txt
No output on successful execution of command.

4
Get Certified!
Get more information at http://training.linuxfoundation.org/certification/lfcs

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy