Why the login-shell is bash, but the /bin/sh is the link of dash? [duplicate]












0















This question already has an answer here:




  • What is the point of sh being linked to dash?

    4 answers




Generally,the value of environment variable SHELL is /bin/bash, it means normal shell environment is Bash,However,the /bin/sh is the link of Dash, what is the Dash effect?



Another question: Although our shell environment is bash, why sometimes it will go wrong because of dash?










share|improve this question









New contributor




liaoweizhi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











marked as duplicate by karel, Eric Carvalho, Community Dec 26 at 12:31


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.















  • Welcome to Ask Ubuntu. Maybe this will help - wiki.ubuntu.com/DashAsBinSh , which states "The major reason to switch the default shell was efficiency. bash is an excellent full-featured shell appropriate for interactive use; indeed, it is still the default login shell. However, it is rather large and slow to start up and operate by comparison with dash"
    – guiverc
    Dec 26 at 7:07


















0















This question already has an answer here:




  • What is the point of sh being linked to dash?

    4 answers




Generally,the value of environment variable SHELL is /bin/bash, it means normal shell environment is Bash,However,the /bin/sh is the link of Dash, what is the Dash effect?



Another question: Although our shell environment is bash, why sometimes it will go wrong because of dash?










share|improve this question









New contributor




liaoweizhi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











marked as duplicate by karel, Eric Carvalho, Community Dec 26 at 12:31


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.















  • Welcome to Ask Ubuntu. Maybe this will help - wiki.ubuntu.com/DashAsBinSh , which states "The major reason to switch the default shell was efficiency. bash is an excellent full-featured shell appropriate for interactive use; indeed, it is still the default login shell. However, it is rather large and slow to start up and operate by comparison with dash"
    – guiverc
    Dec 26 at 7:07
















0












0








0








This question already has an answer here:




  • What is the point of sh being linked to dash?

    4 answers




Generally,the value of environment variable SHELL is /bin/bash, it means normal shell environment is Bash,However,the /bin/sh is the link of Dash, what is the Dash effect?



Another question: Although our shell environment is bash, why sometimes it will go wrong because of dash?










share|improve this question









New contributor




liaoweizhi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












This question already has an answer here:




  • What is the point of sh being linked to dash?

    4 answers




Generally,the value of environment variable SHELL is /bin/bash, it means normal shell environment is Bash,However,the /bin/sh is the link of Dash, what is the Dash effect?



Another question: Although our shell environment is bash, why sometimes it will go wrong because of dash?





This question already has an answer here:




  • What is the point of sh being linked to dash?

    4 answers








bash unity-dash






share|improve this question









New contributor




liaoweizhi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




liaoweizhi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited Dec 26 at 9:49









SurvivalMachine

1,2473717




1,2473717






New contributor




liaoweizhi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Dec 26 at 6:58









liaoweizhi

11




11




New contributor




liaoweizhi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





liaoweizhi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






liaoweizhi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




marked as duplicate by karel, Eric Carvalho, Community Dec 26 at 12:31


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






marked as duplicate by karel, Eric Carvalho, Community Dec 26 at 12:31


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • Welcome to Ask Ubuntu. Maybe this will help - wiki.ubuntu.com/DashAsBinSh , which states "The major reason to switch the default shell was efficiency. bash is an excellent full-featured shell appropriate for interactive use; indeed, it is still the default login shell. However, it is rather large and slow to start up and operate by comparison with dash"
    – guiverc
    Dec 26 at 7:07




















  • Welcome to Ask Ubuntu. Maybe this will help - wiki.ubuntu.com/DashAsBinSh , which states "The major reason to switch the default shell was efficiency. bash is an excellent full-featured shell appropriate for interactive use; indeed, it is still the default login shell. However, it is rather large and slow to start up and operate by comparison with dash"
    – guiverc
    Dec 26 at 7:07


















Welcome to Ask Ubuntu. Maybe this will help - wiki.ubuntu.com/DashAsBinSh , which states "The major reason to switch the default shell was efficiency. bash is an excellent full-featured shell appropriate for interactive use; indeed, it is still the default login shell. However, it is rather large and slow to start up and operate by comparison with dash"
– guiverc
Dec 26 at 7:07






Welcome to Ask Ubuntu. Maybe this will help - wiki.ubuntu.com/DashAsBinSh , which states "The major reason to switch the default shell was efficiency. bash is an excellent full-featured shell appropriate for interactive use; indeed, it is still the default login shell. However, it is rather large and slow to start up and operate by comparison with dash"
– guiverc
Dec 26 at 7:07












2 Answers
2






active

oldest

votes


















0














General comment about sh



The shell sh is a symbolic link to dash, which is a shell with a very light foot-print. It means that it can work quickly and will not use much memory. But the built-in commands are few, simple and have different syntax compared to more advanced shells (for example bash).



