Facebook Twitter Instagram
    TecAdmin
    • Home
    • Ubuntu 20.04
      • Upgrade Ubuntu
      • Install Java
      • Install Node.js
      • Install Docker
      • Install LAMP Stack
    • Tutorials
      • AWS
      • Shell Scripting
      • Docker
      • Git
      • MongoDB
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    Home»General Articles»how to change permissions of folder and subfolders in Linux

    how to change permissions of folder and subfolders in Linux

    RahulBy RahulMay 4, 20191 Min ReadUpdated:June 22, 2021

    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.

    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
    Previous ArticleHow To Install Dovecot on Ubuntu 18.04 & 16.04 LTS
    Next Article How to Remove a directory from Git Repository

    Related Posts

    How to Find Django Install Location in Linux

    Updated:April 27, 20221 Min Read

    (Resolved) – ReactJS 404 Error on Page Reload

    2 Mins Read

    Adding a New SSH Key in GitHub

    Updated:April 1, 20223 Mins Read

    13 Best Linux Terminal Emulators and Bash Editors

    8 Mins Read

    How To Install Oracle VirtualBox on Debian 11

    2 Mins Read

    How to Search Recently Modified Files in Linux

    2 Mins Read

    1 Comment

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

      great article bro many thankx

      Reply

    Leave A Reply Cancel Reply

    Recent Posts
    • Switching Display Manager in Ubuntu – GDM, LightDM & SDDM
    • Changing the Login Screen Background in Ubuntu 22.04 & 20.04
    • How To Install PHP (8.1, 7.4 or 5.6) on Ubuntu 22.04
    • (Resolved) Please install all available updates for your release before upgrading
    • How to Install LightDM Display Manager on Ubuntu
    Facebook Twitter Instagram Pinterest
    © 2022 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

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