Difference between revisions of "BOSS-Linux/C2/The-Linux-Environment/English-timed"

From Script | Spoken-Tutorial
Jump to: navigation, search
(Created page with "{| border=1 |'''Time''' |'''Narration''' |- |00:01 |Welcome to this spoken tutorial on the Linux environment and ways to manupulate it. |- |00:07 |A working linux system, wil...")
 
Line 4: Line 4:
 
|-
 
|-
  
|00:01
+
|00:00
 
|Welcome to this spoken tutorial on the Linux environment and ways to manupulate it.
 
|Welcome to this spoken tutorial on the Linux environment and ways to manupulate it.
 
|-
 
|-
 
|00:07
 
|00:07
|A working linux system, will be required to try out the examples illustrated in this tutorial.
+
|A working linux system, preferably Ubuntu will be required to try out the examples illustrated in this tutorial.
 
|-
 
|-
|00:12
+
|00:13
 
|We assume that you know how to get started with the Linux operating system and have some basic idea about commands, file systems and shell .
 
|We assume that you know how to get started with the Linux operating system and have some basic idea about commands, file systems and shell .
 
|-
 
|-
|00:20
+
|00:22
 
|If you are interested, or need to brush these concepts up , please feel free to do so through another spoken tutorial available on our website.
 
|If you are interested, or need to brush these concepts up , please feel free to do so through another spoken tutorial available on our website.
 
 
|-
 
|-
|00:30
+
|00:32
 +
|Please note that Ubuntu 10.10 was used for recording this tutorial.
 +
|-
 +
|00:36
 
|Please also note that Linux is case sensitive and all the commands used in this tutorial are in lower case unless otherwise mentioned.
 
|Please also note that Linux is case sensitive and all the commands used in this tutorial are in lower case unless otherwise mentioned.
 
|-
 
|-
|00:40
+
|00:46
 
|The Linux environment determines how the operating system behaves with you, how it responds to your commands, how it interprets your actions and so on.
 
|The Linux environment determines how the operating system behaves with you, how it responds to your commands, how it interprets your actions and so on.
 
|-
 
|-
|00:48
+
|00:55
 
|Linux can be highly customized by changing the settings of the shell.  
 
|Linux can be highly customized by changing the settings of the shell.  
 
|-
 
|-
|00:51
+
|00:58
 
|Let us understand how all this can be done.
 
|Let us understand how all this can be done.
 
|-
 
|-
|00:54
+
|00:59
 
|The behaviour of the shell is generally determined by the shell variables.
 
|The behaviour of the shell is generally determined by the shell variables.
 
|-
 
|-
|00:58
+
|01:04
 
|There are mainly two kinds of shell variables:
 
|There are mainly two kinds of shell variables:
  
Line 39: Line 41:
 
Local Variables
 
Local Variables
 
|-
 
|-
|01:06
+
|01:12
 
|Environment variables, named so because they are available entirely in the user's total environment.  
 
|Environment variables, named so because they are available entirely in the user's total environment.  
 
|-
 
|-
|01:12
+
|01:19
 
|These are also available in subshells spawned by the shell like the ones for running shell scripts.  
 
|These are also available in subshells spawned by the shell like the ones for running shell scripts.  
 
|-
 
|-
|01:18
+
|01:24
 
|Local Variables , which as the name suggests have a more restricted or limited availability.  
 
|Local Variables , which as the name suggests have a more restricted or limited availability.  
 
|-
 
|-
|01:24
+
|01:31
 
|These are not available in the subshells spawned by the shell.  
 
|These are not available in the subshells spawned by the shell.  
 
|-
 
|-
|01:28
+
|01:36
 
|While in this tutorial, we will mainly talk about environment variables, let us first see how the value of these shell variables can be seen.
 
|While in this tutorial, we will mainly talk about environment variables, let us first see how the value of these shell variables can be seen.
 
|-
 
|-
|01:41
+
|01:48
 
|To see all the variables available in the current shell , we run the command set.
 
|To see all the variables available in the current shell , we run the command set.
 
|-
 
|-
|01:46
+
|01:53
 
| Type at the terminal '''set''' space pipeline character '''more''' and press enter.
 
| Type at the terminal '''set''' space pipeline character '''more''' and press enter.
 
