close
第五章 Working With Commands
1.  type→Indicate how a command name is interpreted
    辨識是什麼樣的命令
    範例:mate@404040456debian:~$ type --help
          bash: type: --:無效選項
          type: usage: type [-afptP] name [name ...]
          mate@404040456debian:~$ mkdir --help
          Usage: mkdir [OPTION]... DIRECTORY...
          Create the DIRECTORY(ies), if they do not already exist.
 
        Mandatory arguments to long options are mandatory for short options too.
        -m, --mode=MODE   set file mode (as in chmod), not a=rwx - umask
        -p, --parents     no error if existing, make parent directories as needed
        -v, --verbose     print a message for each created directory
        -Z               set SELinux security context of each created directory
                         to the default type
        --context[=CTX]  like -Z, or if CTX is specified then set the SELinux
                         or SMACK security context to CTX
        --help     顯示此求助說明並離開
        --version  顯示版本資訊並離開
 
2.  which→Display which executable program will be executed
    顯示會執行哪個可執行程式
 
3.  help→Get help for shell builtins
    得到shell 內部命令的幫助文檔
    範例:mate@404040456debian:~$ help type
          type: type [-afptP] name [name ...]
          Display information about command type.
    
          For each NAME, indicate how it would be interpreted if used as a
          command name.
    
          Options:
          -a display all locations containing an executable named NAME;
     Includes aliases, builtins, and functions, if and only if
     the `-p' option is not also used
          -f suppress shell function lookup
          -P force a PATH search for each NAME, even if it is an alias,
     builtin, or function, and returns the name of the disk file
     that would be executed
          -p returns either the name of the disk file that would be executed,
     or nothing if `type -t NAME' would not return `file'.
          -t output a single word which is one of `alias', `keyword',
     `function', `builtin', `file' or `', if NAME is an alias, shell
     reserved word, shell function, shell builtin, disk file, or not
     found, respectively
    
          Arguments:
           NAME Command name to be interpreted.
    
          Exit Status:
          Returns success if all of the NAMEs are found; fails if any are not found.
 
4.  man→Display a command's manual page
    顯示命令手冊頁
    範例:mate@404040456debian:~$ man ls
          LS(1)                              User Commands                                    
          LS(1)
 
          NAME
               ls - list directory contents
 
          SYNOPSIS
                  ls [OPTION]... [FILE]...
 
          DESCRIPTION
        List  information about the FILEs (the current directory by default).  Sort
        entries alphabetically if none of -cftuvSUX nor --sort is specified.
 
        Mandatory arguments to long options are mandatory for short options too.
 
        -a, --all
                do not ignore entries starting with .
 
         -A, --almost-all
                do not list implied . and ..
 
5.  apropos→Display a list of appropriate commands
    顯示一適合的命令清單
    範例:mate@404040456debian:~$ apropos ls
          aconnect (1)         - ALSA sequencer connection manager
          add-shell (8)        - add shells to the list of valid login shells
          alsactl (1)          - advanced controls for ALSA soundcard driver
 
6.  whatis→Display a very brief description of a command
    顯示一個命令的簡潔描述
 
7.  info→Display a command's info entry
    顯示命令info
 
8.  alias→Create an alias for a command
    創造命令的別名
 
 
一、Shall指令裡命令有哪些(四種)?
1. An executable program.
   一個可執行程式,就像我們所看到的位於目錄/usr/bin中的檔案一樣。
   屬於這一類的程式,可以編譯成二進位檔案,也可以是由指令碼語言寫成的程式。
2. A command built into the shell itself.
   一個內建於shell自身的命令,bash支持若干種命令。
   內部命令叫做shell builtins。
3. A shell function.
   一個shell函數
4. An alias.
   一個命令別名。可以定義屬於自己的命令,建立在其它命令之上。
 
二、上課目前學過的指令:
mate@404040456debian:~$ type date 可執行程式
date is /bin/date
mate@404040456debian:~$ type cal 可執行程式
cal is /usr/bin/cal
mate@404040456debian:~$ type df 可執行程式
df is /bin/df
mate@404040456debian:~$ type free 可執行程式
free is /usr/bin/free
mate@404040456debian:~$ type exit  shell 本身的命令
exit is a shell builtin
mate@404040456debian:~$ type pwd  shell 本身的命令
pwd is a shell builtin
mate@404040456debian:~$ type cd  shell 本身的命令
cd is a shell builtin
mate@404040456debian:~$ type ls  命名別名
ls is aliased to `ls --color=auto'
mate@404040456debian:~$ type file  可執行程式
file is /usr/bin/file
mate@404040456debian:~$ type less  可執行程式
less is /usr/bin/less
mate@404040456debian:~$ type cp  可執行程式
cp is /bin/cp
mate@404040456debian:~$ type mv  可執行程式
mv is /bin/mv
mate@404040456debian:~$ type mkdir  可執行程式
mkdir is /bin/mkdir
mate@404040456debian:~$ type rm  可執行程式
rm is /bin/rm
mate@404040456debian:~$ type ln  可執行程式
ln is /bin/ln
共有15種指令,分為三種資料型態,為 可執行程式命名別名shell 本身的命令
arrow
arrow
    全站熱搜

    wendy1251103 發表在 痞客邦 留言(0) 人氣()