How to allow folder permission for another user in Linux?
Consider two user accounts user1
and user2
on one Linux machine. I want user2
to be able to have read and write access to a folder in user1
home directory.
So far created a group for both users and added both users
groupadd twousers
usermod -a -G twousers user1
usermod -a -G twousers user2
then changed the group and the path and changed the permission
chgrp twousers /home/user1/folder
chmod g+rwx /home/user1/folder
Unfortunately user2
is still unable to access the folder /home/user1/folder
. It seems to be quite simple but somehow I am lost. What am I missing?
permissions
add a comment |
Consider two user accounts user1
and user2
on one Linux machine. I want user2
to be able to have read and write access to a folder in user1
home directory.
So far created a group for both users and added both users
groupadd twousers
usermod -a -G twousers user1
usermod -a -G twousers user2
then changed the group and the path and changed the permission
chgrp twousers /home/user1/folder
chmod g+rwx /home/user1/folder
Unfortunately user2
is still unable to access the folder /home/user1/folder
. It seems to be quite simple but somehow I am lost. What am I missing?
permissions
Something often missed is the permissions on the parent directory. It's possible that/home/user1
has no execute permission for user2. The simplest way to fix this would bechmod o+x /home/user1
since I guess you don't want to change the group on the home directory you need to give everyone execute permission on it.
– Philip Couling
4 hours ago
I swear that this exact same question was asked earlier this year but I wasn't able to locate it. Anyway, the other user can't access the directory because thehome
directory of each user is only traversable by the respective user. Rather than having the folder inside of another user'shome
, just put it inmnt
and change the permissions in that directory or create an NFS export that only the two users can access.
– Nasir Riley
4 hours ago
add a comment |
Consider two user accounts user1
and user2
on one Linux machine. I want user2
to be able to have read and write access to a folder in user1
home directory.
So far created a group for both users and added both users
groupadd twousers
usermod -a -G twousers user1
usermod -a -G twousers user2
then changed the group and the path and changed the permission
chgrp twousers /home/user1/folder
chmod g+rwx /home/user1/folder
Unfortunately user2
is still unable to access the folder /home/user1/folder
. It seems to be quite simple but somehow I am lost. What am I missing?
permissions
Consider two user accounts user1
and user2
on one Linux machine. I want user2
to be able to have read and write access to a folder in user1
home directory.
So far created a group for both users and added both users
groupadd twousers
usermod -a -G twousers user1
usermod -a -G twousers user2
then changed the group and the path and changed the permission
chgrp twousers /home/user1/folder
chmod g+rwx /home/user1/folder
Unfortunately user2
is still unable to access the folder /home/user1/folder
. It seems to be quite simple but somehow I am lost. What am I missing?
permissions
permissions
edited 1 hour ago
Paradox
171112
171112
asked 4 hours ago
A.DumasA.Dumas
5317
5317
Something often missed is the permissions on the parent directory. It's possible that/home/user1
has no execute permission for user2. The simplest way to fix this would bechmod o+x /home/user1
since I guess you don't want to change the group on the home directory you need to give everyone execute permission on it.
– Philip Couling
4 hours ago
I swear that this exact same question was asked earlier this year but I wasn't able to locate it. Anyway, the other user can't access the directory because thehome
directory of each user is only traversable by the respective user. Rather than having the folder inside of another user'shome
, just put it inmnt
and change the permissions in that directory or create an NFS export that only the two users can access.
– Nasir Riley
4 hours ago
add a comment |
Something often missed is the permissions on the parent directory. It's possible that/home/user1
has no execute permission for user2. The simplest way to fix this would bechmod o+x /home/user1
since I guess you don't want to change the group on the home directory you need to give everyone execute permission on it.
– Philip Couling
4 hours ago
I swear that this exact same question was asked earlier this year but I wasn't able to locate it. Anyway, the other user can't access the directory because thehome
directory of each user is only traversable by the respective user. Rather than having the folder inside of another user'shome
, just put it inmnt
and change the permissions in that directory or create an NFS export that only the two users can access.
– Nasir Riley
4 hours ago
Something often missed is the permissions on the parent directory. It's possible that
/home/user1
has no execute permission for user2. The simplest way to fix this would be chmod o+x /home/user1
since I guess you don't want to change the group on the home directory you need to give everyone execute permission on it.– Philip Couling
4 hours ago
Something often missed is the permissions on the parent directory. It's possible that
/home/user1
has no execute permission for user2. The simplest way to fix this would be chmod o+x /home/user1
since I guess you don't want to change the group on the home directory you need to give everyone execute permission on it.– Philip Couling
4 hours ago
I swear that this exact same question was asked earlier this year but I wasn't able to locate it. Anyway, the other user can't access the directory because the
home
directory of each user is only traversable by the respective user. Rather than having the folder inside of another user's home
, just put it in mnt
and change the permissions in that directory or create an NFS export that only the two users can access.– Nasir Riley
4 hours ago
I swear that this exact same question was asked earlier this year but I wasn't able to locate it. Anyway, the other user can't access the directory because the
home
directory of each user is only traversable by the respective user. Rather than having the folder inside of another user's home
, just put it in mnt
and change the permissions in that directory or create an NFS export that only the two users can access.– Nasir Riley
4 hours ago
add a comment |
1 Answer
1
active
oldest
votes
The problem you are experiencing was to expect. Indeed, you are trying to share a folder inside another user home
folder, which, for obvious security reasons, is (and should) only be accessible to the owner (and root
, but that's another story).
In order to solve your problem, you should create another folder, where the potential parent(s) folder(s) will have the same permissions for both users e.g. /data/folder_to_share
.
Here is a brief step-by-step example:
Create a parent folder (not necessary but it's for the sake of the example):
# cd /
# mkdir data
Create a shared subfolder:
# cd data
# mkdir shared_folder
optional : at this stage you could copy the content of the future shared folder into
shared_folder
.
# cp -p /path/to/folder/* /data/shared_folder/
Create a group
share
and two usersbob
andalice
to it:
# group add shared
# usermod -aG share bob
# usermod -aG share alice
Recursively change group folder ownership:
# chgrp -R shared /data
Adding reading, writing and executing (only for files already executables) permissions for the group
shared
:
# chmod -R g+rwX /data
Bob
andAlice
will now be able to do whatever they want inside the foldershared
but as well indata
.
Depending on your use case, you could just have one level but this example shows how the parent folder permissions can affect a folder deeper into the filesystem and allows for more scalability and granularity.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f507571%2fhow-to-allow-folder-permission-for-another-user-in-linux%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The problem you are experiencing was to expect. Indeed, you are trying to share a folder inside another user home
folder, which, for obvious security reasons, is (and should) only be accessible to the owner (and root
, but that's another story).
In order to solve your problem, you should create another folder, where the potential parent(s) folder(s) will have the same permissions for both users e.g. /data/folder_to_share
.
Here is a brief step-by-step example:
Create a parent folder (not necessary but it's for the sake of the example):
# cd /
# mkdir data
Create a shared subfolder:
# cd data
# mkdir shared_folder
optional : at this stage you could copy the content of the future shared folder into
shared_folder
.
# cp -p /path/to/folder/* /data/shared_folder/
Create a group
share
and two usersbob
andalice
to it:
# group add shared
# usermod -aG share bob
# usermod -aG share alice
Recursively change group folder ownership:
# chgrp -R shared /data
Adding reading, writing and executing (only for files already executables) permissions for the group
shared
:
# chmod -R g+rwX /data
Bob
andAlice
will now be able to do whatever they want inside the foldershared
but as well indata
.
Depending on your use case, you could just have one level but this example shows how the parent folder permissions can affect a folder deeper into the filesystem and allows for more scalability and granularity.
add a comment |
The problem you are experiencing was to expect. Indeed, you are trying to share a folder inside another user home
folder, which, for obvious security reasons, is (and should) only be accessible to the owner (and root
, but that's another story).
In order to solve your problem, you should create another folder, where the potential parent(s) folder(s) will have the same permissions for both users e.g. /data/folder_to_share
.
Here is a brief step-by-step example:
Create a parent folder (not necessary but it's for the sake of the example):
# cd /
# mkdir data
Create a shared subfolder:
# cd data
# mkdir shared_folder
optional : at this stage you could copy the content of the future shared folder into
shared_folder
.
# cp -p /path/to/folder/* /data/shared_folder/
Create a group
share
and two usersbob
andalice
to it:
# group add shared
# usermod -aG share bob
# usermod -aG share alice
Recursively change group folder ownership:
# chgrp -R shared /data
Adding reading, writing and executing (only for files already executables) permissions for the group
shared
:
# chmod -R g+rwX /data
Bob
andAlice
will now be able to do whatever they want inside the foldershared
but as well indata
.
Depending on your use case, you could just have one level but this example shows how the parent folder permissions can affect a folder deeper into the filesystem and allows for more scalability and granularity.
add a comment |
The problem you are experiencing was to expect. Indeed, you are trying to share a folder inside another user home
folder, which, for obvious security reasons, is (and should) only be accessible to the owner (and root
, but that's another story).
In order to solve your problem, you should create another folder, where the potential parent(s) folder(s) will have the same permissions for both users e.g. /data/folder_to_share
.
Here is a brief step-by-step example:
Create a parent folder (not necessary but it's for the sake of the example):
# cd /
# mkdir data
Create a shared subfolder:
# cd data
# mkdir shared_folder
optional : at this stage you could copy the content of the future shared folder into
shared_folder
.
# cp -p /path/to/folder/* /data/shared_folder/
Create a group
share
and two usersbob
andalice
to it:
# group add shared
# usermod -aG share bob
# usermod -aG share alice
Recursively change group folder ownership:
# chgrp -R shared /data
Adding reading, writing and executing (only for files already executables) permissions for the group
shared
:
# chmod -R g+rwX /data
Bob
andAlice
will now be able to do whatever they want inside the foldershared
but as well indata
.
Depending on your use case, you could just have one level but this example shows how the parent folder permissions can affect a folder deeper into the filesystem and allows for more scalability and granularity.
The problem you are experiencing was to expect. Indeed, you are trying to share a folder inside another user home
folder, which, for obvious security reasons, is (and should) only be accessible to the owner (and root
, but that's another story).
In order to solve your problem, you should create another folder, where the potential parent(s) folder(s) will have the same permissions for both users e.g. /data/folder_to_share
.
Here is a brief step-by-step example:
Create a parent folder (not necessary but it's for the sake of the example):
# cd /
# mkdir data
Create a shared subfolder:
# cd data
# mkdir shared_folder
optional : at this stage you could copy the content of the future shared folder into
shared_folder
.
# cp -p /path/to/folder/* /data/shared_folder/
Create a group
share
and two usersbob
andalice
to it:
# group add shared
# usermod -aG share bob
# usermod -aG share alice
Recursively change group folder ownership:
# chgrp -R shared /data
Adding reading, writing and executing (only for files already executables) permissions for the group
shared
:
# chmod -R g+rwX /data
Bob
andAlice
will now be able to do whatever they want inside the foldershared
but as well indata
.
Depending on your use case, you could just have one level but this example shows how the parent folder permissions can affect a folder deeper into the filesystem and allows for more scalability and granularity.
edited 2 hours ago
answered 3 hours ago
ParadoxParadox
171112
171112
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f507571%2fhow-to-allow-folder-permission-for-another-user-in-linux%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Something often missed is the permissions on the parent directory. It's possible that
/home/user1
has no execute permission for user2. The simplest way to fix this would bechmod o+x /home/user1
since I guess you don't want to change the group on the home directory you need to give everyone execute permission on it.– Philip Couling
4 hours ago
I swear that this exact same question was asked earlier this year but I wasn't able to locate it. Anyway, the other user can't access the directory because the
home
directory of each user is only traversable by the respective user. Rather than having the folder inside of another user'shome
, just put it inmnt
and change the permissions in that directory or create an NFS export that only the two users can access.– Nasir Riley
4 hours ago