E
Eric Hansen
Guest
Every Linux system comes with chmod, which allows you to change the mode of a file, directory, etc... Next to chown (change owner) chmod is the next most important programs you can have in your arsenal to properly secure your system. Here I'll go over some of the basics of chmod and how it can help you, and then the next part will cover some more advanced topics like the sticky bit.
Switches
chmod comes with a few nice features to help you in your usage. Some of the important ones are what we'll cover.
Prints out information, mostly if a file was modified or not.
Similar to -v but supresses any text unless its to tell you that a file's been modified.
This lets you change multiple files and folders to the same permissions. This is a huge time saver when you're setting up files on a web server, for example, when it requires 755 permission and the folder is set to 644.
By default if you run a command like "chmod -R 000 /" it will essentially break your system. This switch prevents this from happening.
If a file already exists with the permissions you want you can use this switch instead and not specify the mode at all.
File Permission Types
When you upload files via FTP you will most likely have to modify the permissions, especially if you have your web server properly configured. There are three different types of permissions to be concerned with:
How Permissions Work
With chmod there are 3 different types of permissions each group has:
Switches
chmod comes with a few nice features to help you in your usage. Some of the important ones are what we'll cover.
Code:
-v, --verbose output a diagnostic for every file processed
Code:
-c, --changes like verbose but report only when a change is made
Code:
-R, --recursive change files and directories recursively
Code:
--preserve-root fail to operate recursively on '/'
Code:
--reference=RFILE use RFILE's mode instead of MODE values
File Permission Types
When you upload files via FTP you will most likely have to modify the permissions, especially if you have your web server properly configured. There are three different types of permissions to be concerned with:
- User
- Group
- World
How Permissions Work
With chmod there are 3 different types of permissions each group has:
- read (4)
- write (2)
- execute (1)
Attachments
Last edited: