{"id":9645,"date":"2014-09-16T05:05:16","date_gmt":"2014-09-15T19:05:16","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=9645"},"modified":"2015-05-23T14:27:05","modified_gmt":"2015-05-23T04:27:05","slug":"linux-bash-shell-login-primer-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/linux-bash-shell-login-primer-tutorial\/","title":{"rendered":"Linux Bash Shell Login Primer Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/Linux\/Linux_prompt-4of.jpg\"><img decoding=\"async\" id='lii' style=\"float:left; border: 15px solid pink;\" alt=\"Linux Bash Shell Login Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/Linux\/Linux_prompt-4of.jpg\" title=\"Linux Bash Shell Login Primer Tutorial\" onmouseover=\"  this.src = this.src.replace('.jpg', '.GIF').replace('.gif', '.jpg').replace('.GIF', '.gif');    \" \/><\/a><p class=\"wp-caption-text\">Linux Bash Shell Login Primer Tutorial<\/p><\/div>\n<p>When you login to Linux the operating system looks to a file called &#8230;<\/p>\n<p>\/etc\/profile<\/p>\n<p>&#8230; to perform its commands.<\/p>\n<p>Within that file, if you are in a default Bash environment shell, as we are with Mac OS X application Terminal you may see a line of code, as highlighted in <font color='red'>red<\/font> like &#8230;<\/p>\n<p><code><br \/>\n# System-wide .profile for sh(1)<\/p>\n<p>if [ -x \/usr\/libexec\/path_helper ]; then<br \/>\n\teval `\/usr\/libexec\/path_helper -s`<br \/>\nfi<\/p>\n<p>if [ \"${BASH-no}\" != \"no\" ]; then<br \/>\n\t<font color='red'>[ -r \/etc\/bashrc ] && . \/etc\/bashrc<\/font><br \/>\nfi<br \/>\n<\/code><\/p>\n<p>&#8230; which then proceeds to take commands from a file called &#8230;<\/p>\n<p>\/etc\/bashrc<\/p>\n<p>&#8230; which may contain code like &#8230;<\/p>\n<p><code><br \/>\n# System-wide .bashrc file for interactive bash(1) shells.<br \/>\nif [ -z \"$PS1\" ]; then<br \/>\n   return<br \/>\nfi<\/p>\n<p>PS1='h:W u$ '<br \/>\n# Make bash check its window size after a process completes<br \/>\nshopt -s checkwinsize<br \/>\n# Tell the terminal about the working directory at each prompt.<br \/>\nif [ \"$TERM_PROGRAM\" == \"Apple_Terminal\" ] && [ -z \"$INSIDE_EMACS\" ]; then<br \/>\n    update_terminal_cwd() {<br \/>\n        # Identify the directory using a \"file:\" scheme URL,<br \/>\n        # including the host name to disambiguate local vs.<br \/>\n        # remote connections. Percent-escape spaces.<br \/>\n\tlocal SEARCH=' '<br \/>\n\tlocal REPLACE='%20'<br \/>\n\tlocal PWD_URL=\"file:\/\/$HOSTNAME${PWD\/\/$SEARCH\/$REPLACE}\"<br \/>\n\tprintf 'e]7;%sa' \"$PWD_URL\"<br \/>\n    }<br \/>\n    PROMPT_COMMAND=\"update_terminal_cwd; $PROMPT_COMMAND\"<br \/>\nfi<\/p>\n<p><\/code><\/p>\n<p><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/Linux\/Linux_prompt-4of.jpg\"title=\"Click picture\">Today<\/a>, we change this \/etc\/bashrc file so that a current date and time is added to the Linux prompt (and for advice we thank <a target=_blank title='Bash prompt ideas' href='http:\/\/www.thegeekstuff.com\/2008\/09\/bash-shell-ps1-10-examples-to-make-your-linux-prompt-like-angelina-jolie\/'>this excellent link<\/a>) by the amendment in <font color='orange'>orange<\/font> as shown below for \/etc\/bashrc &#8230;<\/p>\n<p><code><br \/>\n# System-wide .bashrc file for interactive bash(1) shells.<br \/>\nif [ -z \"$PS1\" ]; then<br \/>\n   return<br \/>\nfi<\/p>\n<p>PS1='h:W u <font color='orange'>d [t]<\/font>$ '<br \/>\n# Make bash check its window size after a process completes<br \/>\nshopt -s checkwinsize<br \/>\n# Tell the terminal about the working directory at each prompt.<br \/>\nif [ \"$TERM_PROGRAM\" == \"Apple_Terminal\" ] && [ -z \"$INSIDE_EMACS\" ]; then<br \/>\n    update_terminal_cwd() {<br \/>\n        # Identify the directory using a \"file:\" scheme URL,<br \/>\n        # including the host name to disambiguate local vs.<br \/>\n        # remote connections. Percent-escape spaces.<br \/>\n\tlocal SEARCH=' '<br \/>\n\tlocal REPLACE='%20'<br \/>\n\tlocal PWD_URL=\"file:\/\/$HOSTNAME${PWD\/\/$SEARCH\/$REPLACE}\"<br \/>\n\tprintf 'e]7;%sa' \"$PWD_URL\"<br \/>\n    }<br \/>\n    PROMPT_COMMAND=\"update_terminal_cwd; $PROMPT_COMMAND\"<br \/>\nfi<\/p>\n<p><\/code><\/p>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d9645' onclick='var dv=document.getElementById(\"d9645\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"http:\/\/www.rjmprogramming.com.au\/wordpress\/?tag=Linux\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d9645' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>When you login to Linux the operating system looks to a file called &#8230; \/etc\/profile &#8230; to perform its commands. Within that file, if you are in a default Bash environment shell, as we are with Mac OS X application &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/linux-bash-shell-login-primer-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,29,37],"tags":[132,707,1565,725,885,1252,1319],"class_list":["post-9645","post","type-post","status-publish","format-standard","hentry","category-elearning","category-operating-system","category-tutorials","tag-bash","tag-linux","tag-login","tag-mac-os-x","tag-operating-system-2","tag-terminal","tag-tutorial"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/9645"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=9645"}],"version-history":[{"count":1,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/9645\/revisions"}],"predecessor-version":[{"id":14979,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/9645\/revisions\/14979"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=9645"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=9645"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=9645"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}