I'm on Mac OSX and I've always had to run the gcloud command with sudo. I can usually work around it, but it has started to cause me some issues. I tried following this answer here, but I am not sure where the gcloud command gets called from. It's not in /usr/bin.
I have found that my gcloud sdk is installed at /Users/Max/Desktop/google-cloud-sdk/, and I have tried adding /bin/gcloud and '/lib/gcloud.py' from that path. No luck! Any idea how I can give NOPASSWD permissions to this command?
I'm on macOS and my issue was that my google-cloud-sdk install folder and it's config folder at ~/.config/gcloud were owned by root. The fix is to sudo chown -R <your-username> google-cloud-skd and sudo chown -R <your-username> ~/.config/gcloud. And done: no more sudo.
I was able to resolve this issue myself. This article was very helpful. Ultimately, you just have to add sudo privileges to the gcloud command. You will have to give those permissions by running sudo visudo and adding a line in the following format:
<yourusername> ALL=NOPASSWD: <command1>, <command2>
Mine line ended up looking like this:
Max ALL=NOPASSWD: /Users/Max/Desktop/google-cloud-sdk/bin/gcloud
The part that tripped me up was figuring out where the gcloud command was installed. You have to add that path at the end of the permissions. You can find out where it is installed by running which gcloud.
Related
I have a python script that does calculations on google compute engine instances. The code works fine in terms of doing the calculations, but at certain points in the code it needs to add/delete files from a cloud storage bucket and I do this using gsutil. This works well when run from my local computer, but isn't working when the same code is run from a google cloud instance. By "not working" an error message is reported at the offending line, but my code carries on running and just ignores the steps that involve gsutil.
My understanding from Google's documentation is that gcloud instances boot with the "gsutil" utility already installed. My instances boot running a script like this (where is my actual google username):
#! /bin/bash
sudo apt-get update
sudo apt-get -yq install python-pip
sudo pip install --upgrade google-cloud
sudo pip install --upgrade google-cloud-storage
sudo pip install --upgrade google-api-python-client
sudo pip install --upgrade google-auth-httplib2
mkdir -p /home/<xxxx>/code
mkdir -p /home/<xxxx>/rawdata
mkdir -p /home/<xxxx>/processeddata
sudo chown -R <xxxx> /home/<xxxx>
gsutil cp gs://<codestorebucket>/worker-python-code/* /home/<xxxx>/code/
gsutil -m cp gs://<rawdatabucket>/* /home/<xxxx>/rawdata/
I dont run my code from the boot script yet as I want to "SSH" into the instance and run it myself from the command line while I am still developing. When I SHH into the instance the directories have all been created and all of the code and raw datafiles have been copied. I can run my ".py" file and it runs, but there are lines which use the python command:
subprocess.call('gsutil -q rm gs://<mybuckname>/<myfilename>', shell=True)
This generates an error which reads:
ERROR: (gsutil) Failed to create the default configuration. Ensure your have the correct permissions on: [/home/<xxxx>/.config/gc
loud/configurations].
Could not create directory [/home/<xxxx>/.config/gcloud/configurations]: Permission denied.
If it provides any clues, in the "daemon.log" file there an error line which reads:
chown: invalid user: ‘<xxxxx>’
which is reported when the sudo chown... command line runs.
The instances have full access to all APIs. If I run
whoami
The response is "xxxxx". If I run
echo $UID
The response is 1000.
I am a Linux novice, as I have only "learnt" about it through needing to do stuff on google instances. There is a link here where a user appears to have a similar problem. He fixes it using a sudo chown type command line, but when I run an equivalent command I am told that it "cannot access '/home/paulgarlick07/.config/': No such file or directory"
I'm really confused, and any help would be very much appreciated. If any additional info is required to help resolve this please let me know!
gsutil is not a program. It is a script. Therefore you need to execute a shell with gsutil as a command line argument. You will need to pass the full pathname for gsutil which might be different on your system.
subprocess.call('/bin/sh /usr/bin/gsutil -q rm gs://<mybuckname>/<myfilename>', shell=True)
If you are running gsutil from a service, then you will need to ensure that the user that the service is running under has gsutil setup. gsutil stores its configuration files based from the home directory of the user that it is executing under.
I installed elasticsearch this way :
retrieved the tar.gz on windows, extracted it and put it on a zip
uploaded the zip over ssh on a server and use 'unzip file' to unzip it.
I modified the elasticsearch file so that it has this line
export JAVA_HOME = "/home/xxx/project1/jdk1.8.0_73_linux64"
just below
#!/bin/sh
now when I go into /home/xxx/project1/elasticsearch/bin and type
./elasticsearch
I get
-bash: ./elasticsearch: Permission denied
What could I do to get more information about the problem?
I'm logged as user xxx
Thanks.
The problem is, that you've installed elastic being logged in as root. Now you're surely logged in as not root. If you're working as a user with root privileges, you potentially could start elastic, but it tells you, you can't run in as root. The owner of your elastic folder is root (he installed it). So, all you need to do is to change the owner of a folder to your xxx-user (to let him run elastic). You can easily do it executing a command:
chown -R new_owner path
for example, user is xxx and path is /opt/elasticsearch-2.3.5:
chown -R xxx /opt/elasticsearch-2.3.5
"-R" parameter ensures, that not only folder, but all files inside will recursively change the owner you provide.
Try to install using the package Yum Install for elasticsearch.
Else try: Its sounds like the user permission to access the files.
Ensure that you have downloaded the linux distribution (Optional) Since you have mentioned its tar.gz.
If you have extracted using sudo command then you need to change the user permission for elasticsearch folder to logged in user OR start the elasticsearch using sudo command
sudo ./elasticsearch -d
Check the execution permission if not please do the same by following command
sudo chmod +x /home/xxx/project1/elasticsearch/bin/elasticsearch.sh
Try this things if not please create a chat window and invite me.
Looking ahead I will immediately say that the ES app doesn't work using the sudo
In my case with ES 6.8.1 version on ubuntu i solved the problem using this steps:
Add the current user(or any other) to ES group:
sudo adduser <yourName> elasticsearch
Add possibility to execute ES:
sudo chmod +x /usr/share/elasticsearch/bin/elasticsearch
Then i changed owner of some paths**, in my case these were:
sudo chown -R <yourName>:elasticsearch /etc/default/elasticsearch
sudo chown -R <yourName>:elasticsearch /etc/elasticsearch
sudo chown -R <yourName>:elasticsearch /var/log/elasticsearch
**I started the application several times and then looked where I had no permission
Then i started ./usr/share/elasticsearch/bin/elasticsearch and saw the long-awaited JSON on port 9200 :)
Hope this will help someone.
I'm having a bad time trying to install OpenFOAM using Docker(on a MacOSX El Capitan). I've been following the official tutorial.
When I try to execute the first script (installOpenFOAM+), through the command line:
docker-machine ssh default $HOME/installOpenFOAM+ $HOME
I get the following result on the terminal screen:
machine does not exist
I've been looking for a solution online over and over but it seems nobody has had an issue like this. Has someone here faced the same problem?
Try making the install script executable before the first script, it seems to work for some people. That is, use
chmod +x installOpenFOAM+
I also had tough time installing Openfoam using docker.
After you install docker, you need to create a virtual machine (named default).
Once it is done, change the permission of install script. Then try to install it.
docker-machine create --driver virtualbox default
chmod a+x installMacOpenFOAM+
docker-machine ssh default $HOME/installMacOpenFOAM+ $HOME
I am not able to stat the application.
I recently installed Arch Linux on my Raspberry Pi and, after logging in as root and creating myself a user account I tried to use the sudo command. This was the result:
[phillipus#alarmpi home]$ sudo mkdir Public
bash: sudo: command not found
After searching for the problem, I logged in as root and executed pacman -S sudo. This was followed by a long output and a confirmation of installation. Following this, I retried to use sudo both as root and as my user, both times getting the same response. Following another solution to the problem, I tried to add myself to /etc/sudoers, only to find out that it didn't exist.
I am not very experienced with Linux, so could you please try to explain your responses fully?
First, you need to install the sudo package to use sudo:
pacman -S sudo
After that, you need to edit the sudoers file and add your username to it.
You can add yor user to the wheel group using usermod -G wheel yourusername and uncomment the %wheel ALL=(ALL) ALLline in the sudoers file. For more information, have a look at Sudo - ArchWiki
I have just installed MariaDB via homebrew on my Mac. At the end of the installation I got the following error:
Warning: The post-install step did not complete successfully
You can try again using `brew postinstall mariadb`
If I run brew postinstall mariadb I get:
==> /usr/local/Cellar/mariadb/5.5.34/bin/mysql_install_db --verbose --user=andrew --basedir=/usr/loca
MariaDB is hosted on launchpad; You can find the latest source and
email lists at http://launchpad.net/maria
Please check all of the above before mailing us! And remember, if
you do mail us, you should use the /usr/local/Cellar/mariadb/5.5.34/scripts/mysqlbug script!
READ THIS: https://github.com/mxcl/homebrew/wiki/troubleshooting
Which isn't helpful! The tutorial I was following told me to run unset TEMPDIR, then mysql_install_db --user=mysql --basedir=$(brew --prefix mariadb); running those results in the following:
/usr/local/opt/mariadb/bin/my_print_defaults: Can't read dir of '/usr/local/etc/my.cnf.d' (Errcode: 2)
Fatal error in defaults handling. Program aborted
chown: ./data: Operation not permitted
Cannot change ownership of the database directories to the 'mysql'
user. Check that you have the necessary permissions and try again.
I suspect the problem has something to do with the /usr/local/etc/my.cnf.d folder. I've seen this referred to in a couple of things I've tried, but it doesn't exist on my machine. I have tried a few different mysql_install_db commands I've found in other tutorials, but they all throw up a (different) error message.
Thanks for any help!
Just open the config file at /usr/local/etc/my.cnf with your editor and comment out the following line:
!includedir /usr/local/etc/my.cnf.d
Having been unsuccessful with further Googling of the problem I tried manually creating a /usr/local/etc/my.cnf.d and now the mysql_install_db command seems to have worked okay. I'm not sure if this is the appropriate solution or if my.cnf.d not existing is indicative of a deeper problem with the install but, as things seem to be working, I'll mark as resolved.
[Update] As I was a little unsure in my answer whether this was the 'correct' solution I just wanted to confirm that, after a month, everything is still working fine.
None of the solution here helped, I had to do this:
The post-install step did not complete successfully MySQL Mac OS Sierra
in short,
I made a backup of the folder /usr/local/var/mysql , then removed it
removed Mariadb brew remove mariadb
reinstalled Mariadb brew install mariadb
run brew services start mariadb
After that I could access with mysql -u root
You might have an orphaned configuration file. I was able to solve this problem by deleting an old /usr/local/etc/my.cnf. YMMV.
If you're having this problem in 2021
This worked for me:
sudo mysql_install_db
sudo chown -R <YOUR USER NAME HERE> /usr/local/mysql # for example sudo chown -R jperez /usr/mysql
sudo chgrp -R admin /usr/local/mysql
After that, running mysql or mariadb will show the database prompt.
This problem seems to have recently gone away.
A simple bew upgrade resolved the problem for me.
You may want to go
/usr/local/mysql
and delete the old MySQL file and install again