In this lesson, we're going to discuss
how to configure devices and how you can use
common services to customize how the system interacts
with certain hardware.
Now today's computers have come a long way
from our traditional ones.
Apart from massive increases in speed, memory,
and storage capabilities, the most notable changes
are in the configuration and setup.
In this lesson, we're going to explore
some common hardware settings and some commands
that Linux has for managing your hardware.
Now, device files represent information
about hardware devices, and in some cases,
they define the settings about how those devices
can be used and customized.
These files are going to be located
in several different directories
and sub directories in your Linux system.
For example, if you go to the /proc directory,
it contains various files that represent system
information that's reported by the kernel.
In particular, the /proc/ devices file contains a list
of all the device drivers
that the kernel is currently running.
Each of those are going to be separated by character
and block storage devices for easier reference.
This /sys directory is a virtual file system
similar to /proc, but this one is going to focus more
on creating a hierarchical view of that device information.
For example, if you look at /sys/devices,
this is a sub directory that includes
files that expose details about specific devices.
The next directory we have is /dev.
The /dev directory contains device driver files that enable
the system and users to access the devices themself.
For example, you can mount a block storage device
by referencing it from the /dev directory,
like /dev/sda1 for the first hard drive.
Similarly, the /dev/mapper is going to
contain all your logical volumes, encrypted volumes,
and other devices that are managed by the device mapper.
On the other hand, the /etc directory contains
configuration files for many components,
including components that interface
with the different devices.
For example, /etc/X11 is going to be a sub directory
that contains configuration files for input
and output devices that might impact your x.org
server environment, such as your mouse,
your keyboard, and your monitors.
Now, when we talk about devices, we have these type
of devices that are known as hot-pluggable.
Now a hot-pluggable device can be physically added
or removed from the system without requiring a reboot
in order for you to use that device.
So you can hot-plug it.
You can plug it in at any time.
Hot-pluggable devices will be detected by the system
as they're being plugged in.
Whereas cold-pluggable devices like RAM modules,
the CPU's processor, and some internal storage devices
are not sensed when they're connected to a running system,
and instead you need to shut down or reboot that system
before they'll recognize those.
Most modern Linux distributions support hot-plugging
for many standard BUS types, in particular,
USB, firewire, SATA, and other related technologies.
Even expansion bus technologies like PCIE
are able to support hot-plugging
in many modern Linux distributions.
Another thing we want to talk about is the udev utility.
The udev utility handles module loading for both
cold-pluggable and hot-pluggable devices.
It's going to load up the modules for cold-pluggable devices
when the system is initially booted up.
The modules for hot-pluggable devices though,
can be loaded by udev dynamically
during the system's run time anytime
you plug in one of those devices.
Udev will then manage the automatic detection
and configuration of those hardware devices for you.
Another directory we need to focus on is /et/udev/rules.d.
This directory is used to configure rules
for how udev functions.
You can create files in this directory
to tell udev to configure a device
in a certain way, or run a certain command
whenever a device is plugged in.
For example, you might want to create a symbolic link
to a specific device every time it's plugged in.
This way, you can always refer to that device
in the same way instead of having to rely on
the unpredictable or non-descriptive /dev naming scheme
like /dev/sda1 or /dev/sdb2
or whatever it happens to assign randomly.
There's actually a couple of other directories
that are used to configure these udev rules.
For example, the /etc/udev/rules.d directory
is also going to be used for local administration of udev.
An administrator can apply their own customizations
to this directory, so udev behaves in accordance
with the administrator's preferences and desires
and it can match up to your organization's business needs.
Another one we have is /usr/lib/udev/rules.d.
And this directory also contains udev rules.
However, these rules are generated by the system
and you should really refrain from editing them.
Rules in this directory are low priority,
so a custom rule named 60-keyboard.rules
in the /etsy/udev/rules.d will supersede
the default 60-keyboard.rules
inside the /usr/lib/udev/rules.d path.
Therefore, anything that's really important to you
make sure you put it in the /etsy/udev/rules.d
directory instead.
The next command we're going to talk
about is the udev admin command,
which is spelled U-D-E-V-A-D-M.
The udev admin command is used to manage udev.
Now the udev admin command has various
sub commands as well, and each one performs certain tasks
to modify the behavior of the system udev admin
or it's related components.
If you use the info sub command you'll be able to view
the device's vendor ID, product ID,
serial number, and much more.
This sub command of info is also used
to retrieve device information that's stored
from the udev database as well as detailed device attributes
from the /system file system.
Now, the control sub command is going to modify
the running state of udev.
For example, if you use the option --reload-rules
underneath the control sub command,
this will allow udev to read any new rules
that you may have added to the system.
The trigger subcommand is going to execute rules that apply
to any device that is currently plugged in
and you can also specify an action using the -c option
such as adding, removing, or changing.
The monitor subcommand is used to watch
for events sent by the kernel or by a udev rule.
The test subcommand is going to be used to simulate
a udev event that's running for device
and present the results as output.
To run your udev admin command, type U-D-E-V-A-D-M
the options, the sub command, and then the arguments.
Now, the next thing we're going to talk
about is printers and printers are typically bundled
with software utilities that enable you
to configure the settings for that printer.
These utilities may target a specific operating system
so you definitely need to confirm whether
or not they will run on your Linux system.
Even if you can't run the manufacturer software utilities
on Linux, you may be able to work
with that printer through a Linux utility instead
that's an open source alternative.
For example, there's something known as CUPS, C-U-P-S.
This is the common Unix printing system
and it is a print management system
for Linux that enables a computer to function
as a print server.
CUPS is going to be designed for scheduling print jobs,
processing administrative commands,
and providing printer status information
to local and remote programs.
CUPS will also provide a web-based interface
for configuring the service.
Changes made through this interface
will modify the /etc/cups/cupsd.dotconf file
and the /etc/cups/cups-files.config file.
The next command we have is lpr,
and this submits files for printing.
Files supplied to the command line are going to be sent
to the specified printer or to the print queue
if the printer is busy.
Without specifying the printer to use,
the command is going to send the print job
to its default printer which you can configure using CUPS.
The lpr command will read the print file
from standard input if there's no files
that are supplied at the command line.
The lpr command has various options, including -E
which is an option that's used to force encryption
when connecting to a server.
P with the destination option is going to be used
to send the print job to the destination printer specified.
Number of copies is an option that's used
to set the number of copies that you're going to print
from one to 100.
T and name is an option used to set the job name.
L is an option to specify the print file
that's going to be already format and sent to the destination
without being filtered.
O is an option that's used to set the job option
like printing and landscape mode,
scaling the printed output, printing double sided,
or something else like that.
Job options will vary depending on the printer
but using that -O option will give you
all those different options you can choose from.
P is an option which is used to print the specified file
with a shaded header that includes the date, the time,
the job name, and the page number
and this is commonly used in corporate environments.
The -R option will be used to specify
that the printed files need to be deleted after printing.
All right, if you want to use the lpr command, simply type
in lpr the options and the file names that you want to print.