linux操作系统下cu命令介绍和使用案例

韵味老鸟 2024-09-16 16:28:42

linux 操作系统下cu命令介绍和使用案例

cu命令是Linux系统中用于与远程计算机进行串行通信的工具。它通常用于通过串行端口(如调制解调器或串行设备)连接到其他计算机

cu命令概述基本语法bashcu [options] [user@]hostname主要功能通过串行端口或网络与远程计算机建立连接。支持文件传输和终端仿真。可以用于调试串行设备或进行远程管理。常用选项-l, --line: 指定要使用的串行设备(如 /dev/ttyS0)。-s, --send: 发送文件到远程计算机。-r, --receive: 从远程计算机接收文件。-e, --escape: 设置转义字符,默认是~。-x, --no-echo: 禁用本地回显。-n, --noclobber: 不覆盖现有文件。

安装部署:

root@meng:~# which cu

root@meng:~# cu

Command 'cu' not found, but can be installed with:

apt install cu # version 1.07-27build3, or

apt install opencu # version 3-2

root@meng:~# apt install opencu

Reading package lists... Done

Building dependency tree... Done

Reading state information... Done

The following additional packages will be installed:

libevent-2.1-7

The following NEW packages will be installed:

libevent-2.1-7 opencu

0 upgraded, 2 newly installed, 0 to remove and 224 not upgraded.

Need to get 163 kB of archives.

After this operation, 442 kB of additional disk space will be used.

Do you want to continue? [Y/n] y

Get:1 http://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy/main amd64 libevent-2.1-7 amd64 2.1.12-stable-1build3 [148 kB]

Get:2 http://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy/universe amd64 opencu amd64 3-2 [14.6 kB]

Fetched 163 kB in 26s (6293 B/s)

Selecting previously unselected package libevent-2.1-7:amd64.

(Reading database ... 75197 files and directories currently installed.)

Preparing to unpack .../libevent-2.1-7_2.1.12-stable-1build3_amd64.deb ...

Unpacking libevent-2.1-7:amd64 (2.1.12-stable-1build3) ...

Selecting previously unselected package opencu.

Preparing to unpack .../archives/opencu_3-2_amd64.deb ...

Unpacking opencu (3-2) ...

Setting up libevent-2.1-7:amd64 (2.1.12-stable-1build3) ...

Setting up opencu (3-2) ...

Processing triggers for man-db (2.10.2-1) ...

Processing triggers for libc-bin (2.35-0ubuntu3.1) ...

Scanning processes...

Scanning linux images...

Running kernel seems to be up-to-date.

No services need to be restarted.

No containers need to be restarted.

No user sessions are running outdated binaries.

No VM guests are running outdated hypervisor (qemu) binaries on this host.

命令案例:由于虚拟机没有连接线,无法验证

root@meng:~# cu

cu: open("/dev/ttyUSB0"): No such file or directory

root@meng:~# ls /dev/tty

tty tty14 tty20 tty27 tty33 tty4 tty46 tty52 tty59 tty8 ttyS13 ttyS2 ttyS26 ttyS4

tty0 tty15 tty21 tty28 tty34 tty40 tty47 tty53 tty6 tty9 ttyS14 ttyS20 ttyS27 ttyS5

tty1 tty16 tty22 tty29 tty35 tty41 tty48 tty54 tty60 ttyS0 ttyS15 ttyS21 ttyS28 ttyS6

tty10 tty17 tty23 tty3 tty36 tty42 tty49 tty55 tty61 ttyS1 ttyS16 ttyS22 ttyS29 ttyS7

tty11 tty18 tty24 tty30 tty37 tty43 tty5 tty56 tty62 ttyS10 ttyS17 ttyS23 ttyS3 ttyS8

tty12 tty19 tty25 tty31 tty38 tty44 tty50 tty57 tty63 ttyS11 ttyS18 ttyS24 ttyS30 ttyS9

tty13 tty2 tty26 tty32 tty39 tty45 tty51 tty58 tty7 ttyS12 ttyS19 ttyS25 ttyS31 ttyprintk

root@meng:~# ls /dev/tty^C

root@meng:~# cu -l /dev/ttyS

ttyS0 ttyS10 ttyS12 ttyS14 ttyS16 ttyS18 ttyS2 ttyS21 ttyS23 ttyS25 ttyS27 ttyS29 ttyS30 ttyS4 ttyS6 ttyS8

ttyS1 ttyS11 ttyS13 ttyS15 ttyS17 ttyS19 ttyS20 ttyS22 ttyS24 ttyS26 ttyS28 ttyS3 ttyS31 ttyS5 ttyS7 ttyS9

root@meng:~# cu -l /dev/ttyS0

cu: /dev/ttyS0: Input/output error

root@meng:~# cu -l /dev/ttyS0 -s 9600

cu: /dev/ttyS0: Input/output error

root@meng:~# cu root@192.168.10.17

cu: open("/dev/ttyUSB0"): No such file or directory

root@meng:~#

0 阅读:5

韵味老鸟

简介:感谢大家的关注