{"id":5843,"date":"2021-03-01T06:24:40","date_gmt":"2021-03-01T06:24:40","guid":{"rendered":"https:\/\/miloserdov.org\/?p=5843"},"modified":"2021-03-01T12:50:49","modified_gmt":"2021-03-01T12:50:49","slug":"how-to-run-terminal-as-root-in-kali-linux-how-to-run-a-gui-program-as-root","status":"publish","type":"post","link":"https:\/\/miloserdov.org\/?p=5843","title":{"rendered":"How to run terminal as root in Kali Linux? How to run a GUI program as root"},"content":{"rendered":"<div class=\"0b20205ac99e89c6cabdb919fd9d1a8a\" data-index=\"1\" style=\"float: none; margin:10px 0 10px 0; text-align:center;\">\n<script async src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script>\r\n<ins class=\"adsbygoogle\"\r\n     style=\"display:block; text-align:center;\"\r\n     data-ad-format=\"fluid\"\r\n     data-ad-layout=\"in-article\"\r\n     data-ad-client=\"ca-pub-7219829351026140\"\r\n     data-ad-slot=\"9942251718\"><\/ins>\r\n<script>\r\n     (adsbygoogle = window.adsbygoogle || []).push({});\r\n<\/script>\r\n\r\n\n<\/div>\n<h2 style=\"text-align: justify;\">\n\tWhat needs to be done to make the terminal run as root?<br \/>\n<\/h2>\n<p style=\"text-align: justify;\">\n\tLet&#39;s consider several options\n<\/p>\n<h3 style=\"text-align: justify;\">\n\t1. Switch to root user<br \/>\n<\/h3>\n<p style=\"text-align: justify;\">\n\tIn recent versions of Kali Linux, the default user has changed: before it was root, and now it is a regular user.\n<\/p>\n<p style=\"text-align: justify;\">\n\tIf you want to revert to the previous option, that is, make the root user the main user, then this is possible.\n<\/p>\n<p style=\"text-align: justify;\">\n\tFirst, set the root password:\n<\/p>\n<pre class=\"brush:bash;\" style=\"text-align: justify;\">\r\nsudo passwd root<\/pre>\n<p style=\"text-align: justify;\">\n\t<a href=\"https:\/\/miloserdov.org\/wp-content\/uploads\/2021\/03\/passwd.png\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" class=\"alignnone size-full wp-image-5848\" height=\"282\" src=\"https:\/\/miloserdov.org\/wp-content\/uploads\/2021\/03\/passwd.png\" width=\"406\" \/><\/a>\n<\/p>\n<p style=\"text-align: justify;\">\n\tNow, when you turn on your computer, you can log in as root:\n<\/p>\n<p style=\"text-align: justify;\">\n\t<a href=\"https:\/\/miloserdov.org\/wp-content\/uploads\/2021\/03\/root-login.png\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" class=\"alignnone size-full wp-image-5847\" height=\"250\" src=\"https:\/\/miloserdov.org\/wp-content\/uploads\/2021\/03\/root-login.png\" width=\"404\" \/><\/a>\n<\/p>\n<p style=\"text-align: justify;\">\n\tAs a result, all opened terminals will have elevated privileges.\n<\/p>\n<p style=\"text-align: justify;\">\n\t<a href=\"https:\/\/miloserdov.org\/wp-content\/uploads\/2021\/03\/whoami.png\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" class=\"alignnone size-full wp-image-5846\" height=\"315\" src=\"https:\/\/miloserdov.org\/wp-content\/uploads\/2021\/03\/whoami.png\" width=\"551\" \/><\/a>\n<\/p>\n<h3 style=\"text-align: justify;\">\n\t2. Open a root session<br \/>\n<\/h3>\n<p style=\"text-align: justify;\">\n\tStart a terminal with as a normal user and run in it:\n<\/p>\n<pre class=\"brush:bash;\" style=\"text-align: justify;\">\r\nsudo su -<\/pre>\n<p style=\"text-align: justify;\">\n\tA root user session will be opened, all commands will be executed with elevated privileges.\n<\/p>\n<p style=\"text-align: justify;\">\n\t<a href=\"https:\/\/miloserdov.org\/wp-content\/uploads\/2021\/03\/su.png\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" class=\"alignnone size-full wp-image-5845\" height=\"433\" src=\"https:\/\/miloserdov.org\/wp-content\/uploads\/2021\/03\/su.png\" width=\"719\" \/><\/a>\n<\/p>\n<p style=\"text-align: justify;\">\n\tAnother option to start a session with elevated privileges is to run the following command:\n<\/p>\n<pre class=\"brush:bash;\">\r\nsudo bash<\/pre>\n<p style=\"text-align: justify;\">\n\tTo end the root session press <strong>Ctrl+d<\/strong>.\n<\/p>\n<h3 style=\"text-align: justify;\">\n\t3. Using sudo, including with internal Bash commands<br \/>\n<\/h3>\n<p style=\"text-align: justify;\">\n\tIn fact, few commands require superuser rights. And for those that require root privileges, just run them with sudo:\n<\/p>\n<pre class=\"brush:bash;\" style=\"text-align: justify;\">\r\nsudo COMMAND<\/pre>\n<p style=\"text-align: justify;\">\n\tBut what if we need to add a line to a file requiring elevated privileges with the following command:\n<\/p>\n<pre class=\"brush:bash;\" style=\"text-align: justify;\">\r\nsudo echo &quot;something&quot; &gt;&gt; \/etc\/file_requiring_elevated_privileges<\/pre>\n<p style=\"text-align: justify;\">\n\tThe command must be executed with elevated privileges, which should give write permissions to the file. But in this case, neither <strong>&gt;<\/strong> nor <strong>&gt;&gt;<\/strong> can be used, including as root. And an error like this will be displayed:\n<\/p>\n<pre class=\"brush:plain;\" style=\"text-align: justify;\">\r\nbash: \/etc\/file: Access Denied<\/pre>\n<p style=\"text-align: justify;\">\n\tYou can work around this problem by opening a superuser session:\n<\/p>\n<pre class=\"brush:bash;\" style=\"text-align: justify;\">\r\nsudo su -<\/pre>\n<p style=\"text-align: justify;\">\n\tOr with the tee command. Use it with the <strong>&#8211;append<\/strong> or <strong>-a<\/strong> options &#8211; this is important, without these options the file will be completely overwritten. Example:\n<\/p>\n<pre class=\"brush:bash;\" style=\"text-align: justify;\">\r\necho &#39;new line&#39; | sudo tee --append \/etc\/apt\/sources.list<\/pre>\n<p style=\"text-align: justify;\">\n\tThe above command will append a new line to the existing file.\n<\/p>\n<p style=\"text-align: justify;\">\n\tBut the peculiarity of the tee command is that it will not only add the file, but also print the added line to the console. If you do not want the data to be returned to the console again, then redirect the output to <strong>\/dev\/null<\/strong>.\n<\/p>\n<p style=\"text-align: justify;\">\n\tExample:\n<\/p>\n<pre class=\"brush:bash;\" style=\"text-align: justify;\">\r\necho &#39;new line&#39; | sudo tee --append \/etc\/apt\/sources.list &gt; \/dev\/null<\/pre>\n<p style=\"text-align: justify;\">\n\tThis will work in a similar way, but no &#39;new line&#39; will be displayed.\n<\/p>\n<p style=\"text-align: justify;\">\n\tAnother use case for echo to write or add to a file as administrator:\n<\/p>\n<pre class=\"brush:bash;\" style=\"text-align: justify;\">\r\nsudo sh -c &quot;echo &#39;something&#39; &gt;&gt; \/etc\/privilegedfile&quot;<\/pre>\n<p style=\"text-align: justify;\">\n\tThe command uses both single and double quotes, which means that if the string you add to the file also contains quotes, then they must be escaped with backslashes.\n<\/p>\n<h3 style=\"text-align: justify;\">\n\t4. Using sudo without a password<br \/>\n<\/h3>\n<p style=\"text-align: justify;\">\n\tIf it is not a problem for you to add sudo before commands, but you do not like entering a password every time, then the following command will allow you to run commands with sudo and will not be prompted for a password:\n<\/p>\n<pre class=\"brush:bash;\" style=\"text-align: justify;\">\r\necho &#39;%sudo ALL=(ALL) NOPASSWD: ALL&#39; | sudo tee --append \/etc\/sudoers<\/pre>\n<p style=\"text-align: justify;\">\n\tUse this only if you understand the security risks!\n<\/p>\n<h2 style=\"text-align: justify;\">\n\tHow to run a GUI program as root<br \/>\n<\/h2>\n<p style=\"text-align: justify;\">\n\tAny program, including those with a graphical interface, can be run as root. This is usually required for file managers and text editors, so that it is convenient to navigate through folders and edit files with limited access.\n<\/p>\n<p style=\"text-align: justify;\">\n\tIn fact, everything starts in the same way as with the console utilities:\n<\/p>\n<pre class=\"brush:bash;\" style=\"text-align: justify;\">\r\nsudo COMMAND<\/pre>\n<p style=\"text-align: justify;\">\n\tBut you need to know the name of the command. You can find out the name of the command using the following algorithm:\n<\/p>\n<ul>\n<li style=\"text-align: justify;\">\n\t\topen the program you want to run as root\n\t<\/li>\n<li style=\"text-align: justify;\">\n\t\tlook at the menu item &ldquo;About the program&rdquo;.\n\t<\/li>\n<\/ul>\n<p style=\"text-align: justify;\">\n\tFor example, a popular text editor with root privileges can be started like this:\n<\/p>\n<pre class=\"brush:bash;\" style=\"text-align: justify;\">\r\nsudo gedit \/PATH\/TO\/FILE<\/pre>\n<p style=\"text-align: justify;\">\n\tOn Kali Linux (Xfce), the file manager executable is called <strong>thunar<\/strong>. You can run it as root like this:\n<\/p>\n<pre class=\"brush:bash;\" style=\"text-align: justify;\">\r\nsudo thunar<\/pre>\n<p style=\"text-align: justify;\">\n\tYou can also specify the folder you want to open:\n<\/p>\n<pre class=\"brush:bash;\" style=\"text-align: justify;\">\r\nsudo thunar \/etc<\/pre>\n<p style=\"text-align: justify;\">\n\t<a href=\"https:\/\/miloserdov.org\/wp-content\/uploads\/2021\/03\/thunar.png\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" class=\"alignnone size-full wp-image-5844\" height=\"673\" src=\"https:\/\/miloserdov.org\/wp-content\/uploads\/2021\/03\/thunar.png\" width=\"959\" srcset=\"https:\/\/miloserdov.org\/wp-content\/uploads\/2021\/03\/thunar.png 959w, https:\/\/miloserdov.org\/wp-content\/uploads\/2021\/03\/thunar-768x539.png 768w\" sizes=\"(max-width: 959px) 100vw, 959px\" \/><\/a>\n<\/p>\n<p style=\"text-align: justify;\">\n\tIn Cinnamon, the file manager is called <strong>Nemo<\/strong>, run as root:\n<\/p>\n<pre class=\"brush:bash;\" style=\"text-align: justify;\">\r\nsudo nemo<\/pre>\n<p style=\"text-align: justify;\">\n\tYou can also specify the folder to open:\n<\/p>\n<pre class=\"brush:bash;\" style=\"text-align: justify;\">\r\nsudo nemo \/etc\r\n<\/pre>\n\n<div style=\"font-size: 0px; height: 0px; line-height: 0px; margin: 0; padding: 0; clear: both;\"><\/div>","protected":false},"excerpt":{"rendered":"<p>What needs to be done to make the terminal run as root? Let&#39;s consider several options 1. Switch to root user In recent versions of Kali Linux, the default user has changed: before it was root, and now it is a regular user. If you want to revert to the<a href=\"https:\/\/miloserdov.org\/?p=5843\" class=\"read-more\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":5847,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19],"tags":[675,86,25,85,502,674,673],"class_list":["post-5843","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-work-environment","tag-echo","tag-gui","tag-kali-linux","tag-linux-command-line","tag-root","tag-su","tag-sudo"],"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/miloserdov.org\/index.php?rest_route=\/wp\/v2\/posts\/5843"}],"collection":[{"href":"https:\/\/miloserdov.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/miloserdov.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/miloserdov.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/miloserdov.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5843"}],"version-history":[{"count":3,"href":"https:\/\/miloserdov.org\/index.php?rest_route=\/wp\/v2\/posts\/5843\/revisions"}],"predecessor-version":[{"id":5857,"href":"https:\/\/miloserdov.org\/index.php?rest_route=\/wp\/v2\/posts\/5843\/revisions\/5857"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/miloserdov.org\/index.php?rest_route=\/wp\/v2\/media\/5847"}],"wp:attachment":[{"href":"https:\/\/miloserdov.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5843"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/miloserdov.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5843"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/miloserdov.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5843"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}