Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»General Articles»how to change permissions of folder and subfolders in Linux

    how to change permissions of folder and subfolders in Linux

    By RahulJune 22, 20211 Min Read

    Setting the proper file permission for any web application is an important part of web hosting. In this tutorial, you will learn how to change file permissions on folder and sub-folders recursively in a single command.

    Advertisement

    As you know, In Linux everything is treated as a file. A folder is also known as directory file denoted by ‘d‘ in the permission section. The below command will set the owner to www-data and group-owner to ubuntu for all files and directories and subdirectories.

    sudo chown -R www-data:ubuntu /var/www/html
    

    Use the chmod command to change the permissions for all files, directories, and subdirectories.

    sudo chmod -R 755 /var/www/html
    

    Note – The permission 755 is good to set for directories but not on files. This set the execute bit on files which is not recommended for any production environments excluded some specific cases. We recommend setting permissions separately for files and directories.

    Set permissions on files:

    sudo find /var/www/html -type f -exec chmod 644 {} \;
    

    Set permissions on directories:

    sudo find /var/www/html -type d -exec chmod 755 {} \;
    

    All done.

    files linux permission
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    tail Command in Linux with Examples

    What is a Orphan Process in Unix/Linux

    How To Display Warning Message to Unauthorized SSH Access

    View 1 Comment

    1 Comment

    1. John walker on May 17, 2019 8:45 am

      great article bro many thankx

      Reply

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • tail Command in Linux with Examples
    • What is a Orphan Process in Unix/Linux
    • How To Display Warning Message to Unauthorized SSH Access
    • How to Set a Custom SSH Login Banner and MOTD
    • Understanding Reverse DNS: What it is and Why it Matters?
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.