{"id":188,"date":"2020-08-18T19:23:47","date_gmt":"2020-08-18T20:23:47","guid":{"rendered":"http:\/\/www.linux-tutorial.info\/?page_id=77"},"modified":"2020-08-24T13:55:50","modified_gmt":"2020-08-24T14:55:50","slug":"this-is-the-page-title-toplevel-22","status":"publish","type":"page","link":"http:\/\/www.linux-tutorial.info\/?page_id=188","title":{"rendered":"Different Kinds of Shells"},"content":{"rendered":"\n<title>Different Kinds of Shells<\/title>\n<p>\nThe great-grandfather of all shells is \/bin\/sh, called simply sh or the\nBourne Shell, named after its developer, Steven Bourne. When it was first\nintroduced in the mid-1970s, this was a godsend as it allowed\n<em>interaction<\/em> with the <glossary>operating system<\/glossary>.\nThis is the &#8220;standard&#8221; shell that you will find on every version in <glossary>UNIX<\/glossary>\n(at least all those I have seen). Although many changes have been made to\n<glossary>UNIX<\/glossary>, <command>sh<\/command> has remained basically unchanged.\n<\/p>\n<p>\nAll the capabilities of &#8220;the <glossary>shell<\/glossary>&#8221;\nI&#8217;ve talked about so far apply to <command>sh<\/command>.\nAnything I&#8217;ve talked about that sh can do, the others can do as well. So rather\nthan going on about what sh can do (which I already did), I am going to talk\nabout the characteristics of some other shells.\n<\/p>\n<p>\nLater, I am going to talk about the C-Shell, which kind of throws a monkey\nwrench into this entire discussion. Although the concepts are much the same\nbetween the C-Shell and other shells, the constructs are often quite different.\nOn the other hand, the other shells are extensions of the Bourne Shell, so the\nsyntax and constructs are basically the same.\n<\/p>\n<p>\nBe careful here. This is one case in which I have noticed that the various\nversions of Linux are different. Not every <glossary>shell<\/glossary>\nis in every distribution. Therefore,\nthe shells I am going to talk about may not be in your distribution. Have no\nfear! If there is a feature that you really like, you can either take the source\ncode from one of the other shells and add it or you can find the different\nshells all over the Internet, which is much easier.\n<\/p>\n<p>\nLinux includes several different shells and we will get into the specific of many\nof them as we move along. In addition, most different shells are available\nunder a <glossary>GPL<\/glossary> license that you can install yourself. Although\nrelatively few shells are installed by default, many others are usually available\non your distribution CDs\/DVD.\n<\/p>\n<p>\nAs I mentioned earlier, <glossary>environment<\/glossary>\nvariables are set up for you as you are\nlogging in or you can set them up later. Depending on the <glossary>shell<\/glossary>\nyou use, the files used and where they are located is going to be different. Some variables\nare made available to everyone on the system and are accessed through a common\nfile. Others reside in the user&#8217;s <glossary>home directory<\/glossary>.\n<\/p>\n<p>\nNormally, the files residing in a users <glossary>home directory<\/glossary>\ncan be modified.\nHowever, a system <glossary>administrator<\/glossary>\nmay wish to prevent users from doing so. Often,\nmenus are set up in these files to either make things easier for the user or to\nprevent the user from getting to the <glossary>command line<\/glossary>.\n(Often users never need to get that far.) In other cases, <glossary>environment<\/glossary>\nvariables that shouldn&#8217;t be changed need to be set up for the user.\n<\/p>\n<p>\nOne convention I will be using here is how I refer to the different shells.\nOften, I will say &#8220;the bash&#8221; or just &#8220;bash&#8221; to refer to the Bourne-Again Shell\nas a concept and not the program <command>\/bin\/bash<\/command>. I will use &#8220;bash&#8221; to refer to the\n&#8220;Bourne Shell&#8221; as an abstract entity and not specifically to the program\n<command>\/bin\/sh<\/command>.\n<\/p>\n<p>\nWhy the Bourne-Again Shell? Well, this <glossary>shell<\/glossary>\nis compatible with the Bourne\nShell, but has many of the same features as both the Korn Shell (<command>ksh<\/command>) and\nC-Shell (<command>csh<\/command>). This is especially important to me as I flail violently when I\ndon&#8217;t have a Korn or Bourne-Again Shell.\n<\/p>\n<p>\nMost of the issues I am going to address here are detailed in the\nappropriate man-pages and other documents. Why cover them here? Well, in keeping\nwith one basic premise of this website, I want to show you the relationships\ninvolved. In addition, many of the things we are going to look at are not\nemphasized as much as they should be. Often, users will go for months or years\nwithout learning the magic that these shells can do.\n<\/p>\n<p>\nOnly one oddity really needs to be addressed: the behavior of the different\nshells when moving through symbolic links. As I mentioned before, symbolic links\nare simply pointers to files or directories elsewhere on the system. If you\nchange directories into symbolic links, your &#8220;location&#8221; on the disk is different\nthan what you might think. In some cases, the <glossary>shell<\/glossary>\nunderstands the distinction\nand hides from you the fact that you are somewhere else. This is where the\nproblem lies.\n<\/p>\n<p>\nAlthough the concept of a <glossary>symbolic link<\/glossary>\nexists in most versions of <glossary>UNIX<\/glossary>,\n it\nis a relatively new aspect. As a result, not all applications and programs\nbehave in the same way. Let&#8217;s take the directory \/usr\/spool as an example.\nBecause it contains a lot of administrative information, it is a useful and\ncommonly accessed directory. It is actually a <glossary>symbolic link<\/glossary>\nto <directory>\/var\/spool<\/directory>. If we\nare using ash as our <glossary>shell<\/glossary>,\n when we do a cd \/usr\/spool and then pwd, the system\nresponds with: <directory>\/var\/spool<\/directory>. This is where we are &#8220;physically&#8221; located, despite\nthe fact that we did a <keyinput>cd \/usr\/spool<keyinput>. If we do a <keyinput>cd ..<\/keyinput>\n(to move up to our parent directory), we are now located in <directory>\/var<\/directory>. All this seems logical. This is also the behavior of csh and sh on some systems.\n<\/p>\n<p>\nNOTE: Please do not take this as an absolute. The behaviour of shells changes occassionally, so by the time you read this, your favorite shell might  behave differently.\n<\/p>\n<p>\nIf we use bash, things are different. This time, when we do a cd \/usr\/spool\nand then pwd, the system responds with <directory>\/usr\/spools<\/directory>. This is where we are\n&#8220;logically&#8221;. If we now do a cd .., we are located in \/usr. Which of these is the\n&#8220;correct&#8221; behavior? Well, I would say <i>both<\/i>. There is nothing to define\nwhat the &#8220;correct&#8221; behavior is. Depending on your preference, either is correct.\nI tend to prefer the behavior of <command>ksh<\/command>. However, the behavior of ash is also\nvalid.\n<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Different Kinds of Shells The great-grandfather of all shells is \/bin\/sh, called simply sh or the Bourne Shell, named after its developer, Steven Bourne. When it was first introduced in the mid-1970s, this was a godsend as it allowed interaction &hellip; <a href=\"http:\/\/www.linux-tutorial.info\/?page_id=188\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-188","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages\/188","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=188"}],"version-history":[{"count":2,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages\/188\/revisions"}],"predecessor-version":[{"id":877,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages\/188\/revisions\/877"}],"wp:attachment":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=188"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}