Setting Up File Permissions
2. About Ownership
Who Can Change File’s Permissions?
First, the root User may be the Default one in Lubuntu.
So to Check What User you are on:whoami
Again, check What’s your User’s Primary Group Name:
id -gn
- You Can Freely Change Permissions over Files/Directories Your User’s Hold.
- But you need Admin Super User Powers to Change Permissions on Entities he Do Not Hold!
3. Setting up File Permissions
Setting Up Permissions on Files and Directories.
Basic Building Blocks for the Permission Command.
Ownership Types:
- Use ‘u‘ to Setup Permissions for the User Owner
- Use ‘g‘ to Setup Permissions for the Primary Group Owner
- Use ‘u+g‘ to Setup Permissions for the User and Primary Group Owner
- Use ‘a‘ to Setup Permissions for All (World)
- Use ‘o‘ for Revoking Actual Permissions and Giving Permissions to the Others (the Before Disabled ones)
- Use ‘x‘ to Setup Execution Permission
- Use ‘w‘ to Setup Write/Delete Permission
- Use ‘r‘ to Setup Read Permission
- Use ‘+‘ to Give Permission
- Use ‘–‘ to Remove Permission
Permission Types:
Giving/Removing Permissions:
Generic Permission Command Form:
chmod ownershipSubject[+/-]r/w/x [myEntity]
For Instance:
mkdir $HOME/world
To Give ‘All’ (read,write/delete,execute) Permissions on the ‘world’ Directory to ‘Everybody’:
chmod a+rwx $HOME/world
(Normally Take Care Before to Open a Directory to the World Because this Can Compromise your System Security!)
Now to Check Permissions Setup:
ls -l $HOME
To Remove the ‘Write/Delete’ Permission to the ‘World’:
chmod a-w $HOME/world
To Give the ‘Write/Delete’ Permission the ‘world’ Only to the Owner:
chmod u+w $HOME/world
To Give the ‘Write/Delete’ Permission the ‘world’ Also to the Owner’s Primary Group:
chmod g+w $HOME/world
To Remove the ‘Execution’ Permission to the ‘World’:
chmod a-x $HOME/world
To Give the ‘Execution’ Permission to the ‘world’ to the Owner:
chmod u+x $HOME/world
To Give the ‘Execution’ Permission to the ‘world’ Also to the Owner’s Primary Group:
chmod g+x $HOME/world
After that Only your User and your User’s Primary Group will be able to Access the ‘world’ Directory Directory on Shell!