How To Use Chmod | Change Mode

Learn How to Use Chmod On Files and Set the Correct Permissions

So you have a script that you want to install on your computer and as you are reading the instructions, you come across a section about certain directory or file permission that have to be CHMOD 777 or 755, etc. The first thought that pops into your head is, “What is CHMOD?” Many people are not familiar with CHMOD (change mode).

To select Chmod right click a folder or file

To select Chmod right click a folder or file

What is CHMOD?

For those of you that do not know what CHMOD means, CHMOD is the abbreviation for Change Mode. CHMOD (change mode) is a command for UNIX which sets all of the access limits on a directory or file. For all operating systems that are UNIX based, such as Linux, the permission is a critical component.

You have so many files that you need other files to never touch. It would be a terrible thing, for instance, if your forum PHP script began reading or overwriting server passwords or deleting directories all of a sudden. This is why CHMOD (change mode) is so important.

If you use Perl, typically the majority of operating systems will require you to CHMOD (change mode) the Perl script executable file before it will be able to run on your system. This is quite a security advantage over PHP. Typically, if a PHP file is there, it can be executed automatically.

Therefore, if you happen to have a PHP script that is able to write on your server and that PHP script goes on to create yet another PHP script, it may be able to run random commands on the server, some of which you may not even be aware of. This is obviously a bad idea and you will regret not using CHMOD (change mode).

Now, you may be wondering what it means when you see something such as “CHMOD 777”. What are those numbers for, you ask? Well, the answer to that question is kind of technical. You see, the numbers are the binary representation of the permission scheme.

Permission structures tend to get a little tricky from one server to the next, according to ownership of the files. Typically, the owner of the file is able to change permissions. The majority of FTP programs will allow you to view the whole directory listing. That should allow you to see who the owner of the file is and the group that is able to access the file as the owner.

Chmod 777 (File Permissions are for everyone – be careful choosing 777)

Chmod 777

Chmod 777

Chmod 755 (This is a screenshot of 755 File Permissions)

Chmod 755

Chmod 755

How to Use CHMOD

When it comes to the CHMOD (change mode) command, there are three major permissions. The CHMOD (change mode) groups are you, the owner, the UNIX group and anyone else. A common CHMOD (change mode) command would look something like, “CHMOD 755”.

This command will let you rename, remove or add a file in addition to reading or editing a file. It also indicates that the UNIX group and anyone else are only allowed to read or edit that particular file. No one else will be able to rename, delete or add to the file.

Three kinds of CHMOD (change mode) permissions can be assigned to the file

These permissions are execute, read and write.

  1. The read permission gets a value set at 4
  2. The write permission is 2
  3. The execute permission gets a value of 1

If a command specifies a 7 for the first digit, it indicates that all of the CHMOD (change mode) permission types have been assigned to it. If it has a 0, then no rights have been assigned to the file at all. If it specifies a 6, then it lets the server know that the user is allowed to write and read the file, but is not allowed to execute it.

The majority of HTML files are assigned a 644 permission and most script files are a 755. Any of the configuration files in a script package will usually require a CHMOD (change mode) permission of 777. However, you must use caution if you assign a permission of 777 to everyone.

This type of CHMOD (change mode) permission allows anyone who is able to access the server to add, edit, read, rename or remove the file. It is usually best to think about security and assign the minimum amount of permission required to get the results that you desire.

Free (FTP) File Transfer Protocol Programs

  1. Core FTP
  2. File Zilla FTP

Leave a Reply

Your email address will not be published. Required fields are marked *