How to use gcc in Ubuntu without Root privilege? - linux

I'm using an Ubuntu server to run npm install.
I have to use an account which is not sudoer to run services.
I would say this is a service account.
However, when I type gcc --version, it show permission denied.
-bash: /usr/bin/gcc: Permission denied
I found out that gcc is in charge of root account.
So my question is that is there any way I can just use gcc to run npm install without changing any permission?
I'm not allowed to give sudo permission to this service account.
I ran "ls -lah /usr/bin/gcc" and the result is
lrwxrwxrwx 1 root root 5 May 21 2019 /usr/bin/gcc -> gcc-7

Related

Permission denied while trying install vue/cli on ubuntu 20.04

I'm trying to install Vue CLI on ubuntu 20.04 with the following command:
sudo npm install -g #vue/cli
I got permission denied error
2021/06/13 14:35:24.163955 cmd_run.go:1002: WARNING: cannot create user data directory: cannot create "/nonexistent/snap/node/4749": mkdir /nonexistent: permission denied
I used the following code to solve the permission denied problem in the directory that I'm developing the project but the solution did not solve the problem
chmod -R 777 /Desktop/vuejs
I founded the solution because I installed node js using Snap package from Snap Store, which has different permission caused the problem. installing Vue CLI using npm needed permission for making a directory in the snap directory, even changing permissions to 777 in the snap directory is not a good solution becouse changing file system directories permission like snap or usr hurts your ubuntu operation system, in my case after changing usr and snap directory permission to 777 my root permission gone and I had to reinstall ubuntu operation system
you can install node js version 14.x using apt with the following command
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
also the following link is useful to install other nodejs versions
nodejs debinstall

Unable to yum install in fedora even as root user