|-
 
|-
|01:53
+
|02:00
 
|We can see all the current shell variables ,  
 
|We can see all the current shell variables ,  
 
|-
 
|-
|01:58
+
|02:04
 
|For example : take a look at the '''HOME''' environment variable also notice the value assigned to it.
 
|For example : take a look at the '''HOME''' environment variable also notice the value assigned to it.
 
|-
 
|-
|02:07
+
|02:15
 
|press '''Enter''' to move through the list and in order to come out press '''q'''
 
|press '''Enter''' to move through the list and in order to come out press '''q'''
 
|-
 
|-
|02:14
+
|02:21
 
|Here the output from set was pipelined to more in order to display a more systematic multipage output of the variable list.
 
|Here the output from set was pipelined to more in order to display a more systematic multipage output of the variable list.
 
|-
 
|-
|02:31
+
|02:38
 
|To see only the environment variables run the command '''env'''
 
|To see only the environment variables run the command '''env'''
 
|-
 
|-
|02:38
+
|02:45
 
|Type at the terminal'''env'''  space 'vertical-bar' '''more''' and press enter
 
|Type at the terminal'''env'''  space 'vertical-bar' '''more''' and press enter
 
|-
 
|-
|02:46
+
|02:52
|For example, Notice the '''SHELL''' variable whose value is '''slash bin slash bash'''  
+
|For example,
 +
 
 +
Notice the '''SHELL''' variable whose value is '''slash bin slash bash'''  
 
|-
 
|-
|02:53
+
|03:00
 
|Again, you may press '''q''' to come out of the list.
 
|Again, you may press '''q''' to come out of the list.
 
|-
 
|-
|03:00
+
|03:07
 
|Now let us discuss some of the more important environment variables in linux.  
 
|Now let us discuss some of the more important environment variables in linux.  
 
|-
 
|-
|03:05
+
|03:11
|We would be using bash shell for all our demonstrations here.  
+
|We would be using the bash shell for all our demonstrations here.  
 
|-
 
|-
|03:09
+
|03:15
 
|Different shells are customized in slightly different ways.
 
|Different shells are customized in slightly different ways.
 
|-
 
|-
|03:12
+
|03:19
 
|To see what a variable actually stores we have to prefix a dollar sign to the name of that variable and use the '''echo''' command along with it.
 
|To see what a variable actually stores we have to prefix a dollar sign to the name of that variable and use the '''echo''' command along with it.
 
|-
 
|-
|03:24
+
|03:30
 
|The first environment variable that we would see is the '''SHELL''' variable.  
 
|The first environment variable that we would see is the '''SHELL''' variable.  
 
|-
 
|-
|03:28
+
|03:35
 
|It stores the name of the current shell.
 
|It stores the name of the current shell.
 
|-
 
|-
|03:31
+
|03:37
|To see what is the value of the '''SHELL''' variable, type at the terminal '''echo''' space '''dollar S-H-E-L-L''' in capitals and press '''enter.'''
+
|To see what is the value of the '''SHELL''' variable, type at the terminal '''echo''' space '''dollar S-H-E-L-L''' in capital and press '''enter.'''
 
|-
 
|-
|03:48
+
|03:55
 
|Here '''slash bin slash bash''' is the shell where we are currently operating.
 
|Here '''slash bin slash bash''' is the shell where we are currently operating.
 
|-
 
|-
|03:56
+
|04:02
 
|The next variable is '''HOME.'''
 
|The next variable is '''HOME.'''
 
|-
 
|-
|03:58
+
|04:05
 
|When we login into Linux, it normally places us in a directory named after our user name.  
 
|When we login into Linux, it normally places us in a directory named after our user name.  
 
|-
 
|-
|04:04
+
|04:11
 
|This directory is called the home directory and this is exactly what is available in HOME variable.
 
|This directory is called the home directory and this is exactly what is available in HOME variable.
 
|-
 
|-
|04:10
+
|04:17
 
|To see the value, type at the terminal '''echo''' space '''dollar H-O-M-E''' in capital and press '''enter'''
 
|To see the value, type at the terminal '''echo''' space '''dollar H-O-M-E''' in capital and press '''enter'''
 
|-
 
|-
|04:22
+
|04:29
 
