An introduction to the sudo command and configuration file Sudo कमांड और विन्यास के लिए एक परिचय संचिका

by Sukrit Dhandhania on December 29, 2008 Sukrit Dhandhania द्वारा 29 दिसम्बर 2008 पर

लिनक्स

Ubuntu Linux users may be familiar with using the “sudo” command in Linux. Ubuntu Linux हो लिनक्स में sudo "कमांड का प्रयोग" से परिचित कर सकते हैं उपयोगकर्ता. It's a very useful feature in Linux that allows the administrator of a Linux machine to grant “root” privileges to a particular user or group of users. यह लिनक्स में एक बहुत ही उपयोगी सुविधा है कि एक Linux मशीन के प्रशासक अनुदान 'को जड़ किसी विशेष उपयोगकर्ता या उपयोगकर्ताओं के समूह में विशेषाधिकार "की अनुमति देता है. It can also be configured so that this privilege is limited to one or more commands. यह भी तो विन्यस्त किया जा सकता है कि यह विशेषाधिकार एक या एक से अधिक आदेश तक सीमित है. The Ubuntu team, for example, have decided to block the root user from logging in by default and instead allow users to use sudo to perform administrative tasks. Ubuntu टीम, उदाहरण के लिए, डिफ़ॉल्ट रूप से करने में प्रवेश करने और उपयोगकर्ताओं के बजाय sudo का उपयोग करने के लिए प्रशासनिक कार्य की अनुमति से जड़ उपयोगकर्ता खंड का फैसला किया है. So if you are using Ubuntu Linux, sudo privileges have been setup so that you have full “root” privileges. तो अगर तुम Ubuntu Linux प्रयोग कर रहे हैं, sudo विशेषाधिकार गया सेटअप है, ताकि आप पूरी तरह जड़ "है" विशेषाधिकार. Let's take a closer look at setting up and configuring sudo privileges on your machine. चलो स्थापित करने और अपनी मशीन पर sudo विशेषाधिकारों को विन्यस्त पर एक करीब देखो. Before proceeding please note that you should not try the following on a production server. कृपया ध्यान दें आगे बढ़ने से पहले कि तुम एक उत्पादन सर्वर पर निम्नलिखित की कोशिश नहीं करनी चाहिए. Please try out the examples in this tutorial on a test machine and get familiar with sudo before you try it out on a production server. कृपया एक परीक्षण मशीन पर इस ट्यूटोरियल में उदाहरण कोशिश sudo से परिचित हो इससे पहले कि आप इसे आज़माने के एक उत्पादन सर्वर पर. sudo is a very powerful tool and must be used with extreme caution. sudo एक बहुत शक्तिशाली उपकरण है और अत्यंत सावधानी के साथ किया जाना चाहिए.

To my knowledge the “sudo” package ships with all Linux distributions. मेरी जानकारी में sudo "" सभी Linux वितरण के साथ पैकेज जहाज. So I'll skip the installation and jump straight to the configuration. तो मैं छोड़ स्थापना और विन्यास के लिए सीधे छलांग हूँ. For this tutorial I will use a Red Hat Linux machine. इस ट्यूटोरियल के लिए मैं एक Red Hat Linux मशीन का उपयोग करेंगे. Log into your Linux machine as root and run the following command on the command line: जड़ के रूप में अपने लिनक्स मशीन में प्रवेश करें और कमांड लाइन पर निम्नलिखित कमांड चलायें:

# visudo # Visudo

The above command will open the “sudo” configuration, which is at /etc/sudoers , using the default editor on your machine, which is Vim on mine. इसके बाद के संस्करण कमान sudo "खुला" विन्यास, जो / पर आदि sudoers / आपकी मशीन है, जो मेरा है पर विम है पर डिफ़ॉल्ट संपादक का उपयोग करेंगे. Scroll down to the section where you see the following text: अनुभाग के लिए नीचे स्क्रॉल आप निम्नलिखित पाठ जहां देखें:

root    ALL=(ALL) ALL सभी = सब (जड़) सभी

The breakup of this sudo configuration syntax goes like this. इस sudo विन्यास वाक्यविन्यास का गोलमाल इस तरह से चला जाता है. You first define the 'user' for which you want to setup sudo. तुम पहले 'प्रयोक्ता', जिसके लिए आप सेटअप sudo को परिभाषित करना चाहते. Then comes the 'hostname' where the command is allowed to run. आती है तो 'होस्टनाम' जहां कमांड को चलाने की अनुमति दी है. This could be one specific hostname or “ALL” as in the example above. यह एक विशिष्ट होस्टनाम या "सभी" के रूप में उपरोक्त उदाहरण में हो सकता है. And last is the 'command' for which you want to give the 'user' administrative privilege. और आखिरी 'कमांड' जिसके लिए आप '' उपयोगकर्ता प्रशासनिक विशेषाधिकार देना चाहते है.

