wanmin444 发表于 2015-12-31 11:03:13

Unix commands in Mac OS X

  参考: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.
  
页: [1]
查看完整版本: Unix commands in Mac OS X