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?

  • what is the result of ls /dev/ttyS0? – ctrl-alt-delor Jan 17 '17 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 '17 at 10:58
  • @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 '17 at 11:01
  • 1
    Add yourself to group dialout, it is also more secure. – ctrl-alt-delor Jan 17 '17 at 11:02

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
  • ... 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 '17 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 '17 at 22:44
  • @HrvojeT you are right. Changed the command above too. – blametheadmin Jan 18 '17 at 7:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.