1
00:00:00,210 --> 00:00:01,470
Now a lot of times in Linux,

2
00:00:01,470 --> 00:00:03,360
we're going to have to do operations

3
00:00:03,360 --> 00:00:05,130
on the files that we create

4
00:00:05,130 --> 00:00:07,560
but the most common one is just to view them.

5
00:00:07,560 --> 00:00:11,130
Now, in this example, we're going to use the log file

6
00:00:11,130 --> 00:00:14,010
because we're going to tend to spend a lot of time there.

7
00:00:14,010 --> 00:00:15,930
So we're going to test out two versions

8
00:00:15,930 --> 00:00:19,380
of how to view these, the cat, which stands for concatenate

9
00:00:19,380 --> 00:00:21,510
and the less command.

10
00:00:21,510 --> 00:00:25,170
Now the original use of cat was to join two files

11
00:00:25,170 --> 00:00:27,450
or put the contents on one file into another

12
00:00:27,450 --> 00:00:30,510
but we typically use it to view small files.

13
00:00:30,510 --> 00:00:31,800
So we go see what happens when we use it

14
00:00:31,800 --> 00:00:33,273
with the larger type of file.

15
00:00:43,170 --> 00:00:45,180
Now we say we see a lot of the file,

16
00:00:45,180 --> 00:00:46,560
but we don't see all of it.

17
00:00:46,560 --> 00:00:48,720
Now we can scroll up with a scroll bar

18
00:00:48,720 --> 00:00:50,910
but there's more efficient ways to do this.

19
00:00:50,910 --> 00:00:52,020
This time, we're going to go through this

20
00:00:52,020 --> 00:00:53,403
by using the less command.

21
00:01:00,240 --> 00:01:01,920
Now we see with this display

22
00:01:01,920 --> 00:01:05,640
we can easily put everything on the same screen.

23
00:01:05,640 --> 00:01:08,490
Now to scroll up and down, you can use the up down arrow,

24
00:01:09,780 --> 00:01:11,310
or you can use d,

25
00:01:11,310 --> 00:01:16,310
page up and page down, if you want to use full pages,

26
00:01:17,430 --> 00:01:19,230
space bar also works.

27
00:01:19,230 --> 00:01:20,790
Now you see this command prompt

28
00:01:20,790 --> 00:01:23,193
a colon pretty much at the bottom left.

29
00:01:24,240 --> 00:01:25,770
You can search through this as well.

30
00:01:25,770 --> 00:01:27,040
So do /SELinux

31
00:01:31,140 --> 00:01:33,870
and now we can search this file as well.

32
00:01:33,870 --> 00:01:36,870
So less has a lot more features than cat

33
00:01:36,870 --> 00:01:38,850
and is typically used more.

34
00:01:38,850 --> 00:01:40,830
Now, if we want to go to the next instance

35
00:01:40,830 --> 00:01:43,830
of the particular search results that we use,

36
00:01:43,830 --> 00:01:45,183
I want to use d n.

37
00:01:49,110 --> 00:01:50,890
So I'm just tapping in the n key

38
00:01:53,250 --> 00:01:56,253
to go to the next result.

39
00:01:57,120 --> 00:01:59,910
If I want to go back, I just use the capitalization,

40
00:01:59,910 --> 00:02:00,873
So shift n.

41
00:02:04,800 --> 00:02:06,300
To get out of this can use quit.

42
00:02:06,300 --> 00:02:07,710
I'm going to press the q key.

43
00:02:07,710 --> 00:02:11,700
Now, another thing that we can do is use the head command.

44
00:02:11,700 --> 00:02:14,850
Now head and tail defaults to 10 lines.

45
00:02:14,850 --> 00:02:16,320
So this is very useful,

46
00:02:16,320 --> 00:02:19,560
if we know we only want to see the top portion of a file

47
00:02:19,560 --> 00:02:20,550
typically want to use the head

48
00:02:20,550 --> 00:02:22,050
for something that's repetitive,

49
00:02:22,050 --> 00:02:24,270
so we don't really need to,

50
00:02:24,270 --> 00:02:26,430
it gives us enough information to get the gist

51
00:02:26,430 --> 00:02:27,990
of what we're looking at.

52
00:02:27,990 --> 00:02:30,990
And the tail is usually used for logs

53
00:02:30,990 --> 00:02:33,480
to see the most recent occurrence of something,

54
00:02:33,480 --> 00:02:34,350
'cause that's typically when we're trying to

55
00:02:34,350 --> 00:02:35,220
track something down.

56
00:02:35,220 --> 00:02:37,110
So I'm try this really quick,

57
00:02:37,110 --> 00:02:42,110
I'm going to do head /var/logs/messages

58
00:02:44,607 --> 00:02:46,620
and see it gives us the first 10.

59
00:02:46,620 --> 00:02:48,870
Now we can also set the amount of lines

60
00:02:48,870 --> 00:02:50,370
that we're going to use.

61
00:02:50,370 --> 00:02:51,780
So let's try this,

62
00:02:51,780 --> 00:02:52,730
lets use sudo head,

