ps -aux | grep daemon2
时间: 2023-06-24 21:09:16 浏览: 65
这是一个 Linux 命令,用于查看所有正在运行的进程,并通过过滤器 grep 来查找包含 "daemon2" 字符串的进程。
具体来说,ps 命令用于显示当前正在运行的进程状态,-aux 参数表示显示所有用户的进程详细信息,包括 PID、进程状态、CPU 占用率、内存占用率等。而 "|" 符号则表示将 ps 命令的输出作为 grep 命令的输入,grep 命令用于过滤出包含 "daemon2" 字符串的进程。
相关问题
ps aux 查看用户或组
`ps aux` 命令可以查看当前系统中正在运行的所有进程的详细信息,包括进程的名字、进程 ID、运行时间、所属用户、所属组等等。
如果您想要查看某个进程所属的用户或组,可以使用 `ps aux` 命令结合 `grep` 命令来过滤出该进程,然后查看该进程的详细信息。
例如,如果您想要查看 `nginx` 进程所属的用户或组,可以使用以下命令:
```
ps aux | grep nginx
```
该命令将输出所有包含 `nginx` 关键字的进程信息,包括进程的名字、进程 ID、运行时间、所属用户、所属组等等。您可以查看该进程的所属用户和组信息,例如:
```
root 12345 0.0 0.1 12345 6789 ? Ss Aug14 0:00 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
nginx 12346 0.0 0.2 23456 7890 ? S Aug14 0:00 nginx: worker process
nginx 12347 0.0 0.2 23456 7890 ? S Aug14 0:00 nginx: worker process
```
在上面的输出中,第一列是进程的所属用户(root、nginx),第二列是进程的进程 ID(12345、12346、12347)。
将此Shell脚本中sshd服务改为xrdp服务并生成新的脚本
好的,你可以尝试使用以下脚本,它实现的功能与原脚本相同,只不过将 sshd 服务改为 xrdp 服务:
```bash
#!/bin/bash
# 检查 xrdp 服务是否已经启动
pn=$(ps aux | grep -v grep | grep xrdp-sesman | wc -l)
# 如果 /var/run/xrdp 目录不存在,则创建该目录并设置权限
[ -d /var/run/xrdp ] || mkdir -m 0755 /var/run/xrdp
# 如果 xrdp 服务已经启动,则杀掉当前进程
if [ "${pn}" != "0" ]; then
pid=$(ps aux | grep -v grep | grep xrdp-sesman | awk '{print $2}')
kill $pid
fi
# 启动 xrdp 服务
/usr/sbin/xrdp-sesman --nodaemon
# 注意:这里的脚本只启动 xrdp-sesman 服务,如果还需要启动 xrdp 服务,请修改相应的命令。
相关推荐
![.zip](https://img-home.csdnimg.cn/images/20210720083646.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)