|The next environment variable is  '''PATH.'''
 
|The next environment variable is  '''PATH.'''
 
|-
 
|-
|04:26
+
|04:32
 
|The '''PATH''' variable contains the absolute paths of the directories that the shell is supposed to search for locating any executable command.
 
|The '''PATH''' variable contains the absolute paths of the directories that the shell is supposed to search for locating any executable command.
 
|-
 
|-
|04:33
+
|04:40
 
|Lets see the value of the path variable.
 
|Lets see the value of the path variable.
 
|-
 
|-
|04:36
+
|04:43
 
|Again, type at the terminal '''echo''' space '''dollar P-A-T-H ''' in capitals and press enter
 
|Again, type at the terminal '''echo''' space '''dollar P-A-T-H ''' in capitals and press enter
 
|-
 
|-
|04:45
+
|04:51
|On my computer it shows '''slash user slash local slash sbin slash user slash bin etc'''.
+
|On my computer it shows '''slash user slash local slash sbin slash user slash local slash bin slash user slash sbin slash user slash bin''' etc.
 
|-
 
|-
|04:57
+
|05:04
 
|This may slightly vary from one system to another.
 
|This may slightly vary from one system to another.
 
   
 
   
 
|-
 
|-
|05:00
+
|05:07
 
|It is actually a list of directories separated by the :(colon) delimiter, that the shell would search in this order for finding an executable command.
 
|It is actually a list of directories separated by the :(colon) delimiter, that the shell would search in this order for finding an executable command.
 
|-
 
|-
|05:11
+
|05:18
 
|We can also add our own directory to this list so that our directory is also searched by the shell.
 
|We can also add our own directory to this list so that our directory is also searched by the shell.
 
|-
 
|-
|05:18
+
|05:25
 
|In order to add our own directory type at the terminal  
 
|In order to add our own directory type at the terminal  
 
|-
 
|-
|05:22
+
|05:29
|'''P-A-T-H''' in capitals 'equal-to' '''dollar P-A-T-H''' again in capital '''colon  slash home slash''' the name of my own home directory and press enter.
+
|'''P-A-T-H''' in capital 'equal-to' '''dollar P-A-T-H''' again in capital '''colon  slash home slash''' the name of my own home directory and press enter.
 
|-
 
|-
|05:47
+
|05:54
 
|Now if we '''echo''' the value of '''PATH''',  
 
|Now if we '''echo''' the value of '''PATH''',  
 
|-
 
|-
|05:57
+
|06:04
|Our added directory will also be a part of the '''PATH''' variable.  
+
|our added directory will also be a part of the '''PATH''' variable.  
 
|-
 
|-
|06:03
+
|06:10
 
|See the directory is now present here.
 
|See the directory is now present here.
 
|-
 
|-
|06:09
+
|06:16
 
|Another interesting variable is the '''LOGNAME.'''
 
|Another interesting variable is the '''LOGNAME.'''
 
|-
 
|-
|06:12
+
|06:20
 
|It stores the username of the currently active user.  
 
|It stores the username of the currently active user.  
 
|-
 
|-
|06:16
+
|06:24
 
|In order to see the value type '''echo''' space '''dollar LOGNAME''' and press '''enter.'''
 
|In order to see the value type '''echo''' space '''dollar LOGNAME''' and press '''enter.'''
 
|-
 
|-
|06:28
+
|06:35
 
|When we open the terminal we can see the dollar sign, which is the prompt at which we enter all our commands.  
 
|When we open the terminal we can see the dollar sign, which is the prompt at which we enter all our commands.  
 
|-
 
|-
|06:35
+
|06:42
 
|This is the primary prompt string represented by the environment variable PS1.  
 
|This is the primary prompt string represented by the environment variable PS1.  
 
|-
 
|-
|06:40
+
|06:47
 
|There is a secondary prompt string also
 
|There is a secondary prompt string also
 
|-
 
|-
|06:43
+
|06:50
 
|If our command is long and it spans for more than one line then from the second line onwards we can see a greater than sign “>” as the prompt
 
|If our command is long and it spans for more than one line then from the second line onwards we can see a greater than sign “>” as the prompt
 
|-
 
|-
|06:53
+
|07:00
 
|This is the secondary prompt string represented by the environment variable PS2.
 
