Mac air: IOError: [Errno 13] Permission denied - linux

I write the log under /var/log/mysite
drwxrwxr-x 6 Ariel wheel 204B 12 25 09:42 myproject/
When executing python file,I got permission denied
IOError: [Errno 13] Permission denied: '/var/log/myproject/django.log'
How can I safely set the permission to the user Ariel ??

Run your command with sudo for elevated privileges. Run:
sudo !!
in order to execute your previous command (that caused the error) with sudo.
Alternatively you can use sudo chown -R $USER /Library/Python (or /var/log if you wish).
If all fails (very unlikely), try sudo chmod -R +xw /var/log/.

The user of the python process need execute permission for the directories /var, /var/log, /var/log/myproject and write permission for the file.

Related

what should I do with the n upgrade node permission in fedora 32

I am using this command to upgrade the node version in fedora 32:
npm install -g n
n stable
when I using the n stable command, shows error like this:
cp: cannot remove '/usr/local/bin/corepack': Permission denied
cp: cannot remove '/usr/local/bin/npm': Permission denied
cp: cannot remove '/usr/local/bin/npx': Permission denied
cp: cannot remove '/usr/local/include/node/common.gypi': Permission denied
cp: cannot remove '/usr/local/include/node/config.gypi': Permission denied
cp: cannot remove '/usr/local/include/node/node.h': Permission denied
cp: cannot remove '/usr/local/include/node/node_api.h': Permission denied
cp: cannot remove '/usr/local/include/node/js_native_api.h': Permission denied
cp: cannot remove '/usr/local/include/node/js_native_api_types.h': Permission denied
cp: cannot remove '/usr/local/include/node/node_api_types.h': Permission denied
cp: cannot remove '/usr/local/include/node/node_buffer.h': Permission denied
cp: cannot remove '/usr/local/include/node/node_object_wrap.h': Permission denied
cp: cannot remove '/usr/local/include/node/node_version.h': Permission denied
cp: cannot remove '/usr/local/include/node/v8config.h': Permission denied
cp: cannot remove '/usr/local/include/node/v8-internal.h': Permission denied
I did not want to using root user to upgrade the node, what should I do? Just change the /usr/local folder permission to current user? does this way had any side effect? I am not sure, what is the best way to make the n stable command work?
The installation section in the documentation of n has instructions to avoid using sudo or working as an admin.
Quoting from the current version:
To avoid requiring sudo for n and npm global installs, it is
suggested you either install to your home directory using N_PREFIX,
or take ownership of the system directories:
# make cache folder (if missing) and take ownership
sudo mkdir -p /usr/local/n
sudo chown -R $(whoami) /usr/local/n
# make sure the required folders exist (safe to execute even if they already exist)
sudo mkdir -p /usr/local/bin /usr/local/lib /usr/local/include /usr/local/share
# take ownership of Node.js install destination folders
sudo chown -R $(whoami) /usr/local/bin /usr/local/lib /usr/local/include /usr/local/share

python serial [Errno 13] Permission denied: /dev/tty*

I try to open serial port, but cant with permission.
But works with sudo.
How i can get permission for serial port?
sas#sas-linuxmint ~ $groups sas
sas : sas adm tty dialout cdrom sudo dip plugdev lpadmin sambashare
This my code:
def get_serial_port():
ser_devs = [dev for dev in os.listdir('/dev') if dev.startswith('tty')]
for i in ser_devs:
port = "/dev/" + i
try :
ser = serial.Serial(port, 19200)
if ser.is_open:
print("OPEN!!!!!!!!!!!!!!!!!!!!!! {}".format(port))
ser.close()
except serial.SerialException as e:
print(e, port)
return None
output:
[Errno 13] could not open port /dev/ttyprintk: [Errno 13] Permission denied: '/dev/ttyprintk' /dev/ttyprintk
for all ports.
I tried change mod for port, but it doesn't work too
sudo chmod 766 /dev/ttyS10
sudo chmod -R a+rw /dev/ttyS10
sudo chmod 777 /dev/ttyS10
sudo chmod 666 /dev/ttyS10
I tried using the following command:
sudo gpasswd --add ${USER} dialout
To add dialout to my group but with no luck. The following worked for me: (assuming tty1 is the name)
sudo chmod 666 /dev/tty1
may be 2 years late but, you simply add your user to the tty group
eg:
sudo usermod -a -G tty $USER
link

Permission Denied when trying to read file w/644 permission

