http://ws.edu.isoc.org/workshops/2006/ccTLD-Samoa/day1/freebsd/freebsdref-1up.pdf
基本知識
~
~/
home directory
使用者的家目錄
一登入就會進入的目錄
../
上一層資料夾
./
現在的資料夾
====================================
Getting out of trouble
^C (Ctrl-C)
停止正在執行的command
^U (Ctrl-U)
清除該行
exit
logout
Exit from the shell
ESC :q! ENTER
Quit from vi without saving
===================================================
查找指令的詳細用法
man cmd
man 5 cmd
man -a cmd
Show manual page for command "cmd".
c的function也能查
If a page with the same name exists in multiple sections,
you can give the section number,
or -a to show pages from all sections.
=================================================
System status
date
顯示當前日期時刻
uptime
顯示最後一次開機到現在的時間 和 load stats
who
w
顯示誰在系統上
正在做什麼
============================================================
目錄 資料夾
pwd
Show current directory ("print working directory")
Change current directory:
cd subdir
Move into a subdirectory of the current directory
cd ..
Move up one level, to the parent directory
cd /
cd /absolute/path
to the filesystem root, 到根目錄
to an absolute location, 從根目錄開始算的絕對路徑
cd ~username
cd
cd ~
cd ~/
to a particular user's home directory, 到user家目錄
or to your own home directory
ls
ls path
List contents of current directory or given directory
list
可以列出 當前資料夾 或 你給的資料夾(path為資料夾路徑) 的內容物
藍:資料夾
綠:執行檔
白:一般文件
ls -a
List all files, including hidden files
檔名第一個字母是'.'就是隱藏檔
ls -d
List directory itself, rather than its contents
ls -l
List directory in long form (lowercase 'L', not number one)
Show permissions on file or directory.
,------- type (-=file, d=directory)
/ ,------ rwx perms for user (owner)
/ / ,---- rwx perms for group
/ / / ,-- rwx perms for other
-rwxrwxrwx
For a file:
r allows read;
w allows write/append;
x allows execute.
For a directory:
r allows listing contents;
w allows creation or deletion of files within directory;
x allows directory to be entered
ls -ld
ls -ld path
-l 加上 -d
好像可以看到自己家目錄的容量上限512,但單位不明
mkdir path
Create a directory
rmdir path
Delete an empty directory
rm -rf subdir
等於-r -f
Recursively delete a directory and all its contents - DANGEROUS!
rm -r subdir
移除資料夾
於上面的差別是?
===============================================================
檔案
rm filename
Delete (remove) file
cp filename newname
Copy one file
cp file1 file2 ... subdir/
Copy a file or files into another directory.
(The trailing slash on the subdir is not essential,
but prevents errors when you are copying
one file and 'subdir' does not exist)
mv oldname newname
Rename one file or directory
ex. mv test.txt ./test.txt
mv file1 file2 ... subdir/
Move a file or files into another directory
ln -s path newname
Make newname a symbolic or soft link pointing to path , which may
be a file or directory and can be anywhere on the filesystem.
=======================================
搜尋檔案
locate str
Search for filenames matching str in the locate database
find path -type f
Find all files under the given path (use "." for current directory)
find path -type f -name 'foo*'
Find all files under the given path whose name begins "foo"
find path -type f | xargs cmd
Find all files under path and apply cmd to each of them
find path -type f -print0 | xargs -0 cmd
Safer version of above (works with filenames that contain spaces)
===================================================================================
Processes
ps auxw
Show all processes
ps auxw | grep procname
Show all processes matching pattern "procname"
(note that "grep procname" itself may be shown)
top
Show continuously the most active processes (q to quit)
可以看哪個程序最耗CPU
=======================================
Shell facilities
which foo
Search for command foo in PATH and show where it was found
history
history 20
顯示所有輸入過的指令
顯示最近輸入的20個指令
↑(方向鍵 上)
顯示之前輸入過的指令
!num
Re-execute command num from history
cmd1; cmd2
Run cmd1 followed by cmd2
cmd1 && cmd2
Run cmd1 , then cmd2 only if cmd1 was successful ($? = 0)
clear
cls
清螢幕
=======================================================================
Job control
^C (Ctrl-C)
停止正在前景執行的command
^Z (Ctrl-Z)
Suspend current foreground process (makes suspended job)
把正在前景執行的command掛在背景裡
暫緩執行
jobs
List jobs under this shell
kill %n
Terminate job number n
fg
fg %n
Restart suspended process in foreground
bg
bg %n
Restart suspended process in background
cmd &
Start command as background job
=======================================
File redirection
^D (Ctrl-D)
Send end- of-file on standard input
cmd1 | cmd2
Pipe output of cmd1 to input of cmd2
cmd >out.txt
Redirect command standard output to file
cmd 2>err.txt [sh]
Redirect command error output to file
cmd >out.txt 2>&1 [sh]
cmd >&out.txt [csh]
Redirect both standard and error output to file
cmd >>out.txt
Append to out.txt instead of replacing it
cmd <in.txt
Redirect command standard input from file
=========================================================
編輯 閱讀
cat > filename
????內容???
???內容?????^D
建立檔案
輸入內容
輸入內容 ctrl+d 編輯結束
cat ????.???
開啟檔案,閱讀?
其他的,就問男人吧XD
more
less
ee
vi
沒有留言:
張貼留言