Error when run file createdb.sh when install Hyperledger Explorer - hyperledger-fabric

When I ran the createdb.sh file, there was an error:\
could not change directory to "/root/gopath/src/github.com/hyperledger/fabric/fabric-samples/blockchain-explorer/app/persistence/fabric/postgreSQL/db": Permission denied
psql: error: ./explorerpg.sql: No such file or directory
could not change directory to "/root/gopath/src/github.com/hyperledger/fabric/fabric-samples/blockchain-explorer/app/persistence/fabric/postgreSQL/db": Permission denied
psql: error: ./updatepg.sql: No such file or directory</code>
I follow the instructions in https://github.com/hyperledger/blockchain-explorer\
I have done all the steps and apply permission to db/
There is file create.sh
and folder db

# this is your command
sudo -u postgres ~~
With the sudo -u option you run the command as the postgres user.
https://helpmanual.io/help/sudo/
sudo
-u, --user=user run command (or edit file) as specified user name
or ID
It is expected that the postgres user will not have privileged access to the /root directory.
Here are three solutions.
1. Change the file mode bits /root dir
Not recommended.
sudo chmod -R 775 /root
2. Add postgres to super user group
ubuntu18.04
centos7
# ubuntu 18.04
sudo usermod -aG sudo postgres
su - postgres
# centos7
sudo usermod -aG wheel postgres
su - postgres
3. Independently divide the workspace
Running applications under the root directory is dangerous and contradicts the Linux user philosophy.
Create a new workspace under the /home directory
Set permissions for the new workspace
Move your application and code
Grant permissions to postgres

Related

Giving write permission to a user on linux server to create Anaconda env

I have both a root access and my own account on the server. Now I have anaconda installed as root and under /opt/anaconda3.
I have access to anaconda as a user on that same server. But when I try to create an environment in conda it always gives me this error.
NotWritableError: The current user does not have write permissions to a required path.
path: /opt/.conda/environments.txt
uid: 1002
gid: 1002
If you feel that permissions on this path are set incorrectly, you can manually
change them by executing
$ sudo chown 1002:1002 /opt/.conda/environments.txt
When I run
sudo chown 1002:1002 /opt/.conda/environments.txt
It does allow me to create an env then with no issues. But it only works for that session. Next time login again same issue.
So I think I need to add write permission to my user id to this file.
How do I do that?
Should I login as root by doing
sudo su -
And then do
chmod u+rw
But how do I specify uid and gid as mentioned above to get the write access to this file.
Thanks
Try doing the below steps,
sudo chown 1002:1002 /opt/.conda/environments.txt
sudo chmod u+w /opt/.conda/environments.txt
sudo chmod g+w /opt/.conda/environments.txt

process_usershare_file: stat of failed. Permission denied Samba

I created a shared folder using samba in ubuntu to enable windows machines can access it with the following command:
$ sudo net usershare add documents /home/developer/documents "Developer documents" everyone:F guest_ok=y
I give 777 permissions to the folder:
$ sudo chmod 0777 /home/developer/documents
And then I check what I've done
$ sudo net usershare info --long
When I want to see if the folder is visible from all windows machine, you can see. However, you cann't access that folder and get error of: "Permission Denied"
The message in: /var/log/samba/log.ip-domain is:
process_usershare_file: stat of /var/lib/samba/usershares/backuparsac failed. Permission denied
Then, I try to add some rules to my smb.conf
[documents]
comment = Documents for Developers
path = /home/developer/documents
browseable = yes
writable = yes
read only = yes
guest ok = yes
directory mask = 0777
but the error of Permission denied keeps coming. Is there anything else I need to do? I need this folder can be accessed by all windows machines.
NOTE: I use Ubuntu 14.04
The cause is that Samba does not synchronize its users with the system.
This solved the issue in my case, on Kubuntu 14.10:
sudo apt-get install libpam-smbpass
sudo service samba restart
If you don't want to synchronize users with PAM, simply add a user to Samba's password database:
sudo smbpasswd -a <user>
After that, the user will be able to open shared folders on the Samba machine.
Your configuration file seems to be fine.
I reckon there might be a permission issue in your parent folder.
I suggest you check /home and /home/developer both have 755 rather than 750 permission.
Then check sudo -u nobody ls /home/developer/documents.
If ls is successful, the samba is likely to work as you expected as well

Rsync mkdir permission denied

