Cannot use RVM-installed Ruby with sudo
Use rvmsudo command instead of sudo
Use rvmsudo command instead of sudo
ERROR: While executing gem … (Gem::FilePermissionError) You don’t have write permissions for the /Library/Ruby/Gems/2.3.0 directory. Install RVM (optional) Set the gem folder in your shell resource file. I.e. .zshrc, .bashrc etc export GEM_HOME=”$HOME/.gem” Install you gem gem i LIBRARY_NAME
Only the root user needs sudo requirement to login to mysql. I resolved this by creating a new user and granting access to the required databases: CREATE USER ‘newuser’@’localhost’ IDENTIFIED BY ‘password’; GRANT ALL PRIVILEGES ON database_name.* TO ‘newuser’@’localhost’; now newuser can login without sudo requirement: mysql -u newuser -p
You can follow these steps to compile/debug applications as superuser. Rename your java-application sudo mv /usr/lib/jvm/java-6-openjdk/jre/bin/java /usr/lib/jvm/java-6-openjdk/jre/bin/java.ori Create following script and store it as /usr/lib/jvm/java-6-openjdk/jre/bin/java #!/bin/bash # file: /usr/lib/jvm/java-6-openjdk/jre/bin/java # descr: Starter for jdk. Runs jdk as root when # cmd-line-arg “–run-as-root” is specified. # jre=”/usr/lib/jvm/java-6-openjdk/jre/bin/java.ori” run_as_root=false args= # Filter command-line argument for arg in … Read more
Another way is to use the -t switch to ssh: ssh -t user@server “sudo script” See man ssh: -t Force pseudo-tty allocation. This can be used to execute arbi- trary screen-based programs on a remote machine, which can be very useful, e.g., when implementing menu services. Multiple -t options force tty allocation, even if ssh … Read more
It is better to run as little of the program as possible with elevated privileges. You can run the small part that needs more privilege via the subprocess.call() function, e.g. import subprocess returncode = subprocess.call([“/usr/bin/sudo”, “/usr/bin/id”])
$ sudo pip install Installs the package globally in your python installation, i.e. for all users. $ pip install –user Installs to the local user directory, i.e. ~/.local/lib/python — just you. Example: $ sudo pip install jupyter $ jupyter notebook Will run jupyter, open a web browser, allow you to work with notebooks. $ pip … Read more
Yes, it is a bit annoying but you can fix it with some links: sudo ln -s /usr/local/bin/node /usr/bin/node sudo ln -s /usr/local/lib/node /usr/lib/node sudo ln -s /usr/local/bin/npm /usr/bin/npm sudo ln -s /usr/local/bin/node-waf /usr/bin/node-waf There might be more but that is all I have run across so far. Lack of node-waf will cause some npm … Read more
I also saw this change on my Mac when I went from running pip to sudo pip. Adding -H to sudo causes the message to go away for me. E.g. sudo -H pip install foo man sudo tells me that -H causes sudo to set $HOME to the target users (root in this case). So … Read more
Results: Use who am i | awk ‘{print $1}’ OR logname as no other methods are guaranteed. Logged in as self: evan> echo $USER evan evan> echo $SUDO_USER evan> echo $LOGNAME evan evan> whoami evan evan> who am i | awk ‘{print $1}’ evan evan> logname evan evan> Normal sudo: evan> sudo -s root> echo … Read more