為什麼我的終端機上無法使用"cd"這個指令呢? [論壇 - LinuxMint]


正在瀏覽:   1 名遊客


 到底部   前一個主題   下一個主題  [無發表權] 請登錄或者註冊



為什麼我的終端機上無法使用"cd"這個指令呢?
會員三級
註冊日期:
2008/12/11 21:09
所屬群組:
已註冊使用者
等級: 10
HP : 0 / 236
MP : 43 / 10198
EXP: 44
離線
如題。
因為想要在我的Linux Mint上安裝FreeFileSync
到官方網站去下載來的檔案是tar.gz
網上查到的資料是要用指令來安裝
可是…第一個步驟就是用cd指令切換到檔案所在的資料夾中…
依教學打開終端機,輸入CD的相關指令
終端機卻回應"無此指令"

請問各位先輩,該如何才能正常使用呢?謝謝。

2016/12/21 13:21
應用擴展 工具箱
回覆: 為什麼我的終端機上無法使用"cd"這個指令呢?
會員五級
註冊日期:
2012/4/22 10:50
所屬群組:
已註冊使用者
等級: 37
HP : 0 / 905
MP : 679 / 30217
EXP: 23
離線
seven777 寫到:
如題。
因為想要在我的Linux Mint上安裝FreeFileSync
到官方網站去下載來的檔案是tar.gz
網上查到的資料是要用指令來安裝
可是…第一個步驟就是用cd指令切換到檔案所在的資料夾中…
依教學打開終端機,輸入CD的相關指令
終端機卻回應"無此指令"

請問各位先輩,該如何才能正常使用呢?謝謝。


CD 應該要使用小寫 cd,

也有可能是其他未知因素導致您發生的情況,可能需要釐清。

================================================================================

以下我測試的環境是「XUbuntu 16.04 64位元」,

一開始測試使用的「Shell」是「bash

執行


$ CD



顯示


CD: command not found




執行


$ cd /tmp



然後再執行


$ pwd



顯示


/tmp



表示可以切換到「/tmp」


執行


$ cd ~



或是執行


$ cd $HOME



然後再執行


$ pwd



顯示


/home/user



表示可以切換到家目錄

================================================================================

執行



$ which cd



沒有顯示,直接跳下一個提示字元。

關於「which」的用法,可以執行「$ man which」。

================================================================================


執行


$ whereis cd



顯示


cd:



關於「whereis」的用法,可以執行「$ man whereis」。

================================================================================

執行


$ type cd



顯示


cd is a shell builtin




表示「cd」這個指令,是「bash」內建的。

所以可以執行下面指令,來查詢「cd」的使用方法


$ help cd



顯示


cd: cd [-L|[-P [-e]] [-@]] [dir]
Change the shell working directory.

Change the current directory to DIR. The default DIR is the value of the
HOME shell variable.

The variable CDPATH defines the search path for the directory containing
DIR. Alternative directory names in CDPATH are separated by a colon (:).
A null directory name is the same as the current directory. If DIR begins
with a slash (/), then CDPATH is not used.

If the directory is not found, and the shell option `cdable_vars' is set,
the word is assumed to be a variable name. If that variable has a value,
its value is used for DIR.

Options:
-L force symbolic links to be followed: resolve symbolic links in
DIR after processing instances of `..'
-P use the physical directory structure without following symbolic
links: resolve symbolic links in DIR before processing instances
of `..'
-e if the -P option is supplied, and the current working directory
cannot be determined successfully, exit with a non-zero status
-@ on systems that support it, present a file with extended attributes
as a directory containing the file attributes

The default is to follow symbolic links, as if `-L' were specified.
`..' is processed by removing the immediately previous pathname component
back to a slash or the beginning of DIR.

Exit Status:
Returns 0 if the directory is changed, and if $PWD is set successfully when
-P is used; non-zero otherwise.




可以執行「$ type type」顯示「type is a shell builtin」。
可以執行「$ type help」顯示「help is a shell builtin」。
也可以執行「$ type type help」會顯示兩行結果。
關於「type」的用法,可以執行「$ help type」。
關於「help」的用法,可以執行「$ help help」。
也可以執行「$ man bash-builtins」。

================================================================================

或是執行下面指令,閱讀cd的使用說明 (需要安裝「manpages-posix」這個套件)

$ man 1posix cd


執行


$ whatis cd



顯示


cd (1posix) - change the working directory




關於「whatis」的用法,可以執行「$ man whatis」。

================================================================================

若「Shell」是使用「zsh」,則是執行下面指令,查詢cd使用說明


$ run-help cd



或是執行


$ less /usr/share/zsh/help/cd




「zsh」一樣可以執行「$ type cd」,會顯示「cd is a shell builtin」。

================================================================================


若「Shell」是使用「fish」,則是執行下面指令,查詢cd使用說明


$ cd -h



或是執行


$ man /usr/share/fish/man/man1/cd.1



也可以先執行


$ set BROWSER w3m



然後執行


$ help cd



等同於執行


$ w3m file:///usr/share/doc/fish/commands.html#cd



或是等同於執行


$ w3m /usr/share/doc/fish/commands.html#cd



除了「w3m」,還可以改成其他的瀏覽器,可以參考這篇「回覆」列的。


「fish」一樣可以執行「$ type cd」,會顯示


cd is a function with definition
...略...



================================================================================

一些下指令的討論案例和相關連結,紀錄在這個「索引

以上提供參考,報告完畢


2016/12/21 13:35
應用擴展 工具箱
回覆: 為什麼我的終端機上無法使用"cd"這個指令呢?
會員三級
註冊日期:
2008/12/11 21:09
所屬群組:
已註冊使用者
等級: 10
HP : 0 / 236
MP : 43 / 10198
EXP: 44
離線
samwhelp 寫到:
CD 應該要使用小寫 cd,

也有可能是其他未知因素導致您發生的情況,可能需要釐清。

================================================================================

以下我測試的環境是「XUbuntu 16.04 64位元」,

一開始測試使用的「Shell」是「bash

執行


$ CD



中間略

一些下指令的討論案例和相關連結,紀錄在這個「索引

以上提供參考,報告完畢



大夥新年快樂
年底的事務真的多到爆炸
以至於發文後就一直沒有機會回來看回覆
謝謝"samwhelp"大的指導
但內容真的太豐富了
也許需要一些時間來好好的消化一下了
先謝謝samwhelp大,若還有問題,會再上來請教大家的,謝謝各位~

2017/1/1 21:39
應用擴展 工具箱


 [無發表權] 請登錄或者註冊


可以查看帖子.
不可發帖.
不可回覆.
不可編輯自己的帖子.
不可刪除自己的帖子.
不可發起投票調查.
不可在投票調查中投票.
不可上傳附件.
不可不經審核直接發帖.