I am trying to use "Rsync" to copy my spark directory to all the slave machines by this command:
rsync -avL --progress /path/to/spark-0.9.0-incubating ubuntu#<Public_ip_of_slave>:/usr/local`
I am following the instructions on this site:
http://docs.sigmoidanalytics.com/index.php/Setup_hadoop_2.0.0-cdh4.2.0_and_spark_0.9.0_on_ubuntu_aws_cluster"
but I am facing an error which is permission denied to make the folders in the destination.
Can anyone help me?
The ubuntu user (which you are using for scp) does not have the appropriate directory permissions on /usr/local at the remote server.
Misconfiguration can result in security issues so changing the directory permission of /usr/local is not recommended. If you wish to do so run:
ssh ubuntu#remote-server 'sudo chown root:ubuntu /usr/local'
where remote-server is the hostname or IP of the remote server and assuming that ubuntu is an administrator. You may also allow all others to write to the directory:
ssh ubuntu#remote-server 'sudo chmod o+w /usr/local'
but this is more dangerous than the previous option.
Alternatively, you may copy it into your home directory first then issue a sudo command to move the files into /usr/local:
rsync -avL --progress /path/to/spark-0.9.0-incubating ubuntu#remote-server:~
ssh ubuntu#remote-server 'sudo mv ~/spark-0.9.0-incubating /usr/local'
~ will be expanded to the home directory of the user, which in this case is likely to be /home/ubuntu/.
Do remember to change the permissions of /usr/local/spark-0.9.0-incubating as appropriate to allow access to authorized users using the chmod command.

Cherokee: accessing uwsgi configuration file

I'm running into a permissions problem with Cherokee+uWSGI on Ubuntu Server 13.10 intended for a Django production environment. When I start uWSGI manually as root user prior to launching cherokee, everything goes smooth:
sudo uwsgi --ini /home/instytut21/instytut21l/instytut21/uwsgi.ini
But when I try to access the site through the server (running as www-data) without that, I keep getting a 503 Service Unavailable response and the following message in the logs:
sudo cat /var/log/cherokee/instytut21.error.log
realpath() of /home/instytut21/instytut21.pl/instytut21/uwsgi.ini failed:
[core/utils.c line 3574]
I've spent a good while trying to figure out what causes the problem. I've tried giving ownership to $USER:www-data and www-data:www-data with all kinds of file permissions ranging from 600 to 777.
I don't want to run the server as root for security reasons. How can I make the ini file accessible to cherokee?
I finally found a solution to a similar problem at www-data permissions? . I slightly modified it and solved my problem by executing the following commands.
Own the whole directory by me and group www-data:
sudo chown -R $USER:www-data /home/instytut21/instytut21.pl/
Grant all permissions to the group:
sudo chmod -R g+rwx /home/instytut21/instytut21.pl/
Ensure all uploaded filed get the same permissions:
sudo chmod -R g+s /home/instytut21/instytut21.pl/

PostgreSQL won't start: "server.key" has group or world access

Whenerver I start PostgreSQL using command:
$ sudo /etc/init.d/postgresql start
Pg doesn't start up. The error reported is:
* Starting PostgreSQL 8.4 database server
* The PostgreSQL server failed to start. Please check the log output:
2010-01-21 22:10:00 PST FATAL: private key file "server.key" has group or world access
2010-01-21 22:10:00 PST DETAIL: File must be owned by the database user or root, must have no write permission for "group", and must have no permissions for "other".
... and when I try to access psql as the postgres user with:
$ sudo su postgres
$ psql
it gives me an error:
could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
I had solved it using ..
1) Enter the relevant directory (use> locate server.key)
2) Back up old server.key link.
3) Copy ssl-cert-snakeoil.key to server.key
4-5) Change its owner & group to postgres
6) Ensure the permissions are 700 or 740 (as requested by error message)
Recipe for my Ubuntu 12.04 & postgresql-8.3:
sudo cd /var/lib/postgresql/8.3/main/
sudo mv server.key server.key-0
sudo cp /etc/ssl/private/ssl-cert-snakeoil.key server.key
sudo chown postgres server.key
sudo chgrp postgres server.key
sudo chmod 740 server.key
sudo /etc/init.d/postgres-8.3 start
And now its working !
Thanks for support.
How about not to hard copying the Server Key and leaving it where and like it is.
Instead it is simplier to:
Change the "server.key" link Permissions in PostgreSQL Data Directory (its the Location where the Link to the private certificate.key File resides)
# cd /var/lib/postgresql/9.1/main/
to
# chown -R postgres:postgres server.key`
And make sure that the original Certificate in
# /etc/ssl/private/ssl-cert-snakeoil.key
has those Properties, by Setting them
# chmod 640 ssl-cert-snakeoil.key
# chown root:ssl-cert ssl-cert-snakeoil.key
This Solution has been tested on Debian.
Please remember that CentOS can use the SELinux with extended User Rights Management, which can be viewed by
# ls -laZ *
As the error message says, fix the permissions for the key file server.key. The server runs as user "postgres" which should own the file. Try
#cd <path/to/pgsql/data>
#chown postgres server.key
#chmod 0640 server.key
It happened to me and it turned out that I removed erroneously the postgres user from "ssl-cert" group, set it back with
gpasswd -a postgres ssl-cert
Setthe permissions of /etc/ssl/private to root:ssl-cert. Comments on this issue made me try this solution.
NOTE: even tough the answer is accepted, it didn't solve my issue. To help someone else i wanted to answer here.
sudo chown postgres /var/lib/postgresql/8.4/main/server.key
sudo chmod 0640 /var/lib/postgresql/8.4/main/server.key
Hit tab after postgresql to confirm your version.
Follow this https://www.postgresql.org/docs/9.6/ssl-tcp.html
use "chmod og-rwx server.key"
and change user to postgres user using chown command.

Resources