Compile node projects without using sudo - unix

I feel like this is more of a unix question, but I'm looking to compile node projects without using the sudo command each time.
Example:
$ node server.js
Results in the following error:
node.js:63
throw e;
^
Error: EACCES, Permission denied
....
Is there any way to permanently give node root access?
Thanks!
Matt

Root has permanent root access, so just become root.
$ sudo su
Or:
Install node.js without using sudo
Double-check that your directories you are working in are actually writable by a non-root user.

Related

JFrog Xray installation Docker install on CentOS - permission denied

Trying to install JFrog Xray on a CentOS machine, using the Docker installer.
I've created a /opt/xray directory, where I've downloaded the install file into.
Then ran chmod +x xray on this file.
When I try to install using sudo "./xray install", I get the following output:
[root#xray xray]# sudo ./xray install
INFO: Using XRAY_MOUNT_ROOT=/root/.jfrog/xray
Verifying Xray prerequisites ...
WARNING: Running with 3GB Total RAM
WARNING: Running with 1 CPU Cores
The System resources are not aligned with Xray minimal prerequisites, Do you want to proceed with the process? [Y
touch: cannot touch '/data/installer.info': Permission denied
Are you adding this node to an existing cluster? (not relevant for the first cluster node) [Y/n]: n
mkdir: cannot create directory '/xray_global_mount_root/xray': Permission denied
./wrapper.sh: line 583: /xray_global_mount_root/xray/ha/ha-node.properties: No such file or directory
./wrapper.sh: line 586: /data/installer.info: Permission denied
./wrapper.sh: line 589: /data/installer.info: Permission denied
./wrapper.sh: line 592: /data/installer.info: Permission denied
ERROR: Installation failed
Any ideas what may be causing this?
I had a similar issue on RHEL and it was selinux getting in the way. To fix it, change the following line in the xray script: -
XRAY_VOLUMES="-v ${XRAY_MOUNT_ROOT}/xray-installer:/data -v ${XRAY_MOUNT_ROOT}:/xray_global_mount_root"
To this: -
XRAY_VOLUMES="-v ${XRAY_MOUNT_ROOT}/xray-installer:/data:z -v ${XRAY_MOUNT_ROOT}:/xray_global_mount_root:z"
(basically adding :z to each volume).
This makes sure the folder is labelled to be used by multiple containers in selinux.

How do I remove a file in my root directory?

I tried to create a directory /data as a mount point but that failed for other reasons, now I've got a weird file/data thing in my root directory that just won't die:
user#PC:~$ sudo ls /data
ls: cannot access /data: Transport endpoint is not connected
user#PC:~$ sudo rm -rf /data
rm: cannot remove ‘/data’: Is a directory
I initially created it using mkdir but if I browse to the file in ubuntu it looks like a file in the file browser. How do I get rid of this thing?
First try unmounting then you should be able to delete it.
Then if that fails, and this is going to sound like a Windows solution but it might work, try rebooting and doing unmount/remount delete again.

sudo login root

I am trying to get root access on a webserver using:
sudo login root
but I get:
sudo: no tty present and no askpass program specified
I also don't have permission to the sudoers file. How can I proceed?
sudo su -
If you are in the sudoer file, which it seems like you are not.
su -
If you know the root password
If you have neither of these, the admin obviously doesn't want you to have root access.

Permission denied on SBT installation

So I "installed" SBT by following directions here under the "UNIX" section by downloading the jar and creating the sbt script to run it - however instead of putting it in ~/bin/ I put it in /usr/local/sbt/. I added it to my PATH variable and when I try to run it without sudo I get a Permission denied error (below). Also below is what I see when I type in ls -l in the sbt directory.
$ sbt compile
bash: /usr/local/sbt/sbt: Permission denied
-rwxrwxr-- 1 root wheel 120 Jun 20 09:21 sbt*
-rwxrwxr--# 1 adelbertc staff 1096763 Jun 20 09:20 sbt-launch.jar*
Help?
Try changing the permissions so that you can execute it:
sudo chmod o+x /usr/local/sbt/sbt /usr/local/sbt/sbt-launch.jar
Otherwise, you can add yourself to the wheel group, or change the owner so that you own it:
sudo chown adelbertcs:staff /usr/local/sbt/sbt
(assuming that your username is adelbertcs).

Sudo Path - not finding Node.js

I need to run node on my Ubuntu machine with sudo access. The directory of node is in the sudo path but when trying to run it i get a command not found. I can explicitly call node which does work.
//works
node
>
which node
/root/local/node/bin/node
echo sudo $PATH
sudo /root/local/node/bin:/usr/bin/node:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
sudo node --version
sudo: node: command not found
//explicitly calling it works
sudo node /root/local/node/bin
>
Um, I don't think there's such a thing as a "sudo path" - your second command there is just echoing "sudo" followed by your regular path. In any case, if you're running things with sudo you really, really should not depend on a path - you should give the explicit pathname for every command and file argument whenever possible, to minimize security risks. If sudo doesn't want to run something, you need to use visudo to add it to /etc/sudoers.

Resources