How to Change Permissions All Directories to 755 and Files to 644 Linux Ubuntu

How to Change Permissions All Directories to 755 and Files to 644 Linux Ubuntu

It is very important to secure directories and files in any system. If you do not protect the directory and files in your system then anyone can misuse it. There is a very simple command for this in Linux. Using this you can secure your file system and directories. In this tutorial, you will learn how to change permissions for all directories to 755 and files to 644 in Linux.

To change the permissions of files and directories, you need to use the chmod command. The chmod command is used to modify the permissions of files and directories, and it can be used with various parameters and arguments to change the permissions of multiple files and directories at once.

The most common permissions used in Linux are:

  • read: allows the file to be viewed and read
  • write: allows the file to be modified and updated
  • execute: allows the file to be executed as a program

These permissions are assigned to three different groups of users:

  • User: the owner of the file or directory
  • Group: a specific group of users who are granted access to the file or directory
  • Other: anyone else who is not the owner or a member of the group

How to Change Permissions All Directories to 755 and Files to 644 Linux Ubuntu

Steps to change all folder permissions to 755 and files to 644 in linux ubuntu:

  • Step 1: Open your terminal
  • Step 2: Navigate to the directory
  • Step 3: Change all folder permissions to 755 ubuntu
  • Step 4: Change all file permissions to 644
  • Step 5: Verify the permissions

Step 1: Open your terminal

First of all, open your terminal on your Linux machine. You can open terminal by pressing Ctrl + Alt + T or by clicking on the terminal icon in your applications menu.

Step 2: Navigate to the directory

Execute the following command on the terminal to navigate to your directory:

cd directory

For example, if you want to change the permissions of all the files and directories in the /var/www/html directory, you would enter the following command:

cd /var/www/html

Step 3: Change all folder permissions to 755 ubuntu

Execute the following command on terminal to change the permissions of all directories to 755, enter the following command:

find . -type d -exec chmod 755 {} ;

This command will find all directories in the current directory and set their permissions to 755. The -type d option specifies that you want to find directories only.

The -exec option tells the command to execute the chmod command on each directory that it finds. The {} symbol represents the directory that the command finds, and the ; symbol terminates the command.

Step 4: Change all file permissions to 644

Execute the following command on the terminal to change the permissions of all files to 644, enter the following command:

find . -type f -exec chmod 644 {} ;

This command will find all files in the current directory and set their permissions to 644. The -type f option specifies that you want to find files only.

The -exec option tells the command to execute the chmod command on each file that it finds. The {} symbol represents the file that the command finds, and the ; symbol terminates the command.

Step 5: Verify the permissions

After executing these commands, it’s important to verify that the permissions have been changed correctly. To do this, use the following command to display the permissions of all files and directories:

ls -l

You should see a list of all files and directories, along with their permissions. Directories should have permissions of ‘drwxr-xr-x’ (755), and files should have permissions of ‘-rw-r–r–‘ (644). If you see anything else, you may need to run the commands again.

Conclusion

In conclusion, changing the permissions of files and directories is an essential task for securing your Linux system. By following the steps outlined above, you can easily change the permissions of all directories to 755 and files to 644. Remember to verify the permissions to ensure that they have been changed correctly.

Recommended Tutorials

AuthorAdmin

My name is Devendra Dode. I am a full-stack developer, entrepreneur, and owner of Tutsmake.com. I like writing tutorials and tips that can help other developers. I share tutorials of PHP, Python, Javascript, JQuery, Laravel, Livewire, Codeigniter, Node JS, Express JS, Vue JS, Angular JS, React Js, MySQL, MongoDB, REST APIs, Windows, Xampp, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL and Bootstrap from a starting stage. As well as demo example.

Leave a Reply

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