|This is the secondary prompt string represented by the environment variable PS2.
 
|-
 
|-
|06:58
+
|07:05
 
|To see the value of the secondary command prompt, type at the terminal '''echo''' space '''dollar PS2'''  and press '''enter.'''
 
|To see the value of the secondary command prompt, type at the terminal '''echo''' space '''dollar PS2'''  and press '''enter.'''
|-
 
|07:13
 
|We may change our primary prompt string to say “at the rate” (@) at the prompt.
 
 
|-
 
|-
 
|07:20
 
|07:20
|In order to get this done Type ''' PS1'''  'equal-to' now within quotes 'at the rate(@)' “ and press enter.
+
|We may change our primary prompt string to say “at the rate” <@> at the prompt.
 +
|-
 +
|07:28
 +
|In order to get this done Type ''' PS1'''  'equal-to' now within quotes 'at the rate' “ and press enter.
 
|-
 
|-
|07:34
+
|07:41
 
|Now instead of the '''dollar''' sign we can see the '''at the rate''' sign as the prompt.
 
|Now instead of the '''dollar''' sign we can see the '''at the rate''' sign as the prompt.
 
|-
 
|-
|07:43
+
|07:50
 
|We may do something more interesting. Like we may display our username at the prompt.  
 
|We may do something more interesting. Like we may display our username at the prompt.  
 
|-
 
|-
|07:49
+
|07:56
 
|Just type '''PS1''' in capital 'equal-to' within quotes '''dollar LOGNAME''' and press '''enter'''
 
|Just type '''PS1''' in capital 'equal-to' within quotes '''dollar LOGNAME''' and press '''enter'''
 
|-
 
|-
|08:05
+
|08:12
 
|Now my username is my prompt.
 
|Now my username is my prompt.
 
|-
 
|-
|08:09
+
|08:16
 
|To revert back type '''PS1''' 'equal-to' dollar within quotes and press enter."
 
|To revert back type '''PS1''' 'equal-to' dollar within quotes and press enter."
 
|-
 
|-
|08:21
+
|08:28
 
|We have assigned values to many of the environment variables.  
 
|We have assigned values to many of the environment variables.  
 
|-
 
|-
|08:25
+
|08:32
 
|But, remember one thing that these modifications are only applicable for the current session.  
 
|But, remember one thing that these modifications are only applicable for the current session.  
 
|-
 
|-
|08:30
+
|08:37
 
|Like we had just added our directory to the PATH variable.  
 
|Like we had just added our directory to the PATH variable.  
 
|-
 
|-
|08:34
+
|08:40
 
|If we close the terminal and open it again or open a new terminal altogether and check the path variable by echoing its value
 
|If we close the terminal and open it again or open a new terminal altogether and check the path variable by echoing its value
 
|-
 
|-
|08:53
+
|09:00
|We will be surprised to see that our modifications are no longer present.
+
|we will be surprised to see that our modifications are no longer present.
 
|-
 
|-
|08:59
+
|09:05
 
|The way by which we can make these modifications permanent will be covered in some advanced tutorial.
 
|The way by which we can make these modifications permanent will be covered in some advanced tutorial.
 
|-
 
|-
|09:06
+
|09:13
 
|Often we want to re-execute a command that we had executed in the recent past. What do we do? Do we have to type the entire command again?
 
|Often we want to re-execute a command that we had executed in the recent past. What do we do? Do we have to type the entire command again?
 
|-
 
|-
|09:15
+
|9:22
 
| No, there are a number of solutions.
 
| No, there are a number of solutions.
 
|-
 
|-
|09:19
+
|09:26
 
|First, normally if you press the up  key on your keyboard then it will show the last command that you typed.  
 
|First, normally if you press the up  key on your keyboard then it will show the last command that you typed.  
 
|-
 
|-
|09:26
+
|09:33
|Keep pressing it and it will keep scrolling through the previous commands.
+
|Keep pressing and it will keep scrolling through the previous commands.
 
|-
 
|-
|09:30
+
|09:37
 
|To go back press the down key.  
 
|To go back press the down key.  
 
|-
 
|-
|09:36
+
|09:42
 
|But when you have to scroll through many commands this becomes a little clumsy and tedious. A better way is to use the '''history''' command.
 
