1
00:00:00,270 --> 00:00:02,220
In this lesson, we're going to discuss

2
00:00:02,220 --> 00:00:04,590
how to configure devices and how you can use

3
00:00:04,590 --> 00:00:07,710
common services to customize how the system interacts

4
00:00:07,710 --> 00:00:09,330
with certain hardware.

5
00:00:09,330 --> 00:00:11,610
Now today's computers have come a long way

6
00:00:11,610 --> 00:00:13,170
from our traditional ones.

7
00:00:13,170 --> 00:00:15,840
Apart from massive increases in speed, memory,

8
00:00:15,840 --> 00:00:18,720
and storage capabilities, the most notable changes

9
00:00:18,720 --> 00:00:21,150
are in the configuration and setup.

10
00:00:21,150 --> 00:00:22,890
In this lesson, we're going to explore

11
00:00:22,890 --> 00:00:25,590
some common hardware settings and some commands

12
00:00:25,590 --> 00:00:28,440
that Linux has for managing your hardware.

13
00:00:28,440 --> 00:00:30,900
Now, device files represent information

14
00:00:30,900 --> 00:00:33,750
about hardware devices, and in some cases,

15
00:00:33,750 --> 00:00:36,420
they define the settings about how those devices

16
00:00:36,420 --> 00:00:38,490
can be used and customized.

17
00:00:38,490 --> 00:00:40,320
These files are going to be located

18
00:00:40,320 --> 00:00:41,730
in several different directories

19
00:00:41,730 --> 00:00:44,670
and sub directories in your Linux system.

20
00:00:44,670 --> 00:00:47,520
For example, if you go to the /proc directory,

21
00:00:47,520 --> 00:00:50,010
it contains various files that represent system

22
00:00:50,010 --> 00:00:52,650
information that's reported by the kernel.

23
00:00:52,650 --> 00:00:56,730
In particular, the /proc/ devices file contains a list

24
00:00:56,730 --> 00:00:58,260
of all the device drivers

25
00:00:58,260 --> 00:01:00,270
that the kernel is currently running.

26
00:01:00,270 --> 00:01:02,520
Each of those are going to be separated by character

27
00:01:02,520 --> 00:01:05,760
and block storage devices for easier reference.

28
00:01:05,760 --> 00:01:08,730
This /sys directory is a virtual file system

29
00:01:08,730 --> 00:01:12,240
similar to /proc, but this one is going to focus more

30
00:01:12,240 --> 00:01:15,870
on creating a hierarchical view of that device information.

31
00:01:15,870 --> 00:01:19,830
For example, if you look at /sys/devices,

32
00:01:19,830 --> 00:01:21,630
this is a sub directory that includes

33
00:01:21,630 --> 00:01:25,320
files that expose details about specific devices.

34
00:01:25,320 --> 00:01:28,110
The next directory we have is /dev.

35
00:01:28,110 --> 00:01:31,770
The /dev directory contains device driver files that enable

36
00:01:31,770 --> 00:01:35,370
the system and users to access the devices themself.

37
00:01:35,370 --> 00:01:38,370
For example, you can mount a block storage device

38
00:01:38,370 --> 00:01:41,400
by referencing it from the /dev directory,

39
00:01:41,400 --> 00:01:46,400
like /dev/sda1 for the first hard drive.

40
00:01:46,410 --> 00:01:49,650
Similarly, the /dev/mapper is going to

41
00:01:49,650 --> 00:01:52,590
contain all your logical volumes, encrypted volumes,

42
00:01:52,590 --> 00:01:56,070
and other devices that are managed by the device mapper.

43
00:01:56,070 --> 00:01:59,160
On the other hand, the /etc directory contains

44
00:01:59,160 --> 00:02:01,620
configuration files for many components,

45
00:02:01,620 --> 00:02:03,330
including components that interface

46
00:02:03,330 --> 00:02:05,070
with the different devices.

47
00:02:05,070 --> 00:02:10,050
For example, /etc/X11 is going to be a sub directory

48
00:02:10,050 --> 00:02:12,390
that contains configuration files for input

49
00:02:12,390 --> 00:02:15,570
and output devices that might impact your x.org

50
00:02:15,570 --> 00:02:17,760
server environment, such as your mouse,

51
00:02:17,760 --> 00:02:20,280
your keyboard, and your monitors.

52
00:02:20,280 --> 00:02:22,860
Now, when we talk about devices, we have these type

53
00:02:22,860 --> 00:02:25,290
of devices that are known as hot-pluggable.

54
00:02:25,290 --> 00:02:28,110
Now a hot-pluggable device can be physically added

