0% found this document useful (0 votes)
3 views11 pages

Operating-System Lab5

The document provides an overview of Linux file types, permissions, and commands related to file management. It explains different file types, how to set permissions using the chmod command, and the purpose of the umask command. Additionally, it includes a challenge and a task list for practical application of the concepts discussed.

Uploaded by

mr3370628
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)
3 views11 pages

Operating-System Lab5

The document provides an overview of Linux file types, permissions, and commands related to file management. It explains different file types, how to set permissions using the chmod command, and the purpose of the umask command. Additionally, it includes a challenge and a task list for practical application of the concepts discussed.

Uploaded by

mr3370628
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/ 11

Operating System:

Lab 5

preencoded.png
Linux File Types
• - (Regular file): Contains data, text, or programs.
• d (Directory): Holds other files and directories.
• l (Symbolic link): A pointer to another file or directory.
• c (Character special file): Represents character devices (e.g.,
terminals).
• b (Block special file): Represents block devices (e.g., hard drives).

Explanation: The first character in a file's long listing (ls -l)


indicates its type. Symbolic links always show rwxrwxrwx permissions,
which are dummy values; the actual permissions reside with the target
file.
preencoded.png
preencoded.png
File Permissions
Description: Control who can read, write, and execute files and directories.

Attributes:

• r (Read): Allows reading the file or listing a directory's contents.

• w (Write): Allows modifying a file or creating/deleting/renaming files in a directory.

• x (Execute): Allows executing a file or entering a directory.

Examples:

• -rwx------: Owner has full access; others have none.

• -rw-r--r--: Owner can read/write; group and others can read.

• drwxr-x---: Owner can enter and modify the directory; group can enter.

Explanation: Permissions are displayed in the long listing (ls -l) as three sets of rwx
(owner, group, others).

preencoded.png
File Permissions
Description: The id command is used to display the user and group IDs associated with
the current user or a specified user. It provides information like the user ID (UID), group ID (GID), and the groups the user belongs to.

Command: id

Output: uid=1000(user) gid=1000(user) groups=1000(user),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),120(lpadmin),131(sambashare)

Explanation :
uid=1000(user): This indicates that the user's unique ID is 1000, and the
username associated with it is "user".
gid=1000(user): This shows the user's primary group ID is also 1000, and the
group name is "user".
groups=1000(user),4(adm),...: This lists all the groups the user belongs to.
Each group is shown with its ID and name. For example, 4(adm) means the user
is a member of the group "adm" with ID 4.

preencoded.png
File Permissions
Description: The chmod command is used to change the permissions (read, write, execute) of files and directories.
It controls who can access and modify these files.

Command: chmod

Example: chmod 755 myfile.sh

Explanation :
755 represents the permissions in octal notation.
The first digit (7) represents the owner's permissions.
The second digit (5) represents the group's permissions.
The third digit (5) represents the permissions for others (everyone else).
Octal Permission Breakdown:4: Read (r)
2: Write (w)
1: Execute (x)
Adding these values gives the octal representation:7 = 4 + 2 + 1 (rwx - read, write, execute)5 = 4 + 1 (r-x - read and execute)Therefore,
chmod 755 myfile.sh sets the owner to have read, write, and execute permissions, and the group and others to have read and execute
permissions.
preencoded.png
preencoded.png
Challenge

1) You have three files in the /home/student/docs/ directory. Set the correct
permissions using chmod with three-digit notation:

1. report.txt – The owner can read and write, the group can only read, and others have
no access.
2. script.sh – The owner can read, write, and execute, but no one else can access it.
3. public.txt – Everyone can read, but no one can write or execute.
Questions:
• What are the correct three-digit permission values for each file?
• Use chmod to apply the correct permissions

preencoded.png
File Permissions
Description: The umask command sets the default permissions for newly created files and directories.
It defines which permissions are masked out (removed) from the default permissions.

Command: umask Example: umask 022

Explanation :
022 is the umask value in octal notation.
The first digit (0) represents special permissions (which we'll ignore for simplicity).
The second digit (2) represents the permissions to be removed from the group.
The third digit (2) represents the permissions to be removed from others.
Umask and Permissions:
The default permissions for files are usually 666 (rw-rw-rw-).
The default permissions for directories are usually 777 (rwxrwxrwx).
The umask value is subtracted from these defaults to determine the actual permissions.
In the example umask 022:
Files: 666 - 022 = 644 (rw-r--r--)
Directories: 777 - 022 = 755 (rwxr-xr-x)
Output: The umask command by itself displays the current umask value. preencoded.png
preencoded.png
Task
1) Create a directory called linux_assessment
9) Inside the docs directory, create a text file
in your home directory
10) Create a symbolic link to report.txt
2) Navigate into the directory
11) Use ls -l to check file details
3) Create a text file with the line "Learning
12) Confirm file types using the file command
Linux commands“
13) Create multiple files
4) Create a directory called docs
14) List all files starting with "data"
5) Check the file type of commands.txt
15) Search for "Linux" in commands.txt
6) Find the full path to the ls command
16) Find commands related to "directory"
7) Create an alias ll for ls -la
17) List all defined aliases
8) Open and close the manual for cp

preencoded.png

You might also like