|But when you have to scroll through many commands this becomes a little clumsy and tedious. A better way is to use the '''history''' command.
 
|-
 
|-
|09:45
+
|09:52
 
|Type at the prompt '''history'''
 
|Type at the prompt '''history'''
 
|-
 
|-
|09:51
+
|09:58
 
|and press enter, see a list of previously executed commands appears
 
|and press enter, see a list of previously executed commands appears
 
|-
 
|-
|09:57
+
|10:04
 
|If instead of the large list you want to see, only the last ten  
 
|If instead of the large list you want to see, only the last ten  
 
|-
 
|-
|10:02
+
|10:08
 
|Type '''history space 10''' and press ''enter'''
 
|Type '''history space 10''' and press ''enter'''
 
|-
 
|-
|10:13
+
|10:20
 
|Notice, in this list, there is a number assigned to each of the previously executed commands.  
 
|Notice, in this list, there is a number assigned to each of the previously executed commands.  
 
|-
 
|-
|10:20
+
|10:27
 
|In order to repeat a particular command.
 
|In order to repeat a particular command.
 
|-
 
|-
|10:24
+
|10:32
 
|Just type exclamation mark followed by the number of the command for example 442 in my case would execute '''echo space dollar PATH'''  
 
|Just type exclamation mark followed by the number of the command for example 442 in my case would execute '''echo space dollar PATH'''  
 
|-
 
|-
|10:44
+
|10:51
 
|If you need to re execute the last command simply type exclamation mark twice and press enter.
 
|If you need to re execute the last command simply type exclamation mark twice and press enter.
 
|-
 
|-
|10:56
+
|11:03
 
|The next thing we would see is called tilde substitution. The tilde(~) character is a shorthand for the home directory.
 
|The next thing we would see is called tilde substitution. The tilde(~) character is a shorthand for the home directory.
 
|-
 
|-
|11:05
+
|11:12
 
|So say you have a directory with name testtree in your home directory. You can move to it by typing '''cd''' space '''~(tilde)''' slash '''testtree'''.  
 
|So say you have a directory with name testtree in your home directory. You can move to it by typing '''cd''' space '''~(tilde)''' slash '''testtree'''.  
 
|-
 
|-
|11:18
+
|11:25
 
|One may also toggle between the current working directory and the last directory used by giving the command
 
|One may also toggle between the current working directory and the last directory used by giving the command
 
'''cd  '~(tilde)' minus''' or only '''cd  minus'''  
 
'''cd  '~(tilde)' minus''' or only '''cd  minus'''  
 
|-
 
|-
|11:28
+
|11:35
 
|Like now that we are in the '''testtree''' directory, the last directory we visited was the home directory.   
 
|Like now that we are in the '''testtree''' directory, the last directory we visited was the home directory.   
 
|-
 
|-
|11:34
+
|11:41
 
|So if we run '''cd space minus''' and press enter. It will go to the home directory.  
 
|So if we run '''cd space minus''' and press enter. It will go to the home directory.  
 
|-
 
|-
|11:40
+
|11:47
 
|Run it again and it will take us back to the '''testtree''' directory.
 
|Run it again and it will take us back to the '''testtree''' directory.
 
|-
 
|-
|11:47
+
|11:55
 
|The last but quite important command we will see is the '''alias''' command.  
 
|The last but quite important command we will see is the '''alias''' command.  
 
|-
 
|-
|11:51
+
|11:59
 
|It may happen that you have a large command that needs to be run again and again.  
 
|It may happen that you have a large command that needs to be run again and again.  
 
|-
 
|-
|11:57
+
|12:04
 
|In this case we can give it a short '''alias''' name and use the '''alias''' name instead ,to invoke it.
 
|In this case we can give it a short '''alias''' name and use the '''alias''' name instead ,to invoke it.
 
|-
 
|-
|12:03
+
|12:11
 
|Assuming that you have such a long directory hierarchy that you frequently visit for music, you may create an alias for it like this
 
|Assuming that you have such a long directory hierarchy that you frequently visit for music, you may create an alias for it like this
 
|-
 