55
00:02:28,110 --> 00:02:31,020
or removed from the system without requiring a reboot

56
00:02:31,020 --> 00:02:32,820
in order for you to use that device.

57
00:02:32,820 --> 00:02:34,050
So you can hot-plug it.

58
00:02:34,050 --> 00:02:36,360
You can plug it in at any time.

59
00:02:36,360 --> 00:02:39,330
Hot-pluggable devices will be detected by the system

60
00:02:39,330 --> 00:02:40,890
as they're being plugged in.

61
00:02:40,890 --> 00:02:44,010
Whereas cold-pluggable devices like RAM modules,

62
00:02:44,010 --> 00:02:47,250
the CPU's processor, and some internal storage devices

63
00:02:47,250 --> 00:02:50,220
are not sensed when they're connected to a running system,

64
00:02:50,220 --> 00:02:53,670
and instead you need to shut down or reboot that system

65
00:02:53,670 --> 00:02:55,710
before they'll recognize those.

66
00:02:55,710 --> 00:02:58,800
Most modern Linux distributions support hot-plugging

67
00:02:58,800 --> 00:03:01,920
for many standard BUS types, in particular,

68
00:03:01,920 --> 00:03:06,450
USB, firewire, SATA, and other related technologies.

69
00:03:06,450 --> 00:03:09,390
Even expansion bus technologies like PCIE

70
00:03:09,390 --> 00:03:10,950
are able to support hot-plugging

71
00:03:10,950 --> 00:03:13,740
in many modern Linux distributions.

72
00:03:13,740 --> 00:03:17,160
Another thing we want to talk about is the udev utility.

73
00:03:17,160 --> 00:03:20,100
The udev utility handles module loading for both

74
00:03:20,100 --> 00:03:22,920
cold-pluggable and hot-pluggable devices.

75
00:03:22,920 --> 00:03:25,620
It's going to load up the modules for cold-pluggable devices

76
00:03:25,620 --> 00:03:27,930
when the system is initially booted up.

77
00:03:27,930 --> 00:03:30,120
The modules for hot-pluggable devices though,

78
00:03:30,120 --> 00:03:32,190
can be loaded by udev dynamically

79
00:03:32,190 --> 00:03:34,110
during the system's run time anytime

80
00:03:34,110 --> 00:03:36,210
you plug in one of those devices.

81
00:03:36,210 --> 00:03:38,790
Udev will then manage the automatic detection

82
00:03:38,790 --> 00:03:42,060
and configuration of those hardware devices for you.

83
00:03:42,060 --> 00:03:47,060
Another directory we need to focus on is /et/udev/rules.d.

84
00:03:48,750 --> 00:03:51,000
This directory is used to configure rules

85
00:03:51,000 --> 00:03:52,890
for how udev functions.

86
00:03:52,890 --> 00:03:54,870
You can create files in this directory

87
00:03:54,870 --> 00:03:56,880
to tell udev to configure a device

88
00:03:56,880 --> 00:03:59,040
in a certain way, or run a certain command

89
00:03:59,040 --> 00:04:01,140
whenever a device is plugged in.

90
00:04:01,140 --> 00:04:03,840
For example, you might want to create a symbolic link

91
00:04:03,840 --> 00:04:06,930
to a specific device every time it's plugged in.

92
00:04:06,930 --> 00:04:09,390
This way, you can always refer to that device

93
00:04:09,390 --> 00:04:11,580
in the same way instead of having to rely on

94
00:04:11,580 --> 00:04:15,570
the unpredictable or non-descriptive /dev naming scheme

95
00:04:15,570 --> 00:04:20,570
like /dev/sda1 or /dev/sdb2

96
00:04:20,730 --> 00:04:23,400
or whatever it happens to assign randomly.

97
00:04:23,400 --> 00:04:25,260
There's actually a couple of other directories

98
00:04:25,260 --> 00:04:27,780
that are used to configure these udev rules.

99
00:04:27,780 --> 00:04:32,780
For example, the /etc/udev/rules.d directory

100
00:04:33,150 --> 00:04:36,780
is also going to be used for local administration of udev.

101
00:04:36,780 --> 00:04:39,300
An administrator can apply their own customizations

102
00:04:39,300 --> 00:04:42,300
to this directory, so udev behaves in accordance

103
00:04:42,300 --> 00:04:44,850
with the administrator's preferences and desires

104
00:04:44,850 --> 00:04:48,270
and it can match up to your organization's business needs.

105
00:04:48,270 --> 00:04:53,270
Another one we have is /usr/lib/udev/rules.d.

