Linux uux命令教程:在远程系统上执行命令和在本地系统上使用远程文件执行命令(附案例详解和注意事项)

Linux uux命令介绍

uux命令(全称:Unix to Unix execution),主要用于在远程系统上执行命令,或者在本地系统上使用远程系统的文件执行命令。这个命令不会立即执行,而是将请求排队,直到uucico守护进程调用系统并执行它。

Linux uux命令适用的Linux版本

uux命令在大多数Linux发行版中都可以使用,包括但不限于Ubuntu、Debian、Fedora、CentOS等。如果某些Linux发行版中没有预装此命令,可以通过包管理器(如apt、yum或dnf)进行安装。例如,在CentOS 7中,可以使用yum install uucp命令进行安装,而在CentOS 8中,则需要使用dnf install uucp命令。

[linux@bashcommandnotfound.cn ~]$ sudo yum update && sudo yum install uucp  # CentOS 7
[linux@bashcommandnotfound.cn ~]$ sudo dnf update && sudo dnf install uucp  # CentOS 8 、Fedora
[linux@bashcommandnotfound.cn ~]$ sudo apt update && sudo apt install htop # Debian/Ubuntu

Linux uux命令的基本语法

uux命令的基本语法如下:

uux [options] command

Linux uux命令的常用选项或参数说明

以下是uux命令的一些常用选项:

选项说明
--p--stdin读取标准输入,并将其用作要执行的命令的标准输入
-c--nocopy不将本地文件复制到spool目录,这是默认设置

Linux uux命令实例详解

下面是一些uux命令的使用实例。

实例1:在远程系统上执行命令

[linux@bashcommandnotfound.cn ~]$ uux "remote_system!command"

这个命令会在名为remote_system的远程系统上执行command命令。

实例2:在本地系统上使用远程文件执行命令

[linux@bashcommandnotfound.cn ~]$ uux "command remote_system1!file1 remote_system2!file2"

这个命令会在本地系统上执行command命令,command命令会使用来自remote_system1file1文件和来自remote_system2file2文件。

实例3:在远程系统上执行带参数的命令

[linux@bashcommandnotfound.cn ~]$ uux "remote_system!command argument"

这个命令会在名为remote_system的远程系统上执行带有argument参数的command命令。

实例4:在远程系统上执行多个命令

[linux@bashcommandnotfound.cn ~]$ uux "remote_system!(command1; command2)"

这个命令会在名为remote_system的远程系统上依次执行command1command2命令。

实例5:在远程系统上执行带有输入重定向的命令

[linux@bashcommandnotfound.cn ~]$ uux "remote_system!command < file"

这个命令会在名为remote_system的远程系统上执行command命令,并将file文件作为command命令的输入。

实例6:在远程系统上执行带有输出重定向的命令

[linux@bashcommandnotfound.cn ~]$ uux "remote_system!command > file"

这个命令会在名为remote_system的远程系统上执行command命令,并将command命令的输出重定向到file文件。

实例7:在远程系统上执行带有管道的命令

[linux@bashcommandnotfound.cn ~]$ uux "remote_system!command1 | command2"

这个命令会在名为remote_system的远程系统上执行command1命令,并将command1命令的输出作为command2命令的输入。

实例8:在远程系统上执行带有环境变量的命令

[linux@bashcommandnotfound.cn ~]$ uux "remote_system!VAR=value command"

这个命令会在名为remote_system的远程系统上设置环境变量VAR的值为value,然后执行command命令。

Linux uux命令的注意事项

  • uux命令不会立即执行,而是将请求排队,直到uucico守护进程调用系统并执行它。
  • 如果在执行uux命令时遇到bash: uux: command not found错误,说明您的系统中可能没有安装uux命令,您可以按照上面的指示进行安装。

Linux uux相关命令

更多详细内容可以参考:
linux入门学习教程 - Linux入门自学网
Linux uux命令教程:如何在不同Unix系统之间执行命令和传输文件

  • 10
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
UUCP(Unix-to-Unix Copy)是一种在Unix系统之间传输文件和数据的协议。它使用通用的拨号连接或TCP/IP网络连接,可以在不同的Unix系统之间传输文件、电子邮件和其他数据。 以下是UUCP的一个实例: 假设有两台Unix服务器A和B,我们想要从A服务器将文件传输到B服务器。 1. 首先,在A服务器上安装UUCP,并在B服务器上安装UUCP。 2. 在A服务器上创建一个名为“myfile”的文件,并将其放在本地文件系统的“/home/user”目录下。 3. 在A服务器上编辑UUCP配置文件“/etc/uucp/sys”文件,添加以下行: ``` B Any LoginName MyPassword ``` 其中,B是B服务器的名称,LoginName是您在B服务器上的登录用户名,MyPassword是您在B服务器上的登录密码。 4. 在B服务器上编辑UUCP配置文件“/etc/uucp/sys”文件,添加以下行: ``` A Any LoginName MyPassword ``` 其中,A是A服务器的名称,LoginName是您在A服务器上的登录用户名,MyPassword是您在A服务器上的登录密码。 5. 在A服务器上运行以下命令: ``` uucp /home/user/myfile B:/home/user/myfile ``` 这将把本地文件“/home/user/myfile”传输到B服务器的“/home/user/myfile”目录下。 uux是UUCP的另一个工具,它允许在远程Unix系统执行命令。以下是uux的一个实例: 假设我们想在远程Unix系统B上执行命令“ls -l”并将输出发送回本地Unix系统A。 1. 在A服务器上编辑UUCP配置文件“/etc/uucp/sys”文件,添加以下行: ``` B Any LoginName MyPassword ``` 2. 在B服务器上编辑UUCP配置文件“/etc/uucp/sys”文件,添加以下行: ``` A Any LoginName MyPassword ``` 3. 在A服务器上运行以下命令: ``` uux B ls -l > output.txt ``` 这将在B服务器上执行命令“ls -l”,并将输出发送回A服务器的“output.txt”文件中。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值