sudo command is not working on mac os x [closed] - macos

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
When run sudo command anywhere in my terminal then I get following error
Zafars-MacBook-Pro:etc zafarsaleem$ sudo
sudo: /private/etc/sudoers is mode 0755, should be 0440
sudo: no valid sudoers sources found, quitting
I followed this link but when I ran ls -al / command I got following output for . which is not similar to the one in the link but stil I followed the whole tutorial but it didnt work and I am still getting above output after running sudo command. How can I fis this issue?
drwxr-xr-x 34 root wheel 1224 Jan 22 07:43 .

The question is "sudo: /private/etc/sudoers is mode 0755, should be 0440"
If you know the password for the root, you could enter in the terminal "su root", and then type the password mode can modify /etc/sudoers file as root (chmod 0440 / etc/ sudoers).
Hope it could work.

Related

Unable to autoload freerdp-shadow-cli [closed]

Closed. This question is not about programming or software development. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 3 months ago.
Improve this question
Xrdp server on kali linux. Also there is installed freerdp2-shadow-x11 to start the shadow session.
The shadow server is started with the freerdp-shadow-cli command in the terminal of a running xrdp session. And only so.Interactively on the command line with output.
I need it to run in the background from autoload along with the session of the user connected to the server.
Partially, I solved it with a script:
#!/bin/bash
freerdp-shadow-cli -auth -port:3389 -may-interact > /dev/null 2>&1 &
interactively, this script is executed and everything works, but if you add it to autoload (.zshrc file), then the script will only run when you open the terminal with your hands.
And so, experts, the question is:
How can I make the script autoload?
Finally figured it out myself
From the very beginning:
apt install freerdp2-shadow-x11
nano /home/user/RDS.sh
RDS.sh:
#!/bin/bash
#gnome-terminal -e
freerdp-shadow-cli -auth -port:3389 -may-interact > /dev/null
2>&1 &
cli:
chmod 755 RDS.sh
nano /home/user/.config/autostart/shadow.desktop
shadow.desktop:
[Desktop Entry]
Name=shadow
GenericName=A descriptive name
Comment=Some description about your script
Exec=/home/user/RDS.sh
Terminal=false
Type=Application
X-GNOME-Autostart-enabled=true
cli:
chmod 755 shadow.desktop
reboot
-may-interact -only show desktop

Changing user in docker container changes bash settings [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
I'm experiencing this behavior:
I have a docker image:
FROM ubuntu:latest
...
RUN useradd -m develop
USER develop
When I run the container:
docker run -it my_image
I get a terminal with all the features such as LS_COLORS, completion of files/directories names with TAB, etc. But if I run the container with root user:
docker run -it -u 0 my_image
And then, in the container:
~$ su develop
Now my prompt doesn't havae any of the above features, and is very hard to work with. Can someone explain this behavior? I assume it has something to do with all the initialization scripts such as .bashrc, /etc/profile, etc., but I don't quite understand the difference between the two above scenarios.
EDIT
Thanks #ItayB for the answer, I just figured it out also :).
But still, the behavior is not exactly the same as if I would just login as develop:
~$ docker run -it -u 0 build_agent:0.5
root#6acf7b900da3:/# su develop
$ bash
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.
bash: /root/.bashrc: Permission denied
develop#6acf7b900da3:/$ cd ~
bash: cd: /root: Permission denied
develop#6acf7b900da3:/$
As you can see, the environment variables are still set as if I was "Root" user. Why is that?
I think you should explicitly call bash after switching user:
$ docker run -it -u 0 my_image
root#74765d85882a:/# su develop
$ bash
develop#74765d85882a:/$

Why sudo pm-suspend does not work in i3 tiling window manager? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 4 years ago.
Improve this question
I have a little problem with the i3 tiling window manager's ~/.i3/config file.
I am trying to set the pm-suspend utility as a key-binding of Mod4 (the windows key) + p (the p char).
I have this bash script called suspendandlock in /usr/bin/:
#!/bin/bash
sudo pm-suspend | i3lock -i /home/antony/unity-desk.png -p default -d -n
I previously modified the /etc/sudoers file with visudo, adding this line:
%users ALL = NOPASSWD: /usr/sbin/pm-suspend
So that no one needs the password to execute pm-suspend utility.
Then I have my i3 config file, where I added this:
bindsym $mod+p exec suspendandlock
Where $mod is the Mod4 key.
The script works fine from gnome-terminal when I type the suspendandlock command -> it suspends the system and blocks the screen as expected.
But when I type Mod4+p from keyboard it only blocks the screen without executing pm-suspend.
Why does it not work?
Does anyone knows where I am wrong?
It looks like OP solved the problem, but for anyone else who needed to fix it (myself included), just run:
sudo usermod -aG users `whoami`
which pm-suspend || sudo apt-get install pm-utils #make sure you have pm-suspend command, install it if you don't
run sudo visudo and add:
%users ALL = NOPASSWD: /usr/sbin/pm-suspend
and then add:
bindsym $mod+p exec "sudo pm-suspend | i3lock"
to ~/.i3/config. Running $mod+p will now lock and then suspend your computer.

PostgreSQL initdb permission denied but owner is postgres [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I am trying to install postgresql90 with macports. I keep getting this weird error when trying to run initdb:
sudo su postgres -c '/opt/local/lib/postgresql90/bin/initdb -D /opt/local/var/db/postgresql90/defaultdb'
returns this error:
sh: /opt/local/lib/postgresql90/bin/initdb: Permission denied
So I am thinking, "Ok well maybe the permissions on initdb are busted". Then I do:
sudo ls -l /opt/local/lib/postgresql90/bin/initdb
and get back:
-rwxr-xr-x 1 postgres postgres 66952 25 Sep 10:06 /opt/local/lib/postgresql90/bin/initdb
So I have the right permissions on initdb. I also checked defaultdb to see the permissions and they say the owner is postgres as well...
Check the directory /opt/local/var/db/postgresql90/defaultdb. It either doesn't exist, or the permissions of the parent directory aren't correct. Run the following:
sudo chown postgres:postgres /opt/local/var/db/postgresql90
A plausible explanation would be that the sudoers file is configured with NOEXEC in a way that programs launched with sudo cannot themselves execute other programs. Permission denied is exactly what you'd get in this case.
Otherwise, another thing to check is if postgres has been installed on a partition that would be mounted with the noexec attribute.

How to run a script as root on Mac OS X? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
What should I type on the Mac OS X terminal to run a script as root?
As in any unix-based environment, you can use the sudo command:
$ sudo script-name
It will ask for your password (your own, not a separate root password).
Or you can access root terminal by typing sudo -s
sudo ./scriptname
In order for sudo to work the way everyone suggest, you need to be in the admin group.
sudo ./scriptname
sudo bash will basically switch you over to running a shell as root, although it's probably best to stay as su as little as possible.

Resources