Tuesday, May 28, 2013

Linux Love

Accessing Serial port in Linux:

In some linux distributions including Ubuntu (version > 11.10), user cannot access /dev/ttyS0 and other communication ports if he is not member of a particular group. In case of Ubuntu, user should be member of dialout group to access communication ports.
Before 11.10, dialout group was among default user groups and every user is member of this group. But since 12.04, dialout has been removed from default groups.
This means any user who wants to access communication ports should explicitly add himself to dialout group.
Below are instructions to check required group and commands to add user to that group:

Checking Required group

tmirza@pkl-nutools:~$ ls -l /dev/ttyS0
crw-rw---- 1 root dialout 4, 64 Jul 31 00:49 /dev/ttyS0
The above command shows that only root and dialout group members can access /dev/ttyS0

Checking User Group

tmirza@pkl-nutools:~$ groups tmirza
tmirza adm cdrom sudo dip plugdev lpadmin sambashare
The above command shows that tmirza user does not belong to dialout group.

Adding user to Group

tmirza@pkl-nutools:~$ sudo adduser tmirza dialout
Adding user `tmirza' to group `dialout' ...
Adding user tmirza to group dialout
Done.
We need to put these steps in our release-notes or Getting Started Guide. Adding user to specific group is required for NDA to work properly. Otherwise launch configuration dialog will show error message Unable to find any connectable communication port. Make sure you have permission to access communication ports. as shown in Permissions_error.png
NOTE: User need to log out and log back in again for adduser to be effective




Important Linux Commands:
 
Check CPU is 64 bit or 32 bit:
  • egrep -c ' lm ' /proc/cpuinfo
Check installed OS is 32 or 64:
  • uname -m
 Checking Ubuntu Version
  • lsb_release -a
Switching to root user (Ubuntu):
  • sudo su -
Remotely copy files without breaking links:
  • rsync --progress -avhe ssh /path/of/source /path/of/destination