Unix commands in Mac OS X

來源:互聯網
上載者:User

標籤:

參考:http://www.renfei.org/blog/mac-os-x-terminal-101.html

One command line includes 4 parts: Command Name、Options、Arguments、Extras . 

man <command-name> :  Give the manual of this command.

 

絕對和相對路徑

     / : Root directory

     ..  : Parent directory. 

 

目錄操作

     pwd : Print working directory, which will show the absolute path of current folder.

     ls  : List directory contents.      Ls –la  : List all contents including hidden contents.

     cd : Change directory.

   mkdir : Make directories.

     rmdir:  Remove directories.

   mvdir:  Move or rename a directory.

      處理特殊字元(space, bracket, quotation mark, !, $, &, *, ;, \, …)

      \ : Use back slash before the character.        cd Punlic/Drop\ Box/      ( = cd “Public/Drop Box”).

 

檔案操作

      cp  : Copy files.  

      mv : Move files.

      rm :  Remove files

      vi:  or vim :  A programmers text editor

      nano:  Nano‘s another editor, an enhanced free pico clone.

    cat : Concatenate and print files.  It reads files sequentially, writing them to the standard output.

               cat file1 : Will print the contents of file1 to the standard output.

               cat file1 file2 > file3:  Will sequentially print the cntents of file1 and file2 to the file3.

               cat file1 – file2 – file3:   ???

      od:  Octal, decimal, hex, ASCII dump

      less:

      which:  Locate a program file in the user’s path.

      find :   find . -name "*.c" -print

    file:  Determine file type. 

      head:  Display first lines of a file.  head -10 filename.

  tail:  Display the last part of a file. 

      cut:  Cut out selected portions of each lie of a flie.

      colrm:  Remove columns from a file.    colrm 8 20 filename

      diff: Compare files line by line.

      sort: Sort lines of text file.       

      uniq:  Report or filter out repeated lines in a file.

      comm: Select or regject lines common to two files.

      wc:  Word, line, character, and byte count.  

      nl: Line numbering filter.        nl file1 > file2

 

進程操作

  ps : Process status     ps u

  kill : Terminate or signal a process.               kill -9 30142

             The kill utility sends a signal to the processes specified by the pid operand(s).

     Only the super-user may send signals to other user‘s processes.

             Some of the more commonly used signals:

      1  HUP (hang up)

      2  INT (interrupt)

      3  QUIT

      6   ABRT (abort)

      9  KILL (non-catchable, non-ignorable kill)

      14   ALRM (alarm )

      15  TERM (software termination signal)

時間操作: 

  date:  Display or set date and time.

  cal:  Display a calendar and the date of easter        cal 4 2015.   

      time: time command execution (totoal time elapsed.)

       

系統管理

      w:  Display who is logged in and what they are doing.

  who: 

      whoami: 

      su  : Substitute user identify. 

      Sudo : Substitute user do, or super user do.  It allows a permitted user to execute a command as the superuser or another user.

 

Unix commands in Mac OS X

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.