{"id":226,"date":"2022-12-07T10:29:45","date_gmt":"2022-12-07T13:29:45","guid":{"rendered":"https:\/\/gpads.recife.ifpe.edu.br\/alsm\/csin\/?p=226"},"modified":"2022-12-07T10:30:14","modified_gmt":"2022-12-07T13:30:14","slug":"como-mudar-o-padrao-de-inicializacao-runlevel-em-sistemas-com-systemd","status":"publish","type":"post","link":"https:\/\/gpads.recife.ifpe.edu.br\/alsm\/csin\/index.php\/2022\/12\/07\/como-mudar-o-padrao-de-inicializacao-runlevel-em-sistemas-com-systemd\/","title":{"rendered":"Como mudar o padr\u00e3o de inicializa\u00e7\u00e3o (runlevel) em sistemas com systemd"},"content":{"rendered":"\n<p>Alguns sistemas Linux, principalmente os que s\u00e3o feitos com base no Debian, usam o processo de inicializa\u00e7\u00e3o <strong>systemd<\/strong>. Estes sistemas utilizam <strong>targets<\/strong> ao inv\u00e9s de <strong>run-levels<\/strong>. Com isso o arquivo <code><strong>\/etc\/inittab<\/strong><\/code> n\u00e3o \u00e9 mais utilizado. Quando precisa montar um sistema como servidor e n\u00e3o quer uma inicializa\u00e7\u00e3o do ambiente gr\u00e1fico, o ideal \u00e9 que o mesmo inicialize com o modo texto.<\/p>\n\n\n\n<p>Modifica\u00e7\u00f5es no <strong>systemd<\/strong> podem ser feitas utilizando o comando <strong><code>systemctl<\/code><\/strong> ou fazendo link simb\u00f3licos para o n\u00edvel apropriado. Seguem m\u00e9todos de mudan\u00e7a:<\/p>\n\n\n\n<h2 class=\"has-vivid-purple-color has-text-color wp-block-heading\"><strong>M\u00e9todo 1<\/strong><\/h2>\n\n\n\n<p>Para verificar o n\u00edvel de execu\u00e7\u00e3o do sistema atual, digite o seguinte comando:<\/p>\n\n\n\n<pre class=\"wp-block-code has-black-color has-text-color has-background\" style=\"background-color:#ababab\"><code lang=\"bash\" class=\"language-bash\">sudo systemctl get-default<\/code><\/pre>\n\n\n\n<p>a sa\u00edda ser\u00e1:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">graphical.target<\/code><\/pre>\n\n\n\n<p>Podemos observar que a inicializa\u00e7\u00e3o padr\u00e3o est\u00e1 para modo gr\u00e1fico. Antes de mudar, \u00e9 bom verificar quais os tipos dispon\u00edveis no sistema. O mesmo pode ser feito com o comando:<\/p>\n\n\n\n<pre class=\"wp-block-code has-black-color has-text-color has-background\" style=\"background-color:#ababab\"><code lang=\"bash\" class=\"language-bash\">sudo systemctl list-units --type=target<\/code><\/pre>\n\n\n\n<p>A sa\u00edda ser\u00e1:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">UNIT                   LOAD   ACTIVE SUB    DESCRIPTION\nbasic.target           loaded active active Basic System\ncryptsetup.target      loaded active active Encrypted Volumes\ngetty.target           loaded active active Login Prompts\ngraphical.target       loaded active active Graphical Interface\nlocal-fs-pre.target    loaded active active Local File Systems (Pre)\nlocal-fs.target        loaded active active Local File Systems\nmulti-user.target      loaded active active Multi-User System\nnetwork-online.target  loaded active active Network is Online\nnetwork.target         loaded active active Network\nnss-user-lookup.target loaded active active User and Group Name Lookups\npaths.target           loaded active active Paths\nremote-fs.target       loaded active active Remote File Systems\nslices.target          loaded active active Slices\nsockets.target         loaded active active Sockets\nsound.target           loaded active active Sound Card\nswap.target            loaded active active Swap\nsysinit.target         loaded active active System Initialization\ntime-sync.target       loaded active active System Time Synchronized\ntimers.target          loaded active active Timers\n\nLOAD   = Reflects whether the unit definition was properly loaded.\nACTIVE = The high-level unit activation state, i.e. generalization of SUB.\nSUB    = The low-level unit activation state, values depend on unit type.<\/code><\/pre>\n\n\n\n<p>Para mudar a inicializa\u00e7\u00e3o para o antigo modo 3 (terminal), utilizaremos o padr\u00e3o multi usu\u00e1rio. Para isso execute o seguinte comando:<\/p>\n\n\n\n<pre class=\"wp-block-code has-black-color has-text-color has-background\" style=\"background-color:#ababab\"><code lang=\"bash\" class=\"language-bash\">sudo systemctl set-default multi-user.target<\/code><\/pre>\n\n\n\n<p>Confirme executando o comando passado inicialmente neste post e a sa\u00edda ser\u00e1:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">multi-user.target<\/code><\/pre>\n\n\n\n<p>Para que as altera\u00e7\u00f5es tenham efeito, reinicie o sistema, ou pelo comando reboot ou shutdown.<\/p>\n\n\n\n<h2 class=\"has-vivid-purple-color has-text-color wp-block-heading\"><strong>M\u00e9todo 2<\/strong><\/h2>\n\n\n\n<p>Outra forma \u00e9 pelos links simb\u00f3licos. Os arquivos est\u00e3o ligados dentro da pasta <code><strong>\/lib\/systemd\/system<\/strong><\/code> , desta forma alterando o link nesta pasta estaremos alterando a inicializa\u00e7\u00e3o do sistema. Observe o exemplo a seguir, supondo que a inicializa\u00e7\u00e3o padr\u00e3o est\u00e1 em modo gr\u00e1fico e gostar\u00edamos de inicializar e modo texto e com suporte a multi usu\u00e1rio:<\/p>\n\n\n\n<pre class=\"wp-block-code has-black-color has-text-color has-background\" style=\"background-color:#ababab\"><code lang=\"bash\" class=\"language-bash\">sudo ln -sf \/lib\/systemd\/system\/runlevel3.target \/etc\/systemd\/system\/default.target<\/code><\/pre>\n\n\n\n<p>ou<\/p>\n\n\n\n<pre class=\"wp-block-code has-black-color has-text-color has-background\" style=\"background-color:#ababab\"><code lang=\"bash\" class=\"language-bash\">sudo ln -sf \/lib\/systemd\/system\/multi-user.target \/etc\/systemd\/system\/default.target<\/code><\/pre>\n\n\n\n<p>Verifique se est\u00e1 tudo certo com o comando <code><strong>sudo systemctl get-default<\/strong><\/code> dever\u00e1 aparecer como padr\u00e3o multi usu\u00e1rio. Confirme reiniciando o sistema.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Alguns sistemas Linux, principalmente os que s\u00e3o feitos com base no Debian, usam o processo de inicializa\u00e7\u00e3o systemd. Estes sistemas utilizam targets ao inv\u00e9s de run-levels. Com isso o arquivo \/etc\/inittab n\u00e3o \u00e9 mais utilizado. Quando precisa montar um sistema como servidor e n\u00e3o quer uma inicializa\u00e7\u00e3o do ambiente gr\u00e1fico, o ideal \u00e9 que o [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[29,27,28],"class_list":["post-226","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-config","tag-linux","tag-systemd"],"_links":{"self":[{"href":"https:\/\/gpads.recife.ifpe.edu.br\/alsm\/csin\/index.php\/wp-json\/wp\/v2\/posts\/226","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gpads.recife.ifpe.edu.br\/alsm\/csin\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gpads.recife.ifpe.edu.br\/alsm\/csin\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gpads.recife.ifpe.edu.br\/alsm\/csin\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gpads.recife.ifpe.edu.br\/alsm\/csin\/index.php\/wp-json\/wp\/v2\/comments?post=226"}],"version-history":[{"count":8,"href":"https:\/\/gpads.recife.ifpe.edu.br\/alsm\/csin\/index.php\/wp-json\/wp\/v2\/posts\/226\/revisions"}],"predecessor-version":[{"id":234,"href":"https:\/\/gpads.recife.ifpe.edu.br\/alsm\/csin\/index.php\/wp-json\/wp\/v2\/posts\/226\/revisions\/234"}],"wp:attachment":[{"href":"https:\/\/gpads.recife.ifpe.edu.br\/alsm\/csin\/index.php\/wp-json\/wp\/v2\/media?parent=226"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gpads.recife.ifpe.edu.br\/alsm\/csin\/index.php\/wp-json\/wp\/v2\/categories?post=226"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gpads.recife.ifpe.edu.br\/alsm\/csin\/index.php\/wp-json\/wp\/v2\/tags?post=226"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}