Both shells (sh and bash) are useful but for different purposes.



How to make a shellscript run by bash



If you run a text file with commands, a shellscript, you can force it to run by a certain shell. Otherwise it may default to a shell, that does does not work as intended, for example because some built-in command does not exist or the syntax for a built-in command is different.



So in order to make a shellscript run with bash, you can force it





  • by calling it from bash



    bash shellscriptname



  • by writing a line at the top of the file, a first line with the content



    #!/bin/bash


    This is called 'shebang'. The shebang can point to other shells too, for example sh or csh but also other programs, for example python or bc. If you make the shellscript file executable



    chmod +x shellscriptname


    you can run it with the following command



    ./shellscriptname                        # when in the current directory
    path-to-the-script-file/shellscriptname # when somewhere else
    shellscriptname # when in a directory in PATH


    and it will be executed by the shell or other program in the shebang.








share|improve this answer































    0














    They main point is that bash is meant for interactive use, dash is used for system scripts.



    bash comes with whole lot of features, among which is line editing. You have specific shortcuts to delete a word, jump to beginning of line, etc. This is convenient for writing commands interactively. However that comes at a price of performance and boot up times.



    dash on the other hand is meant for writing system scripts that are fast and portable, thus helping keep the boot times short, and on Ubuntu it is compiled without line editing, even without vi editing mode. Thus, it has less overhead. bash is capable of running exactly same scripts /bin/dash runs ( if they are written with portable syntax, of course ), but dash is just faster at doing these same things.



    Note, of course, that users are free to change their login shell via chsh command, and you don't have to stick with bash if that's not what you prefer.






    share|improve this answer




























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      0














      General comment about sh



      The shell sh is a symbolic link to dash, which is a shell with a very light foot-print. It means that it can work quickly and will not use much memory. But the built-in commands are few, simple and have different syntax compared to more advanced shells (for example bash).



      Both shells (sh and bash) are useful but for different purposes.



      How to make a shellscript run by bash



      If you run a text file with commands, a shellscript, you can force it to run by a certain shell. Otherwise it may default to a shell, that does does not work as intended, for example because some built-in command does not exist or the syntax for a built-in command is different.



      So in order to make a shellscript run with bash, you can force it





      • by calling it from bash



        bash shellscriptname



      • by writing a line at the top of the file, a first line with the content



        #!/bin/bash


        This is called 'shebang'. The shebang can point to other shells too, for example sh or csh but also other programs, for example python or bc. If you make the shellscript file executable



        chmod +x shellscriptname


        you can run it with the following command



        ./shellscriptname                        # when in the current directory
        path-to-the-script-file/shellscriptname # when somewhere else
        shellscriptname # when in a directory in PATH


        and it will be executed by the shell or other program in the shebang.








      share|improve this answer




























        0














        General comment about sh



        The shell sh is a symbolic link to dash, which is a shell with a very light foot-print. It means that it can work quickly and will not use much memory. But the built-in commands are few, simple and have different syntax compared to more advanced shells (for example bash).



        Both shells (sh and bash) are useful but for different purposes.



        How to make a shellscript run by bash



        If you run a text file with commands, a shellscript, you can force it to run by a certain shell. Otherwise it may default to a shell, that does does not work as intended, for example because some built-in command does not exist or the syntax for a built-in command is different.



        So in order to make a shellscript run with bash, you can force it





        • by calling it from bash



          bash shellscriptname



        • by writing a line at the top of the file, a first line with the content



          #!/bin/bash


          This is called 'shebang'. The shebang can point to other shells too, for example sh or csh but also other programs, for example python or bc. If you make the shellscript file executable



          chmod +x shellscriptname


          you can run it with the following command



          ./shellscriptname                        # when in the current directory
          path-to-the-script-file/shellscriptname # when somewhere else
          shellscriptname # when in a directory in PATH


          and it will be executed by the shell or other program in the shebang.








        share|improve this answer


























          0












          0








          0






          General comment about sh



          The shell sh is a symbolic link to dash, which is a shell with a very light foot-print. It means that it can work quickly and will not use much memory. But the built-in commands are few, simple and have different syntax compared to more advanced shells (for example bash).



          Both shells (sh and bash) are useful but for different purposes.



          How to make a shellscript run by bash



          If you run a text file with commands, a shellscript, you can force it to run by a certain shell. Otherwise it may default to a shell, that does does not work as intended, for example because some built-in command does not exist or the syntax for a built-in command is different.



          So in order to make a shellscript run with bash, you can force it





          • by calling it from bash



            bash shellscriptname



          • by writing a line at the top of the file, a first line with the content



            #!/bin/bash


            This is called 'shebang'. The shebang can point to other shells too, for example sh or csh but also other programs, for example python or bc. If you make the shellscript file executable



            chmod +x shellscriptname


            you can run it with the following command



            ./shellscriptname                        # when in the current directory
            path-to-the-script-file/shellscriptname # when somewhere else
            shellscriptname # when in a directory in PATH


            and it will be executed by the shell or other program in the shebang.








          share|improve this answer














          General comment about sh



          The shell sh is a symbolic link to dash, which is a shell with a very light foot-print. It means that it can work quickly and will not use much memory. But the built-in commands are few, simple and have different syntax compared to more advanced shells (for example bash).



          Both shells (sh and bash) are useful but for different purposes.



          How to make a shellscript run by bash



          If you run a text file with commands, a shellscript, you can force it to run by a certain shell. Otherwise it may default to a shell, that does does not work as intended, for example because some built-in command does not exist or the syntax for a built-in command is different.



          So in order to make a shellscript run with bash, you can force it





          • by calling it from bash



            bash shellscriptname



          • by writing a line at the top of the file, a first line with the content



            #!/bin/bash


            This is called 'shebang'. The shebang can point to other shells too, for example sh or csh but also other programs, for example python or bc. If you make the shellscript file executable



            chmod +x shellscriptname


            you can run it with the following command



            ./shellscriptname                        # when in the current directory
            path-to-the-script-file/shellscriptname # when somewhere else
            shellscriptname # when in a directory in PATH


            and it will be executed by the shell or other program in the shebang.









          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Dec 26 at 9:05

























          answered Dec 26 at 7:59









          sudodus

          22.9k32874




          22.9k32874

























              0














              They main point is that bash is meant for interactive use, dash is used for system scripts.



              bash comes with whole lot of features, among which is line editing. You have specific shortcuts to delete a word, jump to beginning of line, etc. This is convenient for writing commands interactively. However that comes at a price of performance and boot up times.



              dash on the other hand is meant for writing system scripts that are fast and portable, thus helping keep the boot times short, and on Ubuntu it is compiled without line editing, even without vi editing mode. Thus, it has less overhead. bash is capable of running exactly same scripts /bin/dash runs ( if they are written with portable syntax, of course ), but dash is just faster at doing these same things.



              Note, of course, that users are free to change their login shell via chsh command, and you don't have to stick with bash if that's not what you prefer.






              share|improve this answer


























                0














                They main point is that bash is meant for interactive use, dash is used for system scripts.



                bash comes with whole lot of features, among which is line editing. You have specific shortcuts to delete a word, jump to beginning of line, etc. This is convenient for writing commands interactively. However that comes at a price of performance and boot up times.



                dash on the other hand is meant for writing system scripts that are fast and portable, thus helping keep the boot times short, and on Ubuntu it is compiled without line editing, even without vi editing mode. Thus, it has less overhead. bash is capable of running exactly same scripts /bin/dash runs ( if they are written with portable syntax, of course ), but dash is just faster at doing these same things.



                Note, of course, that users are free to change their login shell via chsh command, and you don't have to stick with bash if that's not what you prefer.






                share|improve this answer
























                  0












                  0








                  0






                  They main point is that bash is meant for interactive use, dash is used for system scripts.



                  bash comes with whole lot of features, among which is line editing. You have specific shortcuts to delete a word, jump to beginning of line, etc. This is convenient for writing commands interactively. However that comes at a price of performance and boot up times.



                  dash on the other hand is meant for writing system scripts that are fast and portable, thus helping keep the boot times short, and on Ubuntu it is compiled without line editing, even without vi editing mode. Thus, it has less overhead. bash is capable of running exactly same scripts /bin/dash runs ( if they are written with portable syntax, of course ), but dash is just faster at doing these same things.



                  Note, of course, that users are free to change their login shell via chsh command, and you don't have to stick with bash if that's not what you prefer.






                  share|improve this answer












                  They main point is that bash is meant for interactive use, dash is used for system scripts.



                  bash comes with whole lot of features, among which is line editing. You have specific shortcuts to delete a word, jump to beginning of line, etc. This is convenient for writing commands interactively. However that comes at a price of performance and boot up times.



                  dash on the other hand is meant for writing system scripts that are fast and portable, thus helping keep the boot times short, and on Ubuntu it is compiled without line editing, even without vi editing mode. Thus, it has less overhead. bash is capable of running exactly same scripts /bin/dash runs ( if they are written with portable syntax, of course ), but dash is just faster at doing these same things.



                  Note, of course, that users are free to change their login shell via chsh command, and you don't have to stick with bash if that's not what you prefer.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Dec 26 at 11:09









                  Sergiy Kolodyazhnyy

                  69.4k9144305




                  69.4k9144305















                      Popular posts from this blog

                      How did Captain America manage to do this?

                      迪纳利

                      南乌拉尔铁路局