Check Serial Port On Linux

Slsnif is a serial line sniffer software. It listens to the specified serial port and writes all data coming through it into either stdout (default) or a log file (if specified -- see option -l).

How To Check Serial Port On Windows Xp

This is part of a series of blog posts on the Windows Subsystem for Linux (WSL). In Windows Insider build # 16176 WSL now allows access to serial devices (COM ports). Optionally check your current serial settings before updating. Serial Programming Guide for POSIX Operating Systems 5th Edition Michael R. The Serial Programming Guide for POSIX Operating Systems will teach you how to successfully, efficiently, and portably program the serial ports on your UNIX® workstation or PC. Suppose we are reading data from a serial port and a socket. We want to check. My dell dimension 8400 has a serial port on the back. I want to use minicom to interface the serial port on this computer with Ubuntu installed. The output of dmesg| grep tty did not give me much useful information however. I could not find anything with the key word 'Serial'. Check Serial Port On Linux. 9/29/2016 0 Comments Single Port USB to RS-232, RS-422 and RS-485 Serial Adapters Features. Serial Port Wrapper. Step 1: Check your system's serial support. First, let's make sure that your operating system recognizes serial ports in your hardware. You should make a visual.

On this page

  1. Setting up a serial console

Setting up a serial console

This tutorial will show you how to set up a serial console on a Linux system, and connect to it via a null modem cable. This is quite useful if your Linux server is in a headless configuration (no keyboard or monitor), as it allows you to easily get a console on the system if there are any problems with it (especially network problems, when SSH is not available). In the end, the GRUB menu will appear over the serial link, as will the bootup messages (output when booting the system). I'm using Debian Etch on the server and Ubuntu Edgy on my client, although this should work on any Linux distribution.

First steps

One of the most important things we need to check that you do actually have a serial port on the server :). Take a look at the back of your server, and see if it has a 9-pin serial port. Most motherboards have either one or two serial ports. On the system, check to see that Linux is recognising the serial ports:

[email protected]:~# dmesg | grep tty
serial8250: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
00:08: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A

This shows that my system has one serial port, ttyS0 (remember this for later).

GRUB configuration

The next step is to edit the GRUB configuration, so it sends its messages to the serial console. One of the most important things is to set a password, otherwise anyone can connect a serial cable, edit the GRUB configuration line while the system is booting (via the 'e' key), and get root access. When a password is set, interactive menu editing will be disabled, unless the correct password is entered. To set the password, we first need to get the encrypted version of it.

Run grub, and use the 'md5crypt' command to encrypt the password:

grub> md5crypt
Password: ********
Encrypted: $1$AlfMq1$FxRolxW5XvSLAOksiC7MD1

Copy the encrypted version of the password (we need it for the next step), and then type quit to exit.

Now, we need to edit the GRUB configuration. Edit the /boot/grub/menu.lst file (by typing nano /boot/grub/menu.lst), and find this section:

Below that, add:

Test

Replace $1$AlfMq1$FxRolxW5XvSLAOksiC7MD1 with the encrypted form of your password. The second line tells GRUB to initialise the serial port at 38,400 bps (same speed as the standard console), 8 data bits, no parity, and 1 stop bit (basically, the standard settings). Note that the --unit=0 means that it will use the first serial port (ttyS0). If you're using the second serial port (ttyS1), change it to --unit=1. The last line tells GRUB to show its menu on both the serial line and the console (monitor).

Now, we also need to edit the kernel sections, so that they output messages to the serial console. At the end of every kernel line, add console=tty0 console=ttyS0,38400n8 (replace ttyS0 with the correct serial port). In my case, it ended up looking like:

Save and exit, by pressing CTRL+O (to 'output', or save the file), Enter (to accept the file name) and CTRL+X (to actually exit).

Allow logins over Serial Console

Now, the GRUB menu will appear over the serial connection, but we still aren't listening for logins over it (there's no 'getty' running on it yet). Edit the /etc/inittab file, and find this section:

Test serial port linux loopback

Below that (I don't like editing the default lines :P), add:

And that's all there is to it. Your server will now show the GRUB menu over the serial console, and also allow logons (once it has finished booting).

Let's test it!

Now that that's all done, we need to configure our client. I'm using GtkTerm on my laptop, although any terminal program should work (as long as it can use a serial port. On Windows, HyperTerminal should work). My laptop doesn't have a serial port, so I'm using a USB to Serial adapter I bought off eBay (it creates a ttyUSB0 device). Set your terminal program to these settings:

  • Port (Linux):ttyS0 or ttyS1 (if your system has a serial port), or ttyUSB0 (if you're using a USB to Serial converter).
  • Port (Windows): COM1 or COM2
  • Bits per second: 38400
  • Data bits: 8
  • Parity: None
  • Stop bits: 1
  • Flow control: None, although hardware (RTS/CTS) should work properly

Restart the server (probably from a SSH connection, or however you edited the GRUB config above), and then connect the null modem cable as it's starting (ie. at the BIOS screen). Press any key when prompted, and you'll get something like:

This means that GRUB is working fine :). Press enter, and it should boot, showing all messages in the terminal window. Once it boots, it will look something like:

Finally, log in, and check that it works fine:

Port

Linux Check If Port Is Open

Congratulations, everything is set up and working fine.

Hope you enjoyed this tutorial! :)

Daniel15 (Daniel Lo Nigro)
http://www.daniel15.com/
http://www.dansoftaustralia.net/