2014/12/11

Linux 下使用終端機連接 switch (minicom)

RS232 是很多資訊設備仍保留的連接界面,最常用在網路設備上的  console 界面登入。
minicom 是一個 Linux 下可以以終端機模式登入的程式,和以前 dos 時代的鐵力士很相


# 安裝 minicom
mtchang@debian:~$ sudo apt-get install minicom

# 我用的是 usb to rsr232 界面(現在 rs232 port 越來越少見了),藉由 messages 檔案觀看他自動賦予那個 device 編號。這裡抓到的是 ttyUSB0 --> /dev/ttyUSB0
mtchang@debian:~$ sudo tail /var/log/messages -f
Dec 11 09:54:34 debian kernel: [ 3454.792199] usb 5-1: USB disconnect, device number 2
Dec 11 10:32:35 debian kernel: [ 5735.764149] usb 4-1: new full-speed USB device number 4 using uhci_hcd
Dec 11 10:32:35 debian kernel: [ 5735.980153] usb 4-1: New USB device found, idVendor=5372, idProduct=2303
Dec 11 10:32:35 debian kernel: [ 5735.980162] usb 4-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
Dec 11 10:32:35 debian kernel: [ 5735.980170] usb 4-1: Product: USB-Serial Controller
Dec 11 10:32:35 debian kernel: [ 5735.980175] usb 4-1: Manufacturer: Prolific Technology Inc.
Dec 11 10:32:35 debian kernel: [ 5735.982272] pl2303 4-1:1.0: pl2303 converter detected
Dec 11 10:32:35 debian kernel: [ 5735.994354] usb 4-1: pl2303 converter now attached to ttyUSB0
Dec 11 10:32:35 debian mtp-probe: checking bus 4, device 4: "/sys/devices/pci0000:00/0000:00:1a.1/usb4/4-1"
Dec 11 10:32:35 debian mtp-probe: bus: 4, device: 4 was not an MTP device

mtchang@debian:~$ minicom --help
Usage: minicom [OPTION]... [configuration]
A terminal program for Linux and other unix-like systems.

  -b, --baudrate         : set baudrate (ignore the value from config)
  -D, --device           : set device name (ignore the value from config)
  -s, --setup            : enter setup mode
  -o, --noinit           : do not initialize modem & lockfiles at startup
  -m, --metakey          : use meta or alt key for commands
  -M, --metakey8         : use 8bit meta key for commands
  -l, --ansi             : literal; assume screen uses non IBM-PC character set
  -L, --iso              : don't assume screen uses ISO8859
  -w, --wrap             : Linewrap on
  -z, --statline         : try to use terminal's status line
  -7, --7bit             : force 7bit mode
  -8, --8bit             : force 8bit mode
  -c, --color=on/off     : ANSI style color usage on or off
  -a, --attrib=on/off    : use reverse or highlight attributes on or off
  -t, --term=TERM        : override TERM environment variable
  -S, --script=SCRIPT    : run SCRIPT at startup
  -d, --dial=ENTRY       : dial ENTRY from the dialing directory
  -p, --ptty=TTYP        : connect to pseudo terminal
  -C, --capturefile=FILE : start capturing to FILE
  -T, --disabletime      : disable display of online time
  -v, --version          : output version information and exit
  configuration          : configuration file to use

These options can also be specified in the MINICOM environment variable.
This variable is currently unset.
The configuration directory for the access file and the configurations
is compiled to /etc/minicom.

Report bugs to <minicom-devel@lists.alioth.debian.org>.


# 第一次先設定一下連接資訊,畫面如下:
mtchang@debian:~$ sudo minicom -s



# 觀看 default 設定檔
mtchang@debian:~$ cat /etc/minicom/minirc.dfl
# Machine-generated file - use "minicom -s" to change parameters.
pu port             /dev/ttyUSB0
pu baudrate         9600
pu mautobaud        Yes
pu rtscts           No


# 登入系統,以 root 權限啟動 minicom 就可以登入了。
mtchang@debian:~$ sudo minicom