Unix & Linux Stack Exchange
Q&A for users of Linux, FreeBSD and other Unix-like operating systems
Latest Questions
0
votes
1
answers
3614
views
Failed to start tomcat.service after install Tomcat9 by YUM
I installed `tomcat9` on my EC2 server using commands sudo su yum install tomcat9 Then I tried running the command: /usr/sbin/tomcat9 start Then the error message is: Failed to start tomcat.service: Unit tomcat.service not found. Am I missing anything? What file is `tomcat.service`? Where do I need...
I installed
tomcat9
on my EC2 server using commands
sudo su
yum install tomcat9
Then I tried running the command:
/usr/sbin/tomcat9 start
Then the error message is:
Failed to start tomcat.service: Unit tomcat.service not found.
Am I missing anything?
What file is tomcat.service
? Where do I need to create it? What does it contain?
sudo tee /etc/systemd/system/tomcat.service
5月 16 16:08:18 ip-172-31-25-139.us-west-2.compute.internal systemd: tomcat.service: Failed at step EXEC spawning /usr/share/tomcat9/bin/catalina.sh: No such file or dire>
5月 16 16:08:18 ip-172-31-25-139.us-west-2.compute.internal systemd: tomcat.service: Control process exited, code=exited, status=203/EXEC
5月 16 16:08:18 ip-172-31-25-139.us-west-2.compute.internal systemd: tomcat.service: Failed with result 'exit-code'.
5月 16 16:08:18 ip-172-31-25-139.us-west-2.compute.internal systemd: Failed to start tomcat.service - Tomcat Server.
I checked the directory /usr/share/tomcat9/bin
and I did not see the file catalina.sh
.
Am I missing any steps in my installation?
quangkid
(101 rep)
May 16, 2023, 07:48 AM
• Last activity: Jul 9, 2025, 11:02 AM
2
votes
2
answers
3365
views
How to run multiple `socat` and forwarding both TCP and UDP traffic?
I want to forward Microsoft Remote Desktop on a Linux Server, assume that the remote Windows host is `192.168.1.100`, I want to run: ``` socat TCP4-LISTEN:3389,fork TCP4:192.168.1.100:3389 socat UDP4-LISTEN:3389,fork UDP4:192.168.1.100:3389 ``` It works fine when I start the service by hand in the s...
I want to forward Microsoft Remote Desktop on a Linux Server, assume that the remote Windows host is
192.168.1.100
, I want to run:
socat TCP4-LISTEN:3389,fork TCP4:192.168.1.100:3389
socat UDP4-LISTEN:3389,fork UDP4:192.168.1.100:3389
It works fine when I start the service by hand in the shell, but I want to start it with systemd
, and log into /var/log/socat-rdp.log
.
After some trials I can run the service like this:
[Unit]
Description=Socat RDP Forwarding Service
After=network.target
[Service]
Type=forking
User=root
ExecStart=/bin/sh -c "/usr/bin/socat TCP4-LISTEN:3389,fork TCP4:192.168.3.153:3389 > /var/log/socat-rdp.log 2>&1 & /usr/bin/socat UDP4-LISTEN:3389,fork UDP4:192.168.3.153:3389 > /var/log/socat-rdp.log 2>&1 &"
ExecStop=/bin/kill $MAINPID
[Install]
WantedBy=multi-user.target
This configuration starts and runs normally, but when I stop the service with systemctl stop socat-rdp
it returns error code 1, although socat
process is killed as normal.
Are there any better solutions?
ricky9w
(21 rep)
May 4, 2023, 03:08 PM
• Last activity: Jun 19, 2025, 07:04 AM
1
votes
4
answers
4603
views
How to install and run docker with nix
I'm using Debian on WSL. Nix is already install. I install docker with this command: nix-env -iA nixpkgs.docker I want to start the daemon : systemctl start docker > Failed to connect to bus: No such file or directory **update** FYI $XDG_RUNTIME_DIR= /mnt/wslg/runtime-dir $UID=1000 $DBUS_SESSION_BUS...
I'm using Debian on WSL.
Nix is already install.
I install docker with this command:
nix-env -iA nixpkgs.docker
I want to start the daemon :
systemctl start docker
> Failed to connect to bus: No such file or directory
**update**
FYI
$XDG_RUNTIME_DIR= /mnt/wslg/runtime-dir
$UID=1000
$DBUS_SESSION_BUS_ADDRESS has no value
ls -l /mnt/wslg/runtime-dir
>drwx------ 4 pierre pierre 120 Dec 26 00:41 runtime-dir
I can access the bus. But I need to use sudo
sudo systemctl start docker
Now I have this problem
> Failed to start docker.service: Unit docker.service not found.
I think docker.service is this file:
/etc/systemd/system/docker.service
But it doesn't exist on my OS.
I'Ve tried to uninstall and reinstall docker with nix. To no avails
I think that it is linked:
https://discourse.nixos.org/t/docker-packages-systemd-unit-files-dont-work-on-ubuntu/12160
sudo cp ~/.nix-profile/etc/systemd/system/docker.service /etc/systemd/system/docker.service
sudo cp ~/.nix-profile/etc/systemd/system/docker.sock /var/run/docker.sock
sudo systemctl enable docker
Failed to start docker.service: Unit docker.socket not found.
>Failed to start docker.service: Unit docker.socket not found.
After reading this link , I use this command in order to the know where I should replace docker.socket file. :
systemctl list-sockets --all
But no docker.socket is listed
**update
I have made all the commands from scratch. Now I have this problem
A dependency job for docker.service failed. See 'journalctl -xe' for details.
Pierre-olivier Gendraud
(109 rep)
Dec 26, 2022, 08:05 AM
• Last activity: Jun 3, 2025, 10:10 PM
10
votes
5
answers
1763
views
Recommended way for a Linux app to inform user of an exception
In this context, an 'exception' is an undesirable scenario, which could be: a code-level signal (like SIGSEGV), incorrect ways of launching an app (like launching a command-line app as a daemon) etc. For a command-line app, the way to report exceptions to the user is by outputting to stderr - no dou...
In this context, an 'exception' is an undesirable scenario, which could be: a code-level signal (like SIGSEGV), incorrect ways of launching an app (like launching a command-line app as a daemon) etc.
For a command-line app, the way to report exceptions to the user is by outputting to stderr - no doubts here.
For a GUI app using GTK, an error window displayed using GTK's [MessageDialog](https://docs.gtk.org/gtk3/class.MessageDialog.html) can be used. But what if the
MessageDialog
fails, either due to unstable state of the app (SIGSEGV or SIGBUS may not have any recovery) or the API itself failed... in that case, how can a GUI app inform the user?
Finally, a daemon... A daemon needs to inform user either due to a code-level exception (signals) or an external exception - user could launch a command-line app as a daemon, which is not a desirable way of launch, since a command-line app would've exited after its task is completed, but a daemon is expected to run for a long time. The command-line app could detect it was launched as a daemon and inform the user that it was launched incorrectly, but output to stderr does nothing here... how can a command-line app launched as daemon inform user that it was launched incorrectly?
The main question is, how can each of these apps communicate with the user in the above mentioned scenarios? What is Linux's recommendation?
PS: I'm new to Linux and app development in Linux.
NightFuryLxD
(201 rep)
May 24, 2025, 02:18 PM
• Last activity: May 27, 2025, 10:38 AM
1
votes
2
answers
2050
views
Is it possible to set niceness value of a program in advance?
I want my games and certain programs (such as WINE) to be automatically given a higher priority then everything else, and while I'm at it I probably want to adjust the niceness value of a few other things like my window manager to be given a higher priority as well. So is there any way to give a nic...
I want my games and certain programs (such as WINE) to be automatically given a higher priority then everything else, and while I'm at it I probably want to adjust the niceness value of a few other things like my window manager to be given a higher priority as well.
So is there any way to give a niceness level to a program before starting it? So, for example, I want the Steam program to always be run at niceness level -20 to give it priority over everything else. I don't want to have to run it in the command line like this "nice -n -20 steam" every time.
A script could work well enough I suppose for those programs, but that doesn't solve it for things like services. For example, I might want to change the nice value of my window manager, which is started by my display manager, which is started by a service.
Sol33t303
(123 rep)
Apr 27, 2020, 09:39 AM
• Last activity: May 26, 2025, 06:04 AM
32
votes
4
answers
77589
views
What is the avahi daemon?
I just learning about daemon, by that time I came know avahi daemon can you please explain detaily about avahi daemon and why linux has a avahi user ?
I just learning about daemon, by that time I came know avahi daemon can you please explain detaily about avahi daemon and why linux has a avahi user ?
MP Creations
(485 rep)
Feb 11, 2020, 11:29 AM
• Last activity: May 23, 2025, 01:54 AM
47
votes
17
answers
75451
views
How to run Dropbox daemon in background?
I'm using Debian 6 and Dropbox. I followed [these commands](https://www.dropbox.com/install?os=lnx) to install it. When I run `~/.dropbox-dist/dropboxd` — Dropbox works and stuff. Problem is that when I close terminal or, even worse — reboot, Dropbox stops working and I need to run that daemon again...
I'm using Debian 6 and Dropbox. I followed [these commands](https://www.dropbox.com/install?os=lnx) to install it.
When I run
~/.dropbox-dist/dropboxd
— Dropbox works and stuff. Problem is that when I close terminal or, even worse — reboot, Dropbox stops working and I need to run that daemon again.
How can I have the computer automatically start that daemon in the background?
daGrevis
(873 rep)
Apr 3, 2012, 04:49 PM
• Last activity: May 7, 2025, 04:09 PM
11
votes
4
answers
42170
views
systemd - My custom service exits with status code 216/GROUP
I installed the following unit file for an Nodejs Express Server: [Unit] Description=Server for SpeedBot After=network.target [Service] ExecStart=/var/www/SpeedBot/server.js Restart=always User=nobody Group=nobody Environment=PATH=/usr/bin:/usr/local/bin Environment=NODE_ENV=production WorkingDirect...
I installed the following unit file for an Nodejs Express Server:
[Unit]
Description=Server for SpeedBot
After=network.target
[Service]
ExecStart=/var/www/SpeedBot/server.js
Restart=always
User=nobody
Group=nobody
Environment=PATH=/usr/bin:/usr/local/bin
Environment=NODE_ENV=production
WorkingDirectory=/home/pi/SpeedBot/server.js
[Install]
WantedBy=multi-user.target
When I run it and do:
service speedbotserver status
i get:
● speedbotserver.service - Server for SpeedBot
Loaded: loaded (/etc/systemd/system/speedbotserver.service; disabled)
Active: failed (Result: start-limit) since Thu 2017-06-29 01:31:18 UTC; 18h ago
Process: 19189 ExecStart=/var/www/SpeedBot/server.js (code=exited, status=216/GROUP)
Main PID: 19189 (code=exited, status=216/GROUP)
medicengonzo
(231 rep)
Jun 29, 2017, 07:52 PM
• Last activity: Apr 10, 2025, 01:12 PM
4
votes
4
answers
6459
views
How to run rtorrent as systemd service under a dedicated user?
I am trying to get `rtorrent` to run as a `systemd service`, but the service wouldn't start. Here's the config file and any log I can get. Ask for more info if you need to. I am running: ``` $ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 20.04.2 LTS Release...
I am trying to get
rtorrent
to run as a systemd service
, but the service wouldn't start. Here's the config file and any log I can get. Ask for more info if you need to.
I am running:
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.2 LTS
Release: 20.04
Codename: focal
$ systemctl status rtorrent
● rtorrent.service - rTorrent
Loaded: loaded (/etc/systemd/system/rtorrent.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Thu 2021-05-27 08:52:43 EEST; 5min ago
Process: 20199 ExecStart=/usr/bin/tmux new-session -d -P -s rt -n rtorrent /usr/bin/rtorrent (code=exited, status=0/SUCCESS)
Process: 20205 ExecStop=/usr/bin/tmux send-keys -t rt:rtorrent C-q (code=exited, status=1/FAILURE)
Main PID: 20201 (code=exited, status=0/SUCCESS)
May 27 08:52:43 $MACHINE systemd[1] : Starting rTorrent...
May 27 08:52:43 $MACHINE tmux: rt:
May 27 08:52:43 $MACHINE systemd[1] : Started rTorrent.
May 27 08:52:43 $MACHINE tmux: no server running on /tmp/tmux-110/default
May 27 08:52:43 $MACHINE systemd[1] : rtorrent.service: Control process exited, code=exited, status=1/FAILURE
May 27 08:52:43 $MACHINE systemd[1] : rtorrent.service: Failed with result 'exit-code'.
The config file..
/etc/systemd/system/rtorrent.service
[Unit]
Description=rTorrent
Requires=network.target local-fs.target
[Service]
Type=forking
KillMode=none
User=rt
Group=adm
ExecStart=/usr/bin/tmux new-session -d -P -s rt -n rtorrent /usr/bin/rtorrent
ExecStop=/usr/bin/tmux send-keys -t rt:rtorrent C-q
WorkingDirectory=/tmp/tmux-110/
[Install]
WantedBy=multi-user.target
Some more logs:
$ journalctl -u rtorrent
May 27 08:52:43 $MACHINE systemd[1] : Starting rTorrent...
May 27 08:52:43 $MACHINE tmux: rt:
May 27 08:52:43 $MACHINE systemd[1] : Started rTorrent.
May 27 08:52:43 $MACHINE tmux: no server running on /tmp/tmux-110/default
May 27 08:52:43 $MACHINE systemd[1] : rtorrent.service: Control process exited, code=exited, status=1/FAILURE
May 27 08:52:43 $MACHINE systemd[1] : rtorrent.service: Failed with result 'exit-code'.
So far I have added the user rt
to the adm
group, but I can't figure it out why tmux
can't be started as rt
. I also authorized rt
user to launch services thanks to the enable-linger option: loginctl enable-linger rt
I first added the rt
user with:sudo adduser --system --gecos "rTorrent Client" --disabled-password --group --home /home/rt rt
.
How to make rtorrent
run as systemd
service with tmux
as a dedicated user? Or is there any other way to run it as service with systemd
? Any help is really appreciated.
**UPDATE:**
So, just to get a fresh start, I have created a new user named rtorrent
with: sudo adduser --system --gecos "rTorrent System Client" --disabled-password --group --home /home/rtorrent rtorrent
and changed the /etc/systemd/system/rtorrent.service
file to this (also adding system.daemon = true
in /home/rtorrent/.rtorrent.rc
, because of this post ):
[Unit]
Description=rTorrent System Daemon
After=network.target
[Service]
Type=simple
User=rtorrent
Group=rtorrent
ExecStartPre=-/bin/rm -f /home/rtorrent/.session/rtorrent.lock
ExecStart=/usr/bin/rtorrent -o import=/home/rtorrent/.rtorrent.rc
Restart=on-failure
RestartSec=3
[Install]
WantedBy=multi-user.target
But after all I get this error:
$ systemctl status rtorrent
● rtorrent.service - rTorrent System Daemon
Loaded: loaded (/etc/systemd/system/rtorrent.service; enabled; vendor preset: enabled)
Active: activating (auto-restart) (Result: exit-code) since Thu 2021-05-27 10:12:26 EEST; 2s ago
Process: 22855 ExecStartPre=/bin/rm -f /home/rtorrent/.session/rtorrent.lock (code=exited, status=0/SUCCESS)
Process: 22856 ExecStart=/usr/bin/rtorrent -o import=/home/rtorrent/.rtorrent.rc (code=exited, status=255/EXCEPTION)
Main PID: 22856 (code=exited, status=255/EXCEPTION)
Why is this happening? What I am doing wrong?
**UPDATE 2:**
One more thing, This post suggest not dropping any files in the /etc/systemd/system/
, but instead, to drop them in /usr/local/lib/systemd/system
which in Debian based systems is in /lib/systemd/system
. Therefore, I moved the unit-file
there and when enabling it, it automatically created a symlink
to /etc/systemd/system/
. But still,, I get this error:
$ sudo systemctl status rtorrent
● rtorrent.service - rTorrent System Daemon
Loaded: loaded (/lib/systemd/system/rtorrent.service; enabled; vendor preset: enabled)
Active: activating (auto-restart) (Result: exit-code) since Thu 2021-05-27 10:39:14 EEST; 924ms ago
Process: 24530 ExecStartPre=/bin/rm -f /home/rtorrent/.session/rtorrent.lock (code=exited, status=0/SUCCESS)
Process: 24531 ExecStart=/usr/bin/rtorrent -o import=/home/rtorrent/.rtorrent.rc (code=exited, status=255/EXCEPTION)
Main PID: 24531 (code=exited, status=255/EXCEPTION)
techsk8
(703 rep)
May 27, 2021, 06:13 AM
• Last activity: Mar 12, 2025, 06:48 AM
215
votes
2
answers
692892
views
What does "systemctl daemon-reload" do?
I have a service that stopped suddenly. I tried to restart that service but failed and was asked to run: `systemctl daemon-reload`. What does it exactly do? What is a `daemon-reload`?
I have a service that stopped suddenly. I tried to restart that service but failed and was asked to run:
systemctl daemon-reload
.
What does it exactly do? What is a daemon-reload
?
John
(2251 rep)
May 13, 2017, 02:49 AM
• Last activity: Feb 28, 2025, 06:32 PM
0
votes
1
answers
2729
views
Systemd service fails to start Python project
I am trying to make a project written on Python work on a server. I created the following service file: [Unit] Description=My bot service After=multi-user.target [Service] Type=simple Restart=always ExecStart=/usr/bin/python3.10 /home/path/to/bot.py [Install] WantedBy=multi-user.target But this code...
I am trying to make a project written on Python work on a server. I created the following service file:
[Unit]
Description=My bot service
After=multi-user.target
[Service]
Type=simple
Restart=always
ExecStart=/usr/bin/python3.10 /home/path/to/bot.py
[Install]
WantedBy=multi-user.target
But this code doesn't work. If I check service status, it returns the following:
● test.service - My bot service
Loaded: loaded (/etc/systemd/system/test.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Fri 2022-10-21 08:16:07 UTC; 15s ago
Process: 156695 ExecStart=/usr/bin/python3.10 /home/path/to/bot.>
Main PID: 156695 (code=exited, status=1/FAILURE)
Oct 21 08:16:07 instance-1 systemd: test.service: Scheduled restart job, restart coun>
Oct 21 08:16:07 instance-1 systemd: Stopped My bot service.
Oct 21 08:16:07 instance-1 systemd: names.service: Start request repeated too quickly.
Oct 21 08:16:07 instance-1 systemd: test.service: Failed with result 'exit-code'.
Oct 21 08:16:07 instance-1 systemd: Failed to start My bot service.
When I execute the bot directly (
/usr/bin/python3.10 /home/path/to/bot.py
), it works.
When I run a simple Python script as a service, it also works.
I just don't understand what can cause the problem inside the project. Adding WorkingDirectory
parameter into the configurational file didn't change anything
apazent
(21 rep)
Oct 24, 2022, 11:01 AM
• Last activity: Jan 28, 2025, 10:00 AM
1
votes
1
answers
26
views
Allow all users to trigger a data sync to shared directory (groups vs dummy user?)
I have an Ubuntu server with ~6-7 users. We all use some software that requires some shared files and folders to be regularly updated. Let's call that shared directory /opt/science/online-data Within this are some calibration and data files that are updated on an irregular basis on an external publi...
I have an Ubuntu server with ~6-7 users. We all use some software that requires some shared files and folders to be regularly updated. Let's call that shared directory
/opt/science/online-data
Within this are some calibration and data files that are updated on an irregular basis on an external public server not owned by me. I have a cron job that runs an rsync command every day at 5 AM to keep it up-to-date. In everday usage, this folder just needs to be readable by all users (not written to).
However, there are times where the software throws an error indicating that the online-data folder needs to be immediately updated before the software can be used. I'm not always around as admin to run that command. I'd like to set things up so that any of my users can run a script "update_online_data.py" or whatever, and it will trigger the rsync.
I tried doing this by having the online-data folder group set to a specific group "softwaregroup" and giving all users membership, but the users are reporting permission errors. That's probably an error I can figure out (I'm pretty sure this should work.), but I wonder if there is a more secure way to do this anyway? Right now the group membership could in theory allow them to mess up those files when I really do not want them to do anything other than the rsync. Is there a way to create a command that triggers a non-login user specific to this task to do this and only this? (I have a vague idea that daemons or services might be a possibility, but I don't have a lot of experience using them in a custom way.)
ETM
(31 rep)
Dec 31, 2024, 04:55 PM
• Last activity: Jan 6, 2025, 01:36 PM
8
votes
2
answers
4293
views
Start a service on a network request (socket activation)
I have a program that under normal activation listens on some port. I don't want the program running continuously. Is there a "quick and dirty" way to wrap the application in a shell script or similar that will monitor the appropriate port, and start the service on demand? The simplest approach woul...
I have a program that under normal activation listens on some port.
I don't want the program running continuously.
Is there a "quick and dirty" way to wrap the application in a shell script or similar that will monitor the appropriate port, and start the service on demand?
The simplest approach would likely lead to the connection failing since the wrapper would have to let go of the port, and then start up the application. If the client simply connects again a short time later though, it could all work.
But it would of course be even nicer if this was all completely transparent to the client.
user50849
(5482 rep)
Oct 27, 2014, 07:04 PM
• Last activity: Oct 8, 2024, 10:01 AM
0
votes
1
answers
409
views
Have Terminal command run on startup (on MacOS)
I want to have a command run on my computer on startup, without me having to login. I want to do this because I want to have a program running all the time on my computer without me needing to login in the case that I restart my computer (instead of paying for a cloud computing service).
I want to have a command run on my computer on startup, without me having to login.
I want to do this because I want to have a program running all the time on my computer without me needing to login in the case that I restart my computer (instead of paying for a cloud computing service).
Kovy Jacob
(85 rep)
Sep 29, 2024, 03:21 AM
• Last activity: Oct 5, 2024, 12:26 PM
1
votes
1
answers
48
views
What is "p-portal" I saw in System Monitor in Linux on several occasions?
Looking at the following screen shot from System Monitor in Ubuntu 18.04.4 LTS (Linux 4.15.0-1079-oem), you see "(p-portal)" in the process list: [![Screen shot of processes][1]][1] I should have interrogated systemctl, ps and the like while it was up, but was busy on other things and mentally catal...
Looking at the following screen shot from System Monitor in Ubuntu 18.04.4 LTS (Linux 4.15.0-1079-oem), you see "(p-portal)" in the process list:
I should have interrogated systemctl, ps and the like while it was up, but was busy on other things and mentally cataloged it for later follow-up. However, I cannot catch it up again! I cannot find it using DuckDuck, Bing or Google search.
I thought it was perhaps associated with Chrome, which I had open at the time, but haven't seen it again with or without Chrome up. I had installed some Perl modules recently (Moo,Text-Template-1.61, Parallel-ForkManager-2.02), but didn't find it among the source files there.
It doesn't appear in the output of

systemctl list-unit-files
at other times (as I said, I didn't check while it was visible in system monitor), nor output of pstree
nor output from ps
combined with xlsclients
per the answer at https://unix.stackexchange.com/questions/175380/how-to-list-all-running-daemons
I would appreciate hearing if anyone has encountered this process "p-portal" and knows what it is/does.
Dalton Bentley
(113 rep)
Sep 7, 2024, 03:07 PM
• Last activity: Sep 8, 2024, 09:53 AM
0
votes
0
answers
27
views
Hotkey deamon that can deal with single presses of cntrl/super/alt?
I have been using the sxhkd hotkey deamon together with bspwm. But unfortunately, [sxhkd doesn' seem to be able to][1] deal with the setup where the cntrl/super/alt keys are used as both modifiers and single keypress hotkeys: Hotkey 1: super (or Super_L) Hotkey 2: super + Return * When super is pres...
I have been using the sxhkd hotkey deamon together with bspwm. But unfortunately, sxhkd doesn' seem to be able to deal with the setup where the cntrl/super/alt keys are used as both modifiers and single keypress hotkeys:
Hotkey 1: super (or Super_L)
Hotkey 2: super + Return
* When super is pressed-down, then return is pressed and released, hotkey 2 should fire, but hotkey 1 shouldn't
* When super is pressed, and then released and no other key is pressed in the meantime, hotkey 1 should fire.
Some people have suggested using xcape together with sxhkd, but this seems messy to me. Is there a hotkey deamon for linux that can just do this by itself, without requiring an extra tool like xcape?
user56834
(137 rep)
Aug 19, 2024, 02:34 PM
0
votes
2
answers
50
views
When to useradd
I'm writing a daemon in C which needs to do some things as a separate user from root. I will call this user "testuser". My program is installed by its makefile. My question is thus, when should this user testuser be added? I could add it at the end of the install target: ``` install: something somet...
I'm writing a daemon in C which needs to do some things as a separate user from root. I will call this user "testuser". My program is installed by its makefile. My question is thus, when should this user testuser be added? I could add it at the end of the install target:
install:
something
something
useradd -r testuser
however if the user is already added (for example by a previous install) this will fail. -useradd -r testuser
would surpress this error but this seems like bad practice.
Also, another problem with doing it during make install
would be if we are not actually installing the daemon for this system, e.g. make install DESTDIR=something
.
Should I leave the useradd to the system administrator and simply make the daemon fail with an error message if the user is not present? What are the conventions?
spinosarus123
(175 rep)
Jul 4, 2024, 03:53 PM
• Last activity: Jul 4, 2024, 06:19 PM
14
votes
1
answers
11623
views
How to view daemon stdout in openrc?
How do I find stdout of a process in openrc? Here's how I created my daemon. **/etc/init.d/mydaemon** #!/sbin/openrc-run command="python3" command_args="/srv/http/tornado.py" command_background="yes" pidfile="/tmp/tornado.pid" All I get in my logs is: * Starting tornado ... [ ok ] I have default `/e...
How do I find stdout of a process in openrc?
Here's how I created my daemon.
**/etc/init.d/mydaemon**
#!/sbin/openrc-run
command="python3"
command_args="/srv/http/tornado.py"
command_background="yes"
pidfile="/tmp/tornado.pid"
All I get in my logs is:
* Starting tornado ... [ ok ]
I have default
/etc/rc.conf
with set rc_logger="YES"
. What I would like to get is something like systemd allows to view stdout of a daemon with sudo journalctl -u mydaemon
deathangel908
(436 rep)
May 22, 2018, 09:10 PM
• Last activity: Jun 23, 2024, 11:50 AM
19
votes
1
answers
14506
views
What is the difference between start-stop-daemon and running with &?
I am setting up a service in /etc/init.d. I am looking at various scripts in there, some are implemented with `start-stop-daemon ...` and some with `/path/to/script &`. All of them save the pid in a file and do some checks. What is the best practice, what are the differences, what is important to kn...
I am setting up a service in /etc/init.d. I am looking at various scripts in there, some are implemented with
start-stop-daemon ...
and some with /path/to/script &
.
All of them save the pid in a file and do some checks.
What is the best practice, what are the differences, what is important to know here ... ? (in general)
In my particular case I have a simple lightweight localhost http server in java that an application will call once every hour or so and it just gives a stupid random number (no more details here, I just mean it doesn't use the file system or threads or anything complicated in case this matter in my question)
Thanks
Thomas
(953 rep)
Oct 28, 2013, 03:21 PM
• Last activity: Jun 5, 2024, 05:42 PM
1
votes
1
answers
1459
views
Securing Rsync Daemon Over SSH with NON-root user
Unfortunately, due to hosting provider, I am unable to access the rsync daemon as root and secure it accordingly. Instead, in order to take regular remote backups from the server, I have to access the rsync daemon as a non-root user that has limited sudo privileges via the `/etc/sudoers` file. I hav...
Unfortunately, due to hosting provider, I am unable to access the rsync daemon as root and secure it accordingly. Instead, in order to take regular remote backups from the server, I have to access the rsync daemon as a non-root user that has limited sudo privileges via the
/etc/sudoers
file.
I have managed to get this to work and can successfully take backups, using the solution below (scroll down).
**Additional Info Per Request**
a.) non-root-username
has this sudo privilege via /etc/sudoers
:
non-root-username ALL=NOPASSWD: /usr/bin/rsync
b.) The goal is to use a non-root user to take secure remote backups of my system directory called /backups
(using encrypted ssh connection and rysncd instead of rsync protocol to save on resources)
c.) a single directory called /backups
(which can successfully do with the solution below, I just want to make sure it is as secure as possible)
**Question:**
How do I make this non-root-user rsync daemon connection more secure?
**Issues**
Because sudo rsync
does not save environment variables, I have a variety of issues:
1.) In the /etc/rsyncd.conf
the hosts allow =
function no longer works, server-side rsync.log, shows:
rsync allowed access on module data from UNKNOWN (0.0.0.0)
rsync on data/ from root@UNKNOWN (0.0.0.0)
building file list
2.) Via /etc/ssh/sshd_config
and/or /home/non-root-user/.ssh/authorized_keys
I am unable to use ForceCommand
, command=rsync --server --daemon .
, respectively, for the actual rsync command. Any attempt to do so results in:
rsync: did not see server greeting
rsync error: error starting client-server protocol (code 5) at main.c(1675) [Receiver=3.1.3]
2a.) I currently have these values restricting my non-root-backup-user in my /etc/ssh/sshd_config
... any additional recommendations?
Match User non-root-username
X11Forwarding no
AllowTcpForwarding no
PermitTTY no
# ForceCommand /usr/bin/sudo /usr/bin/rsync <-- will not work
# ForceCommand sudo rsync <-- will not work
# ForceCommand rsync <-- will not work
**My current solution:**
Using:
`rsync -a -e "ssh -l non-root-username" --rsync-path="sudo rsync" xx.xx.xx.xx::data /local/path
`
**Update:**
The edit the above command caused @ERROR: auth failed on module data
, therefore I had to change the auth user in the above /etc/rsyncd.conf
to auth users: root
and the same for /etc/rsyncd.conf
root@admin:~# cat /etc/rsyncd.conf
# Global configuration of the rsync service
pid file = /var/run/rsyncd.pid
#hosts allow = 123.123.123.123 <-- hashed out
log file = /var/log/rsync.log
# Username and group for working with backups
uid = root
gid = root
# Don't allow to modify the source files
read only = yes
# Data source information
[data]
use chroot = false
#strict modes = false <-- (defaults to true)
path = /backups
list = yes
auth users = root
secrets file = /etc/rsyncd.passwd
In my /etc/rsyncd.passwd file
, I have:
root@admin:~# cat /etc/rsyncd.passwd
root:password
I have these permissions for /etc/rsyncd.conf
:
root@admin:~# stat /etc/rsyncd.conf
File: /etc/rsyncd.conf
Size: 471 Blocks: 8 IO Block: 4096 regular file
Device: fd00h/64768d Inode: 144028 Links: 1
Access: (0600/-rw-------) Uid: ( 0/ root) Gid: ( 1001/root)
Access: 2022-05-21 13:38:46.797769245 +0800
Modify: 2022-05-21 13:38:42.641735637 +0800
Change: 2022-05-21 13:55:52.384894170 +0800
And, I have these permissions for /etc/rsyncd.passwd
root@admin:~# stat /etc/rsyncd.passwd
File: /etc/rsyncd.passwd
Size: 31 Blocks: 8 IO Block: 4096 regular file
Device: fd00h/64768d Inode: 144040 Links: 1
Access: (0640/-rwxrwxr-x) Uid: ( 0/ root) Gid: ( 1001/root)
Access: 2022-05-21 13:38:06.989448597 +0800
Modify: 2022-05-21 13:37:37.473212811 +0800
Change: 2022-05-21 13:37:37.473212811 +0800
Any tips?
Time-Bandit
(218 rep)
May 22, 2022, 01:14 PM
• Last activity: May 1, 2024, 03:21 PM
Showing page 1 of 20 total questions