[أوبونتث] [لينوإكس] مستعملات يمكن كنت [فميلير ويث] يستعمل ال "[سودو]" أمر في [لينوإكس]. هو سمة مفيدة جدّا في [لينوإكس] أنّ يسمح المديرة من [لينوإكس] آلة إلى منحة "جذر" امتيازات إلى خاصّة مستعملة أو مجموعة المستعملات. هو يستطيع أيضا كنت شكّلت [س ثت] هذا امتياز يكون حددت إلى [أن ور موش] أوامر. [أوبونتث] قد قرّر فريق, مثلا, أن يسدّ الجذر مستعملة من [لوغ ون] بتقصير وبدلا من ذلك سمحت مستعملات أن يستعمل [سودو] أن ينجز مهام إداريّة. هكذا إن أنت يكون تستعمل [أوبونتث] [لينوإكس], [سودو] [ستثب] امتيازات يتلقّى يكون [س ثت] أنت تتلقّى تماما "جذر" امتيازات. [لت'س] أخذت نظرة قريبة في [ستّينغ-وب] ويشكّل [سودو] امتيازات على آلتك. قبل يباشر رجاء بطاقة أنّ أنت سوفت لا يحاول التالي على إنتاج نادلة. رجاء جربت المثل في هذا [تثتوريل] على إختبار آلة وحصلت [فميلير ويث] [سودو] قبل أن يحاول أنت هو خارجا على إنتاج نادلة. [سودو] أداة قوّيّة جدّا وينبغي كنت استعملت مع تحذير متطرّفة.
[تو مي نوولدج] ال "[سودو]" يشحن مجموعة مع كلّ [لينوإكس] توزيعات. هكذا سيتخطّى أنا التجهيز وسييقفز رأسا إلى التشكيل. ل هذا [تثتوريل] سيستعمل أنا حمراء قبعة [لينوإكس] آلة. سجلّ مقياس سرعة داخل ك [لينوإكس] آلة كجذر ويركض الأمر تالي على ال [كمّند لين]:
# [فيسودو]
سيفتح الأمر آنفة ال "[سودو]" تشكيل, أيّ يكون في /etc/sudoers, يستعمل التقصير محررة على آلتك, أيّ يكون [فيم] على خاصّتي. مرّرت إلى أسفل إلى القسم حيث أنت ترى النص تالي:
جذر? ? [ألّ] (كلّ) كلّ
يذهب التحطم من هذا [سودو] تشكيل إعراب مثل هذا. أنت أولى تعيّن ال `مستعملة' ل أيّ أنت تريد أن [ستثب] [سودو]. بعد ذلك يأتي ال `[هوستنم]' حيث الأمر يكون سمحت أن يركض. هذا استطاع كنت واحدة [هوستنم] خاصّة أو "كلّ" بما أنّ في المثال أعلاه. ومتأخّرة ال `أمر' ل أيّ أنت يريد أن يعطي ال `مستعملة' امتياز إداريّة.
[بك تو] التشكيل. في [فيم] درج إلى أسفل إلى الخطّ يبدى أعلاه ويضرب الحرف [و] على لوحت مفاتيحك أن يضيف [نو لين]. الآن أضفت النص تالي, يستبدل [كلفين] مع ك خاصّة [أوسرنم]:
[كلفين] [ألّ] (كلّ) كلّ
أنقذت وخرجت المبرد يستعمل ال [كي كمبينأيشن] تالي:
[إسك]: [وق]
ضربت ال عودة (دخلت) مفتاح أن يطبّق هذا تعليمات. يعطي نحن يتلقّى الآن المستعملة `[كلفين]' كلّ امتيازات إداريّة يستعمل [سودو]. Open a new terminal window and log in as the user that you granted sudo privileges to. Let’s test whether the new permissions have been setup correctly by restarting the Apache web server as user ‘calvin’:
#?sudo /etc/init.d/httpd restart
Password:
Stopping httpd: ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?[ ?OK ?]
Starting httpd: ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?[ ?OK ?]
The system will now prompt you for a password. Enter the password for your username. And voila! The Apache web server should now restart. You can use this for any other administrative task. Granting complete privileges to a user may not always be the best of ideas. So you can limit the user to a few command with administrative privileges. Let’s say you want the user ‘calvin’ to be allowed to only restart the Apache web server. Open the sudo configuration file using the visudo command and edit the line you entered earlier to look like this:
calvin ALL=(ALL) /etc/init.d/httpd restart
Save and exit the file. Log into the terminal as the user ‘calvin’. Now try restarting Apache with sudo:
# sudo /etc/init.d/httpd restart
Password:
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
Great. It works. Now try stopping the web server:
# sudo /etc/init.d/httpd stop
Password:
Sorry, user calvin is not allowed to execute ‘/etc/init.d/httpd stop’ as root on commons.
So as you can see, the user ‘calvin’ can only do what we allow him to do, nothing more. You can add multiple commands in the sudoers file separated by commas. So if you want to allow ‘calvin’ the permission to stop and restart the web server your configuration would read like this:
calvin ALL=(ALL) /etc/init.d/httpd restart,/etc/init.d/httpd stop
Now try stopping the web server, and it should work:
# sudo /etc/init.d/httpd stop
Password:
Stopping httpd: [ OK ]
Another feature of sudo that is pretty useful, particularly if you need to perform an administrative task using a shell script, is setting the sudo privilege without being prompted for a password. Remember that it may not be advisable to do this on a production machine using a username that is shared, because if the password for your username falls into the wrong hands it can spell trouble. So use this feature with caution.
Open the sudoers file and edit the line you entered earlier to look like this:
calvin ALL=(ALL) /etc/init.d/httpd restart NOPASSWD: ALL
The last part of the configuration instructs sudo to not prompt for or expect a password, and allow the user to execute the command that is assigned to it with administrative privileges. Save the file and exit from your text editor and try restart Apache:
# sudo /etc/init.d/httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
There is a lot more customization that can be done to the sudo configuration file. We have just looked at a small segment of it. However, this ought to give you a start. Again, please use it with caution.





























{ 2 trackbacks }
{ 0 comments… add one now }
Leave a Comment