Where do I put scripts executed by systemd units?

Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
For any OS that uses systemd to manage processes and follows the Filesystem Hierarchy Standard by the Linux Foundation
I recently asked where to but a systemd unit file:
Where do I put my systemd unit file on Arch Linux?
I would like to run a python script every 5 minutes (not to be confused with a systemd unit file script that calls the python script). I read the answers to this question:
Run script every 30 min with systemd
This is where my question comes in. Where should or could you store scripts that are run by systemd? Is there a reserved place for these, particularly on Arch Linux?
- For example, logs are placed in
/var/log systemdunit files are placed under/etc/systemd/system
/etc/systemd/system/writehello.service
Here is an example service.
[Unit]
Description=Run python script that writes hello in file on /media/5TB/hello.txt
[Service]
Type=oneshot
ExecStart=# <-- This is what I am looking for
[Install]
WantedBy=multi-user.target
/etc/systemd/system/writehello.timer
Here is a corresponding timer. This is all stuff documented.
[Unit]
Description=test
[Timer]
Persistent=true
OnUnitActiveSec=10s
OnBootSec=10s
[Install]
WantedBy=timers.target
/path/to/writehello.py
This is the path I am looking for.
#!/usr/bin/env python
import os
import datetime
now = datetime.datetime.now()
f1 = open('/media/mydrive/hello.txt','a')
f1.write('hello %sn' % (now))
f1.close
arch-linux systemd directory-structure
 |Â
show 3 more comments
up vote
0
down vote
favorite
For any OS that uses systemd to manage processes and follows the Filesystem Hierarchy Standard by the Linux Foundation
I recently asked where to but a systemd unit file:
Where do I put my systemd unit file on Arch Linux?
I would like to run a python script every 5 minutes (not to be confused with a systemd unit file script that calls the python script). I read the answers to this question:
Run script every 30 min with systemd
This is where my question comes in. Where should or could you store scripts that are run by systemd? Is there a reserved place for these, particularly on Arch Linux?
- For example, logs are placed in
/var/log systemdunit files are placed under/etc/systemd/system
/etc/systemd/system/writehello.service
Here is an example service.
[Unit]
Description=Run python script that writes hello in file on /media/5TB/hello.txt
[Service]
Type=oneshot
ExecStart=# <-- This is what I am looking for
[Install]
WantedBy=multi-user.target
/etc/systemd/system/writehello.timer
Here is a corresponding timer. This is all stuff documented.
[Unit]
Description=test
[Timer]
Persistent=true
OnUnitActiveSec=10s
OnBootSec=10s
[Install]
WantedBy=timers.target
/path/to/writehello.py
This is the path I am looking for.
#!/usr/bin/env python
import os
import datetime
now = datetime.datetime.now()
f1 = open('/media/mydrive/hello.txt','a')
f1.write('hello %sn' % (now))
f1.close
arch-linux systemd directory-structure
I'm not sure I see where there is a security concern here; can you edit your post to explain the problem and your motivations?
â Michael Homer
Aug 31 '15 at 7:56
But why are your script files world-writeable in the first place? That seems like the place to start looking.
â Michael Homer
Aug 31 '15 at 8:05
3
If that's really the question, the answer is just that no, there aren't (maybe you could make a case forsbin?). Putting it somewhere different wouldn't address this hypothetical concern though. I think there's a missing bit of motivation in here somewhere.
â Michael Homer
Aug 31 '15 at 8:10
2
This security concern just isn't real, so the whole premise of the question doesn't hold.
â Michael Homer
Aug 31 '15 at 8:23
1
question is good, upvoted
â akostadinov
Nov 27 '15 at 8:28
 |Â
