1

After every reboot I have to set chmod o+rw /dev/ttyS0 to be able to print to my POS printer via serial port in bash.

Is it possible to save permissions and also baud rate, bits, stop bit and parity after the device is closed?

4
  • what is the result of ls /dev/ttyS0? Jan 17, 2017 at 10:51
  • 1
    In many Linux distributions the entire /dev subtree is not persistent, but it is generated at boot by udev.
    – AlexP
    Jan 17, 2017 at 10:58
  • 1
    @richard crw-rw---- 1 root dialout 4, 64 Sij 17 09:15 /dev/ttyS0 after boot and then I change it to crw-rw-rw- 1 root dialout 4, 64 Sij 17 09:15 /dev/ttyS0 that I can print from bash
    – Hrvoje T
    Jan 17, 2017 at 11:01
  • 1
    Add yourself to group dialout, it is also more secure. Jan 17, 2017 at 11:02

1 Answer 1

6

you can check the group owner of /dev/ttyS0 with:

ls -l /dev/ttyS0

and then add your user in this group:

usermod -a -G {group-name} username
3
  • ... as long as one isn't on one of the operating systems where serial terminals have group wheel. This hasn't answered what the questioner asked about line speed and framing, by the way.
    – JdeBP
    Jan 17, 2017 at 12:45
  • Btw. useradd is for a new user. I am an existing user. I have to use sudo usermod -a -G dialout my_username. Then I can confirm it with the command groups my_username. I just found this because useradd didn't work
    – Hrvoje T
    Jan 17, 2017 at 22:44
  • @HrvojeT you are right. Changed the command above too. Jan 18, 2017 at 7:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .