1
00:00:00,060 --> 00:00:01,020
In this lesson,

2
00:00:01,020 --> 00:00:03,180
we're going to discuss the Bash shell environment

3
00:00:03,180 --> 00:00:05,730
and how you can customize it to enhance your productivity

4
00:00:05,730 --> 00:00:07,740
when working in the command line.

5
00:00:07,740 --> 00:00:10,350
Most of us know how to use a mouse and click icons

6
00:00:10,350 --> 00:00:14,130
to access our files, programs, and folders on our devices,

7
00:00:14,130 --> 00:00:15,960
but this is just one way for us

8
00:00:15,960 --> 00:00:17,910
to communicate with our computers.

9
00:00:17,910 --> 00:00:19,320
The command line and the shell

10
00:00:19,320 --> 00:00:22,260
make up a quick, powerful text-based interface

11
00:00:22,260 --> 00:00:25,590
that developers often use more effectively and efficiently

12
00:00:25,590 --> 00:00:27,330
to communicate with their computers

13
00:00:27,330 --> 00:00:29,280
to accomplish a wide set of task

14
00:00:29,280 --> 00:00:31,920
that every system administrator is going to have to handle

15
00:00:31,920 --> 00:00:34,320
at some point in their Linux career.

16
00:00:34,320 --> 00:00:36,450
Now, scripts can greatly improve efficiency

17
00:00:36,450 --> 00:00:38,970
by minimizing the amount of repetitive typing

18
00:00:38,970 --> 00:00:41,610
that you're going to need to do at the command line interface,

19
00:00:41,610 --> 00:00:43,590
and this can enable you to get more work done

20
00:00:43,590 --> 00:00:45,480
in a shorter amount of time.

21
00:00:45,480 --> 00:00:48,000
Surprisingly, Bash is so much easier

22
00:00:48,000 --> 00:00:49,740
than any other programming language

23
00:00:49,740 --> 00:00:51,450
you might have to work with.

24
00:00:51,450 --> 00:00:53,970
You're going to learn that we can harness the power of scripts

25
00:00:53,970 --> 00:00:56,820
to really help you become more productive at doing your job

26
00:00:56,820 --> 00:00:59,910
and be able to get things done much more efficiently.

27
00:00:59,910 --> 00:01:02,910
First off, you may want to change the way things look and act

28
00:01:02,910 --> 00:01:04,410
inside of your system.

29
00:01:04,410 --> 00:01:05,910
You can make all sorts of changes

30
00:01:05,910 --> 00:01:08,010
to make things easier for you to use.

31
00:01:08,010 --> 00:01:10,110
Many people are going to change their prompts,

32
00:01:10,110 --> 00:01:11,940
the color that things are displayed in,

33
00:01:11,940 --> 00:01:14,250
the paths to make launching things easier,

34
00:01:14,250 --> 00:01:16,380
alias is to make commands easier to run,

35
00:01:16,380 --> 00:01:19,380
changing out their default editors, and much more.

36
00:01:19,380 --> 00:01:21,390
The shell environment is really the mechanism

37
00:01:21,390 --> 00:01:23,640
by which Bash or any other shell

38
00:01:23,640 --> 00:01:26,310
will maintain settings and other behavioral details

39
00:01:26,310 --> 00:01:28,170
about their own shell.

40
00:01:28,170 --> 00:01:29,730
This shell creates an environment

41
00:01:29,730 --> 00:01:31,290
when starting up a session,

42
00:01:31,290 --> 00:01:32,940
and it uses the environment settings

43
00:01:32,940 --> 00:01:35,460
to determine how to interact with the user.

44
00:01:35,460 --> 00:01:37,200
The process of creating a new session

45
00:01:37,200 --> 00:01:39,180
is called shell spawning.

46
00:01:39,180 --> 00:01:41,400
This new session is really a copy

47
00:01:41,400 --> 00:01:43,650
and it's called a child process.

48
00:01:43,650 --> 00:01:46,350
For example, the shell spawns a child process

49
00:01:46,350 --> 00:01:48,300
when the user enters a command.

50
00:01:48,300 --> 00:01:51,000
This child process becomes the new process

51
00:01:51,000 --> 00:01:53,160
and can also create other sub-processes

52
00:01:53,160 --> 00:01:55,380
or child processes from itself.

53
00:01:55,380 --> 00:01:58,140
This can result in multiple generations of processes

54
00:01:58,140 --> 00:02:00,420
in a nested tree architecture.

55
00:02:00,420 --> 00:02:03,510
Now, each process is going to call upon the shell environment

56
00:02:03,510 --> 00:02:06,810
and pass its details onto the next generation going upward

57
00:02:06,810 --> 00:02:09,479
until it reaches the kernel and the processor.

58
00:02:09,479 --> 00:02:11,009
Now, when I talk about a script,

59
00:02:11,009 --> 00:02:13,350
I'm really talking about any computer program

60
00:02:13,350 --> 00:02:15,390
that automates the execution of tasks

61
00:02:15,390 --> 00:02:18,180
for particular runtime or shell environment.

62
00:02:18,180 --> 00:02:20,670
Scripts are written in scripting languages,

63
00:02:20,670 --> 00:02:23,640
which are really just a subset of programming languages.

64
00:02:23,640 --> 00:02:26,580
Scripts typically are not full-fledged programs,

65
00:02:26,580 --> 00:02:29,340
but instead they have a much more limited feature set.

66
00:02:29,340 --> 00:02:31,500
And this is used to integrate with other programs

67
00:02:31,500 --> 00:02:33,030
and operating system components

68
00:02:33,030 --> 00:02:36,420
to achieve the automation and efficiency you're looking for.

69
00:02:36,420 --> 00:02:37,950
Think about a script in programming

70
00:02:37,950 --> 00:02:41,430
the way we use scripts in plays or movies or TV shows.

71
00:02:41,430 --> 00:02:43,680
The script is telling the actors what they should say

72
00:02:43,680 --> 00:02:45,120
and what they should do.

73
00:02:45,120 --> 00:02:46,650
Well, in our world,

74
00:02:46,650 --> 00:02:49,500
a script is going to tell the shell exactly what it should do

75
00:02:49,500 --> 00:02:51,600
to accomplish a given task.

76
00:02:51,600 --> 00:02:52,650
Now, as I said,

77
00:02:52,650 --> 00:02:54,810
you can change the details of your environment

78
00:02:54,810 --> 00:02:55,890
within the shell,

79
00:02:55,890 --> 00:02:59,400
and you do this by changing its variables and their values.

80
00:02:59,400 --> 00:03:02,010
Variables refer to things where the values can change

81
00:03:02,010 --> 00:03:03,360
from time to time.

82
00:03:03,360 --> 00:03:05,760
Think about it as a big placeholder.

83
00:03:05,760 --> 00:03:07,200
Most variables are going to be set

84
00:03:07,200 --> 00:03:09,450
either by the operating system when you log in

85
00:03:09,450 --> 00:03:12,930
or by the shell when you invoke it initially.

86
00:03:12,930 --> 00:03:14,760
These variables are the key components

87
00:03:14,760 --> 00:03:16,410
that comprise the shell environment

88
00:03:16,410 --> 00:03:18,180
and tell the shell how it should operate

89
00:03:18,180 --> 00:03:20,880
and how it should act and present itself to you.

90
00:03:20,880 --> 00:03:23,430
For example, you can set shell variables

91
00:03:23,430 --> 00:03:26,430
by typing VAR equals and the value.

92
00:03:26,430 --> 00:03:29,730
So if I wanted to create a variable called MYVARIABLE,

93
00:03:29,730 --> 00:03:33,120
I can say MYVARIABLE=123,

94
00:03:33,120 --> 00:03:36,120
and this will be able to have that new word, MYVARIABLE,

95
00:03:36,120 --> 00:03:38,520
reference the number 123.

96
00:03:38,520 --> 00:03:41,520
Anytime I want to pull out the information from that variable,

97
00:03:41,520 --> 00:03:43,260
I'll simply type it out in the format

98
00:03:43,260 --> 00:03:46,620
of dollar sign, curly bracket, the variable name,

99
00:03:46,620 --> 00:03:47,970
and curly bracket.

100
00:03:47,970 --> 00:03:49,620
And this can be used inside of your scripts

101
00:03:49,620 --> 00:03:51,240
to retrieve the value from the variable

102
00:03:51,240 --> 00:03:54,330
and then perform logical functions or commands upon it.

103
00:03:54,330 --> 00:03:56,670
For example, if I wanted to display the contents

104
00:03:56,670 --> 00:03:58,380
of my variable to the screen,

105
00:03:58,380 --> 00:04:01,293
I would simply enter echo ${MYVARIABLE}

106
00:04:04,350 --> 00:04:05,760
at the command line environment

107
00:04:05,760 --> 00:04:06,930
and hit Enter.

108
00:04:06,930 --> 00:04:09,000
Then I'm going to see what is echoed,

109
00:04:09,000 --> 00:04:13,050
which is the contents of that variable, which was 123.

110
00:04:13,050 --> 00:04:15,720
Now, there are some built in environmental variables

111
00:04:15,720 --> 00:04:19,140
that you're going to come across as well inside of Bash.

112
00:04:19,140 --> 00:04:23,190
This includes things like path and shell and HISTSIZE.

113
00:04:23,190 --> 00:04:24,023
Let's talk a little bit about

114
00:04:24,023 --> 00:04:26,100
these different environmental variables.

115
00:04:26,100 --> 00:04:27,540
Now, an environmental variable

116
00:04:27,540 --> 00:04:29,220
is really a variable that's inherited

117
00:04:29,220 --> 00:04:30,960
from the parent shell process,

118
00:04:30,960 --> 00:04:32,520
and it's subsequently going to be passed on

119
00:04:32,520 --> 00:04:35,070
to any child processes that respond.

120
00:04:35,070 --> 00:04:37,800
These environmental variables can consist of a name,

121
00:04:37,800 --> 00:04:40,830
usually written in upper case letters, and then a value.

122
00:04:40,830 --> 00:04:43,260
For example, if I'm using the path variable,

123
00:04:43,260 --> 00:04:45,720
it's going to contain the name of the path.

124
00:04:45,720 --> 00:04:47,670
Some of the default environmental variables

125
00:04:47,670 --> 00:04:49,260
include certain functions,

126
00:04:49,260 --> 00:04:50,370
such as HOSTNAME,

127
00:04:50,370 --> 00:04:53,010
which is going to be set to the host name of the system.

128
00:04:53,010 --> 00:04:55,710
SHELL, which is going to be set to the shell path

129
00:04:55,710 --> 00:04:59,250
for the system such as /bin/bash.

130
00:04:59,250 --> 00:05:01,710
MAIL, which is going to be set to where the mail

131
00:05:01,710 --> 00:05:03,480
is going to be stored on a given system,

132
00:05:03,480 --> 00:05:04,313
HOME.

133
00:05:04,313 --> 00:05:06,240
This is a variable that defines the home directory

134
00:05:06,240 --> 00:05:07,350
for the user.

135
00:05:07,350 --> 00:05:08,220
PATH.

136
00:05:08,220 --> 00:05:10,050
This is a variable where it's going to specify

137
00:05:10,050 --> 00:05:11,790
the search path that you should look for

138
00:05:11,790 --> 00:05:13,350
whenever you invoke a command

139
00:05:13,350 --> 00:05:14,820
because it knows those are places

140
00:05:14,820 --> 00:05:18,900
that commands are usually kept, such as the /bin directory.

141
00:05:18,900 --> 00:05:19,980
HISTSIZE.

142
00:05:19,980 --> 00:05:22,320
This is a variable that specifies the number of entries

143
00:05:22,320 --> 00:05:24,150
that are stored in the command history

144
00:05:24,150 --> 00:05:25,800
inside that given shell.

145
00:05:25,800 --> 00:05:26,850
And USER.

146
00:05:26,850 --> 00:05:28,620
This is a variable that specifies the name

147
00:05:28,620 --> 00:05:31,080
of the user that's currently logged in.

148
00:05:31,080 --> 00:05:33,060
Now, environmental variables can also be used

149
00:05:33,060 --> 00:05:35,040
to configure localization options

150
00:05:35,040 --> 00:05:40,040
by editing things inside the /etc/locale.conf file

151
00:05:40,530 --> 00:05:44,040
and then assign the appropriate locale to the variable.

152
00:05:44,040 --> 00:05:47,100
The LC_*variable is going to specify

153
00:05:47,100 --> 00:05:50,070
a collection of localization environmental variables.

154
00:05:50,070 --> 00:05:53,100
The LANG variable is going to specify the locale to use

155
00:05:53,100 --> 00:05:57,900
for all the LC_* variables that aren't explicitly defined.

156
00:05:57,900 --> 00:06:00,210
The LC_ALL is going to be a variable

157
00:06:00,210 --> 00:06:02,880
that specifies the locality use for all options.

158
00:06:02,880 --> 00:06:04,380
And this will override whatever is stored

159
00:06:04,380 --> 00:06:07,350
in LANG and LC_*.

160
00:06:07,350 --> 00:06:09,990
Another environmental variable you can use for localization

161
00:06:09,990 --> 00:06:13,350
is for time zone, which is written as TZ.

162
00:06:13,350 --> 00:06:14,730
TZ stands for time zone,

163
00:06:14,730 --> 00:06:17,520
and it specifies the time zone of your given system

164
00:06:17,520 --> 00:06:19,890
and stores that in that variable.

165
00:06:19,890 --> 00:06:22,290
Now, you can effectively change a shell variable

166
00:06:22,290 --> 00:06:23,970
into an environmental variable

167
00:06:23,970 --> 00:06:26,400
by simply using the export command.

168
00:06:26,400 --> 00:06:29,790
For example, if you have a shell variable called SHELL_VAR,

169
00:06:29,790 --> 00:06:31,770
you can enter export SHELL_VAR

170
00:06:31,770 --> 00:06:34,050
to make it an environmental variable.

171
00:06:34,050 --> 00:06:35,820
You can also change the value of the variable

172
00:06:35,820 --> 00:06:37,170
while you're exporting it

173
00:06:37,170 --> 00:06:39,630
by including the existing environmental variables

174
00:06:39,630 --> 00:06:41,280
and the equal sign.

175
00:06:41,280 --> 00:06:43,260
To do this you can enter something like,

176
00:06:43,260 --> 00:06:48,260
export SHELL_VAR="New value" at your command line.

177
00:06:48,720 --> 00:06:50,160
To run the export command,

178
00:06:50,160 --> 00:06:53,670
simply type in export, the options, and the variable name,

179
00:06:53,670 --> 00:06:56,610
and then the value if you're going to use that option.

180
00:06:56,610 --> 00:06:57,600
The next command we have

181
00:06:57,600 --> 00:07:01,410
is known as the environment command, spelled env.

182
00:07:01,410 --> 00:07:03,750
The env Command is used to run a command

183
00:07:03,750 --> 00:07:06,300
with modified environmental variables.

184
00:07:06,300 --> 00:07:08,070
To do this, you're going to simply supply

185
00:07:08,070 --> 00:07:09,270
the name of a variable

186
00:07:09,270 --> 00:07:11,730
and a value in key value pair format

187
00:07:11,730 --> 00:07:13,680
as well as the command that you want to run.

188
00:07:13,680 --> 00:07:14,670
And this will be able to change

189
00:07:14,670 --> 00:07:16,380
the value of the specified variable

190
00:07:16,380 --> 00:07:19,020
for that particular command session only.

191
00:07:19,020 --> 00:07:22,800
To run this, simply type in env, the options,

192
00:07:22,800 --> 00:07:25,140
the name of the variable equals the value,

193
00:07:25,140 --> 00:07:27,090
and the command you want to run.

194
00:07:27,090 --> 00:07:29,190
If you want to see all of the shell variables,

195
00:07:29,190 --> 00:07:31,560
environmental variables, and shell functions,

196
00:07:31,560 --> 00:07:33,990
you can do this by using this set command.

197
00:07:33,990 --> 00:07:37,080
Simply type in set and hit Enter without any arguments

198
00:07:37,080 --> 00:07:38,850
to print out all of your shell variables,

199
00:07:38,850 --> 00:07:41,460
environmental variables, and shell functions.

200
00:07:41,460 --> 00:07:42,900
You can also use the set command

201
00:07:42,900 --> 00:07:44,880
to enable the use of options in a shell script

202
00:07:44,880 --> 00:07:46,740
to change its behavior too.

203
00:07:46,740 --> 00:07:48,510
Now, to summarize some of the differences

204
00:07:48,510 --> 00:07:49,830
between these three commands,

205
00:07:49,830 --> 00:07:51,240
let's do a quick review.

206
00:07:51,240 --> 00:07:53,850
The export command is going to change the value of the variable

207
00:07:53,850 --> 00:07:55,890
for all of your child processes,

208
00:07:55,890 --> 00:07:57,000
the environmental command

209
00:07:57,000 --> 00:07:58,770
is going to view the environmental variables

210
00:07:58,770 --> 00:08:00,720
or change the value of a variable

211
00:08:00,720 --> 00:08:02,820
for a specified command being run,

212
00:08:02,820 --> 00:08:05,460
and the set command is going to view all the shell variables

213
00:08:05,460 --> 00:08:06,960
or environmental variables

214
00:08:06,960 --> 00:08:10,380
and it can be used to change the value of shell attributes.

215
00:08:10,380 --> 00:08:13,320
All right, the next thing we're going to talk about is search,

216
00:08:13,320 --> 00:08:14,190
and I mentioned earlier

217
00:08:14,190 --> 00:08:16,950
that we had an environmental variable called path.

218
00:08:16,950 --> 00:08:19,050
Well, a search path is really a sequence

219
00:08:19,050 --> 00:08:20,610
of various directory paths

220
00:08:20,610 --> 00:08:23,340
that's going to be used by the shell to locate files.

221
00:08:23,340 --> 00:08:24,870
These paths can be assigned

222
00:08:24,870 --> 00:08:26,820
to the path environmental variable,

223
00:08:26,820 --> 00:08:30,030
and the path variable has a list of all the directory names

224
00:08:30,030 --> 00:08:31,890
separated by colons.

225
00:08:31,890 --> 00:08:33,450
You can also set a new path

226
00:08:33,450 --> 00:08:36,510
to the existing group of path names, modify that path,

227
00:08:36,510 --> 00:08:38,730
or delete a path by overwriting the contents

228
00:08:38,730 --> 00:08:40,470
of this variable.

229
00:08:40,470 --> 00:08:41,700
Now, earlier I talked about

230
00:08:41,700 --> 00:08:44,010
the HISTSIZE environmental variable.

231
00:08:44,010 --> 00:08:45,570
There's also a companion one to this

232
00:08:45,570 --> 00:08:48,030
known as the HISTFILESIZE variable.

233
00:08:48,030 --> 00:08:49,260
This is a shell variable

234
00:08:49,260 --> 00:08:51,660
that enables you to set the maximum number of lines

235
00:08:51,660 --> 00:08:54,090
contained in the command history file.

236
00:08:54,090 --> 00:08:55,980
This is slightly different than HISTSIZE,

237
00:08:55,980 --> 00:08:58,740
because HISTSIZE is telling you how many commands

238
00:08:58,740 --> 00:09:00,090
you can store in memory,

239
00:09:00,090 --> 00:09:03,150
but HISTFILESIZE tells you how many you can store

240
00:09:03,150 --> 00:09:05,250
in the command's history file.

241
00:09:05,250 --> 00:09:07,920
By overriding the value of the HISTFILESIZE,

242
00:09:07,920 --> 00:09:11,220
you can set exactly how many lines or previous commands

243
00:09:11,220 --> 00:09:14,070
you want to be able to have stored in that file.

244
00:09:14,070 --> 00:09:17,370
For example, if you assign a value of 20 to this variable,

245
00:09:17,370 --> 00:09:21,120
the history file will cut off after it gets 20 lines.

246
00:09:21,120 --> 00:09:24,270
By default, the value of this variable is 1000,

247
00:09:24,270 --> 00:09:26,070
meaning your system is memorizing

248
00:09:26,070 --> 00:09:29,370
the last 1000 things you've done in the command line

249
00:09:29,370 --> 00:09:31,890
and storing that in the history file.

250
00:09:31,890 --> 00:09:34,410
Another command we have is known as alias.

251
00:09:34,410 --> 00:09:37,320
The alias command is used to customize the shell environment

252
00:09:37,320 --> 00:09:39,630
by generating command line aliases.

253
00:09:39,630 --> 00:09:41,940
Now, aliases are essentially short hands

254
00:09:41,940 --> 00:09:43,410
for longer expressions.

255
00:09:43,410 --> 00:09:46,590
And by using aliases, you can create short sequences

256
00:09:46,590 --> 00:09:49,290
that you can type in to represent longer commands

