0% found this document useful (0 votes)
6 views3 pages

17 Chmod Command

Uploaded by

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

17 Chmod Command

Uploaded by

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

Linux chmod Practices: 10 Exercises

Practice 1: Changing File Permissions to Read-Only


Objective: Use chmod to make a file read-only.
Instructions:
1. Create a file named Avengers.txt:
touch Avengers.txt
2. Set the file to be read-only for everyone:
chmod 444 Avengers.txt
3. Verify the permissions using ls -l.

Practice 2: Granting Execute Permission


Objective: Use chmod to allow execution of a script.
Instructions:
1. Create a script named BattlePlan.sh:
touch BattlePlan.sh
2. Grant execute permission to the owner:
chmod u+x BattlePlan.sh
3. Verify the permissions with ls -l and test running the script:
./BattlePlan.sh

Practice 3: Removing Write Permissions


Objective: Use chmod to prevent modifications to a file.
Instructions:
1. Create a file named InfinityGauntlet.txt:
touch InfinityGauntlet.txt
2. Remove write permissions for everyone:
chmod -w InfinityGauntlet.txt
3. Verify that you cannot edit the file.

Practice 4: Granting Full Access to the Owner


Objective: Use chmod to give full permissions to the owner only.
Instructions:
1. Create a file named WakandaSecrets.txt:
touch WakandaSecrets.txt
2. Grant the owner full permissions (read, write, execute):
chmod 700 WakandaSecrets.txt
3. Verify the permissions using ls -l.

Practice 5: Making a Directory Accessible to All


Objective: Use chmod to allow everyone access to a directory.
Instructions:
1. Create a directory named SHIELD:
mkdir SHIELD
2. Grant read, write, and execute permissions to everyone:
chmod 777 SHIELD
3. Verify the permissions with ls -ld SHIELD.

Practice 6: Granting Group Access


Objective: Use chmod to allow a group to access a file.
Instructions:
1. Create a file named MissionLog.txt:
touch MissionLog.txt
2. Grant the group read and write permissions:
chmod g+rw MissionLog.txt
3. Verify the permissions using ls -l.

Practice 7: Removing All Permissions


Objective: Use chmod to make a file completely inaccessible.
Instructions:
1. Create a file named VillainsPlan.txt:
touch VillainsPlan.txt
2. Remove all permissions for everyone:
chmod 000 VillainsPlan.txt
3. Verify that the file cannot be opened or edited.

Practice 8: Using Octal Notation


Objective: Use octal numbers to set precise permissions.
Instructions:
1. Create a file named ThorHammer.txt:
touch ThorHammer.txt
2. Set permissions to allow the owner full access, group read-only, and no
access for others:
chmod 740 ThorHammer.txt
3. Verify the permissions with ls -l.

Practice 9: Applying Recursive Permissions


Objective: Use chmod to set permissions for a directory and its contents.
Instructions:
1. Create a directory named Phase1 with files inside:
mkdir Phase1
touch Phase1/{IronMan.txt,Thor.txt,Hulk.txt}
2. Set all files and the directory to be read-only:
chmod -R 444 Phase1
3. Verify permissions using ls -lR Phase1.

Practice 10: Granting Execute Permissions to All


Objective: Use chmod to make a script executable by everyone.
Instructions:
1. Create a script named AvengersAssemble.sh:
touch AvengersAssemble.sh
2. Grant execute permissions to everyone:
chmod a+x AvengersAssemble.sh
3. Verify the permissions with ls -l and run the script:
./AvengersAssemble.sh

You might also like