63
00:02:54,990 --> 00:02:56,340
use the n option,

64
00:02:56,340 --> 00:02:57,790
I'm just going to do five lines.

65
00:03:02,790 --> 00:03:05,390
So now we see that we only get the first five lines.

66
00:03:06,450 --> 00:03:08,150
Let's try the same thing for tail.

67
00:03:15,420 --> 00:03:17,580
So we get the bottom 10 there,

68
00:03:17,580 --> 00:03:19,831
clear the screen to make it a little easier for us.

69
00:03:19,831 --> 00:03:21,390
Let me try this one more time,

70
00:03:21,390 --> 00:03:25,743
and we only want the first bottom five lines.

71
00:03:28,890 --> 00:03:30,210
Okay, we can see how that works.

72
00:03:30,210 --> 00:03:33,540
Next, I'm going to walk you through the process of moving files

73
00:03:33,540 --> 00:03:35,730
from one location to another,

74
00:03:35,730 --> 00:03:37,200
how to create a directory

75
00:03:37,200 --> 00:03:39,570
as well as remove an existing directory.

76
00:03:39,570 --> 00:03:43,110
So on this example, we're going to look at the options folder.

77
00:03:43,110 --> 00:03:44,710
So let's view this really quick,

78
00:03:45,810 --> 00:03:49,683
list up options go to linuxplus.

79
00:03:50,820 --> 00:03:52,620
Now I have five different

80
00:03:52,620 --> 00:03:55,410
acceptable use policy files in here.

81
00:03:55,410 --> 00:03:57,300
And so we're going to copy these over

82
00:03:57,300 --> 00:04:00,570
into our home directory folder.

83
00:04:00,570 --> 00:04:02,190
So we're going to use the copy command

84
00:04:02,190 --> 00:04:05,763
along with the r option that's for recursively.

85
00:04:06,884 --> 00:04:08,250
And then remember we're going to use this tab

86
00:04:08,250 --> 00:04:10,710
to make sure we're getting things together.

87
00:04:10,710 --> 00:04:11,543
All right.

88
00:04:11,543 --> 00:04:13,260
So we want to copy everything

89
00:04:13,260 --> 00:04:14,648
in the linuxplus folder,

90
00:04:14,648 --> 00:04:17,850
again that's what the recursively option is for.

91
00:04:17,850 --> 00:04:20,220
We can just use the tilde symbol here

92
00:04:20,220 --> 00:04:21,899
and create its own directory,

93
00:04:21,899 --> 00:04:23,430
in our home directory,

94
00:04:23,430 --> 00:04:26,760
we should now see a folder called linuxplus.

95
00:04:26,760 --> 00:04:29,040
So we're already presently in our home directory

96
00:04:29,040 --> 00:04:30,060
'cause you can see the tilde symbol

97
00:04:30,060 --> 00:04:31,410
at the end of the prompt.

98
00:04:31,410 --> 00:04:33,110
So we go ahead and list things out

99
00:04:34,110 --> 00:04:38,760
and now you see the linuxplus about four files down

100
00:04:38,760 --> 00:04:41,010
that directory was copied over.

101
00:04:41,010 --> 00:04:43,170
So we can list that out, see what's in there.

102
00:04:43,170 --> 00:04:45,240
Remember it's relative path,

103
00:04:45,240 --> 00:04:47,800
we don't need to put the forward slash

104
00:04:49,290 --> 00:04:51,810
and we can see successfully copied every file that was

105
00:04:51,810 --> 00:04:54,988
in the options linuxplus into our home directory

106
00:04:54,988 --> 00:04:56,940
and named it linuxplus as well.

107
00:04:56,940 --> 00:04:58,110
It's going to automatically just use

108
00:04:58,110 --> 00:04:59,288
the same naming convention

109
00:04:59,288 --> 00:05:03,570
that was used prior when using the copy command.

110
00:05:03,570 --> 00:05:04,860
So we're going to make a new directory,

111
00:05:04,860 --> 00:05:06,310
we're going to name it policies.

112
00:05:09,270 --> 00:05:10,440
Make sure that it got created,

113
00:05:10,440 --> 00:05:11,670
Okay, we see that there.

114
00:05:11,670 --> 00:05:13,920
So we're want to see into the linuxplus folder,

115
00:05:15,570 --> 00:05:17,370
and then again, let's list this out.

116
00:05:18,510 --> 00:05:20,310
It's clear, so we're going to move the

117
00:05:20,310 --> 00:05:22,143
acceptable use policy V1,

118
00:05:24,060 --> 00:05:25,980
we're going to move it to the policies folder.

119
00:05:25,980 --> 00:05:29,700
So the two dots mean we're going to go back

120
00:05:29,700 --> 00:05:30,570
to the parent directory,

121
00:05:30,570 --> 00:05:32,280
which is going to be our home folder,

122
00:05:32,280 --> 00:05:34,980
that's where the policies folder live.

123
00:05:34,980 --> 00:05:37,330
We're going to do the same thing with version two.

124
00:05:40,230 --> 00:05:45,230
Okay, so we list cd into the policies folder

