How to automatically change permissions and owner:group on any file added to a specific directory?
I run an unRAID server (unRAID is based on Slackware) and would like to find a way to automatically change the permissions and ownership of every file added to a specific directory.
Specifically, I would like to upload .torrent
files from my laptop to a specific "Watch" folder on my server using SFTP. The problem is that the rTorrent docker container that is watching that directory is unable to load the uploaded .torrent
files because their owner:user
group is different from that of the container -- root:root
for .torrent
files sent via SFTP, and nobody:users
for the container.
I suspect that the file permissions may also be an issue as the uploaded .torrent
files have 0644
permissions and I believe that they need to have 0755
permissions. I've been able to get rTorrent to autoload these .torrent
files by manually chown to nobody:users
and chmod to 0755
, so I know that Autowatch works with these changes in place.
So, I am hoping that there might be a straightforward way to automatically chown and chmod every file added to this directory. Any ideas?
linux permissions chmod slackware chown
add a comment |
I run an unRAID server (unRAID is based on Slackware) and would like to find a way to automatically change the permissions and ownership of every file added to a specific directory.
Specifically, I would like to upload .torrent
files from my laptop to a specific "Watch" folder on my server using SFTP. The problem is that the rTorrent docker container that is watching that directory is unable to load the uploaded .torrent
files because their owner:user
group is different from that of the container -- root:root
for .torrent
files sent via SFTP, and nobody:users
for the container.
I suspect that the file permissions may also be an issue as the uploaded .torrent
files have 0644
permissions and I believe that they need to have 0755
permissions. I've been able to get rTorrent to autoload these .torrent
files by manually chown to nobody:users
and chmod to 0755
, so I know that Autowatch works with these changes in place.
So, I am hoping that there might be a straightforward way to automatically chown and chmod every file added to this directory. Any ideas?
linux permissions chmod slackware chown
add a comment |
I run an unRAID server (unRAID is based on Slackware) and would like to find a way to automatically change the permissions and ownership of every file added to a specific directory.
Specifically, I would like to upload .torrent
files from my laptop to a specific "Watch" folder on my server using SFTP. The problem is that the rTorrent docker container that is watching that directory is unable to load the uploaded .torrent
files because their owner:user
group is different from that of the container -- root:root
for .torrent
files sent via SFTP, and nobody:users
for the container.
I suspect that the file permissions may also be an issue as the uploaded .torrent
files have 0644
permissions and I believe that they need to have 0755
permissions. I've been able to get rTorrent to autoload these .torrent
files by manually chown to nobody:users
and chmod to 0755
, so I know that Autowatch works with these changes in place.
So, I am hoping that there might be a straightforward way to automatically chown and chmod every file added to this directory. Any ideas?
linux permissions chmod slackware chown
I run an unRAID server (unRAID is based on Slackware) and would like to find a way to automatically change the permissions and ownership of every file added to a specific directory.
Specifically, I would like to upload .torrent
files from my laptop to a specific "Watch" folder on my server using SFTP. The problem is that the rTorrent docker container that is watching that directory is unable to load the uploaded .torrent
files because their owner:user
group is different from that of the container -- root:root
for .torrent
files sent via SFTP, and nobody:users
for the container.
I suspect that the file permissions may also be an issue as the uploaded .torrent
files have 0644
permissions and I believe that they need to have 0755
permissions. I've been able to get rTorrent to autoload these .torrent
files by manually chown to nobody:users
and chmod to 0755
, so I know that Autowatch works with these changes in place.
So, I am hoping that there might be a straightforward way to automatically chown and chmod every file added to this directory. Any ideas?
linux permissions chmod slackware chown
linux permissions chmod slackware chown
edited Jan 4 at 0:35
JakeGould
31.3k1096138
31.3k1096138
asked Jan 3 at 14:59
xthursdayxxthursdayx
112
112
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
You have another two way to reach your goal with built-in tools
first you can use ACL
- Here some reference how to use: https://www.computerhope.com/unix/usetfacl.htm
- You can add in the default ACL of the folder your files are uploaded the user root:root with necessary permission.
- Here some reference how to use: https://www.computerhope.com/unix/usetfacl.htm
second one (and more elegant in my personal opinion):
- Run the rTorrent docker container with UID match the UID own the files I find this page explain it well: https://www.computerhope.com/unix/usetfacl.htm
- Run the rTorrent docker container with UID match the UID own the files I find this page explain it well: https://www.computerhope.com/unix/usetfacl.htm
add a comment |
This may help: https://techarena51.com/blog/inotify-tools-example/
intotify can allow you to trigger a script when the directory is updated. The script could manage your chown and chmod on the fly.
This helped a lot, thanks!
– xthursdayx
Jan 4 at 3:17
add a comment |
As I mentioned in my comment on SO yesterday, this is fairly trivial using inotify.
#!/bin/sh
if [ -x /tmp/watchy ]; then
rm -rf /tmp/watchy
fi
while inotifywait -e close_write -o /tmp/watchy --format %w%f /path/to/watch
do
found=$( tail -n1 /tmp/watchy | grep -E '.torrent$' ) && chown root $found
done
Thanks a lot. If I wanted the script to both chmod and chown would I modify it like this?#!/bin/sh if [ -x /tmp/watchy ]; then rm -rf /tmp/watchy fi while inotifywait -e moved_to -o /tmp/watchy --format %w%f /mnt/cache/Downloads/watched do found=$( tail -n1 /tmp/watchy | grep -E '.torrent$' ) && chown nobody:users $found && chmod 0755 $found done
– xthursdayx
Jan 4 at 3:06
Yes, that would do the job.
– tink
Jan 4 at 3:07
Thanks very much!
– xthursdayx
Jan 4 at 3:09
you're welcome; let me know how you got on.
– tink
Jan 4 at 3:11
I had to change theclose_write
inotifywait event tocreate
in order to get it to work with the uploaded files, but it's working great now. I also added the script as a "User Script" startup daemon (the unRaid equivalent of adding it to/etc/rc.local
) so that it will run in the background all the time, since I quickly realized that the script would stop running as soon as I closed my ssh shell to the headless server.
– xthursdayx
Jan 4 at 5:20
|
show 1 more comment
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
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: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
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%2fsuperuser.com%2fquestions%2f1390197%2fhow-to-automatically-change-permissions-and-ownergroup-on-any-file-added-to-a-s%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
You have another two way to reach your goal with built-in tools
first you can use ACL
- Here some reference how to use: https://www.computerhope.com/unix/usetfacl.htm
- You can add in the default ACL of the folder your files are uploaded the user root:root with necessary permission.
- Here some reference how to use: https://www.computerhope.com/unix/usetfacl.htm
second one (and more elegant in my personal opinion):
- Run the rTorrent docker container with UID match the UID own the files I find this page explain it well: https://www.computerhope.com/unix/usetfacl.htm
- Run the rTorrent docker container with UID match the UID own the files I find this page explain it well: https://www.computerhope.com/unix/usetfacl.htm
add a comment |
You have another two way to reach your goal with built-in tools
first you can use ACL
- Here some reference how to use: https://www.computerhope.com/unix/usetfacl.htm
- You can add in the default ACL of the folder your files are uploaded the user root:root with necessary permission.
- Here some reference how to use: https://www.computerhope.com/unix/usetfacl.htm
second one (and more elegant in my personal opinion):
- Run the rTorrent docker container with UID match the UID own the files I find this page explain it well: https://www.computerhope.com/unix/usetfacl.htm
- Run the rTorrent docker container with UID match the UID own the files I find this page explain it well: https://www.computerhope.com/unix/usetfacl.htm
add a comment |
You have another two way to reach your goal with built-in tools
first you can use ACL
- Here some reference how to use: https://www.computerhope.com/unix/usetfacl.htm
- You can add in the default ACL of the folder your files are uploaded the user root:root with necessary permission.
- Here some reference how to use: https://www.computerhope.com/unix/usetfacl.htm
second one (and more elegant in my personal opinion):
- Run the rTorrent docker container with UID match the UID own the files I find this page explain it well: https://www.computerhope.com/unix/usetfacl.htm
- Run the rTorrent docker container with UID match the UID own the files I find this page explain it well: https://www.computerhope.com/unix/usetfacl.htm
You have another two way to reach your goal with built-in tools
first you can use ACL
- Here some reference how to use: https://www.computerhope.com/unix/usetfacl.htm
- You can add in the default ACL of the folder your files are uploaded the user root:root with necessary permission.
- Here some reference how to use: https://www.computerhope.com/unix/usetfacl.htm
second one (and more elegant in my personal opinion):
- Run the rTorrent docker container with UID match the UID own the files I find this page explain it well: https://www.computerhope.com/unix/usetfacl.htm
- Run the rTorrent docker container with UID match the UID own the files I find this page explain it well: https://www.computerhope.com/unix/usetfacl.htm
answered Jan 3 at 15:55
AtomiX84AtomiX84
4679
4679
add a comment |
add a comment |
This may help: https://techarena51.com/blog/inotify-tools-example/
intotify can allow you to trigger a script when the directory is updated. The script could manage your chown and chmod on the fly.
This helped a lot, thanks!
– xthursdayx
Jan 4 at 3:17
add a comment |
This may help: https://techarena51.com/blog/inotify-tools-example/
intotify can allow you to trigger a script when the directory is updated. The script could manage your chown and chmod on the fly.
This helped a lot, thanks!
– xthursdayx
Jan 4 at 3:17
add a comment |
This may help: https://techarena51.com/blog/inotify-tools-example/
intotify can allow you to trigger a script when the directory is updated. The script could manage your chown and chmod on the fly.
This may help: https://techarena51.com/blog/inotify-tools-example/
intotify can allow you to trigger a script when the directory is updated. The script could manage your chown and chmod on the fly.
answered Jan 3 at 15:46
C BarC Bar
12
12
This helped a lot, thanks!
– xthursdayx
Jan 4 at 3:17
add a comment |
This helped a lot, thanks!
– xthursdayx
Jan 4 at 3:17
This helped a lot, thanks!
– xthursdayx
Jan 4 at 3:17
This helped a lot, thanks!
– xthursdayx
Jan 4 at 3:17
add a comment |
As I mentioned in my comment on SO yesterday, this is fairly trivial using inotify.
#!/bin/sh
if [ -x /tmp/watchy ]; then
rm -rf /tmp/watchy
fi
while inotifywait -e close_write -o /tmp/watchy --format %w%f /path/to/watch
do
found=$( tail -n1 /tmp/watchy | grep -E '.torrent$' ) && chown root $found
done
Thanks a lot. If I wanted the script to both chmod and chown would I modify it like this?#!/bin/sh if [ -x /tmp/watchy ]; then rm -rf /tmp/watchy fi while inotifywait -e moved_to -o /tmp/watchy --format %w%f /mnt/cache/Downloads/watched do found=$( tail -n1 /tmp/watchy | grep -E '.torrent$' ) && chown nobody:users $found && chmod 0755 $found done
– xthursdayx
Jan 4 at 3:06
Yes, that would do the job.
– tink
Jan 4 at 3:07
Thanks very much!
– xthursdayx
Jan 4 at 3:09
you're welcome; let me know how you got on.
– tink
Jan 4 at 3:11
I had to change theclose_write
inotifywait event tocreate
in order to get it to work with the uploaded files, but it's working great now. I also added the script as a "User Script" startup daemon (the unRaid equivalent of adding it to/etc/rc.local
) so that it will run in the background all the time, since I quickly realized that the script would stop running as soon as I closed my ssh shell to the headless server.
– xthursdayx
Jan 4 at 5:20
|
show 1 more comment
As I mentioned in my comment on SO yesterday, this is fairly trivial using inotify.
#!/bin/sh
if [ -x /tmp/watchy ]; then
rm -rf /tmp/watchy
fi
while inotifywait -e close_write -o /tmp/watchy --format %w%f /path/to/watch
do
found=$( tail -n1 /tmp/watchy | grep -E '.torrent$' ) && chown root $found
done
Thanks a lot. If I wanted the script to both chmod and chown would I modify it like this?#!/bin/sh if [ -x /tmp/watchy ]; then rm -rf /tmp/watchy fi while inotifywait -e moved_to -o /tmp/watchy --format %w%f /mnt/cache/Downloads/watched do found=$( tail -n1 /tmp/watchy | grep -E '.torrent$' ) && chown nobody:users $found && chmod 0755 $found done
– xthursdayx
Jan 4 at 3:06
Yes, that would do the job.
– tink
Jan 4 at 3:07
Thanks very much!
– xthursdayx
Jan 4 at 3:09
you're welcome; let me know how you got on.
– tink
Jan 4 at 3:11
I had to change theclose_write
inotifywait event tocreate
in order to get it to work with the uploaded files, but it's working great now. I also added the script as a "User Script" startup daemon (the unRaid equivalent of adding it to/etc/rc.local
) so that it will run in the background all the time, since I quickly realized that the script would stop running as soon as I closed my ssh shell to the headless server.
– xthursdayx
Jan 4 at 5:20
|
show 1 more comment
As I mentioned in my comment on SO yesterday, this is fairly trivial using inotify.
#!/bin/sh
if [ -x /tmp/watchy ]; then
rm -rf /tmp/watchy
fi
while inotifywait -e close_write -o /tmp/watchy --format %w%f /path/to/watch
do
found=$( tail -n1 /tmp/watchy | grep -E '.torrent$' ) && chown root $found
done
As I mentioned in my comment on SO yesterday, this is fairly trivial using inotify.
#!/bin/sh
if [ -x /tmp/watchy ]; then
rm -rf /tmp/watchy
fi
while inotifywait -e close_write -o /tmp/watchy --format %w%f /path/to/watch
do
found=$( tail -n1 /tmp/watchy | grep -E '.torrent$' ) && chown root $found
done
answered Jan 4 at 0:21
tinktink
1,3271914
1,3271914
Thanks a lot. If I wanted the script to both chmod and chown would I modify it like this?#!/bin/sh if [ -x /tmp/watchy ]; then rm -rf /tmp/watchy fi while inotifywait -e moved_to -o /tmp/watchy --format %w%f /mnt/cache/Downloads/watched do found=$( tail -n1 /tmp/watchy | grep -E '.torrent$' ) && chown nobody:users $found && chmod 0755 $found done
– xthursdayx
Jan 4 at 3:06
Yes, that would do the job.
– tink
Jan 4 at 3:07
Thanks very much!
– xthursdayx
Jan 4 at 3:09
you're welcome; let me know how you got on.
– tink
Jan 4 at 3:11
I had to change theclose_write
inotifywait event tocreate
in order to get it to work with the uploaded files, but it's working great now. I also added the script as a "User Script" startup daemon (the unRaid equivalent of adding it to/etc/rc.local
) so that it will run in the background all the time, since I quickly realized that the script would stop running as soon as I closed my ssh shell to the headless server.
– xthursdayx
Jan 4 at 5:20
|
show 1 more comment
Thanks a lot. If I wanted the script to both chmod and chown would I modify it like this?#!/bin/sh if [ -x /tmp/watchy ]; then rm -rf /tmp/watchy fi while inotifywait -e moved_to -o /tmp/watchy --format %w%f /mnt/cache/Downloads/watched do found=$( tail -n1 /tmp/watchy | grep -E '.torrent$' ) && chown nobody:users $found && chmod 0755 $found done
– xthursdayx
Jan 4 at 3:06
Yes, that would do the job.
– tink
Jan 4 at 3:07
Thanks very much!
– xthursdayx
Jan 4 at 3:09
you're welcome; let me know how you got on.
– tink
Jan 4 at 3:11
I had to change theclose_write
inotifywait event tocreate
in order to get it to work with the uploaded files, but it's working great now. I also added the script as a "User Script" startup daemon (the unRaid equivalent of adding it to/etc/rc.local
) so that it will run in the background all the time, since I quickly realized that the script would stop running as soon as I closed my ssh shell to the headless server.
– xthursdayx
Jan 4 at 5:20
Thanks a lot. If I wanted the script to both chmod and chown would I modify it like this?
#!/bin/sh if [ -x /tmp/watchy ]; then rm -rf /tmp/watchy fi while inotifywait -e moved_to -o /tmp/watchy --format %w%f /mnt/cache/Downloads/watched do found=$( tail -n1 /tmp/watchy | grep -E '.torrent$' ) && chown nobody:users $found && chmod 0755 $found done
– xthursdayx
Jan 4 at 3:06
Thanks a lot. If I wanted the script to both chmod and chown would I modify it like this?
#!/bin/sh if [ -x /tmp/watchy ]; then rm -rf /tmp/watchy fi while inotifywait -e moved_to -o /tmp/watchy --format %w%f /mnt/cache/Downloads/watched do found=$( tail -n1 /tmp/watchy | grep -E '.torrent$' ) && chown nobody:users $found && chmod 0755 $found done
– xthursdayx
Jan 4 at 3:06
Yes, that would do the job.
– tink
Jan 4 at 3:07
Yes, that would do the job.
– tink
Jan 4 at 3:07
Thanks very much!
– xthursdayx
Jan 4 at 3:09
Thanks very much!
– xthursdayx
Jan 4 at 3:09
you're welcome; let me know how you got on.
– tink
Jan 4 at 3:11
you're welcome; let me know how you got on.
– tink
Jan 4 at 3:11
I had to change the
close_write
inotifywait event to create
in order to get it to work with the uploaded files, but it's working great now. I also added the script as a "User Script" startup daemon (the unRaid equivalent of adding it to /etc/rc.local
) so that it will run in the background all the time, since I quickly realized that the script would stop running as soon as I closed my ssh shell to the headless server.– xthursdayx
Jan 4 at 5:20
I had to change the
close_write
inotifywait event to create
in order to get it to work with the uploaded files, but it's working great now. I also added the script as a "User Script" startup daemon (the unRaid equivalent of adding it to /etc/rc.local
) so that it will run in the background all the time, since I quickly realized that the script would stop running as soon as I closed my ssh shell to the headless server.– xthursdayx
Jan 4 at 5:20
|
show 1 more comment
Thanks for contributing an answer to Super User!
- 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%2fsuperuser.com%2fquestions%2f1390197%2fhow-to-automatically-change-permissions-and-ownergroup-on-any-file-added-to-a-s%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