|-
|12:13
+
|12:20
|Type '''alias''' space '''cdMusic''' 'equal-to' within double quotes '''cd''' space '''slash home slash the name of my own home directory slash music ''' and press enter
+
|Type '''alias''' space '''cdMusic''' 'equal-to' within double quotes '''cd''' space '''slash home slash arc slash files slash entertainment slash music ''' and press enter
 
|-
 
|-
|12:39
+
|12:47
 
|Now every time you need to switch to this directory simply write '''cdMusic''' and press enter.  
 
|Now every time you need to switch to this directory simply write '''cdMusic''' and press enter.  
 
|-
 
|-
|12:47
+
|12:55
 
|See, we are in the '''music''' directory now.
 
|See, we are in the '''music''' directory now.
 
|-
 
|-
|12:52
+
|12:58
 
|Now, you may type '''cd space minus
 
|Now, you may type '''cd space minus
''' and the prompt to go back to the previous working directory.  
+
''' at the prompt to go back to the previous working directory.  
 
|-
 
|-
|13:01
+
|13:08
 
|To unset an '''alias''' simply write '''unalias space cdMusic''' and press enter
 
|To unset an '''alias''' simply write '''unalias space cdMusic''' and press enter
 
|-
 
|-
|13:13
+
|13:20
 
|Now again if you fire '''cdMusic''' from the terminal, you will get an error stating that the command was not found.
 
|Now again if you fire '''cdMusic''' from the terminal, you will get an error stating that the command was not found.
 
|-
 
|-
|13:22
+
|13:30
 
|Suppose we have two files, '''test1''' and '''test2''' in our present working directory
 
|Suppose we have two files, '''test1''' and '''test2''' in our present working directory
 
|-
 
|-
|13:31
+
|13:38
 
|and if we fire '''rm test1''', '''test1''' is silently deleted.
 
|and if we fire '''rm test1''', '''test1''' is silently deleted.
 
|-
 
|-
|13:38
+
|13:45
 
|We know that '''hyphen i''' option of the '''rm''' command  makes the removal process interactive.
 
|We know that '''hyphen i''' option of the '''rm''' command  makes the removal process interactive.
 
|-
 
|-
|13:45
+
|13:52
 
|So we may set an '''alias''' like, '''alias rm''' equal-to, now within quotes '''rm space hyphen i'''  
 
|So we may set an '''alias''' like, '''alias rm''' equal-to, now within quotes '''rm space hyphen i'''  
 
|-
 
|-
|13:56
+
|14:03
 
|Now when we run '''rm''' ,''' rm hyphen i'''will actually be run.
 
|Now when we run '''rm''' ,''' rm hyphen i'''will actually be run.
 
|-
 
|-
|14:05
+
|14:13
 
|So we saw that while '''test1''' was silently deleted, system asked before deleting '''test2.'''
 
|So we saw that while '''test1''' was silently deleted, system asked before deleting '''test2.'''
 
|-
 
|-
|14:13
+
|14:20
|So, in this tutorial, we have learned about environment variables, history and aliasing.
+
|So, in this tutorial, you have learned about environment variables, history and aliasing.
 
|-
 
|-
|14:18
+
|14:25
 
|This brings me to the end of this tutorial.  
 
|This brings me to the end of this tutorial.  
 
|-
 
|-
|14:21
+
|14:28
 
|Spoken Tutorials are a part of the Talk to a Teacher project, supported by the National Mission on Education through ICT.  
 
|Spoken Tutorials are a part of the Talk to a Teacher project, supported by the National Mission on Education through ICT.  
 
|-
 
|-
|14:29
+
|14:36
 
|More information on the same is available from our website.
 
|More information on the same is available from our website.
 
|-
 
|-
|14:32
+
|14:39
 
|The Script for this tutorial was created by Anirban
 
|The Script for this tutorial was created by Anirban
 
|-
 
|-
|14:36
+
|14:42
|This Anugrath Parashah from MIT university signing off.
+
|This script has been contributed by ----------------------(name of the translator) and this is -----------------------(name of the recorder) from --------------------------(name of the place)signing off.
 
|}
 
|}

Revision as of 14:14, 4 December 2014

