Permission denied in mac terminal - macos

I'm trying to write a command on mac terminal using the root, but it shows me that the permission denied, when I use the sudo it shows that the command not found
can any one please help me
aftheers-MacBook-Air:scripts root# ./ArduinoWifiShield_upgrade.sh
-sh: ./ArduinoWifiShield_upgrade.sh: Permission denied

You have to make the file executable:
chmod +x ArduinoWifiShield_upgrade.sh

To avoid permission denied prompt, type this command and continue
sudo su
Install the packages in this admin mode,
then go back to normal mode
exit

Related

su: failed to execute /bin/bash: Permission denied

I have installed the Postgres v-12 using this blog on my ubuntu 20.04. After installing that when I run the command
pg_ctlcluster 12 main start
I got the below error
Insecure directory in $ENV{PATH} while running with -T switch at
/usr/bin/pg_ctlcluster line 398.
To fix this error I tried to give permission 750 to /bin directory as per the blog and followed the rest of the steps mentioned there. So when I run the command su postgres I gotthe below error
su: failed to execute /bin/bash: Permission denied
I have tried many blogs but didn't get any success.
Can anyone help me to run the Postgres?

Trying to get c++ compiler and getting permission denied

So I am trying to make an irc bot using libircclient. To do this I need the c++ libraries.
I do this by using
sudo apt-get install g++ libcurl4-openssl-dev
The problem is when I do this I get a ton of errors saying
Could not resolve 'security.ubuntu.com' and variations of that
So I typed in apt-get update and got these errors
E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)
E: Unable to lock directory /var/lib/apt/lists/
E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
Before I even typed in my password I did get this error though
sudo: unable to resolve host
Result of Hostname -
DESKTOP-OEHHKKI
/etc/hostname
bash: /etc/hostname: Permission denied
Your /etc/hostname has been messed up, in order to fix it:
1. Open a text editor with root permissions: sudo -H gedit /etc/hostname
And edit the opened file to ONLY contain your machine name, which you can figure out running hostname.
2. You also need to modify this file /etc/hosts, using the same method sudo -H gedit /etc/hosts, so that it looks like:
127.0.0.1 localhost
127.0.1.1 YOUR-MACHINE-NAME
You can use sudo even if the message unable to resolve host appears. Just enter your password as usual and hit Enter.
3. Reboot.

Lost permission for sudo in OSX El Capitan

I'm new to using OSX (using El Capitan 10.11.3) and while trying to change permissions on a file using sudo, I accidentally corrupted it. Now whenever, I try to use sudo to install anything globally, I'm getting the following error message.
sudo: unable to stat /etc/sudoers: Permission denied
sudo: no valid sudoers sources found, quitting
Is there any way to solve it?
I'm also unable to even view the /etc folder
bash: cd: /etc: Permission denied
When I checked permissions on /etc folder, they are as follows
lrwxr-xr-x# 1 root wheel etc -> private/etc
I had the same issue and in my case the permissions of the root folder got corrupted. What people overlook is that / is in fact also a real, normal directory and just like every directory it has ownership and permissions. Ownership should be root:wheel and permission should be 755 (that's rwxr-xr-x).
The easiest way to restore both was starting Script Editor and then typing and running that script:
do shell script "/usr/sbin/chown root:wheel /" with administrator privileges
do shell script "/bin/chmod 755 /" with administrator privileges
You are prompted for amdin password and then chown and chmod come to the rescue. After that sudo was working again.
Disable System Integrity Protection (rootless)
Reboot the Mac and hold down Command + R keys simultaneously after you hear the startup chime, this will boot OS X into Recovery Mode
When the “OS X Utilities” screen appears, pull down the ‘Utilities’ menu at the top of the screen instead, and choose “Terminal”
Type the following command into the terminal then hit return:
csrutil disable; reboot
You’ll see a message saying that System Integrity Protection has been disabled and the Mac needs to restart for changes to take effect, and the Mac will then reboot itself automatically, just let it boot up as normal

Permission denied when installing ruby

I am working on installing another version of ruby on another server which is CentOS 6.7 When while trying to configure ruby within the tmp directory I receive a:
sudo: unable to execute ./configure: Permission denied
Here is exactly what I am doing leading up to this:
mkdir /tmp/ruby && cd /tmp/ruby
curl --progress ftp://ftp.ruby-lang.org/pub/ruby/2.1/ruby-2.1.2.tar.gz | tar xz
cd ruby-2.1.2
./configure --disable-install-rdoc <!-- here is were we fail with permission denied
I am currently logged in as root. I have played around with changing my file permissions and that did not seem to help at all.
Any suggestions?
From this link it appears /tmp is mounted as read-only.
Open /etc/fstab, find the line that mounts your /tmp dir, and remove the noexec flag. Then remount the filesystem (or simply restart your system).
As a side note, you will also want to avoid running ./configure and make as root user. Only when it comes to run make install should you run as root.

Mongodb Error on start

I just downloaded mongodb via homebrew. When I tried starting it by mongod it said that I didn't have the data/db folder for it. I made the folder via sudo command from another stackoverflow page. Now the error that I'm getting is:
exception in initAndListen: 10309 Unable to create/open lock file: /data/db/mongod.lock errno:13 Permission denied Is a mongod instance already running?, terminating
I'm not sure why it's asking me if another instance of mongod is running because I only have one bash shell open.
Any tips would be awesome. Thank you!
Okay, I figured it out. The command after sudo mkdir -p /data/db is
sudo chown $USER /data/db

Resources