Getting the error Error: This command has to be run under the root user. when I try to install in Fedora as root user. Tried in different ways:
Sun May 20 20:18:57 kbsbng#tr
$ sudo yum install mod_ssl
Error: This command has to be run under the root user.
Sun May 20 20:19:00 kbsbng#tr
$ sudo bash
Sun May 20 20:19:03 root#tr
$ yum install mod_ssl
Error: This command has to be run under the root user.
Sun May 20 20:19:15 root#tr
$ su -
[root#tr ~]# yum install mod_ssl
Error: This command has to be run under the root user.
Is there any security setting that is causing this? I am trying all of the above commands by remotely sshing to the machine.
Your root user seems to be corrupted. If user group of root is assigned something out of root (or defined groups in visudo), it'll not perform.
This will solve your problem since you'll be setting user root to group root.
usermod -g root root
usermod -G root root
after entering this, logout and login.

sudo: command not found when I ssh into server

I am a newbie with server handling and Linux. I am trying to install composer on my server so that i can host my Laravel project onto it as mentioned in the tutorial in Ultimate Guide: Deploy Laravel 5.3 App on LEMP Stack. I ssh into the server and after installation of composer when I run sudo mv composer.phar /usr/local/bin/composer I am getting a message in the terminal:
-bash: sudo: command not found
I desperately need some deliberate help
Sudo is probably not installed or not in your path
check to see if you are root in this case sudo is not needed unless you are trying to impersonate another user. just run your command without sudo mv composer.phar /usr/local/bin/composer
See if sudo is your path by running which sudo or echo $PATH. If sudo is not in your path, your path variable might be broken. You can try testing this by executing a common location for sudo /usr/bin/sudo or running locate sudo | grep bin to attempt to find its location.
If you know that sudo was installed, or your path looks broken, try fixing your path. Check your distribution's env file (/etc/environment in ubuntu) to make sure that it is formatted correctly (script commands are illegal in this file)
If you are not root and you want to run a command with root prvileges then you must install sudo. But if you don't have sudo and you are not root then you can't install it. In this case I recommend switching to the root user with su
If you do not have the root password and you own the machine, you can reset the root password with a tutorial such as https://askubuntu.com/questions/24006/how-do-i-reset-a-lost-administrative-password
After you manage to login as root install sudo with apt-get update; apt-get install sudosince you are using Ubuntu.
Verify the the name of your sudoers group with visudo and modify your sudoers file if you need to. https://www.digitalocean.com/community/tutorials/how-to-edit-the-sudoers-file-on-ubuntu-and-centos
if you have an existing sudoers group or you create one you can add yourself to the group. For example if your sudoers group is called sudo run usermod -aG sudo myuser. The sudoers group by default in Ubuntu based Linux is sudo. A sudoers group entry looks like this: %sudo ALL=(ALL:ALL) ALL
If you are trying to impersonate another user and cannot install sudo, you can still use su if it is installed and you have permission / password for the other user.
e.g. su someuser
As suggested in this post, you may have to install sudo in your server.
To do that, log in as root with the following command: su -. Then install sudo with your package manager (if you're in Ubuntu: apt-get install sudo).
Then add your user to the sudo group: usermod -aG sudo <username>.
Finally type exit to log out of the root account and go back to your user.
try to install your sudo using by first logging in as a root(su - ) and then try to install **apt-get or yum sudo **. Make sure your path variable is set so that you would be able to get binary.
which sudo
echo $PATH

CentOS error - sudo: effective uid is not 0, is sudo installed setuid root?

I found another question with the same headline, however, I suppose my case is a bit different.
In an attempt to setup the new project, I needed to install nodejs. I realised that it worked only when used with sudo. For eg. sudo npm
Furthermore, I visited the link https://docs.npmjs.com/getting-started/fixing-npm-permissions and performed
sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}
to change default directory permissions.
Now because I had to sudo npm here as well, I ran
sudo chown -R $(whoami) $(sudo npm config get prefix)/{lib/node_modules,bin,share}
Post this, whenever I try to use sudo, I get this error -
sudo: effective uid is not 0, is sudo installed setuid root?
I understand that my setup for npm should have been better and off root, but I am a Linux novice.
Any help would be appreciated. :)
More information -
ls -l $(which sudo) gives => ---s--x--x. 1 dev root 123832 Aug 13 2015 /usr/bin/sudo
The problem is that you probably changed permissions to the directory /usr/bin.
To resolve that :
1) First be sure that root is owner of this directory /usr/bin :
chown root:root /usr/bin
2) and change permission for this directory :
chmod u+s /usr/bin/sudo
If anyone is still experiencing problems with sudo, I was able t solve it by checking the shell access of the account in WHM. I received the same error because the account had Jailed Shell restrictions. I set it to normal shell and the error was gone.
Issue:
sudo: effective uid is not 0, is sudo installed setuid root?
Noticed:
---s--x--x. 1 dev root 123832 Aug 13 2015 /usr/bin/sudo
user and group should be root and the sudo file should have setuid
Should be
---s--x--x. 1 root root 123832 Aug 13 2015 /usr/bin/sudo
and also double

I'm tried installing aws command line tool

I tried installing the aws command line tool to run the command
aws
on linux
i tried installing it using pip but I get an error
http://docs.aws.amazon.com/cli/latest/userguide/installing.html#install-bundle-other-os
/bin/aws: Permission denied
whenever I run the command
aws help
what should I do?
The output of ls -l /bin/aws shows:
-rw-r--r--. 1 root root 814 Oct 22 18:09 /bin/aws
Which means you have read/write permissions, but no execute permissions. To fix that, you have to run chmod like this:
chmod 755 /bin/aws
After this the output of ls -l /bin/aws should show:
-rwxr-xr-x. 1 root root 814 Oct 22 18:09 /bin/aws
The x means you also have execute permissions now. Also other users will have execute permission. If there are no other limitations, other users can execute it too.
I had the same issue, and couldn't get it to work.
I uninstalled it using the directions on the aws site
I then installed it using homebrew on linux instead, and it works fine:
# as of writing installs aws-cli v2.X
brew install awscli

Resources