Reference: 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.
Absolute and relative paths
/ : Root Directory
.. : Parent directory.
Directory Operations
pwd : Print working directory, which'll 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.
Handling special characters (space, bracket, quotation mark,!, $, &, *,;, \, ...)
\ : Use back slash before the character. CD punlic/drop\ box/(= CD "Public/drop box").
File operations
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 filename
diff: Compare files on line.
sort: Sort lines of text file.
uniq: report or filter out repeated lines in a file.
Comm: Select or Regject lines common to the files.
WC: Word, line, character, and byte count.
NL: line numbering filter. NL file1 > File2
Process actions
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 could 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)
ALRM (Alarm)
term (software termination signal)
Time Operation:
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.)
System Management
W: Display who was logged in and what they was doing.
who:
WhoAmI:
su : Substitute user identify.
Sudo : Substitute user do, or super user does. It allows a permitted user to execute a command as the Superuser or another user.
Unix commands in Mac OS X