Prep-UNIX Tutorial-2

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.


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é)束一個進程局扶。

Quotes

UNIX Tutorial for Beginners

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市,隨后出現(xiàn)的幾起案子三妈,更是在濱河造成了極大的恐慌畜埋,老刑警劉巖,帶你破解...
    沈念sama閱讀 218,682評論 6 507
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件畴蒲,死亡現(xiàn)場離奇詭異悠鞍,居然都是意外死亡,警方通過查閱死者的電腦和手機模燥,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,277評論 3 395
  • 文/潘曉璐 我一進店門咖祭,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人蔫骂,你說我怎么就攤上這事么翰。” “怎么了辽旋?”我有些...
    開封第一講書人閱讀 165,083評論 0 355
  • 文/不壞的土叔 我叫張陵浩嫌,是天一觀的道長。 經(jīng)常有香客問我戴已,道長固该,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 58,763評論 1 295
  • 正文 為了忘掉前任糖儡,我火速辦了婚禮伐坏,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘握联。我一直安慰自己桦沉,他們只是感情好,可當我...
    茶點故事閱讀 67,785評論 6 392
  • 文/花漫 我一把揭開白布金闽。 她就那樣靜靜地躺著纯露,像睡著了一般。 火紅的嫁衣襯著肌膚如雪代芜。 梳的紋絲不亂的頭發(fā)上埠褪,一...
    開封第一講書人閱讀 51,624評論 1 305
  • 那天,我揣著相機與錄音挤庇,去河邊找鬼钞速。 笑死,一個胖子當著我的面吹牛嫡秕,可吹牛的內(nèi)容都是我干的渴语。 我是一名探鬼主播,決...
    沈念sama閱讀 40,358評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼昆咽,長吁一口氣:“原來是場噩夢啊……” “哼驾凶!你這毒婦竟也來了牙甫?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 39,261評論 0 276
  • 序言:老撾萬榮一對情侶失蹤调违,失蹤者是張志新(化名)和其女友劉穎窟哺,沒想到半個月后,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體翰萨,經(jīng)...
    沈念sama閱讀 45,722評論 1 315
  • 正文 獨居荒郊野嶺守林人離奇死亡脏答,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,900評論 3 336
  • 正文 我和宋清朗相戀三年糕殉,在試婚紗的時候發(fā)現(xiàn)自己被綠了亩鬼。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 40,030評論 1 350
  • 序言:一個原本活蹦亂跳的男人離奇死亡阿蝶,死狀恐怖雳锋,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情羡洁,我是刑警寧澤玷过,帶...
    沈念sama閱讀 35,737評論 5 346
  • 正文 年R本政府宣布,位于F島的核電站筑煮,受9級特大地震影響辛蚊,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜真仲,卻給世界環(huán)境...
    茶點故事閱讀 41,360評論 3 330
  • 文/蒙蒙 一袋马、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧秸应,春花似錦虑凛、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,941評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至祸挪,卻和暖如春锣披,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背贿条。 一陣腳步聲響...
    開封第一講書人閱讀 33,057評論 1 270
  • 我被黑心中介騙來泰國打工雹仿, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人闪唆。 一個月前我還...
    沈念sama閱讀 48,237評論 3 371
  • 正文 我出身青樓盅粪,卻偏偏與公主長得像,于是被迫代替她去往敵國和親悄蕾。 傳聞我的和親對象是個殘疾皇子票顾,可洞房花燭夜當晚...
    茶點故事閱讀 44,976評論 2 355

推薦閱讀更多精彩內(nèi)容