/usr/bin/env 'node' Permission Denied - node.js

I installed Node V10.19.0 and tileserver-gl
I created a bash file in my home directory, by the name tileserver.sh
Which contain this code:
xvfb-run -a -s "-screen 0 1024x768x24" tilerserver-gl NewZeland.mbtiles
When I executed it works fine, and listening on port 8080
and I created service of this file in /etc/systemd/system/tileserver.service and enabled
sudo systemctl status tileserver.service
It shows this error:
Loaded: loaded (/etc/systemd/system/tileserver.service: enabled; vendor preset: enabled)
Active: Failed (Result: exit-code) since .....
process: 3729 ExecStart=/home/tilesServer/tileserver.sh ( code=exited, status=126)
Main PID: 3729 ( code=exited, status=126)
mar 26 18:21:57 tileserver systemd started tileserver bash script runing
mar 26 18:21:57 tilerserver tileserver.sh[3729] : /usr/bin/env "node' Permission denied
mar 26 18:21:57 tileserver systemd[1]: tileserver.service: main process exited , code=exited, status=126/n/a
mar 26 18:21:57 tileserver systemd[1]: tileserver.service: Failed with result 'exit-code'
How to resolve this issue and error

I recommended you use NVM and install It as normal user, after your installed NVM you should install NodeJS with nvm install stable to get node stable version and then you will can test.

First I add the nvm path to bachrc
start to debug it. With root
node debug tileserver-gl
It work fine , so I modified the script and working fine

Related

How to fix permission denied issue RedisJson?

When I try to load a redis module with loadmodule in redis.conf, redis-server crashes.
The log shows
Module /etc/modules/librejson.so failed to load: /etc/modules/librejson.so: unable to open shared objects file: Permission denied.
I have read the documentation to install RedisJson, but it does not work for me.
If I comment loadmodule line, the server works fine.
Installation process
sudo dnf update
sudo dnf upgrade
sudo dnf install redis
Configuration
cd /etc/redis
nvim /redis.conf
loadmodule loadmodule /etc/modules/librejson.so
supervised systemd
The rest of the file is kept by default
What I did
I created modules folder inside etc folder
I ran chown redis:root over modules folder
I moved the module to /etc/modules because I had read that homeprotection can block redis when trying to read the module in the /home path.
Then I used ls -l to check permissions and owners:
-rwxr-xr-x. 2 user user user 23668904 Feb 15 09:10 librejson.so
after that, I ran chown redis:root (as redis.conf owners): -rwxr-xr-xr-x. 2 redis root 23668904 Feb 15 09:10 librejson.so
and when I ran sudo systemctl restart redis.service:
Job for redis.service failed because the control process exited with error code.
See "systemctl status redis.service" and "journalctl -xeu redis.service" for details.
systemctl status redis.service:
redis.service - Redis persistent key-value database
Loaded: loaded (/usr/lib/systemd/system/redis.service; enabled; preset: disabled)
Drop-In: /etc/systemd/system/redis.service.d
└─limit.conf
Active: failed (Result: exit-code) since Thu 2023-02-16 13:21:58 CST; 6min ago
Process: 28947 ExecStart=/usr/bin/redis-server /etc/redis/redis.conf --daemonize no --supervised systemd (code=exited, status=1/FAILURE)
Main PID: 28947 (code=exited, status=1/FAILURE)
Status: "Redis is loading..."
CPU: 10ms
Feb 16 13:21:58 fedora systemd[1]: Starting redis.service - Redis persistent key-value database...
Feb 16 13:21:58 fedora systemd[1]: redis.service: Main process exited, code=exited, status=1/FAILURE
Feb 16 13:21:58 fedora systemd[1]: redis.service: Failed with result 'exit-code'.
Feb 16 13:21:58 fedora systemd[1]: Failed to start redis.service - Redis persistent key-value database.
and nothing, I ran out of ideas.
System specs
Fedora 37
Redis server v=7.0.8

Bash script doesn't launch with systemd

