// API callback
related_results_labels_thumbs({"version":"1.0","encoding":"UTF-8","feed":{"xmlns":"http://www.w3.org/2005/Atom","xmlns$openSearch":"http://a9.com/-/spec/opensearchrss/1.0/","xmlns$blogger":"http://schemas.google.com/blogger/2008","xmlns$georss":"http://www.georss.org/georss","xmlns$gd":"http://schemas.google.com/g/2005","xmlns$thr":"http://purl.org/syndication/thread/1.0","id":{"$t":"tag:blogger.com,1999:blog-1255024703457423340"},"updated":{"$t":"2023-10-27T23:44:13.497+05:30"},"category":[{"term":"awk one liners"},{"term":"perl one liners"},{"term":"different methods"},{"term":"sed one liners"},{"term":"Different ways of"},{"term":"Shell Scripting"},{"term":"commands"},{"term":"Perl"},{"term":"shells"},{"term":"awk"},{"term":"Basics"},{"term":"sed"},{"term":"Administration"},{"term":"Filesystem"},{"term":"bash"},{"term":"utilities"},{"term":"Oracle"},{"term":"find"},{"term":"VI editor"},{"term":"awk tutorial"},{"term":"join"},{"term":"sed tutorial"},{"term":"sqlplus"},{"term":"shell script"},{"term":"vim"},{"term":"Productivity"},{"term":"awk parse CSV"},{"term":"file permissions"},{"term":"grep command"},{"term":"inodes"},{"term":"ksh"},{"term":"python"},{"term":"Inodes FAQ"},{"term":"Linux Interview Questions and answers"},{"term":"date"},{"term":"env variable"},{"term":"how to"},{"term":"parse CSV file"},{"term":"perl arrays"},{"term":"perl hash"},{"term":"python3"},{"term":"sed regular expression"},{"term":"typeset"},{"term":"C programming"},{"term":"FTP"},{"term":"GNU date"},{"term":"PATH variable"},{"term":"Soft Skill"},{"term":"associative array"},{"term":"awk date functions"},{"term":"awk sed perl grep substring"},{"term":"awk sum column values"},{"term":"awk time"},{"term":"convert uppercase"},{"term":"date formatting"},{"term":"line count"},{"term":"lines below pattern"},{"term":"linux"},{"term":"mail"},{"term":"mathematical"},{"term":"paste command"},{"term":"perl foreach"},{"term":"perl function"},{"term":"perl split string"},{"term":"profile"},{"term":"ps command"},{"term":"sed insert line"},{"term":"sed replace"},{"term":"shell script duplicates"},{"term":"soft link"},{"term":"sort remove duplicates"},{"term":"source"},{"term":"special variable IFS"},{"term":"split file"},{"term":"timestamps"},{"term":"unix linux process"},{"term":"zero padding"},{"term":"CDPATH"},{"term":"CGI"},{"term":"CPAN module"},{"term":"CPU utilization"},{"term":"IFS"},{"term":"Linux shell scripting interview questions"},{"term":"NSE"},{"term":"Oracle table csv"},{"term":"SUID"},{"term":"XML"},{"term":"__DATA__"},{"term":"__END__"},{"term":"alpha vantage"},{"term":"array"},{"term":"awk concatenate values"},{"term":"awk delimiter square brackets"},{"term":"awk first record group"},{"term":"awk insert column"},{"term":"awk insert line"},{"term":"awk join with delimiter"},{"term":"awk join without delimiter"},{"term":"awk match exact word"},{"term":"awk match pattern specific column"},{"term":"awk max value"},{"term":"awk min value"},{"term":"awk mktime"},{"term":"awk pass parameters"},{"term":"awk pattern matching"},{"term":"awk perl sed change delimiter"},{"term":"awk perl sed print trailer record"},{"term":"awk print lines before pattern"},{"term":"awk read files alternatively"},{"term":"awk sed perl cut extract characters"},{"term":"awk sed perl insert line before pattern"},{"term":"awk sed perl print lines below pattern"},{"term":"awk sed perl reverse file order"},{"term":"awk sed perl reverse string"},{"term":"awk sed perl right padding"},{"term":"awk sed print first few characters"},{"term":"awk sed swap lines in file"},{"term":"awk special variables"},{"term":"awk split file and insert header"},{"term":"awk split files every n line"},{"term":"awk split files on pattern"},{"term":"awk strftime"},{"term":"awk sum group"},{"term":"awk systime"},{"term":"awk unique values"},{"term":"awk varying length delimiter"},{"term":"awk word delimiter"},{"term":"bash arithmetic"},{"term":"bash substring"},{"term":"bc"},{"term":"bc command examples"},{"term":"best practice"},{"term":"case insensitive search"},{"term":"char"},{"term":"comm"},{"term":"comm command examples"},{"term":"command line arguments"},{"term":"compare files"},{"term":"concatenate lines"},{"term":"concatenate variables"},{"term":"convert ascii to hex"},{"term":"convert csv file to query"},{"term":"convert lowercase"},{"term":"convert text to query"},{"term":"cp"},{"term":"cron"},{"term":"ctags"},{"term":"cut"},{"term":"database"},{"term":"date command"},{"term":"date conversion"},{"term":"date functions"},{"term":"delete"},{"term":"delete character"},{"term":"delete control-M"},{"term":"delete line"},{"term":"df command"},{"term":"du command"},{"term":"environment"},{"term":"epoch time"},{"term":"eulers project"},{"term":"exclude directory"},{"term":"expr command"},{"term":"extern"},{"term":"filename"},{"term":"find files only current directory"},{"term":"find files specific directory"},{"term":"find module location"},{"term":"find xargs"},{"term":"find2perl"},{"term":"fold"},{"term":"foreach"},{"term":"gawk"},{"term":"getopts"},{"term":"group count"},{"term":"heredoc"},{"term":"inode changes"},{"term":"insert line beginning"},{"term":"insert line end"},{"term":"iterators"},{"term":"join method"},{"term":"ksh arrays examples"},{"term":"ksh substring"},{"term":"leave directory"},{"term":"length"},{"term":"line number"},{"term":"lines above pattern"},{"term":"link count"},{"term":"links"},{"term":"linux command line options"},{"term":"linux date command"},{"term":"ln command"},{"term":"map"},{"term":"multiple delimiters"},{"term":"multiple pattern search"},{"term":"multiple queries"},{"term":"negative pattern search"},{"term":"omit directory"},{"term":"ord"},{"term":"pandas"},{"term":"parse text file"},{"term":"pass awk variables to shell"},{"term":"paste command join lines"},{"term":"paste command merge files"},{"term":"paste command multiple files"},{"term":"paste command standard input"},{"term":"paste read file alternatively"},{"term":"pattern match"},{"term":"pattern matching"},{"term":"performance"},{"term":"perl DATA handler"},{"term":"perl alias"},{"term":"perl append string"},{"term":"perl builtin function"},{"term":"perl date"},{"term":"perl delete string"},{"term":"perl dumper"},{"term":"perl each"},{"term":"perl eval"},{"term":"perl file find"},{"term":"perl file handling"},{"term":"perl find files"},{"term":"perl hash examples"},{"term":"perl insert line"},{"term":"perl insert string"},{"term":"perl join"},{"term":"perl qr"},{"term":"perl regular expression"},{"term":"perl replace string"},{"term":"perl sed print lines before pattern"},{"term":"perl subtring"},{"term":"perl sum digits"},{"term":"preserve timestamp"},{"term":"prime numbers"},{"term":"print hash"},{"term":"print header"},{"term":"print nth line"},{"term":"print range of lines"},{"term":"print trailer record"},{"term":"ps TIME"},{"term":"push"},{"term":"python file writing"},{"term":"python iterator"},{"term":"python list"},{"term":"python read file"},{"term":"remove duplicates"},{"term":"remove leading zeros"},{"term":"replace characters"},{"term":"replace line"},{"term":"replace string"},{"term":"replace word"},{"term":"retrieve filename"},{"term":"reverse file"},{"term":"review"},{"term":"rlogin"},{"term":"sed delete blank lines"},{"term":"sed delete header trailer"},{"term":"sed delete line before after pattern"},{"term":"sed delete line ranges"},{"term":"sed delete lines ending with"},{"term":"sed delete not containing pattern"},{"term":"sed hold space"},{"term":"sed pattern space"},{"term":"sed print line"},{"term":"sed sum"},{"term":"set options"},{"term":"setuid"},{"term":"shell script UUC"},{"term":"shell script change delimiter"},{"term":"shell script read files alternatively"},{"term":"shell script reverse string"},{"term":"shell script sum"},{"term":"shell script swap lines in file"},{"term":"shell script to insert line before pattern"},{"term":"shell variables"},{"term":"shift"},{"term":"shift command"},{"term":"sort"},{"term":"sort and merge"},{"term":"sort file numerically"},{"term":"sort find duplicates"},{"term":"sort multiple fields"},{"term":"sort reverse"},{"term":"special variables"},{"term":"split"},{"term":"split command"},{"term":"split line"},{"term":"split multiple files"},{"term":"ssh"},{"term":"string length"},{"term":"string reverse"},{"term":"substitution"},{"term":"sum file contents"},{"term":"swap columns"},{"term":"swap lines"},{"term":"sys module"},{"term":"sys.path"},{"term":"table to csv"},{"term":"tac command"},{"term":"tags"},{"term":"time command"},{"term":"time difference"},{"term":"tr"},{"term":"umask"},{"term":"unix"},{"term":"unix find"},{"term":"unix shell scripting interview questions"},{"term":"unix sort examples"},{"term":"unix time"},{"term":"update"},{"term":"values"},{"term":"wantarray example"},{"term":"while loop"},{"term":"while loop IFS"},{"term":"while read multiple delimiters"},{"term":"word count"},{"term":"write method"},{"term":"writelines method"},{"term":"xargs"},{"term":"year 2038"},{"term":"yes command"}],"title":{"type":"text","$t":"The UNIX School"},"subtitle":{"type":"html","$t":"Instructions\/Tutorials on Unix\/Linux commands, C Programming, Unix Administration , Oracle, PL SQL, Perl, Productivity tips soft skills for newbies and professionals."},"link":[{"rel":"http://schemas.google.com/g/2005#feed","type":"application/atom+xml","href":"https:\/\/www.theunixschool.com\/feeds\/posts\/default"},{"rel":"self","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/1255024703457423340\/posts\/default\/-\/env+variable?alt=json-in-script\u0026max-results=5"},{"rel":"alternate","type":"text/html","href":"https:\/\/www.theunixschool.com\/search\/label\/env%20variable"},{"rel":"hub","href":"http://pubsubhubbub.appspot.com/"}],"author":[{"name":{"$t":"Guru Prasad"},"uri":{"$t":"http:\/\/www.blogger.com\/profile\/07898245472802947101"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"generator":{"version":"7.00","uri":"http://www.blogger.com","$t":"Blogger"},"openSearch$totalResults":{"$t":"3"},"openSearch$startIndex":{"$t":"1"},"openSearch$itemsPerPage":{"$t":"5"},"entry":[{"id":{"$t":"tag:blogger.com,1999:blog-1255024703457423340.post-6010857107841778455"},"published":{"$t":"2012-09-13T16:18:00.000+05:30"},"updated":{"$t":"2012-09-13T16:18:19.698+05:30"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"bash"},{"scheme":"http://www.blogger.com/atom/ns#","term":"env variable"},{"scheme":"http://www.blogger.com/atom/ns#","term":"ksh"},{"scheme":"http://www.blogger.com/atom/ns#","term":"profile"},{"scheme":"http://www.blogger.com/atom/ns#","term":"set options"},{"scheme":"http://www.blogger.com/atom/ns#","term":"shells"}],"title":{"type":"text","$t":"$IGNOREEOF vs ignoreeof"},"content":{"type":"html","$t":"\u003Cspan style=\"font-size: x-large;\"\u003EH\u003C\/span\u003Eow to prevent your terminal from getting closed OR prevent from getting the user logged out on pressing Control-D?\u003Cbr \/\u003E\n\u0026nbsp; The answer to this is \u003Cb\u003EIGNOREEOF \/ ignoreeof\u003C\/b\u003E. Let us see what is this IGNOREEOF and the difference between IGNOREEOF and ignoreeof.\u003Cbr \/\u003E\n\u003Cbr \/\u003E\n\u003Cb\u003EControl-D\u003C\/b\u003E:\u003Cbr \/\u003E\n\u0026nbsp; \u0026nbsp;Many of the times we might have pressed some key only to realize that the terminal got closed or he got logged out from his account. The user gets logged out whenever an EOF character is pressed which is Control-D. \u0026nbsp;So, if the user happens to be in his login shell, then logically the Ctrl-D ends up in getting the user's terminal closed as well.\u003Cbr \/\u003E\n\u003Cbr \/\u003E\n\u003Cb\u003EBash\/Bourne shell\u003C\/b\u003E:\u003Cbr \/\u003E\n\u0026nbsp; \u0026nbsp; In Bash\/Bourne shell, the log-out from the user account can be prevented by using the environment variable IGNOREEOF.\u003Cbr \/\u003E\n\u003Ca name='more'\u003E\u003C\/a\u003E\u003Cpre class=\"gpr1\"\u003Eexport IGNOREEOF=2\u003C\/pre\u003E\n\u0026nbsp; \u0026nbsp; The \u003Ca href=\"http:\/\/www.theunixschool.com\/2010\/04\/what-is-difference-between-export-set.html\" target=\"_blank\"\u003Eenv variable\u003C\/a\u003E IGNOREEOF is set to 2. This means, the shell will neglect 'Ctrl-D' key 2 times. A warning message will be displayed to the user on pressing Control-D for 2 times, however on the 3rd time, the user will be logged out. So, the user can set a value of his choice. In this way, the user can prevent himself from getting logged out of the shell. It is ideal to put this setting in the \u003Ca href=\"http:\/\/www.theunixschool.com\/2011\/07\/what-is-profile-file.html\" target=\"_blank\"\u003Eprofile file\u003C\/a\u003E to make it permanent.\u003Cbr \/\u003E\n\u003Cpre class=\"gpr1\"\u003Eexport IGNOREEOF\u003C\/pre\u003E\n\u0026nbsp; By just declaring the environment variable without any value, the shell will neglect Ctrl-D 10 times since 10 is the default value.\u003Cbr \/\u003E\n\u003Cbr \/\u003E\n\u0026nbsp; To unset the variable IGNOREEOF:\u003Cbr \/\u003E\n\u003Cpre class=\"gpr1\"\u003Eunset IGNOREEOF\u003C\/pre\u003E\n\u003Cb\u003EKsh\u003C\/b\u003E:\u003Cbr \/\u003E\n\u0026nbsp; The environment variable IGNOREEOF does not work for k-shell. Instead, it is done using one of the k-shell set command options, \"ignoreeof\". This is the difference between IGNOREEOF and ignoreeof.\u003Cbr \/\u003E\nTo set the 'ignoreeof' option in ksh:\u003Cbr \/\u003E\n\u003Cpre class=\"gpr1\"\u003Eset -o ignoreeof\u003C\/pre\u003E\n\u0026nbsp; \u0026nbsp;This means ignoreeof is set. Once set, the shell will neglect Ctrl-D for 20 times in case of a ksh93, 11 times in case of older ksh shells which are the default values. A user defined value cannot be set in ksh unlike the IGNOREEOF in bash shell.\u003Cbr \/\u003E\n\u003Cbr \/\u003E\n\u0026nbsp; To unset the ignoreeof in ksh:\u003Cbr \/\u003E\n\u003Cpre class=\"gpr1\"\u003Eset +o ignoreeof\n\u003C\/pre\u003E\nNote: ignoreeof works in bash and bourne shells as well."},"link":[{"rel":"replies","type":"application/atom+xml","href":"https:\/\/www.theunixschool.com\/feeds\/6010857107841778455\/comments\/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https:\/\/www.theunixschool.com\/2012\/09\/ignoreeof-prevent-terminal-close-user-logout.html#comment-form","title":"0 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/1255024703457423340\/posts\/default\/6010857107841778455"},{"rel":"self","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/1255024703457423340\/posts\/default\/6010857107841778455"},{"rel":"alternate","type":"text/html","href":"https:\/\/www.theunixschool.com\/2012\/09\/ignoreeof-prevent-terminal-close-user-logout.html","title":"$IGNOREEOF vs ignoreeof"}],"author":[{"name":{"$t":"Guru Prasad"},"uri":{"$t":"http:\/\/www.blogger.com\/profile\/07898245472802947101"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"thr$total":{"$t":"0"}},{"id":{"$t":"tag:blogger.com,1999:blog-1255024703457423340.post-1778858839679732039"},"published":{"$t":"2012-04-17T21:25:00.000+05:30"},"updated":{"$t":"2020-07-11T09:57:28.748+05:30"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"Administration"},{"scheme":"http://www.blogger.com/atom/ns#","term":"CDPATH"},{"scheme":"http://www.blogger.com/atom/ns#","term":"env variable"},{"scheme":"http://www.blogger.com/atom/ns#","term":"shells"}],"title":{"type":"text","$t":"What is CDPATH ?"},"content":{"type":"html","$t":"\u003Cdiv style=\"text-align: justify;\"\u003E\n\u0026nbsp; \u0026nbsp; Has it happened to you wherein you logged in to an account or to an environment and simply printed the command, say \"cd log\" and your directory gets changed to some log directory. The interesting part is: The log directory is not there in the directory from where you fired the cd command. It was somewhere also, however the cd command switched to it correctly. The question now is: \u0026nbsp;If the \"log\" directory is not present in the location from where we are giving the \"cd\" command, how did we reach the log directory? \u0026nbsp;The answer to this question is most probably \u0026nbsp;the \u003Cb\u003ECDPATH \u003C\/b\u003Eenvironment variable would have been set.\u003C\/div\u003E\n\u003Cbr \/\u003E\n\u003Cb\u003E1. What is CDPATH?\u003C\/b\u003E\u003Cbr \/\u003E\n\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;CDPATH is an environment variable. It looks exactly like the PATH variable containing with many different paths concatenated using ':'.\u003Cbr \/\u003E\n\u003Ca name='more'\u003E\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cb\u003E2. What is the use of CDPATH ?\u003C\/b\u003E\u003Cbr \/\u003E\n\u003Cdiv style=\"text-align: justify;\"\u003E\n\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;Say, for example, some directories present in an \"X\" directory are being accessed frequently by the user. Every time the user wants to traverse to any of these directories present in \"X\", \u0026nbsp;he mostly traverses by giving the absolute path which is little time consuming if you have to find it. How nice will it be if we can do \"cd\" to the particular directory as if that directory which you are looking for is right under your current directory. This is what the CDPATH achieves.\u003C\/div\u003E\n\u003Cdiv style=\"text-align: justify;\"\u003E\n\u003Cbr \/\u003E\u003C\/div\u003E\n\u003Cdiv style=\"text-align: justify;\"\u003E\n\u0026nbsp; \u0026nbsp; Normally, when the cd command is given, it checks for the directory name in the current directory and throws error if not found, else traverses to the directory. If the CDPATH is set, the \"cd\" command starts finding the directory in the list of directories present in the CDPATH variable and then makes the directory switch appropriately.\u003C\/div\u003E\n\u003Cbr \/\u003E\n\u003Cb\u003E3. How to set the CDPATH variable?\u003C\/b\u003E\u003Cbr \/\u003E\n\u0026nbsp; \u0026nbsp; \u0026nbsp;Setting the CDPATH variable is exactly like setting the PATH variable. For example:\u003Cbr \/\u003E\n\u003Cpre class=\"gpr1\" style=\"border: 2px groove; margin: 20px; overflow: auto; padding: 6px;\"\u003E$ export CDPATH=\".:\/home\/guru:\/usr\"\n\u003C\/pre\u003E\n\u0026nbsp; \u0026nbsp; \u0026nbsp;This above command will hold good till the session is closed. In order to make this change permanent, we need to put this command in the appropriate \u003Ca href=\"http:\/\/unix-school.blogspot.com\/2011\/07\/what-is-profile-file.html\" target=\"_blank\"\u003E\u003Cb\u003Eprofile file\u003C\/b\u003E\u003C\/a\u003E. The CDPATH command in this example is set with 3 components: The current directory followed by \/home\/guru and the \/usr.\u003Cbr \/\u003E\n\u003Cbr \/\u003E\n\u0026nbsp; Let us try to test this CDPATH variable. Currently, we are in \/home\/guru. There are 3 directories present under it.\u003Cbr \/\u003E\n\u003Cpre class=\"gpr1\" style=\"border: 2px groove; margin: 20px; overflow: auto; padding: 6px;\"\u003E$ pwd\n\/home\/guru\n$ ls -l | grep ^d\ndrwxr-xr-x+ 1 guru None       0 Feb  9 20:18 C\ndrwxr-xr-x+ 1 guru None       0 Apr 15 13:56 bin\ndrwxr-xr-x+ 1 guru None       0 Apr 15 18:35 perl\n\u003C\/pre\u003E\nNow, let us try to switch to the perl directory. And hence we will be in \/home\/guru\/perl. The switch to \"perl\" directory happened because the CDPATH contains the dot(.) at first place, and perl is under current directory(.)\u003Cbr \/\u003E\n\u003Cpre class=\"gpr1\" style=\"border: 2px groove; margin: 20px; overflow: auto; padding: 6px;\"\u003E$ cd perl\n$ pwd\n\/home\/guru\/perl\n\u003C\/pre\u003E\nNow, let us try to switch to the bin directory which is under home whereas we are actually now under perl.\u003Cbr \/\u003E\n\u003Cpre class=\"gpr1\" style=\"border: 2px groove; margin: 20px; overflow: auto; padding: 6px;\"\u003E$ cd bin\n$ pwd\n\/home\/guru\/bin\n\u003C\/pre\u003E\n\u0026nbsp; \u0026nbsp; This is how the CDPATH works. This is highly useful when you have some frequently traversed directories in the environment.\u003Cbr \/\u003E\n\u003Cbr \/\u003E\n\u003Cb\u003E4. How to find the value of the CDPATH variable?\u003C\/b\u003E\u003Cbr \/\u003E\n\u003Cpre class=\"gpr1\" style=\"border: 2px groove; margin: 20px; overflow: auto; padding: 6px;\"\u003E$ echo $CDPATH\n.:\/home\/guru:\/usr\n\u003C\/pre\u003E\n\u003Cb\u003E5. If CDPATH is set, will the cd command still search in the current directory by default before referring to the CDPATH?\u003C\/b\u003E\u003Cbr \/\u003E\n\u003Cdiv style=\"text-align: justify;\"\u003E\n\u0026nbsp; \u0026nbsp; \u0026nbsp; No. Once the CDPATH is set, the cd command will search only in the directories present in the CDPATH variable only. Hence, it is the responsibility of the user to make sure that the current directory is also present in the CDPATH variable. \u003Cbr \/\u003E\nNote: This point holds good when only the directory name is specified with cd. cd when given with absolute or relative path does not refer to the CDPATH command.\u003C\/div\u003E\n\u003Cbr \/\u003E\n\u003Cb\u003E6. Can the current directory be anywhere in the CDPATH variable?\u003C\/b\u003E\u003Cbr \/\u003E\n\u003Cdiv style=\"text-align: justify;\"\u003E\n\u0026nbsp; \u0026nbsp; \u0026nbsp; As such, there is no rule to put the current directory in specific place. However, it SHOULD always be the first component of the CDPATH. It is because if it is not there in first position, the default functioning of the cd command which is to switch to the required directory under current directory may not work. Hence, the cd command should always be made to search for the directory first in the current directory, and then only in the other directories present in the CDPATH variable.\u003C\/div\u003E"},"link":[{"rel":"replies","type":"application/atom+xml","href":"https:\/\/www.theunixschool.com\/feeds\/1778858839679732039\/comments\/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https:\/\/www.theunixschool.com\/2012\/04\/what-is-cdpath.html#comment-form","title":"1 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/1255024703457423340\/posts\/default\/1778858839679732039"},{"rel":"self","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/1255024703457423340\/posts\/default\/1778858839679732039"},{"rel":"alternate","type":"text/html","href":"https:\/\/www.theunixschool.com\/2012\/04\/what-is-cdpath.html","title":"What is CDPATH ?"}],"author":[{"name":{"$t":"Guru Prasad"},"uri":{"$t":"http:\/\/www.blogger.com\/profile\/07898245472802947101"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"thr$total":{"$t":"1"}},{"id":{"$t":"tag:blogger.com,1999:blog-1255024703457423340.post-1943339362230401800"},"published":{"$t":"2010-01-16T19:25:00.000+05:30"},"updated":{"$t":"2012-06-01T14:09:29.711+05:30"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"Basics"},{"scheme":"http://www.blogger.com/atom/ns#","term":"env variable"},{"scheme":"http://www.blogger.com/atom/ns#","term":"PATH variable"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Shell Scripting"}],"title":{"type":"text","$t":"What is a PATH variable?"},"content":{"type":"html","$t":"\u003Cdiv style=\"text-align: justify;\"\u003E\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp; \u0026nbsp; PATH variable is one of the most important concepts of any operating system. \u0026nbsp;PATH variable tells the places from where the Operating System(OS) will search for whenever a command is given. Lets explain it a bit in detail.\u003Cbr \/\u003E\n\u003C\/div\u003E\u003Cdiv style=\"text-align: justify;\"\u003E\u003Cbr \/\u003E\n\u003C\/div\u003E\u003Cdiv style=\"text-align: justify;\"\u003E\u0026nbsp;\u0026nbsp; Say, we fire the \u003Ci\u003Els\u003C\/i\u003E\u0026nbsp;command. Once the ls command is executed, all the files and directories in the current directory are displayed. \u0026nbsp;What happened now in order for the OS to display the files and directories?\u003Cbr \/\u003E\n\u003C\/div\u003E\u003Cdiv style=\"text-align: justify;\"\u003E\u003Cbr \/\u003E\n\u003C\/div\u003E\u003Cdiv style=\"text-align: justify;\"\u003E\u0026nbsp;\u0026nbsp; When the \u003Ci\u003Els\u003C\/i\u003E\u0026nbsp;command is executed, the OS starts searching for an executable named \u003Ci\u003Els\u003C\/i\u003E. \u0026nbsp;Where does it search? It searches in all the directories mentioned in the PATH variable. The moment it finds the executable, it executes the command the the output is displayed.\u003Cbr \/\u003E\n\u003C\/div\u003E\u003Cdiv style=\"text-align: justify;\"\u003E\u003Cbr \/\u003E\n\u003C\/div\u003E\u003Cdiv style=\"text-align: justify;\"\u003EFor example:\u003Cbr \/\u003E\n\u003C\/div\u003E\u003Cdiv style=\"text-align: justify;\"\u003E\u003Cbr \/\u003E\n\u003C\/div\u003E\u003Cdiv style=\"text-align: justify;\"\u003E[XXX : ~gpr]# echo $PATH\u003Cbr \/\u003E\n\u003C\/div\u003E\u003Cdiv style=\"text-align: justify;\"\u003E\/bin:\/usr\/bin\u003Cbr \/\u003E\n\u003C\/div\u003E\u003Cdiv style=\"text-align: justify;\"\u003E\u003Cbr \/\u003E\n\u003C\/div\u003E\u003Cdiv style=\"text-align: justify;\"\u003E\u0026nbsp;\u0026nbsp; \u0026nbsp;The above PATH variable tells that whenever a command is given, the OS will search for the command in the \/bin directory first, followed by the \/usr\/bin directory.\u003Cbr \/\u003E\n\u003C\/div\u003E\u003Cdiv style=\"text-align: justify;\"\u003E\u003Cbr \/\u003E\n\u003C\/div\u003E\u003Cdiv style=\"text-align: justify;\"\u003E\u0026nbsp;\u0026nbsp;Sometimes, when we give a well known command, we get the 'command not found' error. This error occurs usually whenever the PATH variable is corrupted. \u0026nbsp;When the OS started searching for the \u003Ci\u003Els\u003C\/i\u003E\u0026nbsp;command, it did not find the executable in any of the directories defined in the PATH variable and hence the error 'command not found'.\u003Cbr \/\u003E\n\u003C\/div\u003E\u003Cdiv style=\"text-align: justify;\"\u003E\u003Cbr \/\u003E\n\u003C\/div\u003E\u003Cdiv style=\"text-align: justify;\"\u003E\u0026nbsp;\u0026nbsp; This can be corrected by updating the PATH variable with the \/usr\/bin directory.\u003Cbr \/\u003E\n\u003C\/div\u003E\u003Cdiv style=\"text-align: justify;\"\u003E\u003Cbr \/\u003E\n\u003C\/div\u003E\u003Cdiv style=\"text-align: justify;\"\u003E[XXX:~gpr]#PATH=$PATH:\/usr\/bin\u003Cbr \/\u003E\n\u003C\/div\u003E\u003Cdiv style=\"text-align: justify;\"\u003E\u003Cbr \/\u003E\n\u003C\/div\u003E\u003Cdiv style=\"text-align: justify;\"\u003E\u0026nbsp;\u0026nbsp; \u0026nbsp; \u0026nbsp;The above expression states to append the \/usr\/bin directory to the existing PATH variable.\u003Cbr \/\u003E\n\u003C\/div\u003E"},"link":[{"rel":"replies","type":"application/atom+xml","href":"https:\/\/www.theunixschool.com\/feeds\/1943339362230401800\/comments\/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https:\/\/www.theunixschool.com\/2010\/01\/what-is-path-variable.html#comment-form","title":"0 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/1255024703457423340\/posts\/default\/1943339362230401800"},{"rel":"self","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/1255024703457423340\/posts\/default\/1943339362230401800"},{"rel":"alternate","type":"text/html","href":"https:\/\/www.theunixschool.com\/2010\/01\/what-is-path-variable.html","title":"What is a PATH variable?"}],"author":[{"name":{"$t":"Guru Prasad"},"uri":{"$t":"http:\/\/www.blogger.com\/profile\/07898245472802947101"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"thr$total":{"$t":"0"}}]}});