Back to the configuration. वापस विन्यास के लिए. In Vim scroll down to the line shown above and hit the letter o on your keyboard to add a new line. विम में ऊपर दिखाए गए लाइन के नीचे स्क्रॉल करें और अपने कुंजीपटल पर पत्र हिट के लिए एक नई पंक्ति जोड़ें. Now add the following text, replacing calvin with your own username: अब निम्नलिखित पाठ जोड़ने के लिए, अपने उपयोगकर्ता नाम के साथ केल्विन की जगह:

calvin ALL=(ALL) ALL केल्विन सभी = (ALL) ALL

Save and exit the file using the following key combination: सहेजें और निम्न कुंजी संयोजन का उपयोग कर फ़ाइल बाहर निकलें:

ESC :wq ईएससी: wq

Hit the Return (enter) key to apply these instructions. वापस मारो (प्रवेश) कुंजी के लिए इन निर्देशों लागू होते हैं. We have now given the user 'calvin' all administrative privileges using sudo. अब हम 'उपयोगकर्ता' केल्विन सभी प्रशासनिक sudo विशेषाधिकारों का उपयोग कर दिया है. Open a new terminal window and log in as the user that you granted sudo privileges to. एक नया टर्मिनल विंडो खोलें और में प्रवेश करें उपयोगकर्ता जिसे आप sudo विशेषाधिकार के रूप में दी. Let's test whether the new permissions have been setup correctly by restarting the Apache web server as user 'calvin': चलो परीक्षण कि क्या 'उपयोगकर्ता केल्विन' के रूप में Apache वेब सर्वर शुरु द्वारा नई अनुमतियाँ सेटअप सही ढंग से किया गया है:

# sudo /etc/init.d/httpd restart # Sudo / etc / init.d / httpd पुनः आरंभ
Password: पासवर्ड:
Stopping httpd:                                            [  OK  ] रोक httpd: [ठीक]
Starting httpd:                                            [  OK  ] शुरू httpd: ठीक है []

The system will now prompt you for a password. प्रणाली अब तुम एक पासवर्ड के लिए संकेत होगा. Enter the password for your username. आपके उपयोगकर्ता नाम के लिए पासवर्ड दर्ज करें. And voila! और देखा! The Apache web server should now restart. Apache वेब सर्वर अब पुनः आरंभ करना चाहिए. 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. हम कहते हैं कि तुम 'उपयोगकर्ता केल्विन' चाहते हैं कि केवल Apache वेब सर्वर को पुनः आरंभ करने की अनुमति दी है. Open the sudo configuration file using the visudo command and edit the line you entered earlier to look like this: खुला sudo विन्यास visudo आदेश का उपयोग कर फ़ाइल और रेखा तुम्हें पहले प्रवेश के लिए इस तरह देखो संपादित करें:

calvin ALL=(ALL) /etc/init.d/httpd restart केल्विन सभी = सब () / etc / httpd init.d / पुनः आरंभ

Save and exit the file. फ़ाइल सहेजें और बाहर निकलें. Log into the terminal as the user 'calvin'. के रूप में टर्मिनल में प्रवेश करें 'उपयोगकर्ता' केल्विन. Now try restarting Apache with sudo: अब sudo के साथ अपाचे शुरु प्रयास करें:

# sudo /etc/init.d/httpd restart # Sudo / etc / init.d / httpd पुनः आरंभ
Password: पासवर्ड:
Stopping httpd: [ OK ] रोक httpd: [ठीक]
Starting httpd: [ OK ] शुरू httpd: ठीक है []

Great. महान. It works. यह काम करता है. Now try stopping the web server: अब वेब सर्वर को रोकने का प्रयास करें:

# sudo /etc/init.d/httpd stop # Sudo / etc / init.d / httpd रोक
Password: पासवर्ड:
Sorry, user calvin is not allowed to execute '/etc/init.d/httpd stop' as root on commons. क्षमा करें, प्रयोक्ता केल्विन की अनुमति '/ etc / Commons पर रूट के रूप में init.d / httpd बंद' लागू नहीं है.

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. तुम sudoers में कई कमांड जोड़ अल्पविराम के द्वारा अलग फाइल कर सकते हैं. 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 केल्विन सभी = सब () / etc / init.d / httpd पुनः आरंभ, / etc / init.d / httpd रोक