106
00:04:54,120 --> 00:04:57,180
And this directory also contains udev rules.

107
00:04:57,180 --> 00:05:00,150
However, these rules are generated by the system

108
00:05:00,150 --> 00:05:02,490
and you should really refrain from editing them.

109
00:05:02,490 --> 00:05:05,130
Rules in this directory are low priority,

110
00:05:05,130 --> 00:05:08,790
so a custom rule named 60-keyboard.rules

111
00:05:08,790 --> 00:05:13,440
in the /etsy/udev/rules.d will supersede

112
00:05:13,440 --> 00:05:15,990
the default 60-keyboard.rules

113
00:05:15,990 --> 00:05:20,990
inside the /usr/lib/udev/rules.d path.

114
00:05:21,480 --> 00:05:23,880
Therefore, anything that's really important to you

115
00:05:23,880 --> 00:05:28,230
make sure you put it in the /etsy/udev/rules.d

116
00:05:28,230 --> 00:05:30,240
directory instead.

117
00:05:30,240 --> 00:05:31,560
The next command we're going to talk

118
00:05:31,560 --> 00:05:34,020
about is the udev admin command,

119
00:05:34,020 --> 00:05:37,380
which is spelled U-D-E-V-A-D-M.

120
00:05:37,380 --> 00:05:40,980
The udev admin command is used to manage udev.

121
00:05:40,980 --> 00:05:43,140
Now the udev admin command has various

122
00:05:43,140 --> 00:05:46,350
sub commands as well, and each one performs certain tasks

123
00:05:46,350 --> 00:05:49,800
to modify the behavior of the system udev admin

124
00:05:49,800 --> 00:05:51,990
or it's related components.

125
00:05:51,990 --> 00:05:54,900
If you use the info sub command you'll be able to view

126
00:05:54,900 --> 00:05:57,450
the device's vendor ID, product ID,

127
00:05:57,450 --> 00:05:59,760
serial number, and much more.

128
00:05:59,760 --> 00:06:02,010
This sub command of info is also used

129
00:06:02,010 --> 00:06:03,960
to retrieve device information that's stored

130
00:06:03,960 --> 00:06:07,470
from the udev database as well as detailed device attributes

131
00:06:07,470 --> 00:06:10,050
from the /system file system.

132
00:06:10,050 --> 00:06:12,540
Now, the control sub command is going to modify

133
00:06:12,540 --> 00:06:14,550
the running state of udev.

134
00:06:14,550 --> 00:06:18,390
For example, if you use the option --reload-rules

135
00:06:18,390 --> 00:06:20,310
underneath the control sub command,

136
00:06:20,310 --> 00:06:22,890
this will allow udev to read any new rules

137
00:06:22,890 --> 00:06:25,110
that you may have added to the system.

138
00:06:25,110 --> 00:06:28,050
The trigger subcommand is going to execute rules that apply

139
00:06:28,050 --> 00:06:30,540
to any device that is currently plugged in

140
00:06:30,540 --> 00:06:34,260
and you can also specify an action using the -c option

141
00:06:34,260 --> 00:06:37,350
such as adding, removing, or changing.

142
00:06:37,350 --> 00:06:39,660
The monitor subcommand is used to watch

143
00:06:39,660 --> 00:06:43,020
for events sent by the kernel or by a udev rule.

144
00:06:43,020 --> 00:06:45,690
The test subcommand is going to be used to simulate

145
00:06:45,690 --> 00:06:47,970
a udev event that's running for device

146
00:06:47,970 --> 00:06:50,250
and present the results as output.

147
00:06:50,250 --> 00:06:54,930
To run your udev admin command, type U-D-E-V-A-D-M

148
00:06:54,930 --> 00:06:58,680
the options, the sub command, and then the arguments.

149
00:06:58,680 --> 00:06:59,910
Now, the next thing we're going to talk

150
00:06:59,910 --> 00:07:02,400
about is printers and printers are typically bundled

151
00:07:02,400 --> 00:07:04,380
with software utilities that enable you

152
00:07:04,380 --> 00:07:06,660
to configure the settings for that printer.

153
00:07:06,660 --> 00:07:09,870
These utilities may target a specific operating system

154
00:07:09,870 --> 00:07:11,640
so you definitely need to confirm whether

155
00:07:11,640 --> 00:07:14,490
or not they will run on your Linux system.

156
00:07:14,490 --> 00:07:17,100
Even if you can't run the manufacturer software utilities

157
00:07:17,100 --> 00:07:18,750
on Linux, you may be able to work

