# rexec

运程执行Linux系统下命令

## 补充说明

**rexec命令** 用于在指定的远程Linux系统主机上执行命令，向远程rexec服务器发出执行命令的请求。

rexec命令通过检查`$HOME/.netrc`文件（包含远程主机上使用的用户名和密码）来提供自动登录的功能。如果没有发现此类项或系统在安全方式下操作（参阅 securetcpip 命令），rexec命令提示输入一个远程主机的有效用户名和密码。这两种情况下，rexec均导致远程系统上的rexecd使用缺省的compat用户登录认证方法。rexecd不会为了备用的认证方法去查找`/etc/security/user`文件。也可以指定`-n`标志到rexec命令行上来重设自动登录功能。

### 语法

```
rexec(选项)(参数)
```

### 选项

```
-a：表示远程命令的标准错误与标准输出相同，不支持发送任意信号到远程进程；
-l<用户名>：指定连接远程rexec服务器的用户名；
-p<密码>：指定连接远程rexec服务器的密码；
-n：明确地提示输入用户名和密码。
```

### 参数

* 远程主机：指定远程主机（ip地址或主机名）；
* 命令：指定需要在远程主机上执行的命令。

### 实例

要在一个远程主机上执行date命令，输入：

```
rexec host1 date
```

date命令的输出现在显示在本地系统上。本示例中，在本地主机上的`$HOME/.netrc`文件包含远程主机上有效的用户名和密码。如果没有远程主机的`$HOME/.netrc`文件中的有效项，将提示输入登录标识和密码。输入所要求的登录信息后，date命令的输出显示在本地系统上。

要重设自动登录功能并执行远程主机上的date命令，输入：

```
rexec -nhost1 date
```

出现提示时输入用户名和密码，date命令的输出现在显示在本地系统上。

列出远程主机上另一个用户的目录，输入：

```
rexec host1 ls -l /home/karen
```

在远程主机host1上的karen 用户的目录列表显示在本地系统上。

如果没有远程主机的`$HOME/.netrc`文件中的有效项，将提示您输入登录标识和密码。输入要求的登录信息后，在远程主机host1上的karen用户的目录列表显示在本地系统上。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://hezhiqiang.gitbook.io/linux/ming-ling/rexec.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