show 3 more comments
up vote
0
down vote
favorite
up vote
0
down vote
favorite
For any OS that uses systemd to manage processes and follows the Filesystem Hierarchy Standard by the Linux Foundation
I recently asked where to but a systemd unit file:
Where do I put my systemd unit file on Arch Linux?
I would like to run a python script every 5 minutes (not to be confused with a systemd unit file script that calls the python script). I read the answers to this question:
Run script every 30 min with systemd
This is where my question comes in. Where should or could you store scripts that are run by systemd? Is there a reserved place for these, particularly on Arch Linux?
- For example, logs are placed in
/var/log systemdunit files are placed under/etc/systemd/system
/etc/systemd/system/writehello.service
Here is an example service.
[Unit]
Description=Run python script that writes hello in file on /media/5TB/hello.txt
[Service]
Type=oneshot
ExecStart=# <-- This is what I am looking for
[Install]
WantedBy=multi-user.target
/etc/systemd/system/writehello.timer
Here is a corresponding timer. This is all stuff documented.
[Unit]
Description=test
[Timer]
Persistent=true
OnUnitActiveSec=10s
OnBootSec=10s
[Install]
WantedBy=timers.target
/path/to/writehello.py
This is the path I am looking for.
#!/usr/bin/env python
import os
import datetime
now = datetime.datetime.now()
f1 = open('/media/mydrive/hello.txt','a')
f1.write('hello %sn' % (now))
f1.close
arch-linux systemd directory-structure
For any OS that uses systemd to manage processes and follows the Filesystem Hierarchy Standard by the Linux Foundation
I recently asked where to but a systemd unit file:
Where do I put my systemd unit file on Arch Linux?
I would like to run a python script every 5 minutes (not to be confused with a systemd unit file script that calls the python script). I read the answers to this question:
Run script every 30 min with systemd
This is where my question comes in. Where should or could you store scripts that are run by systemd? Is there a reserved place for these, particularly on Arch Linux?
- For example, logs are placed in
/var/log systemdunit files are placed under/etc/systemd/system
/etc/systemd/system/writehello.service
Here is an example service.
[Unit]
Description=Run python script that writes hello in file on /media/5TB/hello.txt
[Service]
Type=oneshot
ExecStart=# <-- This is what I am looking for
[Install]
WantedBy=multi-user.target
/etc/systemd/system/writehello.timer
Here is a corresponding timer. This is all stuff documented.
[Unit]
Description=test
[Timer]
Persistent=true
OnUnitActiveSec=10s
OnBootSec=10s
[Install]
WantedBy=timers.target
/path/to/writehello.py
This is the path I am looking for.
#!/usr/bin/env python
import os
import datetime
now = datetime.datetime.now()
f1 = open('/media/mydrive/hello.txt','a')
f1.write('hello %sn' % (now))
f1.close
arch-linux systemd directory-structure
arch-linux systemd directory-structure
edited 6 mins ago
asked Aug 31 '15 at 7:48
Jonathan Komar
7711829
7711829
I'm not sure I see where there is a security concern here; can you edit your post to explain the problem and your motivations?
â Michael Homer
Aug 31 '15 at 7:56
But why are your script files world-writeable in the first place? That seems like the place to start looking.
â Michael Homer
Aug 31 '15 at 8:05
3
If that's really the question, the answer is just that no, there aren't (maybe you could make a case forsbin?). Putting it somewhere different wouldn't address this hypothetical concern though. I think there's a missing bit of motivation in here somewhere.
â Michael Homer
Aug 31 '15 at 8:10
2
This security concern just isn't real, so the whole premise of the question doesn't hold.
â Michael Homer
Aug 31 '15 at 8:23
1
question is good, upvoted
â akostadinov
Nov 27 '15 at 8:28
 |Â