158
00:07:18,750 --> 00:07:21,330
with that printer through a Linux utility instead

159
00:07:21,330 --> 00:07:23,640
that's an open source alternative.

160
00:07:23,640 --> 00:07:27,780
For example, there's something known as CUPS, C-U-P-S.

161
00:07:27,780 --> 00:07:30,210
This is the common Unix printing system

162
00:07:30,210 --> 00:07:31,800
and it is a print management system

163
00:07:31,800 --> 00:07:34,140
for Linux that enables a computer to function

164
00:07:34,140 --> 00:07:35,790
as a print server.

165
00:07:35,790 --> 00:07:38,610
CUPS is going to be designed for scheduling print jobs,

166
00:07:38,610 --> 00:07:40,290
processing administrative commands,

167
00:07:40,290 --> 00:07:42,290
and providing printer status information

168
00:07:43,212 --> 00:07:44,400
to local and remote programs.

169
00:07:44,400 --> 00:07:47,040
CUPS will also provide a web-based interface

170
00:07:47,040 --> 00:07:48,900
for configuring the service.

171
00:07:48,900 --> 00:07:50,610
Changes made through this interface

172
00:07:50,610 --> 00:07:55,610
will modify the /etc/cups/cupsd.dotconf file

173
00:07:56,460 --> 00:08:00,583
and the /etc/cups/cups-files.config file.

174
00:08:03,570 --> 00:08:05,613
The next command we have is lpr,

175
00:08:06,498 --> 00:08:08,490
and this submits files for printing.

176
00:08:08,490 --> 00:08:10,740
Files supplied to the command line are going to be sent

177
00:08:10,740 --> 00:08:13,080
to the specified printer or to the print queue

178
00:08:13,080 --> 00:08:14,760
if the printer is busy.

179
00:08:14,760 --> 00:08:16,740
Without specifying the printer to use,

180
00:08:16,740 --> 00:08:18,390
the command is going to send the print job

181
00:08:18,390 --> 00:08:22,290
to its default printer which you can configure using CUPS.

182
00:08:22,290 --> 00:08:24,750
The lpr command will read the print file

183
00:08:24,750 --> 00:08:26,970
from standard input if there's no files

184
00:08:26,970 --> 00:08:29,190
that are supplied at the command line.

185
00:08:29,190 --> 00:08:33,150
The lpr command has various options, including -E

186
00:08:33,150 --> 00:08:35,490
which is an option that's used to force encryption

187
00:08:35,490 --> 00:08:37,461
when connecting to a server.

188
00:08:37,461 --> 00:08:40,260
P with the destination option is going to be used

189
00:08:40,260 --> 00:08:44,250
to send the print job to the destination printer specified.

190
00:08:44,250 --> 00:08:46,290
Number of copies is an option that's used

191
00:08:46,290 --> 00:08:48,510
to set the number of copies that you're going to print

192
00:08:48,510 --> 00:08:50,730
from one to 100.

193
00:08:50,730 --> 00:08:54,123
T and name is an option used to set the job name.

194
00:08:55,140 --> 00:08:57,870
L is an option to specify the print file

195
00:08:57,870 --> 00:09:00,690
that's going to be already format and sent to the destination

196
00:09:00,690 --> 00:09:02,250
without being filtered.

197
00:09:02,250 --> 00:09:04,830
O is an option that's used to set the job option

198
00:09:04,830 --> 00:09:06,480
like printing and landscape mode,

199
00:09:06,480 --> 00:09:09,090
scaling the printed output, printing double sided,

200
00:09:09,090 --> 00:09:10,980
or something else like that.

201
00:09:10,980 --> 00:09:13,590
Job options will vary depending on the printer

202
00:09:13,590 --> 00:09:16,170
but using that -O option will give you

203
00:09:16,170 --> 00:09:19,050
all those different options you can choose from.

204
00:09:19,050 --> 00:09:22,260
P is an option which is used to print the specified file

205
00:09:22,260 --> 00:09:25,380
with a shaded header that includes the date, the time,

206
00:09:25,380 --> 00:09:27,450
the job name, and the page number

207
00:09:27,450 --> 00:09:30,240
and this is commonly used in corporate environments.

208
00:09:30,240 --> 00:09:32,820
The -R option will be used to specify

209
00:09:32,820 --> 00:09:36,360
that the printed files need to be deleted after printing.

210
00:09:36,360 --> 00:09:39,990
All right, if you want to use the lpr command, simply type

211
00:09:39,990 --> 00:09:43,563
in lpr the options and the file names that you want to print.