125
00:05:48,750 --> 00:05:50,610
and list everything out.

126
00:05:50,610 --> 00:05:52,710
Okay, we see that was successfully moved over.

127
00:05:52,710 --> 00:05:55,740
Now with the move command, is different from the copy,

128
00:05:55,740 --> 00:05:59,670
It doesn't keep the existing object in place,

129
00:05:59,670 --> 00:06:02,580
it actually deletes it from this current location

130
00:06:02,580 --> 00:06:05,970
and creates it in this destination.

131
00:06:05,970 --> 00:06:09,820
So if we list out the linuxplus

132
00:06:12,120 --> 00:06:14,820
and we see we moved the acceptable use policy

133
00:06:14,820 --> 00:06:16,890
version one and version two.

134
00:06:16,890 --> 00:06:19,830
So again, the move command removes the current object

135
00:06:19,830 --> 00:06:23,100
from its source and puts it a destination.

136
00:06:23,100 --> 00:06:25,298
Any copy keeps the object in place,

137
00:06:25,298 --> 00:06:27,370
but just makes a replica of itself

138
00:06:27,370 --> 00:06:30,150
in the destinated location.

139
00:06:30,150 --> 00:06:33,450
Now we're going to go through and create placeholder files.

140
00:06:33,450 --> 00:06:35,790
So we're going to use the touch command.

141
00:06:35,790 --> 00:06:38,733
'Cause remember this one allows us to create a file,

142
00:06:39,630 --> 00:06:43,203
we'll just name it aup under score, we call it new.text.

143
00:06:46,828 --> 00:06:48,278
We can create a few of those.

144
00:06:53,910 --> 00:06:57,180
Okay, so list this up.

145
00:06:57,180 --> 00:06:59,520
We can see those were added.

146
00:06:59,520 --> 00:07:00,720
Okay if we use the concatenate

147
00:07:00,720 --> 00:07:05,460
we'll see that they they're empty,

148
00:07:05,460 --> 00:07:06,910
there's nothing in those, so.

149
00:07:07,744 --> 00:07:09,540
Or again, we can list it out,

150
00:07:09,540 --> 00:07:11,820
we just see zero bytes on them.

151
00:07:11,820 --> 00:07:13,830
Okay, now what we're going to do next

152
00:07:13,830 --> 00:07:16,080
is we're going to try to remove this linuxplus folder

153
00:07:16,080 --> 00:07:17,880
'cause we no longer need it.

154
00:07:17,880 --> 00:07:19,800
We brought it over just as a placeholder

155
00:07:19,800 --> 00:07:22,200
and then we wanted to put everything to our policies folder.

156
00:07:22,200 --> 00:07:24,030
So let's go back to that.

157
00:07:24,030 --> 00:07:29,030
So going to cd, going to go parent directory, linuxplus,

158
00:07:29,820 --> 00:07:31,950
all right so we're going to see that those

159
00:07:31,950 --> 00:07:33,960
three files are still remaining,

160
00:07:33,960 --> 00:07:36,270
and we're going to try to remove this directory.

161
00:07:36,270 --> 00:07:40,320
Okay, so now there's a remove directory command

162
00:07:40,320 --> 00:07:43,920
but it's only useful and only able enable us be used,

163
00:07:43,920 --> 00:07:46,050
if the current directory you are in

164
00:07:46,050 --> 00:07:48,480
or trying to target is empty.

165
00:07:48,480 --> 00:07:52,203
So we're just going to test it out really quick to see.

166
00:07:53,970 --> 00:07:58,970
So let's say tilde, that means our home directory,

167
00:07:59,100 --> 00:08:00,147
do linuxplus.

168
00:08:03,660 --> 00:08:04,830
And if you look at the error

169
00:08:04,830 --> 00:08:08,400
it says failed to remove because directory is not empty.

170
00:08:08,400 --> 00:08:09,330
So in order to do that,

171
00:08:09,330 --> 00:08:10,380
we're going to have to use the remove

172
00:08:10,380 --> 00:08:12,273
with the recursive option,

173
00:08:13,200 --> 00:08:17,913
tilde, linuxplus, and we see that it went through.

174
00:08:18,810 --> 00:08:21,540
So if we go through back to our home directory

175
00:08:21,540 --> 00:08:22,650
and we list it out,

176
00:08:22,650 --> 00:08:26,943
we should see the linuxplus folder is now gone.

177
00:08:29,520 --> 00:08:32,340
So we're going to do a clean example of just showing how

178
00:08:32,340 --> 00:08:33,960
if you make a directory, that's empty,

179
00:08:33,960 --> 00:08:38,960
going to call it test directory, list this out,

180
00:08:40,409 --> 00:08:45,000
we see the test directory about three from the bottom there,

181
00:08:45,000 --> 00:08:47,513
and now we're going to use the remove directory command.

182
00:08:50,460 --> 00:08:52,683
Again list it out, see it's gone.

183
00:08:53,580 --> 00:08:55,050
So that sums up this walkthrough,

184
00:08:55,050 --> 00:08:57,063
and I will see you in the next lesson.

