
在Windows中,當我執行「tasklist」時,命令提示字元會傳回進程列表,我以為這是內建函數,但它只是System32目錄中的可執行檔。現在我想問linux中的「ps」指令是否也是可執行檔或Bash終端機本身的內建指令。
另一個問題:SSH 只是一個 Bash 終端機嗎?
答案1
列出所有內建指令:
compgen -b
要獲取有關單一命令的信息,可以使用type
command.例如:
type -a cd
cd is a shell builtin
或(檢查一下):
compgen -b | grep cd
cd
範例2:
compgen -b | grep ssh
不回傳任何內容,ssh 是外部命令。
更多資訊 :
- Bash(Unix shell)
man bash
從終端機輸入(詳細文件)。
答案2
我來回答第一部分。首先,一個內建的 shell:
$ help command
command: command [-pVv] command [arg ...]
Execute a simple command or display information about commands.
Runs COMMAND with ARGS suppressing shell function lookup, or display
information about the specified COMMANDs. Can be used to invoke commands
on disk when a function with the same name exists.
Options:
-p use a default value for PATH that is guaranteed to find all of
the standard utilities
-v print a description of COMMAND similar to the `type' builtin
-V print a more verbose description of each COMMAND
Exit Status:
Returns exit status of COMMAND, or failure if COMMAND is not found.
接下來,使用command
內建函數來檢查ps
.
$ command -V ps
ps is hashed (/bin/ps)
因此,ps
它是它自己的二進位檔案。
答案3
嗯,ps
是一個獨立的二進位。嘗試which cmd
或whereis cmd
找到有關任何“cmd”的資訊。您也可以找到適用於 Windows 的此類 unix/linux 命令的 .exe 連接埠。
SSH 在您和遠端電腦之間開啟基於文字的通訊通道(虛擬終端)。 'bash' 是最常用的 shell 之一,但還有其他 shell,例如tcsh
、csh
、ksh
等。