show 3 more comments
I'm not sure I see where there is a security concern here; can you edit your post to explain the problem and your motivations?
â Michael Homer
Aug 31 '15 at 7:56
But why are your script files world-writeable in the first place? That seems like the place to start looking.
â Michael Homer
Aug 31 '15 at 8:05
3
If that's really the question, the answer is just that no, there aren't (maybe you could make a case forsbin?). Putting it somewhere different wouldn't address this hypothetical concern though. I think there's a missing bit of motivation in here somewhere.
â Michael Homer
Aug 31 '15 at 8:10
2
This security concern just isn't real, so the whole premise of the question doesn't hold.
â Michael Homer
Aug 31 '15 at 8:23
1
question is good, upvoted
â akostadinov
Nov 27 '15 at 8:28
I'm not sure I see where there is a security concern here; can you edit your post to explain the problem and your motivations?
â Michael Homer
Aug 31 '15 at 7:56
I'm not sure I see where there is a security concern here; can you edit your post to explain the problem and your motivations?
â Michael Homer
Aug 31 '15 at 7:56
But why are your script files world-writeable in the first place? That seems like the place to start looking.
â Michael Homer
Aug 31 '15 at 8:05
But why are your script files world-writeable in the first place? That seems like the place to start looking.
â Michael Homer
Aug 31 '15 at 8:05
3
3
If that's really the question, the answer is just that no, there aren't (maybe you could make a case for
sbin?). Putting it somewhere different wouldn't address this hypothetical concern though. I think there's a missing bit of motivation in here somewhere.â Michael Homer
Aug 31 '15 at 8:10
If that's really the question, the answer is just that no, there aren't (maybe you could make a case for
sbin?). Putting it somewhere different wouldn't address this hypothetical concern though. I think there's a missing bit of motivation in here somewhere.â Michael Homer
Aug 31 '15 at 8:10
2
2
This security concern just isn't real, so the whole premise of the question doesn't hold.
â Michael Homer
Aug 31 '15 at 8:23
This security concern just isn't real, so the whole premise of the question doesn't hold.
â Michael Homer
Aug 31 '15 at 8:23
1
1
question is good, upvoted
â akostadinov
Nov 27 '15 at 8:28
question is good, upvoted
â akostadinov
Nov 27 '15 at 8:28
 |Â