I'm trying to launch a simple bash script called script-startup.sh when my raspberry Pi boots, using systemd. This script only contains some basic actions on files (copying, moving, executing binaries) and calls make as well to compile bits of codes.
I created a new file with path /etc/systemd/system/baymabx.service :
[Unit]
Description=Baymabx
After=pm2-pi
[Service]
ExecStart=/home/pi/Desktop/baymabx/script-startup.sh
Launching /home/pi/Desktop/baymabx/script-startup.sh in the terminal works as it is intended to be. Also, pm2-pi.service is pm2 starting my backend server, that I need before using my script.
However, after doing systemctl start baymabx and systemctl status baymabx, I get :
● baymabx.service - Baymabx
Loaded: loaded (/etc/systemd/system/baymabx.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Fri 2020-12-11 01:34:06 CET; 3min 2s ago
Process: 359 ExecStart=/home/pi/Desktop/baymabx/script-startup.sh (code=exited, status=203/EXEC)
Main PID: 359 (code=exited, status=203/EXEC)
Dec 11 01:34:06 raspberrypi systemd[1]: Started Baymabx.
Dec 11 01:34:06 raspberrypi systemd[359]: baymabx.service: Failed to execute command: Exec format error
Dec 11 01:34:06 raspberrypi systemd[359]: baymabx.service: Failed at step EXEC spawning /home/pi/Desktop/baymabx/script-startup.sh: Exec format error
Dec 11 01:34:06 raspberrypi systemd[1]: baymabx.service: Main process exited, code=exited, status=203/EXEC
Dec 11 01:34:06 raspberrypi systemd[1]: baymabx.service: Failed with result 'exit-code'.
Anyone know how I can get it to work ?

Apache2: Failed to set up mount namespacing: Permission denied

I have VPS server with Debian 10. I want to start Apache2 with option PrivateTmp=true.
But on start it failed with error: apache2.service: Failed at step NAMESPACE spawning /usr/sbin/apachectl: Permission denied.
● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Fri 2020-11-27 17:17:43 CET; 5s ago
Docs: https://httpd.apache.org/docs/2.4/
Process: 523 ExecStart=/usr/sbin/apachectl start (code=exited, status=226/NAMESPACE)
Nov 27 17:17:43 5091-server systemd[1]: Starting The Apache HTTP Server...
Nov 27 17:17:43 5091-server systemd[523]: apache2.service: Failed to set up mount namespacing: Permission denied
Nov 27 17:17:43 5091-server systemd[523]: apache2.service: Failed at step NAMESPACE spawning /usr/sbin/apachectl: Permission denied
Nov 27 17:17:43 5091-server systemd[1]: apache2.service: Control process exited, code=exited, status=226/NAMESPACE
Nov 27 17:17:43 5091-server systemd[1]: apache2.service: Failed with result 'exit-code'.
Nov 27 17:17:43 5091-server systemd[1]: Failed to start The Apache HTTP Server.
I checked the permissions for tmp:
root#5091-server:~# ls -ld /tmp
drwxrwxrwt 8 root root 4096 Nov 27 17:17 /tmp
root#5091-server:~# ls -ld /var/tmp
drwxrwxrwt 2 root root 4096 Nov 27 17:17 /var/tmp
Any idea which permissions are wrong?
This can work...
sudo sed -i -e 's,PrivateTmp=true,PrivateTmp=false\nNoNewPrivileges=yes,g' /lib/systemd/system/apache2.service
sudo systemctl daemon-reload
sudo systemctl start apache2.service
sudo systemctl status apache2.service
This is related to new systemd security features (v220+?) conflicting with unprivileged LXC containers like the ones inside Proxmox.
Edit apache config (the clean way):
sudo systemctl edit apache2.service
Add this to disable new systemd security features (affect LXC containers like the ones inside Proxmox)
[Service]
PrivateDevices=false
PrivateTmp=false
ProtectControlGroups=false
ProtectKernelModules=false
ProtectSystem=false
Maybe only necessary:
ProtectHome=false
ProtectSystem=false
Then
sudo systemctl start apache2.service
sudo systemctl status apache2.service # Just to check the output
I saw this on apache2 and memcached. Also with systemd-logind. In this last case ssh connection speed was affected. ssh -vvv was stuck on debug1: pledge: filesystem (without VPN), and debug1: pledge: network (with VPN). As mention here and here the problem is solved enabling nesting (also here) on the Proxmox containers.
Probably simply enabling the "nesting" feature for the container (if it is unprivileged) will allow systemd to make use of its namespacing features.
Related
Nested containers in LXD | Ubuntu
Roadmap - Proxmox VE 7.1 The real fix is to upgrade host?
Failed to reset devices.list...Operation not permitted · Issue #2004 · lxc/lxd

MongoDB: expection: connect failed, exiting with code 1

So after installing mongodb in my Ubuntu, I tried to run "mongo", but it said,
MongoDB shell version v4.4.1
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused :
connect#src/mongo/shell/mongo.js:374:17
#(connect):2:6
exception: connect failed
exiting with code 1
So I enabled mongod service and started it, then ran the command,
sudo systemctl status mongod
And It said,
● mongod.service - MongoDB Database Server
Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Thu 2020-09-17 00:23:08 +06; 8min ago
Docs: https://docs.mongodb.org/manual
Process: 45414 ExecStart=/usr/bin/mongod --config /etc/mongod.conf (code=exited, sta>
Main PID: 45414 (code=exited, status=1/FAILURE)
Sep 17 00:23:08 john systemd[1]: Started MongoDB Database Server.
Sep 17 00:23:08 john mongod[45414]: about to fork child process, waiting until server is>
Sep 17 00:23:08 john mongod[45427]: forked process: 45428
Sep 17 00:23:08 john mongod[45414]: ERROR: child process failed, exited with error numbe>
Sep 17 00:23:08 john mongod[45414]: To see additional information in this output, start >
Sep 17 00:23:08 john systemd[1]: mongod.service: Main process exited, code=exited, statu>
Sep 17 00:23:08 john systemd[1]: mongod.service: Failed with result 'exit-code'.
And I can't run the mongodb shell. What should I do?
I came across this issue yesterday and I was able to resolve it by:
removing the mongod.lockfile.
running the config fork command.
remove .lock file:
sudo rm /usr/local/var/mongodb/mongod.lock
Run:
mongod --config /usr/local/etc/mongod.conf --fork.
and use the mongo command again.
mongod need to be running before you can run mongo without that error.
p.s. here is the answer for others who stumble upon original question from the title
I also got that same error , I think this may happened because of some updation in our PC (like .NET framework updation something)
then I uninstalled and reinstalled MongoDB again and its working
You have yo go /etc , modify the mongod.conf, because:
"By default, MongoDB launches with bindIp set to 127.0.0.1,", which binds to the localhost network interface. This means that the mongod can only accept connections from clients that are running on the same machine.
Then could sudo nano mongod.conf and change 127.0.0.1 to 0.0.0.0
You must restart mongo.
Create a folder data in root C: directory.
Create another folder db inside data folder.
Now run mongod in cmd in path
C:\Program Files\MongoDB\Server\5.0\bin>mongo
Don't close this command prompt.
Open another cmd in same path
C:\ProgramFiles\MongoDB\Server\5.0\bin>mongo
Run mongo command.
Now it will connect.

Jenkins fails to start on centOS7

I am using jenkins on my centOS7/linux server. When I start jenkins and checked the status it showed me like this.
>jenkins.service - Jenkins Service
> Loaded: loaded (/etc/systemd/system/jenkins.service; enabled; vendor preset: > disabled)
> Active: failed (Result: exit-code) since Mon 2017-02-20 22:52:19 PST; 22s > ago
> Process: 40251 ExecStart=/usr/bin/java -jar /usr/local/bin/jenkins.war
>(code=exited, status=1/FAILURE)
> Main PID: 40251 (code=exited, status=1/FAILURE)
>Feb 20 22:52:19 CentOS7 systemd[1]: Started Jenkins Service.
>Feb 20 22:52:19 CentOS7 systemd[1]: Starting Jenkins Service...
>Feb 20 22:52:19 CentOS7 java[40251]: Error: Unable to access jarfile >/usr/l...ar
>Feb 20 22:52:19 CentOS7 systemd[1]: jenkins.service: main process exited, >c...RE
>Feb 20 22:52:19 CentOS7 systemd[1]: Unit jenkins.service entered failed state.
>Feb 20 22:52:19 CentOS7 systemd[1]: jenkins.service failed.
>Hint: Some lines were ellipsized, use -l to show in full.
So I uninstalled the jenkins sudo yum remove jenkins by this command, and installed it again sudo yum install jenkins.
Now again facing the same issue.
Can anyone tell me what to do.
Thanks!!
Before you can install Jenkins, you need to setup a Java virtual machine on your system
yum install java-1.8.0-openjdk.x86_64
And set two environment variables: JAVA_HOME and JRE_HOME.
echo 'export JAVA_HOME=/usr/lib/jvm/jre-1.8.0-openjdk' | sudo tee -a /etc/profile
echo 'export JRE_HOME=/usr/lib/jvm/jre' | sudo tee -a /etc/profile
source /etc/profile
Then install jenkins and allow inbound traffic on port 8080.
You can see more details from how to install jenkins on Centos 7.
Hope this helps.
As per Jun, Jenkins required Java 11.
Refer :
Required Java version for Jenkins
at first you cannot get clue, on run systemctl status jenkins.service
until I try to change JENKINS_USER on /etc/init.d/jenkins to root, and show me
Jenkins requires Java versions [17, 11] but you are running with Java 1.8 from /usr/lib/j
Once I upgraded Java to 11 then it started working.

Resources