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
Related
I am running following command
$ chown -R logstash.logstash /usr/share/logstash
$ chmod 777 /usr/share/logstash/data
I'm getting below error
chown: changing ownership of '/var/log/logstash': Operation not permitted
Can anyone pls help!
You need to run these commands with sudo for ex
$ sudo chown -R logstash.logstash /usr/share/logstash
$ sudo chmod 777 /usr/share/logstash/data
Read more about sudo
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.
I have remote server with Debian and I need to edit readonly file fcgid.conf on server. When I use sudo:
sudo su chmod 755 fcgid.conf
it responses:
-bash: sudo: command not found
Also I tried cmod +x:
chmod +x fcgid.conf
And got:
chmod: changing permissions of `fcgid.conf': Operation not permitted
Owner of file is root user and I don't know how to get permission to edit this file.
Sudo is not installed with Debian in the case you have defined a root password in the installation.
Either install sudo with
$ apt-get update
$ apt-get install sudo
and make a sudo rule and add your user into the group:
$ adduser USERNAME sudo
$ visudo
enter:
%sudo ALL = (ALL) ALL
and then run again
$ sudo chmod +x fcgid.conf
see also here: How to properly configure sudoers file, on debian wheezy?
or you try
$ su root
and then
$ chmod +x fcgid.conf
Both methods provide that you know the root/admin password...
On ubuntu 10.04.4 server, I did this:
sudo mkdir -p /data/somedir
sudo chown -R www-data.www-data /data/somedir
sudo chmod -R g+w /data/somedir
sudo usermod -a -G www-data john ##john is current login user.
. With these operations done, I suppose to have write permission in /data/somedir. But when I did this:
echo "123" > /data/somedir/123
, I got:
-bash: /data/somedir/123: Permission denied
The ls -l output:
$ ls -l /data/
total 4
drwxrwxr-x 2 www-data www-data 4096 2012-04-24 22:30 somedir
Question is: why? Is there something I still need to do after that?
Changes made with usermod only take effect on following logins; your existing login session does not yet have the www-data group, as you can verify with id. It is not easy to alter the identity of running processes (newgrp might work); the easiest way to deal is to log out and back in.
there is a network device on my ttyUSB0 port. I can access it with sccren command on linux, but when I try to connect with cu command I get this error:
sudo cu -s 9600 -l /dev/ttyUSB0
cu: open (/dev/ttyUSB0): Permission denied
cu: /dev/ttyUSB0: Line in use
How can I connect with cu command?
Usually it's just the file permissions on /dev/ttyUSB0 that aren't set after connecting the device:
sudo chown $USER /dev/ttyUSB0
Or add yourself to the dialout group:
sudo usermod -a -G dialout $USER