Modifying File and Directory Persmissions Part-1
Modifying File and Directory Persmissions Part-1
Copyright (c) 2019 CompTIA Properties, LLC. All Rights Reserved. | CompTIA.org 1
Topic A: Modify File and Directory Permissions
Exam Objectives:
• 3.1 Given a scenario, apply or acquire the appropriate user and/or
group permissions and ownership.
Copyright (c) 2019 CompTIA Properties, LLC. All Rights Reserved. | CompTIA.org 2
Permissions
Copyright (c) 2019 CompTIA Properties, LLC. All Rights Reserved. | CompTIA.org 3
Permission Attributes
Attribute Description
• Files: Access and view contents of a file.
Read (r)
• Directories: List contents of directory.
Copyright (c) 2019 CompTIA Properties, LLC. All Rights Reserved. | CompTIA.org 4
Permission Contexts
Copyright (c) 2019 CompTIA Properties, LLC. All Rights Reserved. | CompTIA.org 5
Permission String
Copyright (c) 2019 CompTIA Properties, LLC. All Rights Reserved. | CompTIA.org 6
The chmod Command
Copyright (c) 2019 CompTIA Properties, LLC. All Rights Reserved. | CompTIA.org 7
chmod Command Options
Option Used To
Copyright (c) 2019 CompTIA Properties, LLC. All Rights Reserved. | CompTIA.org 8
chmod Symbolic Mode (Slide 1 of 2)
Copyright (c) 2019 CompTIA Properties, LLC. All Rights Reserved. | CompTIA.org 9
chmod Symbolic Mode (Slide 2 of 2)
Copyright (c) 2019 CompTIA Properties, LLC. All Rights Reserved. | CompTIA.org 10
chmod Absolute Mode (Slide 1 of 2)
Copyright (c) 2019 CompTIA Properties, LLC. All Rights Reserved. | CompTIA.org 11
chmod Absolute Mode (Slide 2 of 2)
Copyright (c) 2019 CompTIA Properties, LLC. All Rights Reserved. | CompTIA.org 12
Activity 3-1: Modifying File and Directory
Permissions
• We're concerned about protecting files on a Linux server.
• We'll configure permissions for file owner, group, and other users.
Copyright (c) 2019 CompTIA Properties, LLC. All Rights Reserved. | CompTIA.org 13
Default Permissions
Copyright (c) 2019 CompTIA Properties, LLC. All Rights Reserved. | CompTIA.org 14
The umask Command (Slide 1 of 2)
Copyright (c) 2019 CompTIA Properties, LLC. All Rights Reserved. | CompTIA.org 15
The umask Command (Slide 2 of 2)
Copyright (c) 2019 CompTIA Properties, LLC. All Rights Reserved. | CompTIA.org 16
Activity
Copyright (c) 2019 CompTIA Properties, LLC. All Rights Reserved. | CompTIA.org 17
Activity 3-2: Discussing File and Directory Permissions
• ANSWER:
• ls -l —This command displays the permissions of all files in the directory to help
us sort out the problem. It's likely that the directory's group permissions are
incorrectly set.
Copyright (c) 2019 CompTIA Properties, LLC. All Rights Reserved. | CompTIA.org 18
Activity 3-2: Discussing File and Directory Permissions
• ANSWER:
• Either 664 or rw-rw-r-- is correct.
Copyright (c) 2019 CompTIA Properties, LLC. All Rights Reserved. | CompTIA.org 19
Activity 3-2: Discussing File and Directory Permissions
• A user cannot execute a script (collect.sh) she created and has sent us
the contents of the script via email to inspect. After looking at the
script, we determine the script is correctly written but permissions
are the problem. What command can we issue to adjust the file's
permissions as necessary?
• ANSWER:
• chmod u+x collect.sh
Copyright (c) 2019 CompTIA Properties, LLC. All Rights Reserved. | CompTIA.org 20
Activity 3-2: Discussing File and Directory
Permissions
• A user changed the permissions of a script (myscript.sh) in a shared
directory. The user is curious why everyone can execute the script if
the user owns the script and everyone else only has read access. To
make the script executable, what command did the user mistakenly
issue?
• ANSWER:
• chmod +x myscript.sh —The permissions changed to rwxrwxr-x or 775, which
gives everyone execute permission. To limit execute permission to the user and
group only, the command should have been: chmod ug+x myscript.sh
Copyright (c) 2019 CompTIA Properties, LLC. All Rights Reserved. | CompTIA.org 21
Activity 3-2: Discussing File and Directory
Permissions
• Our team lead is tired of receiving help desk tickets to restore deleted
files from a directory that contains hundreds of files and
subdirectories. She decides to have us fix the problem by making all of
the files read-only. How do we change all the files to read-only
without having to traverse each directory?
• ANSWER:
• chmod -R 644 * —This command changes all files in the current directory to 644
recursively.
Copyright (c) 2019 CompTIA Properties, LLC. All Rights Reserved. | CompTIA.org 22