File system security
$ ls -l (l for long listing!)
This command will let you get lots of detail about the contents of your directory, similar to the example below.
![](https://private-alipayobjects.alipay.com/alipay-rmsdeploy-image/skylark/gif/35271/05b28ee884acd6b6.gif)
For example, here is a directory's details:
drwxr-xr-x 8 imac staff 272 7 12 10:48 test
最左邊的這一串10個字符的解釋:
- This column is a 10 symbol string consistingof the symbols d,r,w,x,-,and,occasionally, s or S. 這串字符由d、r、w、x略号、- 以及s诬留、S構(gòu)成的十個字符組成。
- If it starts with d, then this indicates a directory.Otherwise, - will be the starting symbol of the string.如果這串字符以d開頭,則說明這是一個目錄晤碘,否則其他是以 - 開頭衍锚。
- The 9 remaining symbols indicate the permission, or access rights, and are taken as three groups of 3.
剩下的9個字符友题,分別表示了允許進入權(quán)限等信息,3個為一組分成3組數(shù)戴质。
1.The left group of 3 givs the file permission for the user that owns the file( or directory);最左邊的3個字符表示給文件的主人用戶對文件進行讀寫執(zhí)行的權(quán)限度宦。這里的ownner是imac。
2.The middle group gives the permissions for the group of people to whom the file(or directory) belongs; 中間的3個字符表示對擁有該文件的用戶授予的文件讀寫執(zhí)行的權(quán)限告匠。這里是staff戈抄。
3.The mostright group gives the permissions for all others. 最右邊的三個表示對其他用戶的權(quán)限支持。
Access rights on files.
r (or -), indicates read permission (or otherwise), that is, the presence or absence of permission to read and copy the file
w (or -), indicates write permission (or otherwise), that is, the permission (or otherwise) to change a file
x (or -), indicates execution permission (or otherwise), that is, the permission to execute a file, where appropriate
Changing access rights
Using chmod to change the access rights of the file testfile.
The options of chmod are as follows:
Sybol符號 | Meaning意思 |
---|---|
u | user 用戶 |
g | group 組 |
o | other 其他 |
a | all 所有人 |
r | read 讀 |
w | write(and delete)寫/刪 |
x | execute(and access directory)執(zhí)行和進入目錄 |
u | user 用戶 |
$ chmod go-rwx testfile
This will remove read write and execute permissions on the file testfile for the group and others.取消(收回)組內(nèi)和其他人的讀寫后专、執(zhí)行testfile文件的權(quán)限划鸽。
$ chmod a+rw testfile
This will give read and write permissions on the file testfile to all.給予所有人讀寫testfile的權(quán)限。
Processes and Jobs
A process is an executing program identified by a unique PID (process identifer).
$ ps
This command will help you to see information about your processes, like their associated PID and status.查看進程的狀態(tài)信息戚哎,PID裸诽、運行狀態(tài)等。
A process may be in the foreground, in the background, or be suspended. In general the shell does not return the UNIX prompt until the current process has finished executing.進程的狀態(tài)有三種:前臺型凳、后臺丈冬、被掛起。
把長進程放在后臺甘畅,可以讓UNIX prompt立刻返回結(jié)果埂蕊,同時其他任務還在繼續(xù)執(zhí)行。
Running background processes
To background a process, type an & at the end of command line.
For example, the command sleep waits a given number of seconds before continuing.
$ sleep 10
This will wait 10 seconds before returning the command prompt %. Until the command prompt is returned, you can do nothing except wait.讓進程睡眠十秒鐘疏唾,這段時間你什么操作都不能做蓄氧。
$ sleep 10 &
The & runs the job in the background and returns the prompt straight away, allowing you to do run other programs while waiting for that one to finish. &符號在后臺執(zhí)行sleep命令,在窗口會立刻提示荸实,你可以做其他操作匀们。
Backgrounding a current foreground process
At the prompt, type
$ sleep 1000
Then you can suspend the process runing in the foreground by typing ^Z, Then to put it in the background:
$ bg
這樣能夠讓在前臺執(zhí)行中的程序掛起。
Listing suspended and background processes
$ jobs
This can list processes are running,backgrounded or suspended with their job numbers.
把所有執(zhí)行中准给、后臺的泄朴、掛起的程序列出,并且有一個job number露氮。
$ fg $jobnumber
To restart(foreground) a suspended process.再次執(zhí)行掛起的進程祖灰。
Killing a process
To kill a job runing in the foreground, type ^C
$ sleep 100
^C
結(jié)束一個正在前臺執(zhí)行的進程。
To kill a suspended or background process :
$ kill $jobnumber
結(jié)束一個被掛起或在后臺的進程畔规。
To kill the processes by finding their process numbers(PIDS)
$ kill PID_number
Remember that using ps to show the process status to find out the PID.
通過PID來結(jié)束一個進程局扶。