GNU/Linux >> Belajar Linux >  >> Linux

Tidak ada halaman manual untuk perintah cd

cd adalah perintah shell bawaan.

$ type cd
cd is a shell builtin

Anda dapat membuka halaman bantuan untuk cd di Bash dengan

$ help cd

Yang saat ini ditampilkan (Ubuntu 16.04):

$ help cd
cd: cd [-L|[-P [-e]] [[email protected]]] [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
        [email protected]  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.

Sayangnya, itu tidak menjawab pertanyaan Anda. Ada adalah dokumentasi yang melakukannya, bagaimanapun.

Anda dapat melakukannya dengan

$ man builtins

Ini membuka banyak halaman bantuan dengan less , penampil default saya. Saya dapat menemukan bantuan untuk cd dengan menekan tombol / , lalu ketikkan cd , lalu Enter , dan menekan n dua kali membawa saya ke contoh ketiga dari substring, dan bantuan, yang berbunyi:

   cd [-L|[-P [-e]] [[email protected]]] [dir]
          Change  the  current  directory to dir.  if dir is not supplied,
          the value of the HOME shell variable is the default.  Any  addi‐
          tional arguments following dir are ignored.  The variable CDPATH
          defines the search path for the directory containing  dir:  each
          directory  name  in  CDPATH  is  searched  for dir.  Alternative
          directory names in CDPATH are separated by a colon (:).  A  null
          directory  name  in CDPATH is the same as the current directory,
          i.e., ``.''.  If dir begins with a slash (/), then CDPATH is not
          used.  The  -P  option  causes  cd to use the physical directory
          structure by resolving symbolic links while traversing  dir  and
          before processing instances of .. in dir (see also the -P option
          to the set builtin command); the -L option forces symbolic links
          to  be followed by resolving the link after processing instances
          of .. in dir.  If .. appears in dir, it is processed by removing
          the  immediately previous pathname component from dir, back to a
          slash or the beginning of dir.  If the  -e  option  is  supplied
          with  -P,  and  the current working directory cannot be success‐
          fully determined after a successful directory  change,  cd  will
          return  an unsuccessful status.  On systems that support it, the
          [email protected] option presents the extended  attributes  associated  with  a
          file  as  a directory.  An argument of - is converted to $OLDPWD
          before the directory change is attempted.  If a non-empty direc‐
          tory  name  from  CDPATH is used, or if - is the first argument,
          and the directory change is successful, the absolute pathname of
          the  new  working  directory  is written to the standard output.
          The return value is  true  if  the  directory  was  successfully
          changed; false otherwise.

Cari - argumen tentang baris ketujuh dari akhir:

Argumen - dikonversi menjadi $OLDPWD sebelum perubahan direktori dicoba.

Perhatikan bahwa tidak ada -- argumen - yang tampaknya berarti bahwa itu benar-benar mengabaikannya.


cd bukan perintah, itu dibangun ke dalam shell Anda. Ini diperlukan karena direktori kerja Anda saat ini dikendalikan oleh PWD variabel lingkungan dinamai pwd atau perintah "cetak direktori kerja".

Variabel lingkungan dari proses induk tidak dapat diubah oleh proses anak. Jadi jika shell Anda menjalankan /bin/cd yang mengubah PWD itu hanya akan mempengaruhi /bin/cd dan apapun yang dijalankannya. Itu tidak akan mengubah PWD shell .

Beberapa sistem, seperti OS X dan CentOS, memetakan cd halaman manual ke builtin yang mencantumkan semua shell bawaan dan memberi tahu Anda bahwa Anda harus melihat halaman manual shell Anda.

Anda dapat memeriksa shell apa yang Anda miliki dengan echo $SHELL , mungkin bash .


Linux
  1. Bagaimana Cara Menambahkan Entri Halaman Man Untuk Power Tools Sendiri?

  2. Garis miring dan perintah rsync

  3. Buka halaman manual dan cari string dalam satu perintah

  1. Panduan terminal Linux untuk pemula

  2. 8 tips untuk baris perintah Linux

  3. Di mana kode sumber perintah man terbaru untuk linux?

  1. Tutorial perintah cd Linux untuk pemula (8 Contoh)

  2. Nala:Tampilan Depan yang Lebih Cantik untuk Perintah APT

  3. Perlu Untuk `builtin` Builtin?