{"id":465,"date":"2025-09-19T10:46:47","date_gmt":"2025-09-19T10:46:47","guid":{"rendered":"https:\/\/hosting.international\/blog\/?p=465"},"modified":"2026-04-14T17:13:28","modified_gmt":"2026-04-14T17:13:28","slug":"the-ultimate-guide-to-linux-file-permissions-and-ownership","status":"publish","type":"post","link":"https:\/\/hosting.international\/blog\/the-ultimate-guide-to-linux-file-permissions-and-ownership\/","title":{"rendered":"The Ultimate Guide to Linux File Permissions and Ownership"},"content":{"rendered":"\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"772\" height=\"436\" src=\"https:\/\/hosting.international\/blog\/wp-content\/uploads\/2025\/09\/image-20.png\" alt=\"\" class=\"wp-image-466\" srcset=\"https:\/\/hosting.international\/blog\/wp-content\/uploads\/2025\/09\/image-20.png 772w, https:\/\/hosting.international\/blog\/wp-content\/uploads\/2025\/09\/image-20-300x169.png 300w, https:\/\/hosting.international\/blog\/wp-content\/uploads\/2025\/09\/image-20-768x434.png 768w\" sizes=\"auto, (max-width: 772px) 100vw, 772px\" \/><\/figure>\n\n\n\n<p><br>For anyone managing a website on a VPS hosting platform, mastering the Linux file system is a non-negotiable step toward securing your assets. At the core of efficient server administration lies a critical concept: Linux file permissions and ownership. These settings determine precisely who\u2014be it a user, group, or the system itself\u2014can read, write, and execute files and directories on your server, fundamentally acting as the most critical first line of defense for your overall VPS security. Understanding the chmod and chown mechanisms is crucial for protecting your sensitive website data from unauthorized access and preventing common application errors that lead to downtime. Correctly applying the proper Linux file permissions is essential for hardening your web server and ensuring access control. This guide will walk you through the fundamentals of file and directory management, demystifying the numerical permission system (e.g., 755 or 644) using essential Linux commands like ls, chmod, and chown, making you an effective system administrator.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">The Three Core Permission Types<\/h3>\n\n\n\n<p>Every file and directory on a Linux system has a set of permissions. These are represented by three characters:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>r (Read):<\/strong> Allows you to view the contents of a file or list the contents of a directory.<\/li>\n\n\n\n<li><strong>w (Write):<\/strong> Allows you to modify or delete a file, or add\/remove files within a directory.<\/li>\n\n\n\n<li><strong>x (Execute):<\/strong> Allows you to run a file (if it&#8217;s a script or program) or enter a directory.<\/li>\n<\/ul>\n\n\n\n<p>These permissions are assigned to three types of users:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>User (u):<\/strong> The owner of the file.<\/li>\n\n\n\n<li><strong>Group (g):<\/strong> The group the file belongs to.<\/li>\n\n\n\n<li><strong>Others (o):<\/strong> Everyone else on the system.<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">Viewing Permissions with <code>ls -l<\/code><\/h3>\n\n\n\n<p>To see the permissions for your files and directories, you can use the <code>ls -l<\/code> command in your <strong>SSH<\/strong> terminal.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ls -l\n<\/code><\/pre>\n\n\n\n<p>The output will look something like this:<\/p>\n\n\n\n<p><code>drwxr-xr-x 2 user group 4096 Sep 19 14:00 public_html<\/code> <code>-rw-r--r-- 1 user group 1024 Sep 19 14:05 index.html<\/code><\/p>\n\n\n\n<p>Let&#8217;s break down the first section of that output (<code>drwxr-xr-x<\/code>):<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The first character (<code>d<\/code>) indicates the file type. A <code>d<\/code> means it&#8217;s a directory, while a <code>-<\/code> means it&#8217;s a regular file.<\/li>\n\n\n\n<li>The next nine characters are the permissions, in groups of three: <code>rwx<\/code> (User), <code>r-x<\/code> (Group), and <code>r-x<\/code> (Others).<\/li>\n<\/ul>\n\n\n\n<p>In this example:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The <strong>user<\/strong> (<code>u<\/code>) can read, write, and execute (<code>rwx<\/code>).<\/li>\n\n\n\n<li>The <strong>group<\/strong> (<code>g<\/code>) can read and execute (<code>r-x<\/code>), but not write.<\/li>\n\n\n\n<li>The <strong>others<\/strong> (<code>o<\/code>) can also read and execute (<code>r-x<\/code>), but not write.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Changing Permissions with <code>chmod<\/code><\/h3>\n\n\n\n<p>The <code>chmod<\/code> (<strong>ch<\/strong>ange <strong>mod<\/strong>e) command is used to modify permissions. You can use either symbolic notation (<code>u+r<\/code>, <code>o-w<\/code>) or a more common and precise numerical (octal) notation.<\/p>\n\n\n\n<p>Here\u2019s a simple way to think about the numerical values: Read is <strong>4<\/strong>, Write is <strong>2<\/strong>, and Execute is <strong>1<\/strong>. You simply add these values together to get the number for each group. For example, <code>rwx<\/code> is <code>4+2+1=7<\/code>, and <code>r-x<\/code> is <code>4+0+1=5<\/code>.<\/p>\n\n\n\n<p><strong>Common Permissions for a Website:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Files:<\/strong> A typical secure permission for files is <code>644<\/code>. This gives the owner read\/write (<code>6<\/code>) access and everyone else read-only (<code>4<\/code>) access.<\/li>\n\n\n\n<li><strong>Directories:<\/strong> A typical secure permission for directories is <code>755<\/code>. This allows the owner to read, write, and enter the directory (<code>7<\/code>), while others can only read and enter (<code>5<\/code>).<\/li>\n<\/ul>\n\n\n\n<p><strong>Command Examples:<\/strong> To set permissions for a file: <code>chmod 644 my_file.php<\/code><\/p>\n\n\n\n<p>To set permissions for a directory and all its contents (recursively): <code>chmod -R 755 public_html<\/code><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Changing Ownership with <code>chown<\/code><\/h3>\n\n\n\n<p>The <code>chown<\/code> (<strong>ch<\/strong>ange <strong>own<\/strong>er) command allows you to change the user and group that own a file or directory. This is particularly important for <strong>web hosting security<\/strong>, as you want to ensure your web server user (e.g., <code>www-data<\/code> or <code>nginx<\/code>) can access necessary files while your main user maintains control.<\/p>\n\n\n\n<p><strong>Syntax:<\/strong> <code>chown [user]:[group] [file\/directory]<\/code><\/p>\n\n\n\n<p><strong>Command Example:<\/strong> <code>chown -R myuser:mygroup \/var\/www\/html\/mysite<\/code><\/p>\n\n\n\n<p>This command recursively changes the owner and group of the entire <code>mysite<\/code> directory.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Best Practices for Your Website<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Set <code>755<\/code> for Directories:<\/strong> This allows the web server to access directories to serve content while preventing others from modifying their contents.<\/li>\n\n\n\n<li><strong>Set <code>644<\/code> for Files:<\/strong> This is the standard for most website files, as it allows the server to read them but prevents public writing.<\/li>\n\n\n\n<li><strong>Never Use <code>777<\/code>:<\/strong> Setting permissions to <code>777<\/code> (<code>rwxrwxrwx<\/code>) makes your files writable by everyone. This is a massive <strong>security risk<\/strong> and makes your server an easy target for malware and exploits.<\/li>\n\n\n\n<li><strong>Use <code>chown<\/code> Correctly:<\/strong> Ensure your main user owns the files, but the web server user has the appropriate group permissions to read and execute them.<\/li>\n<\/ol>\n\n\n\n<p>By following this <strong>file permissions tutorial<\/strong>, you&#8217;ll have a strong foundation for managing your <strong>Linux file system<\/strong>. Correct permissions are a non-negotiable aspect of <strong>website performance<\/strong> and <strong>web hosting security<\/strong>.<\/p>\n\n\n\n<p>At Hosting.International, our <strong><a href=\"https:\/\/hosting.international\/cart.php?gid=1\" data-type=\"link\" data-id=\"https:\/\/hosting.international\/cart.php?gid=1\">VPS hosting<\/a><\/strong> plans give you the control you need to fully manage and secure your server environment. Start optimizing your security and performance today!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>For anyone managing a website on a VPS hosting platform, mastering the Linux file system is a non-negotiable step toward securing your assets. At the core of efficient server administration lies a critical concept: Linux file permissions and ownership. These settings determine precisely who\u2014be it a user, group, or the system itself\u2014can read, write, and [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,10],"tags":[100],"class_list":["post-465","post","type-post","status-publish","format-standard","hentry","category-hosting-articles","category-vps","tag-the-ultimate-guide-to-linux-file-permissions-and-ownership"],"_links":{"self":[{"href":"https:\/\/hosting.international\/blog\/wp-json\/wp\/v2\/posts\/465","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hosting.international\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hosting.international\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hosting.international\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hosting.international\/blog\/wp-json\/wp\/v2\/comments?post=465"}],"version-history":[{"count":2,"href":"https:\/\/hosting.international\/blog\/wp-json\/wp\/v2\/posts\/465\/revisions"}],"predecessor-version":[{"id":599,"href":"https:\/\/hosting.international\/blog\/wp-json\/wp\/v2\/posts\/465\/revisions\/599"}],"wp:attachment":[{"href":"https:\/\/hosting.international\/blog\/wp-json\/wp\/v2\/media?parent=465"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hosting.international\/blog\/wp-json\/wp\/v2\/categories?post=465"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hosting.international\/blog\/wp-json\/wp\/v2\/tags?post=465"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}