257
00:09:49,290 --> 00:09:52,200
and all the various options and arguments it has.

258
00:09:52,200 --> 00:09:54,600
For example, I often find myself using

259
00:09:54,600 --> 00:09:57,900
the ls -la command.

260
00:09:57,900 --> 00:10:00,210
This tells me to list out things in a directory

261
00:10:00,210 --> 00:10:01,980
and showing me everything there

262
00:10:01,980 --> 00:10:03,390
in a list that I can understand

263
00:10:03,390 --> 00:10:05,490
and see all of their different characteristics,

264
00:10:05,490 --> 00:10:07,980
such as the owners and the file permissions.

265
00:10:07,980 --> 00:10:10,260
But if I didn't want to type that out each time,

266
00:10:10,260 --> 00:10:13,050
I can create an alias called myls

267
00:10:13,050 --> 00:10:16,980
that then includes the ls -la command inside of it.

268
00:10:16,980 --> 00:10:20,670
To do this, we can go ahead and set it by typing an alias,

269
00:10:20,670 --> 00:10:23,760
the alias name, equals, and the command with options.

270
00:10:23,760 --> 00:10:27,937
So in my case, that would be alias, myls='la -ls'

271
00:10:31,320 --> 00:10:33,120
Now, after running this alias command,

272
00:10:33,120 --> 00:10:36,360
anytime I type in myls in the command line,

273
00:10:36,360 --> 00:10:38,160
it's going to execute the substitute command

274
00:10:38,160 --> 00:10:39,600
that I made the alias for,

275
00:10:39,600 --> 00:10:41,820
which was ls -la.

276
00:10:41,820 --> 00:10:44,130
This is really helpful when you have very long commands

277
00:10:44,130 --> 00:10:44,963
you want to run

278
00:10:44,963 --> 00:10:46,530
and you want to use this as a shorthand.

279
00:10:46,530 --> 00:10:48,660
In this case, I didn't save that much effort

280
00:10:48,660 --> 00:10:50,790
because myls is four characters

281
00:10:50,790 --> 00:10:53,910
and ls -la is six characters.

282
00:10:53,910 --> 00:10:56,250
So it didn't save me too much time here.

283
00:10:56,250 --> 00:10:57,720
Now, another thing you want to think about

284
00:10:57,720 --> 00:10:59,670
is how you can find out how long it takes

285
00:10:59,670 --> 00:11:00,990
for a command to run,

286
00:11:00,990 --> 00:11:02,460
and this will be able to give you a better idea

287
00:11:02,460 --> 00:11:05,370
how you can optimize your frequently used tasks.

288
00:11:05,370 --> 00:11:08,010
To do this, you can use the time command.

289
00:11:08,010 --> 00:11:09,900
The time command is used to gather information

290
00:11:09,900 --> 00:11:12,720
about how long it takes to execute a given command

291
00:11:12,720 --> 00:11:15,750
as well some additional statistics about the input output

292
00:11:15,750 --> 00:11:18,690
and memory used by that command's execution.

293
00:11:18,690 --> 00:11:20,910
By default, the time command is going to give you

294
00:11:20,910 --> 00:11:23,700
three different pieces of statistical information.

295
00:11:23,700 --> 00:11:25,560
The first is the real time that elapsed

296
00:11:25,560 --> 00:11:27,390
between when you started running the command

297
00:11:27,390 --> 00:11:29,040
and when it terminated,

298
00:11:29,040 --> 00:11:31,050
the second is the amount of time spent

299
00:11:31,050 --> 00:11:33,060
running the code inside the user space,

300
00:11:33,060 --> 00:11:35,580
which is known as the user CPU time,

301
00:11:35,580 --> 00:11:38,100
and the third is the system CPU time,

302
00:11:38,100 --> 00:11:39,630
which is the time spent running the code

303
00:11:39,630 --> 00:11:41,370
inside the kernel space.

304
00:11:41,370 --> 00:11:43,410
So by having these three pieces of information

305
00:11:43,410 --> 00:11:45,060
you have the total amount of time,

306
00:11:45,060 --> 00:11:47,880
the time in user space, and the time in kernel space.

307
00:11:47,880 --> 00:11:49,920
This can tell you a lot about a given program

308
00:11:49,920 --> 00:11:51,180
and what permissions it's using