show 3 more comments
4 Answers
4
active
oldest
votes
up vote
4
down vote
accepted
I also was thinking about this same question and wanted to see other's opinion. My take on it is /usr/local/sbin as sbin is where you put things that should be run by admin.
Your analysis is correct the /usr/local is the location dedicated for installing stuff not managed by package manager. But bin is for stuff that should be runnable by regular users. In either case, you should not allow write access to anybody but root to the files in /usr/local. That's the convention as far as I remember (for the whole /usr/).
/opt is usually used for packages that are not used by default on the system and user should set some environment variables to access by bin/man/etc. directories of specific package. Read the links I've provided above.
See RHEL FSH overview as well the latest FHS documentation.
add a comment |Â
up vote
0
down vote
You usually do this with cron. If you worry that some lower-privileges user might edit python script maliciously, just grant him read-rights only, forbidding writing to this file.
2
This answer does not address the question: Where should scripts be placed that are automatically executed by systemd?
â Jonathan Komar
Aug 31 '15 at 8:07
1
I show you different approach; usually you use cron to schedule jobs on your system that need to be run in some fixed time steps. For this, you don't need systemd. If you are trying to use systemd for some specific reason, you did not provide it, hence question is not as clear as it could be.
â MatthewRock
Aug 31 '15 at 8:12
1
There are people all over the place asking how to hammer a nail with screwdriver - in that case, the correct answer is: use hammer. I was trying to make sure you didn't forget you got your hammer out there. Anyway, leaving my answer, since might help someone in the future.
â MatthewRock
Aug 31 '15 at 8:25
4
For all that this question has its flaws, this answer really doesn't even attempt to address it (or any of the past revisions). It could well help someone in the future, but it'd be a coincidence.
â Michael Homer
Aug 31 '15 at 10:05
add a comment |Â
up vote
0
down vote
You can store your scripts in /usr/bin or /usr/local/bin (preferred) or /opt
You have to refer to script in ExecStart= key In service section of unit file
add a comment |Â
up vote
0
down vote
Here are the ideal locations for storing things that will be run (see links for details):
Quote from the File System Hierarchy Standard HS v2.3
Locally installed system administration programs should be placed in /usr/local/sbin.
I understood that when FHS documentation refers to "system", it is referring to some "root" user.
/usr/local/binOR/usr/local/sbinunique to this computer (not available to a package manager, e.g. scripts, software from a CD) i.e. not installed from a common source to all computers (not a package manager)./usr/local/binstuff can be run by all users./usr/local/sbinstuff can be run by root only (it is the system "binary" directory)./usr/binnot unique (shared stuff between computers e.g. from a package manager i.e. a package manager uses this location)/root/bina root user could create this directory instead of using/usr/local/sbin. It is a good place to store things that only a root user runs OR can see (this folder is only executable by root or group root, therefore its contents is not visible to anyone except root) You could even make a bin folder in there to keep things consistent, but no one would know anyway :)/home/<user>/bina standard user could create this directory. It is a good place to store scripts that are run as a standard user by systemd.
The conclusion is that number 1 would be an ideal place to store scripts that are run by a systemd daemon/service.
It makes sense,
- it is a standard location
- it is isolated from your package manager packages
add a comment |Â
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
4
down vote
accepted
I also was thinking about this same question and wanted to see other's opinion. My take on it is /usr/local/sbin as sbin is where you put things that should be run by admin.
Your analysis is correct the /usr/local is the location dedicated for installing stuff not managed by package manager. But bin is for stuff that should be runnable by regular users. In either case, you should not allow write access to anybody but root to the files in /usr/local. That's the convention as far as I remember (for the whole /usr/).
/opt is usually used for packages that are not used by default on the system and user should set some environment variables to access by bin/man/etc. directories of specific package. Read the links I've provided above.
See RHEL FSH overview as well the latest FHS documentation.
add a comment |Â
up vote
4
down vote
accepted
I also was thinking about this same question and wanted to see other's opinion. My take on it is /usr/local/sbin as sbin is where you put things that should be run by admin.
Your analysis is correct the /usr/local is the location dedicated for installing stuff not managed by package manager. But bin is for stuff that should be runnable by regular users. In either case, you should not allow write access to anybody but root to the files in /usr/local. That's the convention as far as I remember (for the whole /usr/).
/opt is usually used for packages that are not used by default on the system and user should set some environment variables to access by bin/man/etc. directories of specific package. Read the links I've provided above.
See RHEL FSH overview as well the latest FHS documentation.
add a comment |Â
up vote
4
down vote
accepted
up vote
4
down vote
accepted
I also was thinking about this same question and wanted to see other's opinion. My take on it is /usr/local/sbin as sbin is where you put things that should be run by admin.
Your analysis is correct the /usr/local is the location dedicated for installing stuff not managed by package manager. But bin is for stuff that should be runnable by regular users. In either case, you should not allow write access to anybody but root to the files in /usr/local. That's the convention as far as I remember (for the whole /usr/).
/opt is usually used for packages that are not used by default on the system and user should set some environment variables to access by bin/man/etc. directories of specific package. Read the links I've provided above.
See RHEL FSH overview as well the latest FHS documentation.
I also was thinking about this same question and wanted to see other's opinion. My take on it is /usr/local/sbin as sbin is where you put things that should be run by admin.
Your analysis is correct the /usr/local is the location dedicated for installing stuff not managed by package manager. But bin is for stuff that should be runnable by regular users. In either case, you should not allow write access to anybody but root to the files in /usr/local. That's the convention as far as I remember (for the whole /usr/).
/opt is usually used for packages that are not used by default on the system and user should set some environment variables to access by bin/man/etc. directories of specific package. Read the links I've provided above.
See RHEL FSH overview as well the latest FHS documentation.
edited Feb 13 '17 at 8:36
muru
34.5k579151
34.5k579151
answered Nov 27 '15 at 8:44
akostadinov
412213
412213
add a comment |Â
add a comment |Â
up vote
0
down vote
You usually do this with cron. If you worry that some lower-privileges user might edit python script maliciously, just grant him read-rights only, forbidding writing to this file.
2
This answer does not address the question: Where should scripts be placed that are automatically executed by systemd?
â Jonathan Komar
Aug 31 '15 at 8:07
1
I show you different approach; usually you use cron to schedule jobs on your system that need to be run in some fixed time steps. For this, you don't need systemd. If you are trying to use systemd for some specific reason, you did not provide it, hence question is not as clear as it could be.
â MatthewRock
Aug 31 '15 at 8:12
1
There are people all over the place asking how to hammer a nail with screwdriver - in that case, the correct answer is: use hammer. I was trying to make sure you didn't forget you got your hammer out there. Anyway, leaving my answer, since might help someone in the future.
â MatthewRock
Aug 31 '15 at 8:25
4
For all that this question has its flaws, this answer really doesn't even attempt to address it (or any of the past revisions). It could well help someone in the future, but it'd be a coincidence.
â Michael Homer
Aug 31 '15 at 10:05
add a comment |Â
up vote
0
down vote
You usually do this with cron. If you worry that some lower-privileges user might edit python script maliciously, just grant him read-rights only, forbidding writing to this file.
2
This answer does not address the question: Where should scripts be placed that are automatically executed by systemd?
â Jonathan Komar
Aug 31 '15 at 8:07
1
I show you different approach; usually you use cron to schedule jobs on your system that need to be run in some fixed time steps. For this, you don't need systemd. If you are trying to use systemd for some specific reason, you did not provide it, hence question is not as clear as it could be.
â MatthewRock
Aug 31 '15 at 8:12
1
There are people all over the place asking how to hammer a nail with screwdriver - in that case, the correct answer is: use hammer. I was trying to make sure you didn't forget you got your hammer out there. Anyway, leaving my answer, since might help someone in the future.
â MatthewRock
Aug 31 '15 at 8:25
4
For all that this question has its flaws, this answer really doesn't even attempt to address it (or any of the past revisions). It could well help someone in the future, but it'd be a coincidence.
â Michael Homer
Aug 31 '15 at 10:05
add a comment |Â
up vote
0
down vote
up vote
0
down vote
You usually do this with cron. If you worry that some lower-privileges user might edit python script maliciously, just grant him read-rights only, forbidding writing to this file.
You usually do this with cron. If you worry that some lower-privileges user might edit python script maliciously, just grant him read-rights only, forbidding writing to this file.
edited Aug 31 '15 at 8:21
answered Aug 31 '15 at 8:06
MatthewRock
3,76821847
3,76821847
2
This answer does not address the question: Where should scripts be placed that are automatically executed by systemd?
â Jonathan Komar
Aug 31 '15 at 8:07
1
I show you different approach; usually you use cron to schedule jobs on your system that need to be run in some fixed time steps. For this, you don't need systemd. If you are trying to use systemd for some specific reason, you did not provide it, hence question is not as clear as it could be.
â MatthewRock
Aug 31 '15 at 8:12
1
There are people all over the place asking how to hammer a nail with screwdriver - in that case, the correct answer is: use hammer. I was trying to make sure you didn't forget you got your hammer out there. Anyway, leaving my answer, since might help someone in the future.
â MatthewRock
Aug 31 '15 at 8:25
4
For all that this question has its flaws, this answer really doesn't even attempt to address it (or any of the past revisions). It could well help someone in the future, but it'd be a coincidence.
â Michael Homer
Aug 31 '15 at 10:05
add a comment |Â
2
This answer does not address the question: Where should scripts be placed that are automatically executed by systemd?
â Jonathan Komar
Aug 31 '15 at 8:07
1
I show you different approach; usually you use cron to schedule jobs on your system that need to be run in some fixed time steps. For this, you don't need systemd. If you are trying to use systemd for some specific reason, you did not provide it, hence question is not as clear as it could be.
â MatthewRock
Aug 31 '15 at 8:12
1
There are people all over the place asking how to hammer a nail with screwdriver - in that case, the correct answer is: use hammer. I was trying to make sure you didn't forget you got your hammer out there. Anyway, leaving my answer, since might help someone in the future.
â MatthewRock
Aug 31 '15 at 8:25
4
For all that this question has its flaws, this answer really doesn't even attempt to address it (or any of the past revisions). It could well help someone in the future, but it'd be a coincidence.
â Michael Homer
Aug 31 '15 at 10:05
2
2
This answer does not address the question: Where should scripts be placed that are automatically executed by systemd?
â Jonathan Komar
Aug 31 '15 at 8:07
This answer does not address the question: Where should scripts be placed that are automatically executed by systemd?
â Jonathan Komar
Aug 31 '15 at 8:07
1
1
I show you different approach; usually you use cron to schedule jobs on your system that need to be run in some fixed time steps. For this, you don't need systemd. If you are trying to use systemd for some specific reason, you did not provide it, hence question is not as clear as it could be.
â MatthewRock
Aug 31 '15 at 8:12
I show you different approach; usually you use cron to schedule jobs on your system that need to be run in some fixed time steps. For this, you don't need systemd. If you are trying to use systemd for some specific reason, you did not provide it, hence question is not as clear as it could be.
â MatthewRock
Aug 31 '15 at 8:12
1
1
There are people all over the place asking how to hammer a nail with screwdriver - in that case, the correct answer is: use hammer. I was trying to make sure you didn't forget you got your hammer out there. Anyway, leaving my answer, since might help someone in the future.
â MatthewRock
Aug 31 '15 at 8:25
There are people all over the place asking how to hammer a nail with screwdriver - in that case, the correct answer is: use hammer. I was trying to make sure you didn't forget you got your hammer out there. Anyway, leaving my answer, since might help someone in the future.
â MatthewRock
Aug 31 '15 at 8:25
4
4
For all that this question has its flaws, this answer really doesn't even attempt to address it (or any of the past revisions). It could well help someone in the future, but it'd be a coincidence.
â Michael Homer
Aug 31 '15 at 10:05
For all that this question has its flaws, this answer really doesn't even attempt to address it (or any of the past revisions). It could well help someone in the future, but it'd be a coincidence.
â Michael Homer
Aug 31 '15 at 10:05
add a comment |Â
up vote
0
down vote
You can store your scripts in /usr/bin or /usr/local/bin (preferred) or /opt
You have to refer to script in ExecStart= key In service section of unit file
add a comment |Â
up vote
0
down vote
You can store your scripts in /usr/bin or /usr/local/bin (preferred) or /opt
You have to refer to script in ExecStart= key In service section of unit file
add a comment |Â
up vote
0
down vote
up vote
0
down vote
You can store your scripts in /usr/bin or /usr/local/bin (preferred) or /opt
You have to refer to script in ExecStart= key In service section of unit file
You can store your scripts in /usr/bin or /usr/local/bin (preferred) or /opt
You have to refer to script in ExecStart= key In service section of unit file
answered Sep 1 '15 at 16:26
AbdulKareem
1011
1011
add a comment |Â
add a comment |Â
up vote
0
down vote
Here are the ideal locations for storing things that will be run (see links for details):
Quote from the File System Hierarchy Standard HS v2.3
Locally installed system administration programs should be placed in /usr/local/sbin.
I understood that when FHS documentation refers to "system", it is referring to some "root" user.
/usr/local/binOR/usr/local/sbinunique to this computer (not available to a package manager, e.g. scripts, software from a CD) i.e. not installed from a common source to all computers (not a package manager)./usr/local/binstuff can be run by all users./usr/local/sbinstuff can be run by root only (it is the system "binary" directory)./usr/binnot unique (shared stuff between computers e.g. from a package manager i.e. a package manager uses this location)/root/bina root user could create this directory instead of using/usr/local/sbin. It is a good place to store things that only a root user runs OR can see (this folder is only executable by root or group root, therefore its contents is not visible to anyone except root) You could even make a bin folder in there to keep things consistent, but no one would know anyway :)/home/<user>/bina standard user could create this directory. It is a good place to store scripts that are run as a standard user by systemd.
The conclusion is that number 1 would be an ideal place to store scripts that are run by a systemd daemon/service.
It makes sense,
- it is a standard location
- it is isolated from your package manager packages
add a comment |Â
up vote
0
down vote
Here are the ideal locations for storing things that will be run (see links for details):
Quote from the File System Hierarchy Standard HS v2.3
Locally installed system administration programs should be placed in /usr/local/sbin.
I understood that when FHS documentation refers to "system", it is referring to some "root" user.
/usr/local/binOR/usr/local/sbinunique to this computer (not available to a package manager, e.g. scripts, software from a CD) i.e. not installed from a common source to all computers (not a package manager)./usr/local/binstuff can be run by all users./usr/local/sbinstuff can be run by root only (it is the system "binary" directory)./usr/binnot unique (shared stuff between computers e.g. from a package manager i.e. a package manager uses this location)/root/bina root user could create this directory instead of using/usr/local/sbin. It is a good place to store things that only a root user runs OR can see (this folder is only executable by root or group root, therefore its contents is not visible to anyone except root) You could even make a bin folder in there to keep things consistent, but no one would know anyway :)/home/<user>/bina standard user could create this directory. It is a good place to store scripts that are run as a standard user by systemd.
The conclusion is that number 1 would be an ideal place to store scripts that are run by a systemd daemon/service.
It makes sense,
- it is a standard location
- it is isolated from your package manager packages
add a comment |Â
up vote
0
down vote
up vote
0
down vote
Here are the ideal locations for storing things that will be run (see links for details):
Quote from the File System Hierarchy Standard HS v2.3
Locally installed system administration programs should be placed in /usr/local/sbin.
I understood that when FHS documentation refers to "system", it is referring to some "root" user.
/usr/local/binOR/usr/local/sbinunique to this computer (not available to a package manager, e.g. scripts, software from a CD) i.e. not installed from a common source to all computers (not a package manager)./usr/local/binstuff can be run by all users./usr/local/sbinstuff can be run by root only (it is the system "binary" directory)./usr/binnot unique (shared stuff between computers e.g. from a package manager i.e. a package manager uses this location)/root/bina root user could create this directory instead of using/usr/local/sbin. It is a good place to store things that only a root user runs OR can see (this folder is only executable by root or group root, therefore its contents is not visible to anyone except root) You could even make a bin folder in there to keep things consistent, but no one would know anyway :)/home/<user>/bina standard user could create this directory. It is a good place to store scripts that are run as a standard user by systemd.
The conclusion is that number 1 would be an ideal place to store scripts that are run by a systemd daemon/service.
It makes sense,
- it is a standard location
- it is isolated from your package manager packages
Here are the ideal locations for storing things that will be run (see links for details):
Quote from the File System Hierarchy Standard HS v2.3
Locally installed system administration programs should be placed in /usr/local/sbin.
I understood that when FHS documentation refers to "system", it is referring to some "root" user.
/usr/local/binOR/usr/local/sbinunique to this computer (not available to a package manager, e.g. scripts, software from a CD) i.e. not installed from a common source to all computers (not a package manager)./usr/local/binstuff can be run by all users./usr/local/sbinstuff can be run by root only (it is the system "binary" directory)./usr/binnot unique (shared stuff between computers e.g. from a package manager i.e. a package manager uses this location)/root/bina root user could create this directory instead of using/usr/local/sbin. It is a good place to store things that only a root user runs OR can see (this folder is only executable by root or group root, therefore its contents is not visible to anyone except root) You could even make a bin folder in there to keep things consistent, but no one would know anyway :)/home/<user>/bina standard user could create this directory. It is a good place to store scripts that are run as a standard user by systemd.
The conclusion is that number 1 would be an ideal place to store scripts that are run by a systemd daemon/service.
It makes sense,
- it is a standard location
- it is isolated from your package manager packages
edited Mar 9 '17 at 9:23
answered Sep 1 '15 at 18:25
Jonathan Komar
7711829
7711829
add a comment |Â
add a comment |Â
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
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f226535%2fwhere-do-i-put-scripts-executed-by-systemd-units%23new-answer', 'question_page');
);
Post as a guest
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
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
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
I'm not sure I see where there is a security concern here; can you edit your post to explain the problem and your motivations?
â Michael Homer
Aug 31 '15 at 7:56
But why are your script files world-writeable in the first place? That seems like the place to start looking.
â Michael Homer
Aug 31 '15 at 8:05
3
If that's really the question, the answer is just that no, there aren't (maybe you could make a case for
sbin?). Putting it somewhere different wouldn't address this hypothetical concern though. I think there's a missing bit of motivation in here somewhere.â Michael Homer
Aug 31 '15 at 8:10
2
This security concern just isn't real, so the whole premise of the question doesn't hold.
â Michael Homer
Aug 31 '15 at 8:23
1
question is good, upvoted
â akostadinov
Nov 27 '15 at 8:28