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

1. Log into your server via SSH.

2. Navigate to the directory you wish to change the permissions for.

3. Run the following command to change all directories to 755:

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

4. Run the following command to change all files to 644:

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

5. Verify the permissions have been changed by running the following command:

ls -l

This will list all the files and directories in the current directory and their permissions.
[ad_1]

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

To change the permissions of all directories to 755 and files to 644, follow these steps:

  • Step 1: Open your terminal
  • Step 2: Navigate to the directory
  • Step 3: Change the permissions of directories to 755
  • Step 4: Change the permissions of files 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 the permissions of directories to 755

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 the permissions of files 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


[ad_2]

Jaspreet Singh Ghuman

Jaspreet Singh Ghuman

Jassweb.com/

Passionate Professional Blogger, Freelancer, WordPress Enthusiast, Digital Marketer, Web Developer, Server Operator, Networking Expert. Empowering online presence with diverse skills.

jassweb logo

Jassweb always keeps its services up-to-date with the latest trends in the market, providing its customers all over the world with high-end and easily extensible internet, intranet, and extranet products.

GSTIN is 03EGRPS4248R1ZD.

Contact
Jassweb, Rai Chak, Punjab, India. 143518
Item added to cart.
0 items - 0.00