{"id":12582,"date":"2021-12-07T04:13:54","date_gmt":"2021-12-07T04:13:54","guid":{"rendered":"https:\/\/linuxways.net\/?p=12582"},"modified":"2021-12-07T04:13:54","modified_gmt":"2021-12-07T04:13:54","slug":"how-to-change-the-default-user-shell-in-linux-os","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/centos\/how-to-change-the-default-user-shell-in-linux-os\/","title":{"rendered":"How to Change the Default User Shell in Linux OS"},"content":{"rendered":"<p>You must have been familiar with the bash shell which we commonly use in the Linux system. In most of the Linux operating systems the default shell is bash but do you know we can change the default bash shell to any other shell like sh, fish, zsh, csh etc. In this article, we will learn how to change the default user shell in Linux OS.<\/p>\n<h2>Find the current shell name<\/h2>\n<p>To change the default user shell, first of all find the current shell you are using. In the Linux system, the default user shell is bash. There is one file named <strong>passwd <\/strong>under the directory \/<strong>etc <\/strong>that stores essential user account information which is needed during the user log in. We can identify the current user shell using that file.<\/p>\n<p>Run the following command to check current user information stored in the file<strong> \/etc\/passwd.<\/strong><\/p>\n<pre>$ grep &lt;current_user&gt; \/etc\/passwd<\/pre>\n<p>Example<\/p>\n<pre>$ grep aayush \/etc\/passwd<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"639\" height=\"91\" class=\"wp-image-12583\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-596.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-596.png 639w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-596-300x43.png 300w\" sizes=\"auto, (max-width: 639px) 100vw, 639px\" \/><\/p>\n<p>In the above example, aayush is the username and bash is the current shell.<\/p>\n<p>Also, you can use echo command to check the current user shell.<\/p>\n<pre>$ echo $SHELL<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"656\" height=\"70\" class=\"wp-image-12584\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-597.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-597.png 656w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-597-300x32.png 300w\" sizes=\"auto, (max-width: 656px) 100vw, 656px\" \/><\/p>\n<h2>List available shells in Linux<\/h2>\n<p>To change the user default shell, we need to find out the available shell lists in the Linux system.<\/p>\n<p>Installed shells can be listed by using the following command.<\/p>\n<pre>$ cat \/etc\/shells<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"697\" height=\"172\" class=\"wp-image-12585\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-598.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-598.png 697w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-598-300x74.png 300w\" sizes=\"auto, (max-width: 697px) 100vw, 697px\" \/><\/p>\n<p>It can be seen that different types of shell such as bash, rbash and dash are available in the system.<\/p>\n<p>Before changing the shell, remember the following things.<\/p>\n<ul>\n<li>Root user can be used to change login shell of other users<\/li>\n<li>If any user account has restricted login shell, then only root user can change the user\u2019s shell<\/li>\n<li>Users will be able to change the shell listed in \/etc\/shells only.<\/li>\n<\/ul>\n<h2>Changing default sh shell to bash shell<\/h2>\n<p>In the Linux operating system, there are many ways to change the default login shell. In this article, we will explain some commonly used methods.<\/p>\n<h3>Using chsh utility<\/h3>\n<p>If you want to change the default user shell then the <strong>chsh<\/strong> utility can be very useful. Run the command <strong>chsh<\/strong> with the option <strong>-s<\/strong> to change the user shell. It also modifies the <strong>\/etc\/passwd<\/strong> file.<\/p>\n<pre>$ chsh -s \/bin\/sh aayush<\/pre>\n<p>Where , aayush is the username and <strong>sh<\/strong> is the shell we are going to change.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"833\" height=\"163\" class=\"wp-image-12586\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-599.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-599.png 833w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-599-300x59.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-599-768x150.png 768w\" sizes=\"auto, (max-width: 833px) 100vw, 833px\" \/><\/p>\n<p>In this example, the default user shell has been changed from bash to sh.<\/p>\n<h3>Using usermod command<\/h3>\n<p>The usermod utility is another way to modify the user account. You just need to specify the option <strong>-s<\/strong> or <strong>-shell<\/strong> to change the default shell for a user. Remember that you need to have a root privileged account to make the changes. Using usermod does not change the user\u2019s current shell but sets a default shell to be used in the next login.<\/p>\n<pre>$ sudo usermod -s \/bin\/bash aayush<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"942\" height=\"230\" class=\"wp-image-12587\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-600.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-600.png 942w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-600-300x73.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-600-768x188.png 768w\" sizes=\"auto, (max-width: 942px) 100vw, 942px\" \/><\/p>\n<p>In the above example, the default shell of the user has been changed from <strong>bash<\/strong> to <strong>sh.<\/strong><\/p>\n<h3>By editing in passwd file<\/h3>\n<p>In the linux system, essential user\u2019s information is stored in the file <strong>\/etc\/passwd<\/strong> which is needed to login. Default user shell can also be changed by manually editing this file. For this edit the file \/etc\/passwd using any text editor and change the shell after the username and home directory of a user and save a file.<\/p>\n<pre>$ sudo vi \/etc\/passwd<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"710\" height=\"62\" class=\"wp-image-12588\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-601.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-601.png 710w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-601-300x26.png 300w\" sizes=\"auto, (max-width: 710px) 100vw, 710px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"728\" height=\"96\" class=\"wp-image-12589\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-602.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-602.png 728w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-602-300x40.png 300w\" sizes=\"auto, (max-width: 728px) 100vw, 728px\" \/><\/p>\n<h3>Change the current user shell<\/h3>\n<p>Changing the current user shell is simple and easy. Just type the shell you want to use in the terminal. But this does not change the default shell for the next login.<\/p>\n<pre>$ rbash<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"610\" height=\"81\" class=\"wp-image-12590\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-603.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-603.png 610w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-603-300x40.png 300w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/p>\n<h2>Conclusion<\/h2>\n<p>In this article, we learned different ways to change default user shell in Linux OS<\/p>\n<p>&nbsp;<\/p>","protected":false},"excerpt":{"rendered":"<p>You must have been familiar with the bash shell which we commonly use in the Linux system. In most of the Linux operating systems the default shell is&hellip;<\/p>","protected":false},"author":1,"featured_media":12778,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,4,5,83,165,2],"tags":[35,725,155],"class_list":["post-12582","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-centos","category-debian","category-mint","category-opensuse","category-red-hat","category-ubuntu","tag-linux","tag-shell","tag-user"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/12582","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=12582"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/12582\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/12778"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=12582"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=12582"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=12582"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}