{"id":3130,"date":"2021-01-08T14:17:39","date_gmt":"2021-01-08T11:17:39","guid":{"rendered":"https:\/\/blog.hostixo.com\/?p=3130"},"modified":"2021-12-15T11:17:03","modified_gmt":"2021-12-15T08:17:03","slug":"linux-sudo-komutu-ve-sudoers-dosyasi","status":"publish","type":"post","link":"https:\/\/www.hostixo.com\/blog\/linux-sudo-komutu-ve-sudoers-dosyasi\/","title":{"rendered":"Linux Sudo Komutu ve Sudoers Dosyas\u0131 Kullan\u0131m\u0131"},"content":{"rendered":"<p>Bu yaz\u0131m\u0131zda size Linux Sudo Komutu ve Sudoers Dosyas\u0131 Kullan\u0131m\u0131 konusundan bahsedece\u011fiz.<\/p>\n<p>Linux sudo komutu root olmayan kullan\u0131c\u0131lar i\u00e7in s\u00fcper kullan\u0131c\u0131 izinleri gerektiren komutlar\u0131 \u00e7al\u0131\u015ft\u0131rmas\u0131na izin vermektedir. Sudoers dosyas\u0131, sistemin sudo komutunu nas\u0131l i\u015flenmesi gerekti\u011fini g\u00f6sterir.<\/p>\n<p>Normal kullan\u0131c\u0131lar\u0131n i\u015fletim sistemlerinde baz\u0131 zamanlar y\u00f6netici yetkisi gerektiren i\u015flemler yapmalar\u0131 gerekir. Sudo normal kullan\u0131c\u0131lar\u0131n sistemde y\u00f6netici yetkisi gerektiren i\u015flemleri yapabilmesi i\u00e7in kullan\u0131lan bir programd\u0131r.<\/p>\n<p>Kullan\u0131c\u0131lar i\u00e7in ayr\u0131 bir y\u00f6netici hesab\u0131 a\u00e7\u0131lmadan ve root parolas\u0131na ihtiya\u00e7 duyulmadan i\u015flemler yap\u0131lmaktad\u0131r. Kullan\u0131c\u0131 yapaca\u011f\u0131 i\u015flemler i\u00e7in kendi ad\u0131n\u0131 kullanaca\u011f\u0131ndan dolay\u0131 yapt\u0131\u011f\u0131 i\u015flemler s\u0131n\u0131rland\u0131r\u0131labilir. Asl\u0131nda en g\u00fcvenilir olan y\u00f6ntem sudo listesine eklenen kullan\u0131c\u0131lara yaln\u0131zca yapacaklar\u0131 i\u015flemler i\u00e7in yetki vermektir.<\/p>\n<h2><span id=\"Linux-Sudo-Komutu-8211-Kavram\">Linux Sudo Komutu \u2013 Kavram<\/span><\/h2>\n<p>Sudo\u2019nun nas\u0131l \u00e7al\u0131\u015ft\u0131\u011f\u0131n\u0131 g\u00f6rmeniz i\u00e7in ilk \u00f6nce SSH \u00fczerinden sunucunuza eri\u015fmeniz gerekmektedir.<\/p>\n<p>Varsay\u0131lan olarak k\u00f6k kullan\u0131c\u0131n\u0131n sudo ekini kullanmas\u0131 gerekmiyor. Bunun nedeni gerekli izinlere sahip olmalar\u0131d\u0131r. K\u00f6k olmayan bir kullan\u0131c\u0131 farkl\u0131 bir kullan\u0131c\u0131 ekleyecekse e\u011fer useradd komutunun yan\u0131na sudo ekini eklemesi gerekmektedir. A\u015fa\u011f\u0131da belirtti\u011fimiz \u015fekilde yapabilirsiniz.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"minimal\">sudo useradd kullan\u0131c\u0131adi<\/pre>\n<p>&nbsp;<\/p>\n<p>Kullan\u0131c\u0131 e\u011fer sudo ekini kullanmazsa <strong>Permission denied (\u0130zin verilmedi)\u00a0<\/strong>mesaj\u0131 ile kar\u015f\u0131la\u015facakt\u0131r.<\/p>\n<h2><span id=\"Sudoers-Dosyasi\">Sudoers Dosyas\u0131<\/span><\/h2>\n<p>Sudo komutu\u00a0<strong>\/etc\/\u00a0<\/strong>dizininde yer alan <strong>sudoers\u00a0<\/strong>dosyas\u0131 \u00fczerinden yap\u0131lmaktad\u0131r.<\/p>\n<p>Sudo komutu sayesinde normal kullan\u0131c\u0131lar i\u00e7in y\u00f6netici seviyesinde izinler verilmektedir. Normalde Ubuntu\u2019yu y\u00fcklerken olu\u015fturdu\u011funuz ilk kullan\u0131c\u0131n\u0131n sudo izni bulunur. Bir <a href=\"https:\/\/www.hostixo.com\/sunucu\/sanal-sunucu\/\" data-internallinksmanager029f6b8e52c=\"3\" title=\"vps sat\u0131n al\">sunucu<\/a> ortam\u0131nda ise varsay\u0131lan k\u00f6k kullan\u0131c\u0131 olmaktad\u0131r. Di\u011fer kullan\u0131c\u0131lar\u0131n da sudo komutunu \u00e7al\u0131\u015ft\u0131rmas\u0131 i\u00e7in ayarlar yapmas\u0131 m\u00fcmk\u00fcn olur. Bu i\u015flem sudoers dosyas\u0131n\u0131n d\u00fczenlenmesi ile yap\u0131labilir.<\/p>\n<div class=\"protip light-purple-box text-light-black\">\n<p><strong>D\u0130KKAT! <\/strong>Sudoers dosyas\u0131n\u0131 hatal\u0131 ya da k\u00f6t\u00fc s\u00f6zdizimi ile editlemek t\u00fcm kullan\u0131c\u0131lar\u0131n kilitlenmesine neden olabilir.<\/p>\n<\/div>\n<h3><span id=\"Sudoers-Dosyasi-Sozdizimi\">Sudoers Dosyas\u0131 S\u00f6zdizimi<\/span><\/h3>\n<p>Sudoers dosyas\u0131n\u0131 tercih etti\u011finiz metin edit\u00f6r\u00fc ile a\u00e7man\u0131z m\u00fcmk\u00fcnd\u00fcr. Biz <strong>vi&#8217; yi <\/strong>tercih ettik:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"minimal\">vi \/etc\/sudoers<\/pre>\n<p>&nbsp;<\/p>\n<p>Bizim sunucumuzdaki dosya bu \u015fekilde g\u00f6r\u00fcnmektedir:<\/p>\n<p><img decoding=\"async\" class=\"alignnone wp-image-3133 size-full lazyload\" data-src=\"https:\/\/www.hostixo.com\/blog\/wp-content\/uploads\/2021\/01\/2021-01-08-1.png\" alt=\"Linux Sudo Komutu ve Sudoers Dosyas\u0131 Kullan\u0131m\u0131\" width=\"915\" height=\"629\" title=\"\" src=\"data:image\/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==\" style=\"--smush-placeholder-width: 915px; --smush-placeholder-aspect-ratio: 915\/629;\"><noscript><img decoding=\"async\" class=\"alignnone wp-image-3133 size-full\" src=\"https:\/\/www.hostixo.com\/blog\/wp-content\/uploads\/2021\/01\/2021-01-08-1.png\" alt=\"Linux Sudo Komutu ve Sudoers Dosyas\u0131 Kullan\u0131m\u0131\" width=\"915\" height=\"629\" title=\"\"><\/noscript><\/p>\n<p>Yukar\u0131da bulunan formatlar ve kurallar\u0131n birka\u00e7\u0131n\u0131 inceleyelim:<\/p>\n<ul>\n<li><strong>#<\/strong> ile ba\u015flayan t\u00fcm sat\u0131rlar yorumlard\u0131r.<\/li>\n<li><strong>root ALL=(ALL:ALL) ALL<\/strong> \u2013 bu ise sat\u0131r k\u00f6k kullan\u0131c\u0131n\u0131n s\u0131n\u0131rs\u0131z izni oldu\u011funu ve sistemde bulunan t\u00fcm komutlar\u0131 \u00e7al\u0131\u015ft\u0131rabilece\u011fini s\u00f6yler.<\/li>\n<li><strong>%admin ALL=(ALL) ALL<\/strong> \u2013 % i\u015fareti bir grubun belirlenmesini sa\u011flar. Y\u00f6netici grubunda bulunan herkes k\u00f6k kullan\u0131c\u0131 ile ayn\u0131 izinlere sahiptir<\/li>\n<li><strong>%sudo \u00a0\u00a0ALL=(ALL:ALL<\/strong><strong>) ALL<\/strong> \u2013 sudo grubunda bulunan t\u00fcm kullan\u0131c\u0131lar\u0131n b\u00fct\u00fcn komutlar\u0131 \u00e7al\u0131\u015ft\u0131rma izninin oldu\u011funu s\u00f6yler.<\/li>\n<\/ul>\n<h3><span id=\"Sudoers-Dosyasini-Duzenlemek\">Sudoers Dosyas\u0131n\u0131 D\u00fczenlemek<\/span><\/h3>\n<p><strong>\/etc\/sudoers\u00a0<\/strong>dosyas\u0131n\u0131 d\u00fczenleme i\u015flemi i\u00e7in a\u015fa\u011f\u0131da belirtti\u011fimiz komutu kullanmal\u0131s\u0131n\u0131z.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"minimal\">sudo visudo -f \/etc\/sudoers<\/pre>\n<p>&nbsp;<\/p>\n<p>Sudoers dosyas\u0131n\u0131 d\u00fczenlemek i\u00e7in visudo kullanman\u0131z\u0131 \u00f6neririz. Visudo sudoers dosyas\u0131 yaln\u0131zca bir kullan\u0131c\u0131 taraf\u0131ndan d\u00fczenlendi\u011finden emin olarak gerekli s\u00f6zdizimi kontrollerini yerine getirir.<\/p>\n<p>Sudo grubunda hangi kullan\u0131c\u0131lar\u0131n yer ald\u0131\u011f\u0131n\u0131 g\u00f6rmek i\u00e7in bir grep komutu kullanmal\u0131s\u0131n\u0131z.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"minimal\">grep \u2018sudo\u2019 \/etc\/group<\/pre>\n<p>&nbsp;<\/p>\n<p>Bu komut size kullan\u0131c\u0131lar\u0131n listesini g\u00f6sterecektir.<\/p>\n<p>\u00d6rnek verecek olursak e\u011fer sudo grubuna ali ad\u0131nda bir kullan\u0131c\u0131n\u0131n eklenmesi i\u00e7in komut sat\u0131r\u0131nda <strong>adduser\u00a0<\/strong>komutunu kullanmal\u0131s\u0131n\u0131z.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"minimal\">adduser bill sudo<\/pre>\n<p>&nbsp;<\/p>\n<p>Grupta kimin olup olmad\u0131\u011f\u0131n\u0131 g\u00f6rmek i\u00e7in e\u011fer grep komutunu kullan\u0131rsan\u0131z ali ad\u0131nda kullan\u0131c\u0131 ad\u0131n\u0131 g\u00f6r\u00fcrs\u00fcn\u00fcz.<\/p>\n<p>Herhangi bir kullan\u0131c\u0131ya k\u00f6k izinlerini vermek isterseniz e\u011fer yapman\u0131z gereken tek \u015fey onlar\u0131 sudo\u2019ya eklemek olacakt\u0131r.<\/p>\n<p>Sudo\u2019dan bir kullan\u0131c\u0131 silmek i\u00e7in a\u015fa\u011f\u0131da belirtti\u011fimiz komutu kullanmal\u0131s\u0131n\u0131z.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"minimal\">deluser ali sudo<\/pre>\n<p>&nbsp;<\/p>\n<p>Deluser komutu ali kullan\u0131c\u0131s\u0131n\u0131 sudo grubundan silecektir.<\/p>\n<p>Art\u0131k ali kullan\u0131c\u0131s\u0131 sudo izni gerektiren i\u015flemleri yapamayacakt\u0131r.<\/p>\n<h3><span id=\"Belirli-Izinler-Vermek-Icin-Sudoers-Dosyasini-Kullanma\">Belirli \u0130zinler Vermek \u0130\u00e7in Sudoers Dosyas\u0131n\u0131n Kullan\u0131m\u0131<\/span><\/h3>\n<p>Ali adl\u0131 kullan\u0131c\u0131n\u0131n sudo izniyle yaln\u0131zca a\u011f komutlar\u0131<em>\u00a0<\/em>gibi belirli komutlarda ki i\u015flemleri yapmas\u0131n\u0131 isterseniz yaz\u0131m\u0131z\u0131 okumaya devam ediniz.<\/p>\n<p>Bu i\u015flemi yapmak olduk\u00e7a basittir. <strong>\/etc\/sudoers.d\/\u00a0<\/strong>dizininde networking ad\u0131 ile bir dosya olu\u015fturun.<\/p>\n<p>Bu dosyan\u0131n olu\u015fturulmas\u0131 i\u00e7in a\u015fa\u011f\u0131da belirtti\u011fimiz komutu \u00e7al\u0131\u015ft\u0131rmal\u0131s\u0131n\u0131z.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"minimal\">sudo visudo -f \/etc\/sudoers.d\/networking<\/pre>\n<p>&nbsp;<\/p>\n<p>Dosyaya a\u015fa\u011f\u0131da yer alan metni eklemelisiniz.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"minimal\">Cmnd_Alias \u00a0\u00a0\u00a0\u00a0CAPTURE = \/usr\/sbin\/tcdump\r\nCmnd_Alias \u00a0\u00a0\u00a0\u00a0SERVERS = \/usr\/sbin apache2ctl, \/usr\/bin\/htpasswd \r\nCmnd_Alias \u00a0\u00a0\u00a0\u00a0NETALL = CAPTURE, SERVERS\r\n%netadmin ALL=NETALL<\/pre>\n<p>&nbsp;<\/p>\n<p>Yukar\u0131da belirtti\u011fimiz dosyada yapt\u0131\u011f\u0131m\u0131z i\u015flem bir netadmin grubu kurmakt\u0131. Netadmin grubunda bulunan\u00a0 kullan\u0131c\u0131lar NETALL i\u00e7inde yer alan t\u00fcm komutlar\u0131 \u00e7al\u0131\u015ft\u0131rma yetkisine sahiptir. NETALL ise CAPTURE ve SERVERS adlar\u0131 alt\u0131nda bulunan t\u00fcm komutlar\u0131 i\u00e7erir. tcpdump komutu, CAPTURE ad\u0131 alt\u0131nda yer al\u0131r. \u00d6rnek verecek olursak e\u011fer <strong>\/usr\/sbin\/tcpdump\u00a0<\/strong>\u015feklinde olacakt\u0131r.<\/p>\n<p>\u015eimdi ali adl\u0131 kullan\u0131c\u0131 netadmin grubuna ekleyece\u011fiz.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"minimal\">sudo adduser ali netadmin<\/pre>\n<p>&nbsp;<\/p>\n<p>Ali adl\u0131 kullan\u0131c\u0131 bundan sonra\u00a0 tcpdump komutu ile birlikte a\u011f ile alakal\u0131 t\u00fcm komutlar\u0131 \u00e7al\u0131\u015ft\u0131racakt\u0131r.<\/p>\n<h2>Sonu\u00e7<\/h2>\n<p>Birden fazla kullan\u0131c\u0131 ile \u00e7al\u0131\u015f\u0131yorsan\u0131z e\u011fer linux sudo komutunun nas\u0131l \u00e7al\u0131\u015ft\u0131\u011f\u0131n\u0131 ve sudoers dosyas\u0131n\u0131n nas\u0131l d\u00fczenlendi\u011fini bilmeniz \u00e7ok \u00f6nemlidir.<\/p>\n<p>Linux Sudo Komutu ve Sudoers Dosyas\u0131 Kullan\u0131m\u0131 ba\u015fl\u0131kl\u0131 yaz\u0131m\u0131z ile ilgili akl\u0131n\u0131za tak\u0131lan sorular\u0131n\u0131z\u0131n yan\u0131t\u0131n\u0131 alabilmeniz i\u00e7in veya \u00f6neride bulunabilmeniz i\u00e7in a\u015fa\u011f\u0131da yer alan yorumlar k\u0131sm\u0131n\u0131 kullanarak bizimle ileti\u015fime ge\u00e7ebilirsiniz.<\/p>\n<p>Dilerseniz daha \u00f6nce blo\u011fumuzda payla\u015ft\u0131\u011f\u0131m\u0131z <a href=\"https:\/\/www.hostixo.com\/blog\/linux-ssh-port-degistirme\/\">Linux SSH Port De\u011fi\u015ftirme<\/a>\u00a0ba\u015fl\u0131kl\u0131 yaz\u0131m\u0131z\u0131 da okuyabilirsiniz.<\/p>\n<p><script type=\"application\/ld+json\">\n{\n  \"@context\": \"https:\/\/schema.org\/\", \n  \"@type\": \"Product\", \n  \"name\": \"Hostixo Blog\",\n  \"image\": \"https:\/\/www.hostixo.com\/blog\/\",\n  \"description\": \"Hostixo Blog\",\n  \"brand\": \"HostixoBlog1\",\n  \"sku\": \"HostixoBlog1\",\n  \"gtin8\": \"HostixoBlog1\",\n  \"gtin13\": \"HostixoBlog1\",\n  \"gtin14\": \"HostixoBlog1\",\n  \"mpn\": \"HostixoBlog1\",\n  \"offers\": {\n    \"@type\": \"Offer\",\n    \"url\": \"https:\/\/www.hostixo.com\/blog\/\",\n    \"priceCurrency\": \"TRY\",\n    \"price\": \"0.99\",\n    \"priceValidUntil\": \"2020-06-09\",\n    \"availability\": \"https:\/\/schema.org\/InStock\",\n    \"itemCondition\": \"https:\/\/schema.org\/NewCondition\"\n  },\n  \"aggregateRating\": {\n    \"@type\": \"AggregateRating\",\n   \"ratingValue\": \"5\",\n    \"bestRating\": \"5\",\n    \"worstRating\": \"4\",\n    \"ratingCount\": \"1456\",\n    \"reviewCount\": \"1446\"\n  },\n  \"review\": {\n    \"@type\": \"Review\",\n    \"name\": \"HostixoBlog1\",\n    \"reviewBody\": \"Hostixo Blog\",\n    \"reviewRating\": {\n      \"@type\": \"Rating\",\n   \"ratingValue\": \"5\",\n      \"bestRating\": \"5\",\n      \"worstRating\": \"4\"\n    },\n    \"datePublished\": \"2020-06-09\",\n    \"author\": {\"@type\": \"Person\", \"name\": \"Hostixo\"},\n    \"publisher\": {\"@type\": \"Organization\", \"name\": \"HostixoBlog1\"}\n  }\n}\n<\/script><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Bu yaz\u0131m\u0131zda size Linux Sudo Komutu ve Sudoers Dosyas\u0131 Kullan\u0131m\u0131 konusundan bahsedece\u011fiz. Linux sudo komutu root olmayan kullan\u0131c\u0131lar i\u00e7in s\u00fcper kullan\u0131c\u0131 izinleri gerektiren komutlar\u0131 \u00e7al\u0131\u015ft\u0131rmas\u0131na izin vermektedir. Sudoers dosyas\u0131, sistemin sudo komutunu nas\u0131l i\u015flenmesi gerekti\u011fini g\u00f6sterir. Normal kullan\u0131c\u0131lar\u0131n i\u015fletim sistemlerinde baz\u0131 zamanlar y\u00f6netici yetkisi gerektiren i\u015flemler yapmalar\u0131 gerekir. Sudo normal kullan\u0131c\u0131lar\u0131n sistemde y\u00f6netici yetkisi gerektiren &hellip;<\/p>\n","protected":false},"author":1,"featured_media":3135,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_mbp_gutenberg_autopost":false,"footnotes":""},"categories":[29],"tags":[],"class_list":["post-3130","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.hostixo.com\/blog\/wp-json\/wp\/v2\/posts\/3130","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostixo.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostixo.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostixo.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostixo.com\/blog\/wp-json\/wp\/v2\/comments?post=3130"}],"version-history":[{"count":0,"href":"https:\/\/www.hostixo.com\/blog\/wp-json\/wp\/v2\/posts\/3130\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.hostixo.com\/blog\/wp-json\/wp\/v2\/media\/3135"}],"wp:attachment":[{"href":"https:\/\/www.hostixo.com\/blog\/wp-json\/wp\/v2\/media?parent=3130"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostixo.com\/blog\/wp-json\/wp\/v2\/categories?post=3130"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostixo.com\/blog\/wp-json\/wp\/v2\/tags?post=3130"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}