Time Narration
00:00 Welcome to this spoken tutorial on the Linux environment and ways to manupulate it.
00:07 A working linux system, preferably Ubuntu will be required to try out the examples illustrated in this tutorial.
00:13 We assume that you know how to get started with the Linux operating system and have some basic idea about commands, file systems and shell .
00:22 If you are interested, or need to brush these concepts up , please feel free to do so through another spoken tutorial available on our website.
00:32 Please note that Ubuntu 10.10 was used for recording this tutorial.
00:36 Please also note that Linux is case sensitive and all the commands used in this tutorial are in lower case unless otherwise mentioned.
00:46 The Linux environment determines how the operating system behaves with you, how it responds to your commands, how it interprets your actions and so on.
00:55 Linux can be highly customized by changing the settings of the shell.
00:58 Let us understand how all this can be done.
00:59 The behaviour of the shell is generally determined by the shell variables.
01:04 There are mainly two kinds of shell variables:

Environment Variables and

Local Variables

01:12 Environment variables, named so because they are available entirely in the user's total environment.
01:19 These are also available in subshells spawned by the shell like the ones for running shell scripts.
01:24 Local Variables , which as the name suggests have a more restricted or limited availability.
01:31 These are not available in the subshells spawned by the shell.
01:36 While in this tutorial, we will mainly talk about environment variables, let us first see how the value of these shell variables can be seen.
01:48 To see all the variables available in the current shell , we run the command set.
01:53 Type at the terminal set space pipeline character more and press enter.
02:00 We can see all the current shell variables ,
02:04 For example : take a look at the HOME environment variable also notice the value assigned to it.
02:15 press Enter to move through the list and in order to come out press q
02:21 Here the output from set was pipelined to more in order to display a more systematic multipage output of the variable list.
02:38 To see only the environment variables run the command env
02:45 Type at the terminalenv space 'vertical-bar' more and press enter
02:52 For example,

Notice the SHELL variable whose value is slash bin slash bash

03:00 Again, you may press q to come out of the list.
03:07 Now let us discuss some of the more important environment variables in linux.
03:11 We would be using the bash shell for all our demonstrations here.
03:15 Different shells are customized in slightly different ways.
03:19 To see what a variable actually stores we have to prefix a dollar sign to the name of that variable and use the echo command along with it.
03:30 The first environment variable that we would see is the SHELL variable.
03:35 It stores the name of the current shell.
03:37 To see what is the value of the SHELL variable, type at the terminal echo space dollar S-H-E-L-L in capital and press enter.
03:55 Here slash bin slash bash is the shell where we are currently operating.
04:02 The next variable is HOME.
04:05 When we login into Linux, it normally places us in a directory named after our user name.
04:11 This directory is called the home directory and this is exactly what is available in HOME variable.
04:17 To see the value, type at the terminal echo space dollar H-O-M-E in capital and press enter
04:29 The next environment variable is PATH.
04:32 The PATH variable contains the absolute paths of the directories that the shell is supposed to search for locating any executable command.
04:40 Lets see the value of the path variable.
04:43 Again, type at the terminal echo space dollar P-A-T-H in capitals and press enter
04:51 On my computer it shows slash user slash local slash sbin slash user slash local slash bin slash user slash sbin slash user slash bin etc.
05:04 This may slightly vary from one system to another.
05:07 It is actually a list of directories separated by the :(colon) delimiter, that the shell would search in this order for finding an executable command.
05:18 We can also add our own directory to this list so that our directory is also searched by the shell.
05:25 In order to add our own directory type at the terminal
05:29 P-A-T-H in capital 'equal-to' dollar P-A-T-H again in capital colon slash home slash the name of my own home directory and press enter.
05:54 Now if we echo the value of PATH,
06:04 our added directory will also be a part of the PATH variable.
06:10 See the directory is now present here.
06:16 Another interesting variable is the LOGNAME.
06:20 It stores the username of the currently active user.
06:24 In order to see the value type echo space dollar LOGNAME and press enter.
06:35 When we open the terminal we can see the dollar sign, which is the prompt at which we enter all our commands.
06:42 This is the primary prompt string represented by the environment variable PS1.
06:47 There is a secondary prompt string also
06:50 If our command is long and it spans for more than one line then from the second line onwards we can see a greater than sign “>” as the prompt
07:00 This is the secondary prompt string represented by the environment variable PS2.
07:05 To see the value of the secondary command prompt, type at the terminal echo space dollar PS2 and press enter.
07:20 We may change our primary prompt string to say “at the rate” <@> at the prompt.
07:28 In order to get this done Type PS1 'equal-to' now within quotes 'at the rate' “ and press enter.
07:41 Now instead of the dollar sign we can see the at the rate sign as the prompt.
07:50 We may do something more interesting. Like we may display our username at the prompt.
07:56 Just type PS1 in capital 'equal-to' within quotes dollar LOGNAME and press enter
08:12 Now my username is my prompt.
08:16 To revert back type PS1 'equal-to' dollar within quotes and press enter."
08:28 We have assigned values to many of the environment variables.
08:32 But, remember one thing that these modifications are only applicable for the current session.
08:37 Like we had just added our directory to the PATH variable.
08:40 If we close the terminal and open it again or open a new terminal altogether and check the path variable by echoing its value
09:00 we will be surprised to see that our modifications are no longer present.
09:05 The way by which we can make these modifications permanent will be covered in some advanced tutorial.
09:13 Often we want to re-execute a command that we had executed in the recent past. What do we do? Do we have to type the entire command again?
9:22 No, there are a number of solutions.
09:26 First, normally if you press the up key on your keyboard then it will show the last command that you typed.
09:33 Keep pressing and it will keep scrolling through the previous commands.
09:37 To go back press the down key.
09:42 But when you have to scroll through many commands this becomes a little clumsy and tedious. A better way is to use the history command.
09:52 Type at the prompt history
09:58 and press enter, see a list of previously executed commands appears
10:04 If instead of the large list you want to see, only the last ten
10:08 Type history space 10' and press enter
10:20 Notice, in this list, there is a number assigned to each of the previously executed commands.
10:27 In order to repeat a particular command.
10:32 Just type exclamation mark followed by the number of the command for example 442 in my case would execute echo space dollar PATH
10:51 If you need to re execute the last command simply type exclamation mark twice and press enter.
11:03 The next thing we would see is called tilde substitution. The tilde(~) character is a shorthand for the home directory.
11:12 So say you have a directory with name testtree in your home directory. You can move to it by typing cd space ~(tilde) slash testtree.
11:25 One may also toggle between the current working directory and the last directory used by giving the command

