As it happens over the time I came across a situation where I was using a Linux machine to connect to some networking boxes. Unfortunately the fact was that the only serial connection available was my personal usb-to-serial cable which I have bought quite some time ago and which was a major pain in the behind to make work under windows 7 64bit. Well long story short making it work under Debian was almost as “happy” and painful experience.
To start with there is enough information all around the Internet but the problems are as usually inconsistency and some Debian specifics. So let us have a look on the pre-requisities for this small exercise. My machine was running Debian Sid/Wheezy with 2.6.32 kernel but it works with the 2.6.38 as well and will probably work wit almost anything. The reason why I am mentioning this is that the first thing you need to find out is if you have the proper driver. The way to see that is your driver type/make etc. you would need to plug it in and search in the dmessages (dunning the dmesg command) or in the messages file located in /var/log/messages.
May 16 22:26:26 Hell kernel: [ 351.649316] usb 2-1.3: new full speed USB device using ehci_hcd and address 3
May 16 22:26:26 Hell kernel: [ 351.742481] usb 2-1.3: New USB device found, idVendor=067b, idProduct=2303
May 16 22:26:26 Hell kernel: [ 351.742488] usb 2-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
May 16 22:26:26 Hell kernel: [ 351.742494] usb 2-1.3: Product: USB-Serial Controller D
May 16 22:26:26 Hell kernel: [ 351.742498] usb 2-1.3: Manufacturer: Prolific Technology Inc.
May 16 22:26:26 Hell kernel: [ 351.830383] USB Serial support registered for pl2303
May 16 22:26:26 Hell kernel: [ 351.830418] pl2303 2-1.3:1.0: pl2303 converter detected
May 16 22:26:26 Hell kernel: [ 351.831987] usbcore: registered new interface driver pl2303
May 16 22:26:26 Hell kernel: [ 351.831990] pl2303: Prolific PL2303 USB to serial adaptor driver
As it happens in my case the usb-toserial reduction is the pl2303 and the driver included in the Debian stock kernel which is nice but not sufficient for anything to work. Now there are two possible things that might have happened when you plug the USB connector in. Either the module has been recognized an loaded automatically or you would need to load it manually (it depends on your udev configuration). The command to find out if the module is loaded already is this:
$ modprobe -l | grep pl2303
As it is obvious that we do work on rather low level of the OS I don’t think that reminding the necessity of being logged in as a root is really needed. If the returned result is empty then the module has not been loaded. In which case it is necessary to load it manually with the following command:
$ modprobe pl2303
and then verify
$ lsmod | grep pl2303
If the result is satisfactory and the module is loaded the next step is to verify that the proper device in the /dev directory has been created. This is a point where various tutorials will claim different things as this is one of the distribution-and-version-specific things. Anyway in the system I’ve described above the file is under /dev/ttyUSB0 Again this might and probably will be different on different systems. You can find what device has been created by the same means as you’ve used for finding out of the driver options – with dmesg command or in the /var/log/messages file
May 16 22:26:26 Hell kernel: [ 351.831964] usb 2-1.3: pl2303 converter now attached to ttyUSB0
Once you find out the what is the device created by udev you’ll need to change two things. If you want to use the console as unprivileged user you need to add this user to the group “dialout” the second and actually more important thing is to change the group ownership of the device file in /dev The reason behind this is that all hardware is by default owned by root and the group root unless specified otherwise. that is fairly good point as normal users don’t normally have the need to access the hardware directly except for few cases and this i exactly one of those.
So the final ownership is owner:root group:dialout
root@Hell:/dev# ls -lah ./tty0
crw-rw-rw- 1 root dialout 4, 0 Jun 11 21:07 ./ttyUSB0
The last step in connecting to the remote system. As in this instance the logic is the same as with dialed connection we need some small software to handle in my case I picked the “cu” software which behaves best amongst those I’ve tested. As the package is in the standard repository you can use the
$ apt-get install cu
or if you think that it might be already installed just try
$ dpkg -l cu
which will give you the following result
$ dpkg -l cu
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Description
ii cu 1.07-20 call up another system
So the last step is to use cu to connect to the device. This can be achieved by
cu -s 9600 -l /dev/ttyUSB0
Where -s parameter is obviously for speed in bauds and th -l parameter is for the line interface.
After this you should be able to communicate with the networking device. Hope this was helpful – I believe I will enhance this article but as t quick & dirty howto it should be all right.