309
00:11:51,180 --> 00:11:53,550
at certain times during it's execution.

310
00:11:53,550 --> 00:11:54,690
To run the time command,

311
00:11:54,690 --> 00:11:56,790
simply type in time, the options,

312
00:11:56,790 --> 00:11:59,190
and the command that you want to evaluate.

313
00:11:59,190 --> 00:12:01,290
All right, we covered a lot in this lesson,

314
00:12:01,290 --> 00:12:02,940
but let's do a quick recap

315
00:12:02,940 --> 00:12:05,190
of what you can do when things go wrong.

316
00:12:05,190 --> 00:12:07,080
Sometimes you're going to encounter some issues

317
00:12:07,080 --> 00:12:07,913
when you're using

318
00:12:07,913 --> 00:12:10,800
or customizing these Bash shell environmental variables.

319
00:12:10,800 --> 00:12:13,110
When you add an alias, if you get an error,

320
00:12:13,110 --> 00:12:14,760
always go back and check your syntax

321
00:12:14,760 --> 00:12:16,620
to make sure you typed it in correctly.

322
00:12:16,620 --> 00:12:19,020
Whenever you're executing scripts or other programs,

323
00:12:19,020 --> 00:12:20,850
if they're not stored in a normal location

324
00:12:20,850 --> 00:12:22,080
for executable files,

325
00:12:22,080 --> 00:12:23,790
they may have trouble finding them.

326
00:12:23,790 --> 00:12:25,740
And so you may need to add their location

327
00:12:25,740 --> 00:12:26,970
to the path variable,

328
00:12:26,970 --> 00:12:29,070
or you're going to have to execute those

329
00:12:29,070 --> 00:12:32,730
by using a dot slash proceeding the command or script's name

330
00:12:32,730 --> 00:12:36,510
to say use the one right here in this current directory.

331
00:12:36,510 --> 00:12:38,340
Remember, if you need to set a variable

332
00:12:38,340 --> 00:12:40,320
for all your shell child processes,

333
00:12:40,320 --> 00:12:42,480
you're going to use the export command.

334
00:12:42,480 --> 00:12:45,240
Also, remember all your environmental variables

335
00:12:45,240 --> 00:12:48,090
do get stored by default in your Bash profile.

336
00:12:48,090 --> 00:12:50,100
So you can configure the environmental variables

337
00:12:50,100 --> 00:12:52,720
inside that file by going to -/.bash_profile

338
00:12:56,190 --> 00:12:57,930
and making those variables available

339
00:12:57,930 --> 00:13:00,210
to all of your shells by default.

340
00:13:00,210 --> 00:13:02,190
For example, if you have a service account

341
00:13:02,190 --> 00:13:04,290
that requires certain environmental variables,

342
00:13:04,290 --> 00:13:06,780
you can set those up inside your Bash profile

343
00:13:06,780 --> 00:13:07,920
for that account.

344
00:13:07,920 --> 00:13:10,200
Just edit the Bash profile file

345
00:13:10,200 --> 00:13:11,760
to change those default variables,

346
00:13:11,760 --> 00:13:12,930
and it will then inherit those

347
00:13:12,930 --> 00:13:15,000
every time you launch a new shell.

348
00:13:15,000 --> 00:13:16,710
Finally, sometimes it's important

349
00:13:16,710 --> 00:13:18,480
that you set environmental variables

350
00:13:18,480 --> 00:13:20,070
for certain software packages

351
00:13:20,070 --> 00:13:22,110
based on the dependencies they have.

352
00:13:22,110 --> 00:13:24,960
For example, let's say that we have a Java application

353
00:13:24,960 --> 00:13:27,360
that relies on the Java runtime environment.

354
00:13:27,360 --> 00:13:29,160
It may only be able to find and access

355
00:13:29,160 --> 00:13:30,240
that runtime environment

356
00:13:30,240 --> 00:13:32,790
if it's referenced inside the path variable,

357
00:13:32,790 --> 00:13:34,980
which is an environmental variable after all.

358
00:13:34,980 --> 00:13:35,940
So you always need to make sure

359
00:13:35,940 --> 00:13:38,610
these things are working properly and working together

360
00:13:38,610 --> 00:13:41,060
to allow you to use your system more effectively.