Now try stopping the web server, and it should work: अब वेब सर्वर को रोकने की कोशिश करो, और यह काम करना चाहिए:

# sudo /etc/init.d/httpd stop # Sudo / etc / init.d / httpd रोक
Password: पासवर्ड:
Stopping httpd: [ OK ] रोक httpd: [ठीक]

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. Sudo की एक और विशेषता है कि बहुत उपयोगी है, खासकर यदि आप एक प्रशासनिक एक खोल स्क्रिप्ट का उपयोग कर कार्य करने की जरूरत है, एक पासवर्ड के लिए प्रेरित किया जा रहा है बिना sudo विशेषाधिकार की स्थापना. 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: खुला sudoers फ़ाइल और रेखा तुम्हें पहले प्रवेश के लिए इस तरह देखो संपादित करें:

calvin ALL=(ALL) /etc/init.d/httpd restart NOPASSWD: ALL केल्विन सभी = सब () / etc / init.d / / ALL: httpd NOPASSWD पुनः आरंभ

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. विन्यास के पिछले भाग sudo निर्देश के तुरंत के लिए है या नहीं एक पासवर्ड की उम्मीद है, और उपयोगकर्ता आदेश है कि प्रशासनिक विशेषाधिकारों के साथ उसे सौंपे है निष्पादित करने की अनुमति. Save the file and exit from your text editor and try restart Apache: अपने पाठ संपादक से बाहर निकलें और फ़ाइल सहेजें और अपाचे पुनः आरंभ करने का प्रयास करें:

# sudo /etc/init.d/httpd restart # Sudo / etc / init.d / httpd पुनः आरंभ
Stopping httpd: [ OK ] रोक httpd: [ठीक]
Starting httpd: [ OK ] शुरू httpd: ठीक है []

There is a lot more customization that can be done to the sudo configuration file. वहाँ एक बहुत अधिक अनुकूलन कि sudo विन्यास फाइल के लिए किया जा सकता है. We have just looked at a small segment of it. हम बस के एक छोटे से क्षेत्र पर ध्यान दिया है. However, this ought to give you a start. बहरहाल, यह तुम्हें देने के लिए एक शुरुआत चाहिए. Again, please use it with caution. फिर से, कृपया इसे सावधानी से उपयोग करें.

Related Posts: संबंधित पोस्ट:
  • How to stop Ubuntu from asking for your sudo password कैसे अपने sudo पासवर्ड के लिए पूछ रहा से Ubuntu रोकने के लिए
  • How to enable the root user account in Ubuntu Linux कैसे Ubuntu Linux में जड़ उपयोगकर्ता खाते में सक्षम करने के लिए
  • How to see a detailed history of the commands run in Linux कैसे Linux में चलाने के आदेश की विस्तृत इतिहास को देखने के लिए
  • How to change the default web browser in Ubuntu कैसे Ubuntu में डिफ़ॉल्ट वेब ब्राउज़र में बदलने के लिए
  • How to install, setup and use Avant Window Navigator (Awn) in Ubuntu Feisty कैसे स्थापित करें, के लिए सेटअप और Ubuntu Feisty में Avant विंडो नेविगेटर (Awn) का उपयोग करें
  • Get Simple Help tutorials just like this one in your email inbox every day - for free! बस अपने ईमेल इनबॉक्स के लिए मुफ्त हर दिन - में यह एक तरह सरल सहायता ट्यूटोरियल जाओ! Just enter your email address below: जरा नीचे अपने ईमेल पते दर्ज करें:

    You can always opt out of this email subscription at any time. तुम हमेशा इस ईमेल सदस्यता से बाहर किसी भी समय विकल्प चुन सकते हैं.

    { 2 trackbacks } (2) trackbacks

    Daily Digest for 2009-01-02 दैनिक 2009/01/02 के लिए डाइजेस्ट
    01.02.09 at 4:03 pm 4:03 पर 01.02.09
    Outrora, eu » Blog Archive » Links dos dias January 6th a January 12th Outrora, यूरोपीय संघ »Blog Archive» कड़ियाँ डॉस dias जनवरी 6 एक जनवरी 12
    01.12.09 at 9:06 am 9:06 पर 01.12.09 हूँ

    { 0 comments… (0 टिप्पणियाँ ... add one now एक अभी जोड़ें } )

    Leave a Comment एक टिप्पणी छोड़ दो

    You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> आप ये HTML टैग और विशेषताएँ: <a href="" उपयोग title=""> <abbr title=""> <acronym कर सकते हैं <blockquote title=""> <b> cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>