小编ALZ*_*ALZ的帖子

`env <command>` 在做什么?

命令env ls -al在做什么?

我有一个 Linux 测试,有一个问题:“如何直接运行命令,而不是它的别名?”
我知道存在一些解决方案,例如在命令前加上一些特殊符号,但我忘记了。现在我知道了\。(从这篇文章中阅读)。

但我也记得我在某处读到过,为了摆脱别名,我们可以在命令前加上env. 我做到了,它似乎有效,但我的回答被认为是错误的。我读infomanenv,但并没有理解太多。

envenv <command>没有任何论据的情况下,究竟在做什么env

command-line shell env command

45
推荐指数
2
解决办法
5万
查看次数

完成后台作业状态的“退出 2”是什么?

我有一个练习将一些数据(来自某些目录的 *conf)放入一个文件中,并且需要在后台执行此操作。我做到了,我想知道输出消息的含义是什么:

[A@localhost tests]$ ls -ld /etc/*conf /usr/*conf > test1_6_conf.txt 2>&1 &
Run Code Online (Sandbox Code Playgroud)

输入上升到这一行:

[1] 2533
Run Code Online (Sandbox Code Playgroud)

这是什么意思?在其他 Enter 之后,会出现另一条消息

[A@localhost tests]$
[1]+  Exit 2                  ls --color=auto -ld /etc/*conf /usr/*conf > test1_6_conf.txt 2>&1
Run Code Online (Sandbox Code Playgroud)

这是什么意思?什么是“出口2”?

输入检查结果 - 似乎一切正常。

[A@localhost tests]$
[A@localhost tests]$ ls -l test1_6_conf.txt
-rw-rw-r--. 1 A A 2641 Nov 22 14:19 test1_6_conf.txt
[A@localhost tests]$ 
Run Code Online (Sandbox Code Playgroud)

我正在使用 CentOS 6.4,Gnome 终端模拟器。

command-line bash job-control exit background-process

12
推荐指数
1
解决办法
8万
查看次数

为什么两个几乎相同的 grep 命令返回不同的输出:w/o 和 with filename

我有 2 个几乎相同的greps:

[Alex@localhost tmp]$ grep /bin/bash /etc/passwd 
root:x:0:0:root:/root:/bin/bash
AlexL:x:500:500::/home/AlexL:/bin/bash
user1:x:501:501:user1 12345:/home/user1:/bin/bash
Run Code Online (Sandbox Code Playgroud)

对比

[AlexL@localhost tmp]$ grep /bin/*sh /etc/passwd    
/etc/passwd:root:x:0:0:root:/root:/bin/bash
/etc/passwd:AlexL:x:500:500::/home/AlexL:/bin/bash
/etc/passwd:user1:x:501:501:user1 12345:/home/user1:/bin/bash
Run Code Online (Sandbox Code Playgroud)

在第二个查询中,我得到了每一行匹配的文件名前缀。我知道要获得相同的结果,我需要将-h选项放在 2nd 中grep,但我的问题是:

为什么他们返回不同的输出? 我应该添加更多东西吗?

该任务包括从/etc/passwd真实用户(无守护进程和系统用户)中检索。

使用:CentOS 6.4, grep gnu 2.6.3 版本

shell grep regular-expression glob

6
推荐指数
1
解决办法
615
查看次数

为什么`nproc` 显示少于`nproc --all`?

这是nprocvsnproc --all和互联网上其他命令的输出。我仍然不明白为什么。它是一个带有 CentOS 6.5 的 QEMU\KVM VM,在其他 CentOS 6.5 上运行。

以下是一些其他命令的输出:

[root@h1-nms ~]# nproc
1
[root@h1-nms ~]# nproc --all
3
[root@h1-nms ~]# lscpu
Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                3
On-line CPU(s) list:   0-2
Thread(s) per core:    1
Core(s) per socket:    1
Socket(s):             3
NUMA node(s):          1
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 13
Stepping:              3
CPU MHz:               2194.710
BogoMIPS:              4389.42
Hypervisor vendor:     KVM
Virtualization type:   full
L1d cache:             32K …
Run Code Online (Sandbox Code Playgroud)

cpu centos qemu

6
推荐指数
1
解决办法
2881
查看次数

列出通过 SSH 连接的用户

我检查了这个答案和这个选项- 这很好,但它需要sudo权利。我需要任何用户都可以执行此命令,因此我使用下一个命令

ps -ef | grep sshd: | grep -v grep
Run Code Online (Sandbox Code Playgroud)

并得到以下结果:

[owner@localhost ~]$ ps -ef | grep sshd: | grep -v grep
root      3175  2217  0 15:09 ?        00:00:00 sshd: [accepted] //Here just oppened putyy from windows pc
sshd      3177  3175  0 15:09 ?        00:00:00 sshd: [net]      //same as above
root      8062  2217  0 12:34 ?        00:00:00 sshd: root@pts/8 
root     24241  2217  0 13:37 ?        00:00:00 sshd: root@pts/10
root     31515  2217  0 14:38 …
Run Code Online (Sandbox Code Playgroud)

users ssh ps

3
推荐指数
1
解决办法
5597
查看次数