cd '~(tilde)' minus or only cd minus

11:35 Like now that we are in the testtree directory, the last directory we visited was the home directory.
11:41 So if we run cd space minus and press enter. It will go to the home directory.
11:47 Run it again and it will take us back to the testtree directory.
11:55 The last but quite important command we will see is the alias command.
11:59 It may happen that you have a large command that needs to be run again and again.
12:04 In this case we can give it a short alias name and use the alias name instead ,to invoke it.
12:11 Assuming that you have such a long directory hierarchy that you frequently visit for music, you may create an alias for it like this
12:20 Type alias space cdMusic 'equal-to' within double quotes cd space slash home slash arc slash files slash entertainment slash music and press enter
12:47 Now every time you need to switch to this directory simply write cdMusic and press enter.
12:55 See, we are in the music directory now.
12:58 Now, you may type cd space minus

at the prompt to go back to the previous working directory.

13:08 To unset an alias simply write unalias space cdMusic and press enter
13:20 Now again if you fire cdMusic from the terminal, you will get an error stating that the command was not found.
13:30 Suppose we have two files, test1 and test2 in our present working directory
13:38 and if we fire rm test1, test1 is silently deleted.
13:45 We know that hyphen i option of the rm command makes the removal process interactive.
13:52 So we may set an alias like, alias rm equal-to, now within quotes rm space hyphen i
14:03 Now when we run rm , rm hyphen iwill actually be run.
14:13 So we saw that while test1 was silently deleted, system asked before deleting test2.
14:20 So, in this tutorial, you have learned about environment variables, history and aliasing.
14:25 This brings me to the end of this tutorial.
14:28 Spoken Tutorials are a part of the Talk to a Teacher project, supported by the National Mission on Education through ICT.
14:36 More information on the same is available from our website.
14:39 The Script for this tutorial was created by Anirban
14:42 This script has been contributed by ----------------------(name of the translator) and this is -----------------------(name of the recorder) from --------------------------(name of the place)signing off.

Contributors and Content Editors

Gaurav, PoojaMoolya, Pratik kamble, Sandhya.np14