Navigating Linux basics from the founder of Gentoo:
Part I
- BASH: Basics of Navigation (Intro)
- File and Directory Management
- Links, and deleting files and directories
- Glob-substitutions (totals and links)
Part II
- Regular Expressions (Intro)
- Folder Assignments, File Search
- Process management
- Text processing and redirection
- Kernel modules (totals and links)
Part III: 1 , 2 , 3 , 4
The uname command gives you lots of interesting information about your system. Here is an example of output on my working machine, after I typed uname -a, which tells the uname command to print all the available information:
$ uname -a
Linux inventor 2.4.20-gaming-r1 #1 Fri Apr 11 18:33:35 MDT 2003 i686 AMD Athlon(tm) XP 2100+ AuthenticAMD GNU/Linux
Now, let's see what kind of information about the system can give uname
-s "Linux" -n "inventor" -r "2.4.20-gaming-r1" -v "#1 Fri Apr 11 18:33:35 MDT 2003" -m "i686" -p "AMD Athlon(tm) XP 2100+" -i "AuthenticAMD" -o "GNU/Linux"
Intriguing! What does uname -a print on you?
And now a little trick. To begin, run uname -r so that the program prints the kernel release that is currently running.
Now look in the directory / lib / modules and - oops! - I'm sure you found a directory with the exact same name! OK, no magic, now is the time to talk about the meaning of the directories in / lib / modules , and also to explain what kernel modules are.
The Linux kernel is the heart of what is commonly called “Linux” —a piece of code that interacts directly with your hardware and abstracts ordinary programs from it. Thanks to the kernel, your text editor does not need to worry about which disk, SCSI or IDE, and maybe even in RAM, it records. The editor simply writes to the file system, and the kernel takes care of the rest.
So what are kernel modules? They are part of the kernel, which is stored on a disk in a special format. At your command, they load into the working kernel and add new functionality to it.
Since kernel modules are loaded on demand, you may have a kernel supporting additional functionality that will normally be turned off and unavailable.
But “once in a hundred years,” these modules will be very useful and can be loaded — often automatically — to support a strange file system or device that you rarely use.
In general, kernel modules allow on-demand capabilities to be added to a working kernel. Without modules, you would have to compile a new kernel and reboot in order to add support for something new.
To view the loaded modules on your system, use the lsmod command:
# lsmod Module Size Used by Tainted: PF vmnet 20520 5 vmmon 22484 11 nvidia 1547648 10 mousedev 3860 2 hid 16772 0 (unused) usbmouse 1848 0 (unused) input 3136 0 [mousedev hid usbmouse] usb-ohci 15976 0 (unused) ehci-hcd 13288 0 (unused) emu10k1 64264 2 ac97_codec 9000 0 [emu10k1] sound 51508 0 [emu10k1] usbcore 55168 1 [hid usbmouse usb-ohci ehci-hcd]
As you can see, quite a few modules are loaded on my system. vmnet and vmmon modules provide the necessary functionality for VMWare Workstation , which allows me to run virtual machines in the desktop window. The nvidia module is released by NVIDIA corporation and allows you to use 3D acceleration in Linux.
Then I have a set of modules that are used to support USB input devices - mousedev, hid, usbmouse, input, usb-ohci, ehci-hcd and usbcore. It makes sense to configure your kernel to support USB modules. Why? Because USB devices are “plug and play” (plug and play) devices and if you have USB support in the modules, you can safely go and buy a new USB device, connect it, and your system will automatically load the appropriate modules for this device. This is a convenient way to do something.
The modules complete this list: emu10k1, ac97_codec and sound, which together provide support for my Audigy sound card.
It should be noted that some of my modules are available directly in the kernel source. For example, all USB modules were compiled from standard Linux kernel sources. However, nvidia, emu10k1 and VMWare modules were obtained from other sources. This emphasizes another important feature of the kernel modules — the ability of third-party manufacturers to add the necessary functionality to the kernel and include it directly into the running kernel. No reboot.
In my /lib/modules/2.4.20-gaming-r1/ folder, there are several
Files that start with the line "modules.":
$ ls /lib/modules/2.4.20-gaming-r1/modules.*
/lib/modules/2.4.20-gaming-r1/modules.dep
/lib/modules/2.4.20-gaming-r1/modules.generic_string
/lib/modules/2.4.20-gaming-r1/modules.ieee1394map
/lib/modules/2.4.20-gaming-r1/modules.isapnpmap
/lib/modules/2.4.20-gaming-r1/modules.parportmap
/lib/modules/2.4.20-gaming-r1/modules.pcimap
/lib/modules/2.4.20-gaming-r1/modules.pnpbiosmap
/lib/modules/2.4.20-gaming-r1/modules.usbmap
These files contain a lot of information about various dependencies. In particular, they contain dependency information for modules - some modules require loading other modules before being launched.
Some kernel modules are designed to work with special devices, such as emu10k1 - a module to support my sound card. For this type of module, the above files also include information about PCI IDs and other equipment identification tags that they support. This information can be used by various scripts, for example “hotplug” (which we will look at in the following manuals) to automatically detect the equipment and load the corresponding modules.
Information on dependencies may not be relevant, especially in the case of installing new modules. To update it, just type depmod -a. The depmod program will scan the modules from your / lib / modules folder and update the dependency information. It does this by scanning the modules in / lib / modules and checking the so-called “symbols” inside the modules.
So, what do kernel modules look like? For kernel 2.4, all module files are usually located in / lib / modules and have a name ending in ".o" (for 2.6 ".ko" - ed.). To see all modules from / lib / modules , enter the following:
# find /lib/modules -name '*.o'
/lib/modules/2.4.20-gaming-r1/misc/vmmon.o
/lib/modules/2.4.20-gaming-r1/misc/vmnet.o
/lib/modules/2.4.20-gaming-r1/video/nvidia.o
/lib/modules/2.4.20-gaming-r1/kernel/fs/fat/fat.o
/lib/modules/2.4.20-gaming-r1/kernel/fs/vfat/vfat.o
/lib/modules/2.4.20-gaming-r1/kernel/fs/minix/minix.o
[ ]
So, how do you load the module into a working kernel? One option is to use the command
insmod and give it the full path to the module that you want to load:
# insmod /lib/modules/2.4.20-gaming-r1/kernel/fs/fat/fat.o
# lsmod | grep fat fat 29272 0 (unused)
Although, usually modules are loaded using the modprobe command. One of the nice things that modprobe does is automatically load all the necessary dependencies for this module. In addition, you do not need to specify the full path and extension of the loadable module.
Let's unload our fat.o module and load it back using modprobe:
# rmmod fat
# lsmod | grep fat
# modprobe fat
# lsmod | grep fat
fat 29272 0 (unused)
As you can see, the work of the rmmod command is very similar to the operation of modprobe, but it has the opposite effect - it unloads the specified module.
You can use the modinfo command to find out a couple of interesting things about your favorite modules:
# modinfo fat
filename: /lib/modules/2.4.20-gaming-r1/kernel/fs/fat/fat.o description: <none> author: <none> license: "GPL"
Also note the /etc/modules.conf file. It contains settings for modprobe and allows you to change the behavior of modprobe. For example, specify which modules to load before / after loading the rest, run scripts before and after loading the module, and much more.
The syntax and functionality of modules.conf are quite complex, and we will not go into them now (type man modules.conf for all the details), but there are a few things you need to know about this file.
First, many distributions generate this file automatically from a set of files in other directories, such as /etc/modules.d/ . For example, Gentoo Linux has such a folder, and running the update-modules command will read all the files from /etc/modules.d/ and merge them into the new /etc/modules.conf . Therefore, after making your changes to the files in /etc/modules.d/, run update-modules if you are using Gentoo. In Debian, the procedure is very similar, except that the folder is called / etc / modutils / .
For kernels of version 2.6, the similar in functionality file and folder from the etc directory are called modprobe.conf and modprobe.d respectively. The syntax is simplified there, see man modprobe.conf
- Editor's note.
My congratulations; You have reached the end of this tutorial on the basics of administering Linux! I hope it helped you to systematize your knowledge about Linux a little. Please join us in the following guide to more advanced aspects of administration, such as access rights, user management, file system, mount, and more. In the next tutorial, we will build on the foundation laid here. And remember, continuing to study this series of tutorials, you will very soon be ready to take exams for an LPIC Level 1 certificate from the Linux Professional Institute.
Speaking about LPIC certification, if you are really interested in it, then I strongly recommend that you study the following sources that have been carefully selected to enhance the knowledge gained in this guide.
There are many good regular expression guides on the net. Here are a couple:
You can read the Filesystem Hierarchy Standard at http://www.pathname.com/fhs/ .
In the Bash series in the examples (will be the translation), I will show you how to use the bash instructions to write your own scripts. This series (especially the first and second parts) will be a good preparation for the LPIC Level 1 exam:
You can learn more about sed in the Sed Guide Series in examples (to be translated). If you are planning to take the LPI exam, be sure to read the first two parts of this series.
To learn more about awk, see the Awk series in the examples (there will be a translation).
If you are not familiar with the vi editor, I strongly recommend that you look at my Vi manual — the cheat sheet method . This tutorial will be easy, but also a rapid introduction to this powerful text editor. Consider this material to be read if you do not know how to use vi.
Thank you Dmitry Minsky (Dmitry.Minsky@gmail.com) for the translation.
Daniel Robbins is the founder of the Gentoo community and the creator of the Gentoo Linux operating system. Daniel lives in New Mexico with his wife, Mary, and two energetic daughters. He is also the founder and head of Funtoo , has written many technical articles for IBM developerWorks , Intel Developer Services and the C / C ++ Users Journal.
Chris Hauser was a UNIX supporter since 1994 when he joined the team of administrators at Taylor University (Indiana, USA), where he received a bachelor's degree in computer science and mathematics. After that, he worked in many areas, including web applications, video editing, drivers for UNIX, and cryptographic protection. Currently working in Sentry Data Systems. Chris also contributed to many free projects, such as Gentoo Linux and Clojure, co-authored The Joy of Clojure .
Airon Griffis lives in Boston, where he spent the last decade working with Hewlett-Packard on projects such as UNIX network drivers for Tru64, Linux security certification, Xen and KVM virtualization, and most recently, the HP ePrint platform. In his spare time, Airon prefers to ponder over the problems of programming while riding his bike, juggling bits, or cheering on the Boston Red Baseball team.
Source: https://habr.com/ru/post/107981/
All Articles