sudo interview questions
Top sudo frequently asked interview questions
I'm writing a C Shell program that will be doing su
or sudo
or ssh
. They all want their passwords in console input (the TTY) rather than stdin or the command line.
Does anybody know a solution?
Setting up password-less sudo
is not an option.
expect could be an option, but it's not present on my stripped-down system.
Source: (StackOverflow)
I've been given sudo access on one of our development RedHat linux boxes, and I seem to find myself quite often needing to redirect output to a location I don't normally have write access to.
The trouble is, this contrived example doesn't work:
sudo ls -hal /root/ > /root/test.out
I just receive the response:
-bash: /root/test.out: Permission denied
How can I get this to work?
Source: (StackOverflow)
I just installed node and npm through the package on nodejs.org and whenever I try to search or install something with npm it throws the following error, unless I sudo the command. I have a feeling this is a permissions issue? I am already the admin.
npm ERR! Error: EACCES, open '/Users/chietala/.npm/-/all/.cache.json'
npm ERR! { [Error: EACCES, open '/Users/chietala/.npm/-/all/.cache.json']
npm ERR! errno: 3,
npm ERR! code: 'EACCES',
npm ERR! path: '/Users/chietala/.npm/-/all/.cache.json' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! System Darwin 12.2.0
npm ERR! command "node" "/usr/local/bin/npm" "search" "bower"
npm ERR! cwd /Users/chietala
npm ERR! node -v v0.10.4
npm ERR! npm -v 1.2.18
npm ERR! path /Users/chietala/.npm/-/all/.cache.json
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, open '/Users/chietala/.npm/-/all/.cache.json'
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /Users/chietala/npm-debug.log
npm ERR! not ok code 0
Source: (StackOverflow)
I've started to use my mac to install python packages in the same way I do with my Windows PC at work, however on my mac I've come across frequent permission denied
errors writing log files & sometimes writing to site-packages.
Therefore I thought about running pip install <package>
under sudo
but is that a safe/acceptable use of sudo considering I'm just wanting this to be installed under my current user account.
Example traceback from a logfile I/O error;
Command /usr/bin/python -c "import setuptools;__file__='/Users/markwalker/build/pycrypto/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /var/folders/tq/hy1fz_4j27v6rstzzw4vymnr0000gp/T/pip-k6f2FU-record/install-record.txt failed with error code 1 in /Users/markwalker/build/pycrypto
Storing complete log in /Users/markwalker/Library/Logs/pip.log
Traceback (most recent call last):
File "/usr/local/bin/pip", line 8, in <module>
load_entry_point('pip==1.1', 'console_scripts', 'pip')()
File "/Library/Python/2.7/site-packages/pip-1.1-py2.7.egg/pip/__init__.py", line 116, in main
return command.main(args[1:], options)
File "/Library/Python/2.7/site-packages/pip-1.1-py2.7.egg/pip/basecommand.py", line 141, in main
log_fp = open_logfile(log_fn, 'w')
File "/Library/Python/2.7/site-packages/pip-1.1-py2.7.egg/pip/basecommand.py", line 168, in open_logfile
log_fp = open(filename, mode)
IOError: [Errno 13] Permission denied: '/Users/markwalker/Library/Logs/pip.log'
update
I am able to install if I use sudo pip install
Source: (StackOverflow)
When I use any command with sudo the Enviroment Variables were not there for example when I set HTTP_PROXY it works fine with wget without sudo but when I type sudo wget it said It cant bypass the proxy setting.
Source: (StackOverflow)
since an update to 10.8 I get the following error, when trying to do a sudo command, which is pretty annoying.
dyld: DYLD_ environment variables being ignored because main executable (/usr/bin/sudo) is setuid or setgid
What does that have to mean? I hope anyone can help.
Source: (StackOverflow)
Normally, docker containers are run using the user root. I'd like to use a different user, which is no problem using docker's USER directive. But this user should be able to use sudo inside the container. This command is missing.
Here's a simple Dockerfile for this purpose:
FROM ubuntu:12.04
RUN useradd docker && echo "docker:docker" | chpasswd
RUN mkdir -p /home/docker && chown -R docker:docker /home/docker
USER docker
CMD /bin/bash
Running this container, I get logged in with user 'docker'. When I try to use sudo, the command isn't found. So I tried to install the sudo package inside my Dockerfile using
RUN apt-get install sudo
This results in Unable to locate package sudo
I've no idea how to manage this. Any suggestions? Thx a lot!
Source: (StackOverflow)
I have a script which runs another script via SSH on a remote server using sudo. However, when I type the password, it shows up on the terminal. (Otherwise it works fine)
ssh user@server "sudo script"
What's the proper way to do this so I can type the password for sudo over SSH without the password appearing as I type?
Source: (StackOverflow)
When running a script via sudo or su I want to get the original user. This should happen regardless of multiple sudo
or su
runs inside of each other and specifically sudo su -
.
Source: (StackOverflow)
I am using Fabric to run commands on a remote server. The user with which I connect on that server has some sudo privileges, and does not require a password to use these privileges. When SSH'ing into the server, I can run sudo blah
and the command executes without prompting for a password. When I try to run the same command via Fabric's sudo
function, I get prompted for a password. This is because Fabric builds a command in the following manner when using sudo
:
sudo -S -p <sudo_prompt> /bin/bash -l -c "<command>"
Obviously, my user does not have permission to execute /bin/bash
without a password.
I've worked around the problem by using run("sudo blah")
instead of sudo("blah")
, but I wondered if there is a better solution. Is there a workaround for this issue?
Source: (StackOverflow)
I have read the Ansible documentation but I am still a bit confused about the three following parameters in ansible playbooks: user, sudo, sudo_user.
I have tried the following playbooks with different combination of the parameters:
user:deploy => Works
user:deploy and sudo: True => Hangs on the git task
user:deploy, sudo: True and sudo_user: deploy => Works
What does sudo_user actually do?
When and why should I use each of these combinations?
- hosts: all
user: deploy
sudo: True
sudo_user: deploy
tasks:
- name: Ensure code directory
file: dest=/home/deploy/code state=directory
- name: Deploy app
git: repo=git@bitbucket.org:YAmikep/djangotutorial.git dest=/home/deploy/code
Thanks
Source: (StackOverflow)
On my Debian server I have a user called "deployer" that does not have sudo
access, and has RVM installed.
When installing Ruby using "deployer", like 1.9.3, it triggers a task to install dependencies
"Installing requirements for debian, might require sudo password."
which fails and stops installation because "deployer" can not sudo.
I don't want to add "deployer" into the sudoers list, and don't want to install RVM for some other user just for a one-time use for installing dependencies.
What is the correct way to install that dependencies? Or how do I list them to install manually?
Source: (StackOverflow)
When installing pip and python I have ran into a snag that says:
The directory '/Users/Parthenon/Library/Logs/pi' or its parent directory is not owned by the current user and the debug log has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want the -H flag.
because I now have to install using sudo
.
I had python and a handful of libraries already installed on my Mac, I'm running Yosemite. I recently had to do a clean wipe and then reinstall of the OS. Now I'm getting this prompt and I'm having trouble figuring out how to change it
Before my command line was Parthenon$
now it's Philips-MBP:~ Parthenon$
I am the sole owner of this computer and this is the only account on it. This seems to be a problem when upgrading to python 3.4, nothing seems to be in the right place, virtualenv isn't going where I expect it to, etc.
Source: (StackOverflow)
I am trying to globally install an npm module I just published. Every time I try to install, either from npm or the folder, I get this error.
npm ERR! Error: ENOENT, chmod '/usr/local/lib/node_modules/takeapeek/lib/cmd.js'
npm ERR! If you need help, you may report this log at:
npm ERR! <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR! <npm-@googlegroups.com>
npm ERR! System Linux 3.8.0-19-generic
npm ERR! command "node" "/usr/local/bin/npm" "install" "-g" "takeapeek"
npm ERR! cwd /home/giodamlio
npm ERR! node -v v0.10.6
npm ERR! npm -v 1.3.6
npm ERR! path /usr/local/lib/node_modules/takeapeek/lib/cmd.js
npm ERR! code ENOENT
npm ERR! errno 34
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/giodamlio/npm-debug.log
npm ERR! not ok code 0
I am using sudo and I have triple checked everything in the package everything should work. I did some searching around, and saw a couple of similer cases none of which have been resolved. Here is what I tried.
- Upgrade npm (
sudo npm install -g npm
)
- Clear the global npm cache (
sudo npm cache clear
)
- Clear the user npm cache (
npm cache clear
)
I noticed that the error had to do with the file I am linking to the path, specifically when npm tried to do a chmod. That shouldn't be a problem, my lib/cli.js
has normal permissions, and npm has superuser permissions during this install.
After digging through the npm docs I found an option that would stop npm from making the bin links(--no-bin-links
), when I tried the install with it, it worked fine.
So what's the deal? Is this some weird fringe case bug that has no solution yet?
Edit: For reference, here is the module I uploaded
Source: (StackOverflow)