I am trying to write a PHP script for a Web server (lighttpd) to read a file in another user.
The Web server runs under user http:
http 1929 336 0 Nov20 /usr/bin/lighttpd -D -f /etc/lighttpd/lighttpd.conf
The file the script is trying to read has the following permissions:
-rw-r--r-- 1 pi www-data 721 Oct 30 05:20 /home/pi/bmSunday
Which I thought meant that any user can read it.
The fopen in the script results in a Permission denied:
Warning: fopen(/home/pi/bmSunday): failed to open stream: Permission denied in /srv/http/p1/index.php
I am running Arch Linux.
uname -r
displays:
4.4.32-2-ARCH
What permissions do I need to set on the file so that user http is allowed to read it?
By the way, am I correct in assuming I can also test the permission via:
sudo -u http cat /home/pi/bmSunday
Using the above command, the result is:
cat: /home/pi/bmSunday: Permission denied
The permissions on the directory are probably wrong, http probably doesn't have execute permission. Add world execute permissions:
chmod o+x /home/pi
You (as a user) in your example have no execute permissions. So yes chmod +x file. Keep in mind this adds execute to both users others.
If you give all other user execute permission on home directory of other users it compromise security to all other user. it will be better if you give permission only http user by acl.
$ setfacl -m u:http:r-x /home/pi

chmod: changing permissions of ‘my_script.sh’: Operation not permitted

when I'm trying to make shell script that error is shown ,what i must do ??
[rehamadel#localhost bin]$ sudo vi my_script.sh
[sudo] password for rehamadel:
[rehamadel#localhost bin]$ ls -l my_script.sh
-rw-r--r--. 1 root root 52 Jul 30 19:25 my_script.sh
[rehamadel#localhost bin]$ chmod u+x my_script.sh
chmod: changing permissions of ‘my_script.sh’: Operation not permitted
Resolving the operation not permitted error:
sudo chmod u+x my_script.sh
You created the file via:
sudo vi my_script.sh
# editing
This means, the owner and group of the file is root. You are not allowed to change files of it by default. You need to change permission (chmod does it) or change the owner:
sudo chown you:yourgroup my_script.sh
This should do it. Save the trouble, without creating the file via sudo.
You've created file my_script.sh with the root user as the owner (because you used sudo), which is why you're not permitted to change the permissions as yourself.
Thus, use sudo chmod u+x my_script.sh, but note that that will make the file only executable for the root user.
To make the file executable by everyone, use sudo chmod a+x my_script.sh.
I faced this error because I uploaded the files via winscp and was trying to change permission on Linux window.
I was able to change permissions via winscp.

LINUX Permission issues

Can anyone help me in fixing the permission issues in Linux.
I am new to Linux and i am trying to run a script called buildAll.sh
by moving to that specific directory and i typed ./buildAll.sh the response i got was
./buildAll.sh: 16: ./buildAll.sh: ./buildJS.sh: Permission denied
i tried to run using sudo ./buildAll.sh , but that didn't work.
Then i tried with chmod -r 777 buildAll.sh and again i tried to run that script but no change.
I have a folder called build which has some dependency can be seen a folder with locked picture.
Can anyone help me to run the script without having the permission issues please
in line 16 your script seems to call buildJS.sh and the permissions OF THAT seem to be incorrect
You obviously have a pervasive permissions problem. Why don't you just start again, unpack the files into a new directory without using sudo or su, and then use chmod +x on the files that need to be executable?
sudo chmod +x buildAll.sh
Should do the trick
It seems by the error message the issue is with buildJS.sh. If buildJS.sh is not in your current directory (it might not be as buildAll.sh might be changing directories), find buildJS.sh and then:
chmod +x ${directory_where_found}/buildJS.sh
Since .sh files should have executable permissions by default you can do this:
cd $YOUR_DIRECTORY
find . -name '*.sh' -exec chmod +x {} \;
I tried with sudo chmod +x buildAll.sh
rm: cannot remove ‘build’: Permission denied
cp: cannot stat ‘./build/.svn’: Permission denied
cp: cannot stat ‘./build/compiler.jar’: Permission denied
cp: cannot stat ‘./build/buildJS.sh’: Permission denied
touch: setting times of ‘build’: Permission denied
./buildAll.sh: line 14: cd: build: Permission denied
./buildAll.sh: line 16: ./buildJS.sh: No such file or directory
You have given permission only to run your script. However, this doesn't mean that you have permission for all of instructions launched by the script. The error message is there to prove it ;) .

Resources