{"id":3735,"date":"2019-06-24T07:50:52","date_gmt":"2019-06-24T07:50:52","guid":{"rendered":"https:\/\/puvox.software\/blog\/?p=3735"},"modified":"2022-11-14T18:04:17","modified_gmt":"2022-11-14T18:04:17","slug":"setup-correct-permissions-on-vps-ubuntu-linux-etc-for-multiple-users","status":"publish","type":"post","link":"https:\/\/puvox.software\/blog\/setup-correct-permissions-on-vps-ubuntu-linux-etc-for-multiple-users\/","title":{"rendered":"Setup correct permissions on VPS (ubuntu, linux, etc..) for multiple users"},"content":{"rendered":"<div class=\"default-content-clss content_3735 type_post \"><p><img fetchpriority=\"high\" decoding=\"async\" class=\"alignnone wp-image-3736  aligncenter\" src=\"https:\/\/puvox.software\/blog\/wp-content\/uploads\/sites\/2\/2019\/06\/wordpress-error-1.png\" alt=\"\" width=\"516\" height=\"181\" srcset=\"https:\/\/puvox.software\/blog\/wp-content\/uploads\/sites\/2\/2019\/06\/wordpress-error-1.png 516w, https:\/\/puvox.software\/blog\/wp-content\/uploads\/sites\/2\/2019\/06\/wordpress-error-1-400x140.png 400w, https:\/\/puvox.software\/blog\/wp-content\/uploads\/sites\/2\/2019\/06\/wordpress-error-1-300x105.png 300w\" sizes=\"(max-width: 516px) 100vw, 516px\" \/><\/p>\n<h1 style=\"text-align: center;\">Fix Permission problems on servers<\/h1>\n<p style=\"text-align: right;\"><span style=\"color: #ff0000;\"><sup><em>Notice: If you are not familiar with linux and unsure how to<br \/>\ncorrectly execute commands, we advise that you<br \/>\nbackup current server, before making the below changes. <\/em><\/sup><\/span><\/p>\n<p>Many times, on VPS servers (ubuntu, linux, debian, etc&#8230;) you might face an issue, like in PHP, showing an error message like:<\/p>\n<p><strong> Warning: <span style=\"color: #993300;\">rename\/move\/write\/access\/create &#8230;..<\/span><\/strong>\u00a0<strong>Permission denied in\u00a0<\/strong> \/path\/your_file.php<\/p>\n<p>Most times, the reason could be that one user (like <strong>root<\/strong>) owns the directory, and another user (i.e. <strong>www-data<\/strong>, which is apache instance user) tries to modify the file. For me, the best solution to such problems was to create a <strong>Group<\/strong> of users (let&#8217;s name it <strong>myusers<\/strong>), consisting of both <strong>root<\/strong> and <strong>www-data<\/strong>:<\/p>\n<pre><strong>groupadd myusers<\/strong>\n<strong>gpasswd -a www-data   myusers \n<\/strong><strong>gpasswd -a root       myusers\n<\/strong><strong>gpasswd -a other_user myusers<\/strong><\/pre>\n<p>and then give that group the needed privileges (change your desired path):<\/p>\n<pre><strong>sudo <a href=\"https:\/\/www.computerhope.com\/unix\/uchown.htm\">chown<\/a> -R :myusers <span style=\"color: #ff0000;\">\/var\/www\/<\/span><\/strong><\/pre>\n<p>So, you can modify the file\/folder from i.e. FTP or terminal, and also from Web-interface (which is Apache).\u00a0 And finally, assign correct <code>chmod<\/code> permissions to\u00a0<code>d<\/code>irectories and <code>f<\/code>iles :<\/p>\n<pre><strong>find <span style=\"color: #ff0000;\">\/var\/www\/<\/span> -type d -exec chmod u+rwx,g+rwx,o+rx {} \\;\nfind <span style=\"color: #ff0000;\">\/var\/www\/<\/span> -type f -exec chmod u+rw,g+rw,o+r {} \\;\n<\/strong><\/pre>\n<p style=\"text-align: left;\"><strong>That&#8217;s all .\u00a0<\/strong><sup>(btw, sometimes, instead of <code>rwx<\/code>\u00a0you might need\u00a0<code>rwx<strong>s<\/strong><\/code>)<\/sup><\/p>\n<p style=\"text-align: left;\"><sub><em>Definitions<\/em>:<br \/>\n<\/sub>*<code style=\"vertical-align: sub;\">u<\/code><span style=\"font-size: 10px; vertical-align: sub;\"> = <\/span><code style=\"vertical-align: sub;\">user<\/code><span style=\"font-size: 10px; vertical-align: sub;\">, <\/span><code style=\"vertical-align: sub;\">g<\/code><span style=\"font-size: 10px; vertical-align: sub;\"> = <\/span><code style=\"vertical-align: sub;\">group<\/code><span style=\"font-size: 10px; vertical-align: sub;\">, <\/span><code style=\"vertical-align: sub;\">o<\/code><span style=\"font-size: 10px; vertical-align: sub;\"> = <\/span><code style=\"vertical-align: sub;\">others<\/code><br \/>\n* <code style=\"vertical-align: sub;\">r<\/code><span style=\"font-size: 10px; vertical-align: sub;\"> = <\/span><code style=\"vertical-align: sub;\">read<\/code><span style=\"font-size: 10px; vertical-align: sub;\"> (same as <\/span><code style=\"vertical-align: sub;\">4<\/code><span style=\"font-size: 10px; vertical-align: sub;\">), <\/span><code style=\"vertical-align: sub;\">w<\/code><span style=\"font-size: 10px; vertical-align: sub;\"> = <\/span><code style=\"vertical-align: sub;\">write<\/code><span style=\"font-size: 10px; vertical-align: sub;\">(same as <\/span><code style=\"vertical-align: sub;\">2<\/code><span style=\"font-size: 10px; vertical-align: sub;\">), <\/span><code style=\"vertical-align: sub;\">x<\/code><span style=\"font-size: 10px; vertical-align: sub;\"> = <\/span><code style=\"vertical-align: sub;\">execute<\/code><span style=\"font-size: 10px; vertical-align: sub;\">(same as <\/span><code style=\"vertical-align: sub;\">1<\/code><span style=\"font-size: 10px; vertical-align: sub;\">)<br \/>\n<\/span><sub>i.e. <code>rwx<\/code> is 4+2+1 = <code>7<\/code>; So,\u00a0<\/sub><sub> <strong><code>u+rwx,g+rwx,o+rx<\/code>\u00a0<\/strong>is same as\u00a0<strong><code>775<\/code><\/strong><br \/>\n<\/sub><\/p>\n<p>_______<\/p>\n<p>Additional resources:<\/p>\n<ul>\n<li><a href=\"https:\/\/askubuntu.com\/questions\/455000\/group-permissions-allow-but-still-get-permission-denied\">question: group-permissions-allow-but-still-get-permission-denied<\/a><\/li>\n<li><a href=\"https:\/\/askubuntu.com\/questions\/982123\/multiple-owner-of-same-folder\">question: multiple-owner-of-same-folder<\/a><\/li>\n<li><a href=\"https:\/\/askubuntu.com\/questions\/722088\/reset-default-permissions-for-var-www\">question: reset-default-permissions-for-var-www<\/a><\/li>\n<li><a href=\"https:\/\/askubuntu.com\/questions\/6723\/change-folder-permissions-and-ownership\">question: change-folder-permissions-and-ownership<\/a><\/li>\n<li><a href=\"https:\/\/askubuntu.com\/questions\/19898\/whats-the-simplest-way-to-edit-and-add-files-to-var-www\">question: whats-the-simplest-way-to-edit-and-add-files-to-var-www<\/a><\/li>\n<li><sup>(Combined command was made from this\u00a0<a href=\"https:\/\/pastebin.com\/raw\/WxH5rVhJ\">source<\/a>)<\/sup><\/li>\n<\/ul>\n<\/div>","protected":false},"excerpt":{"rendered":"<div class=\"default-content-clss excerpt_3735 type_post \"><p>Fix Permission problems on servers Notice: If you are not familiar with linux and unsure how to correctly execute commands, we advise that you backup current server, before making the<a class=\"excerpt-read-more\" href=\"https:\/\/puvox.software\/blog\/setup-correct-permissions-on-vps-ubuntu-linux-etc-for-multiple-users\/\">(Continue Reading)<\/a><\/p>\n<\/div>","protected":false},"author":1,"featured_media":3736,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[13],"tags":[],"class_list":["post-3735","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-website"],"_links":{"self":[{"href":"https:\/\/puvox.software\/blog\/wp-json\/wp\/v2\/posts\/3735","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/puvox.software\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/puvox.software\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/puvox.software\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/puvox.software\/blog\/wp-json\/wp\/v2\/comments?post=3735"}],"version-history":[{"count":0,"href":"https:\/\/puvox.software\/blog\/wp-json\/wp\/v2\/posts\/3735\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/puvox.software\/blog\/wp-json\/wp\/v2\/media\/3736"}],"wp:attachment":[{"href":"https:\/\/puvox.software\/blog\/wp-json\/wp\/v2\/media?parent=3735"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/puvox.software\/blog\/wp-json\/wp\/v2\/categories?post=3735"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/puvox.software\/blog\/wp-json\/wp\/v2\/tags?post=3735"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}