砍敺 media 2014-12-21 14:12 蝺刻摩
3 { Q# N( k! R5 N' i# v6 Q
% _; ~. @3 ?) bsu=switch user ,頧郢oot 撣唾
% L. E* ^, K1 w. q" |% ^sudo 臭誑root甈瑁賊賭誘,靘憒: sudo service mysqld restart,抵隤芣憒銝:" P- R( r- ]. f) Z* t, W
- ] g0 V- c V$ ^. Y; g3 o$ I
Linux摰鋆憟隞嗉蝟餌絞閮剖賡閬root甈嚗撠望盎uper-user privileges (擃甈)嚗銋撠望舐恣⊥憒雿root甈嚗臭誑湔亦究sh餃叵oot撣唾嚗究u(substitute user)隞支雿輻刻嚗銝嗅停臭蝙究udo隞扎
" p; {: B: c5 O4 E! ]# |: Z8 d* n# x) G. W" C& J4 b
1. 雿輻究u隞 - #究u雿輻刻
* Y. K$ `$ |, i8 I - [aaron@phoenix ~]$ su#雿輻究u氳oot
; J4 i( H1 ?3 f - Password:[頛詨叵oot撖蝣奭+ b5 M8 p9 U4 u+ m' a
+ G/ J+ V5 O* h! w- [root@phoenix aaron]# service httpd restart#撌脣氳oot$ A/ \7 N0 G: [
- Stopping httpd: [ OK ]
7 Y2 F: e* o; @. }$ Z - Starting httpd: [ OK ]+ }, S/ [. O* @$ a% ~- I
- - T( Y! C4 S4 |3 m- U2 O) A: P
- [root@phoenix aaron]# exit#aaron
; r7 r2 G' L) K# P
. N+ r/ y: G8 ^' [- #瑁桐隞歹銝閬氳oot
$ n2 ^3 D" E3 j1 [/ K - [aaron@phoenix ~]$ su -c "service httpd restart"2 a: ]1 _+ Q3 V
- Password:[頛詨叵oot撖蝣奭( F1 Y E! i. r3 C' n% Y5 _
- Stopping httpd: [ OK ]
/ J4 ^* O0 ^ p' ?$ @( }( C - Starting httpd: [ OK ] c8 z7 K: N/ e
- c. m6 h+ C- J/ A( |- #瑁susu -撌桀(Shell啣臬西)
! I7 J# C9 P+ f! r4 N; e9 t1 j3 S - [aaron@phoenix ~]$ su
J2 {' G# `/ _" K2 M" g% x0 O7 T - Password:[頛詨叵oot撖蝣奭- G" A% Q$ H- E! C4 |; t% c7 d
- [root@phoenix aaron]# echo $PATH#訐ATH霈賂潛暸雿輻災aronPATH霈
7 x) u, |( F2 N- w9 S. j4 R. z - /usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/aaron/bin
9 x) S1 ^5 P d- @; q7 K) O" C; w
% y" }: e; x, W I+ ]- [aaron@phoenix ~]$ su -
4 R1 R$ s$ L! A( e" ^; ~0 g - Password:[頛詨叵oot撖蝣奭
& I$ r' h5 `9 n" g6 Y' M - [root@phoenix aaron]# echo $PATH#訐ATH霈賂雿輻禿ootPATH霈( S' [! h- o& J- ^
- /usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
銴鋆賭誨蝣
# ?# r" r$ A) M. }3 R; l2. 閮剖sudoer- Z: Q) R! N. U8 `3 F: P
- [aaron@phoenix ~]$ su* z) N& ~5 ]' J5 w; e& B4 ~8 b
- Password:[頛詨叵oot撖蝣奭
% q C$ X1 V6 b; w6 ?9 }# F - ; K8 V" t) V2 Z
- [root@phoenix aaron]# vim /etc/sudoers
, @! i; T/ \0 A- q9 ^4 Z. @+ R
8 j- i: H6 y+ j) q3 G$ s, J- ## Allow root to run any commands anywhere- V) C5 H/ H8 S1 ^
- root ALL=(ALL) ALL# g3 V: f! P* W T$ o
- - V9 O( P0 Q: d3 A" q% E
- ## Allow users to run any commands anywhere4 H9 l5 a9 Z: a+ J. q
- aaron ALL=(ALL) ALL#啣璇閮帶aron臭誑瑁蝞∠⊥
銴鋆賭誨蝣
1 p/ N& y0 a% R% r; P5 A L j3. 蝭靘- #瘝擃甈嚗隞亙停鋡急鈭0 ^; Z9 ?3 ?* O1 [
- [aaron@phoenix ~]$ service httpd restart) r+ x2 i0 ?1 F
- Stopping httpd:
; [/ v' O5 n5 E% A. D - rm: cannot remove `/var/run/httpd/httpd.pid': Permission denied
* d. j3 s$ E/ r9 E, A - 6 v7 a" a9 n) J! W# _ t* V) y# _
- Starting httpd:
1 e) S% a# Y; s3 W6 ?8 K) ^ - touch: cannot touch `/var/lock/subsys/httpd': Permission denied
9 a3 N6 W$ ~1 y A" h! d
9 f3 j8 g8 j" ]- #究udo撠勗臭誑' Z b% G# A* }* _" H
- [aaron@phoenix ~]$ sudo service httpd restart
$ V' p; @0 x% K" |/ n1 Q6 h: X - [sudo] password for aaron:[頛詨亙蝣奭
7 @+ d( `' E5 V$ |; f' ]" s8 O - Stopping httpd: [ OK ]( S% h* u2 n+ z4 S
- Starting httpd: [ OK ]
銴鋆賭誨蝣 #susudo撌桀亙冽潭臬西霈銝砌蝙刻仿root撖蝣潘憒究u撠勗撠root撖蝣澆鈭怠箏鳴敺航賡蝟餌絞鋡思噩亦梢芥sudo航銝砌蝙刻蝞∠⊥嚗芾頛詨亥芸楛撖蝣澆喳荔雿璅憸券迎箸蝞∠⊥
" v8 H1 `* i. D臬http://kezeodsnx.pixnet.net/blog/post/25810396 |