Linux programs how to work with them. Selecting a desktop environment. Command Line Basics

This article does not cover Linux installation. I assume that the reader has already installed one of the distributions of this OS. However, after successful installation, the user usually has many questions, some of which are answered in this article. In preparing this material, Black Cat Linux 6.02 was used, but everything stated below applies almost unchanged to other Linux distributions (for example, Red Hat or Mandrake).

As you know, you can work in Linux in graphics system X Window or in a text console. Most users prefer to work exclusively with the window manager after installation, but there are a wide range of tasks that can be performed (or are much easier) by working in the console. Therefore, this is where I would like to start this article.
First, a little about setup.

Working with the linuxconf program.
If at Linux installations you have configured automatic start X-ov, then you need to first go to the console. To do this, click Ctrl+Alt+F1. You will be taken to a virtual text console and after entering your username and password you will be able to issue commands shell. To return to the X Window, click Alt+F7. Generally speaking, by default you can work in 6 virtual consoles at once, which is often very convenient (switching between them is Alt+F1...Alt+F6).
In the console, enter the command linuxconf. The system management program will start. Here you can manage users, network connections, file systems, boot and other Linux settings. The program is organized as a drop-down menu. Navigation is carried out using the arrow keys, Enter And Tab. As an example, we will show how to create a new user and define its rights. Let's go to Config>User accounts>Normal>User accounts
A list of users is shown here. Click twice Tab to go to the button Add, then Enter. In the column Login name In the window that appears, enter the name of the new user. The remaining fields can be left untouched for now. After pressing the button Accept you will be asked for your password twice - and a new user has been created! I advise working as root as little as possible, since his mistake can cause the most fatal consequences for the system, while regular user can usually damage only its own files.

Linuxconf is also convenient for describing file systems. For example, let's look at how to "teach" Linux to see the Windows partition. Let's go to Config>File systems>Access local drive. A list of file systems described in the file appears /etc/fstab. To add to it new entry, click Add. In the column Partition we write /dev/hda1 for 1st section hard drive, /dev/hda2- for the second, etc. If you want to add the first section second hard disk - write /dev/hdb1, second - /dev/hdb2. In the column Type click Ctrl+x and select the type from the list file system (vfat for Windows). In the column Mount point dialing /mnt/win. After clicking Accept answer yes to the question about creating a new mount point. Now in the catalog /mnt you will have a catalog win, which should contain the contents of the Windows partition, but if you go into it, you will find that it is empty. In order to see your Windows partition in it, you need to give the command in the console mount/mnt/win. Among other Linux OS configuration programs, I would also like to note setup, which easily allows you to configure your keyboard, mouse, sound card and X Window.
Working in the console is quite convenient, but to navigate through directories it is much more pleasant to use Midnight Commander .After calling the command mc A Norton-like file manager appears on the screen, which is almost as powerful as DN or FAR. Personally, I also use mc to set access rights to files and directories, since it is much more convenient for me to use than the utility chown.

Installing applications under Linux.
For Linux, applications are delivered primarily in the form rpm-packages or .tar.gz-archives. Installed rpm-package by command rpm -i package name
Program rpm It will create all the directories necessary for the application to work and put the files there. If you already have a previous version of the application installed, then you need to provide the key on the command line --force to replace the old version. rpm-packages are available on the CD of most Linux distributions, as well as on many ftp servers on the Internet. If the extension rpm-file looks like .src.rpm, that is - source application, and you need to compile it yourself before running it (usually such packages contain instructions on how to do this). To remove a package from the system, issue the command rpm -e package name.
If you received the application as a packaged file with the extension .tar.gz, then to unpack it you need to give the command tar xzvf archive name. Next, you need to find a file with instructions for installing the application, which may vary in each specific case.
By the way, to view the contents of archives without unpacking them manually, it is convenient to use Midnight Commander. When you press Enter on the archive name, you enter it like a regular directory.
I would also like to mention one useful program - fsck. If, for example, while working in Linux you had a power cut or accidentally pressed reset :-), then when you boot the OS will ask for the root password and you will be in single-user mode. In it, the file system is mounted for read and execution only. To repair a damaged file system, issue the command fsck-Aa. After it's finished, give the command reboot, and after a reboot everything should work as before.
To view documentation for any Linux command on the command line, you need to specify: man command_name. The standard documentation viewer will launch and tell you about the usage, switches and configuration files of this command. If the information is not enough, then in the catalog /usr/doc you will find complete manuals to most Linux programs.
I would like to finish the review of useful programs launched from the console with document processing utilities. If you have ever tried to read text files created in DOS or Windows in Linux, you must have encountered the problem of transcoding. The fact is that Linux uses KOI-8 encoding, which is different from DOS or Windows. A utility is used to convert text recode. For example, we will show how to convert a file myfile.txt(Windows encoding) in KOI-8:
recode -wk myfile.txt myfile.koi
After executing this command, a file will be created in the current directory myfile.koi, which can be viewed with any text editor under Linux. Key -wk specifies conversion options (Windows - KOI8). There are 14 more possible keys. A list of them with a description can be obtained by issuing the command recode without parameters.
We are also interested in the program mswordview. It is designed to transform doc- files ( Microsoft Word) V HTML- a format that is supported by many editors on Linux. Now you won't need to keep Windows and MS Office on your hard drive just because you need to work with doc-files. By the way, the famous free office suite StarOffice, which runs on Linux, also works great with Microsoft Office files.
Now let's move on to working with X Window. If you don’t have X running by default, then run the command in the console xinit. If everything is configured normally, you will be taken to the graphical console. Next you need to give a command to start the window manager (for example, kde For KDE, or icewm For IceWM). These two operations can be replaced by one - a script startx. If none of the methods discussed above works, it means that your Xs are most likely configured incorrectly, and then you can try to fix it with the program setup discussed above.

There are quite a few window managers for Linux. Some of them claim to be similar to Windows 95 or MacOS, but most still have the original interface. In this article I will talk about KDE- in my opinion, this is better environment for work. I don't want to offend fans Gnome, but on my machine it runs much slower, which doesn't suit me.
After launching KDE, you are presented with an environment that at first glance looks like Windows. There is a button in the lower left corner TO, similar to a button Start in a well-known OS. At the bottom of the screen there is a taskbar, a clock, and a keyboard indicator. Well, in general, everything is like THERE. But this apparent similarity between the KDE and Windows interfaces will wear off pretty soon. You will see how much more convenient it is to work with the first one.
To begin with, I would advise running the script KAppFinder(its shortcut is on the desktop), which will add to the menu Personal those applications that are not included in KDE (for example, utilities Gnome, Netscape Navigator).
In order to configure appearance KDE, right-click on an empty space on the desktop and select Display properties. Here you can change the background, screen saver, fonts and display styles of KDE applications.
Shortcuts on the desktop are created similarly to Windows 98, i.e. via menu item New in the pop-up menu. This article looked at how to use the command mount you need to mount other hard disk partitions previously described in the file /etc/fstab using the program linuxconf. In KDE, you can create shortcuts on your desktop that correspond to these sections. To do this, click right button mouse on an empty desktop field to call up a pop-up menu. Choose New>System Device File. Give it a name (for example, "Windows"). Go to the tab Device. Here in the column Device set the section (for example, /dev/hda1), and in the column Mount point- the directory that was specified in linuxconf (in this article - /mnt/win). Count File system leave unchanged. After clicking OK, a “Windows” shortcut will appear on the desktop. Now, in order to get to this partition, you will no longer need to issue the mount command every time. When you double-click on the shortcut, mounting will occur automatically and you will see the contents of your Windows partition. By the way, I would like to dwell separately on the program that allows you to view catalogs. It's called kfm and launched from the menu System>File Manager. With this application you can not only manage files (like Microsoft Explorer), but also view html-files (which is very convenient when reading documentation), as well as “climbing” through ftp-archives, as if in their own way hard drive. The fact is that kfm has a built-in quite powerful browser that supports different encodings text, working through proxies, cookies and a lot of other stuff.

We are also interested in the application kpackage- Package Manager. It allows you to install and uninstall Linux applications without resorting to a console utility rpm described above. On the left side of the screen there is a list of installed packages, divided by category. When you select one of them, its description is shown on the right side of the screen.
Now a few words about typing. There are “numerous” editors for this noble occupation in Linux. Some (for example, ed, vi) have remained from THOSE times when people worked at “stupid” terminals and could only dream of X-s. In addition, Linux comes with a very powerful text editor Emacs, however, more than one article can be written about it. Now I will talk about two editors for KDE - kedit("Simple text editor") and kwrite("Advanced Editor"). I use the kedit editor all the time. It is small, fast and convenient. Allows you to check spelling, align text, open pages directly from the Internet and write them back. Your message can be sent immediately by mail. By the way, a little advice: in order to view the contents of a file in Windows encoding without using the utility recode described above, open this file in kedit and then to the menu Settings>Font select any font whose name ends with "1251". After this, you will be able to see the contents of the file, but you are unlikely to be able to change it.

Editor kwrite intended for typing program code rather than text. It allows you to mark up syntax, make bookmarks and much more that you cannot do kedit. In my opinion, one of its main advantages is the ability to rollback (similar to Undo on Windows).
Finally, I would like to note the program console. This is a graphical terminal emulator. Launched from X and functions as a virtual console. IN console you can enter commands shell or run Midnight Commander. Personally I use console to quickly launch the necessary applications in KDE. I don’t know about you, but I find it much more convenient to type on the keyboard kmmail, kedit or netscape than clicking on drop-down menus or shortcuts. Just don’t forget to put a sign after the application name "&" , otherwise the console will be locked until you exit it.

Even at the stage of preliminary study of the Linux system (stage: what is Linux and how to approach it), the user encounters such a term as Terminal. It scares some people away, but for others, on the contrary, it makes them want to try it.

Illustration linuxformat.com

Hello! I'm Anatoly Guslyakov, moderator of the Comss.ru website. Starting today we are opening a series interesting topics under the general title “Learning Linux Together.” Discussion topics will be in the form of articles or messages, which will cover various materials on the study of Ubuntu and its derivative systems. The material will be posted not only by the administration of the resource, but also by users who want to share their knowledge (personal knowledge is what is interesting, without copy-pasting from third-party resources). If voluminous topics will be posted, you must first discuss them with the resource administration; perhaps the proposed topic will be published as a separate article.

The goal is to learn the basics of Linux systems. The technique is probably not entirely ordinary, there will be no teachers, or rather, each user taking part will be a teacher. We will share our knowledge openly in a good-natured and warm atmosphere. Each topic of discussion (lesson) will end with practical consolidation of new knowledge on your system and comments with screenshots.

Let's start the first discussion!

Terminal and useful commands

Even at the stage of preliminary study of the Linux system (stage: what is Linux and how to approach it), the user encounters such a term as Terminal. It scares some people away, while others, on the contrary, have a desire to try it (why not try yourself as a programmer? 🙂).

What is Linux

There, on the Internet, we find information among user comments that it turns out that this thing is used to manage the entire system, install programs, correct errors, and generally do everything with its help.

The terminal is a graphical program that emulates a console, the user documentation from the site help.ubuntu.ru tells us.

All terminal commands also work in the console. The console works without a graphical shell and is usually necessary when there are problems starting the system.

So what is Terminal? The terminal is a tool that allows you to control the system directly, and also allows you to see any of our actions performed in any graphical program and in the system as a whole, that is, the user opening any folder and opening any program, at the same moment occur in as commands in the terminal.

Examples of the most popular commands (the terminal can be launched using hotkeys: Ctrl+Alt+T):

(package index update)

(direct program update)

Let's look at the components of the command:

  • sudo - run command with administrator rights (after entering it, you must enter the administrator password, the password itself is not visible, but don’t be afraid, enter it and then press the enter key);
  • apt-get is a powerful tool for installing and updating packages;
  • update — updating the list of packages, upgrade — updating the packages themselves.

- program installation;

— deleting the program;

It is best to install programs by adding their repositories, this will enable further automatic update programs, having first checked that the program is not in the Center Ubuntu applications(this way we check if this repository is not connected to us).

For most commands, you can get help by typing the additional command --help after the command.

And finally a few interesting teams:

— the command displays the version of the Linux kernel;

- list of active network connections;

- good mood team

Popular terminal emulators

As it turns out there is various emulators terminal. Each of them is interesting in its own way.

Let's look at the most popular terminal emulators:

Guake— a drop-down terminal reminiscent of the console from the popular game Quake. The terminal is loaded into memory, so calling the terminal is faster than a standard terminal. Available in the Ubuntu repository, so you can install it from the Ubuntu Application Center.

Final term— “smart” terminal emulator. Remembers the entered commands and offers them in a drop-down menu the next time you type them. Like most terminal emulators, Final term supports hotkeys, but through editing the settings file. Unfortunately, it froze during testing, but there is an explanation for this; Final term does not leave the alpha testing stage for a long time.

Let's move on to installation. At the time of writing this article, the program repository was not working, so we will install it from the source code. Additional tool Git, which we will install to install Final term, will be useful to us in the future for installing other programs.

(required quite popular tools)

(additional packages for GTK)

(download sources)

(let's move onVfolderfinalterm)

(createfolderbuild)

(let's move onVfolderbuild)

(tool for automatic assembly programs from source code)

(direct installation)

Terminator is a cross-platform terminal emulator that supports Microsoft systems Windows, Mac OS X, Linux, Unix X11. A convenient terminal emulator that allows you to create horizontal and vertical tabs, customize the interface display, many hotkeys and connect additional plugins.

You can install from the Ubuntu Application Center.

RXVT (color terminal with unicode support) is a very lightweight terminal emulator. I didn't find any settings. Its minimalism is similar to the built-in XTerm, but RXVT removes some features, such as Tektronix 4014 emulation and tool-style configuration.

Available in the native Ubuntu repository.

Well, for those who continue to use the standard Terminal, I suggest you decorate it a little with a picture, for example, a penguin named Tux (the official mascot of Linux).

Have a great mood everyone. See you in the discussion of the topic.

Comments and reviews

When adding a comment, please read the Community Guidelines

This article will talk about mastering the Linux OS. Others UNIX-like systems such as FreeBSD, AIX and Solaris will be covered in the next article.

First of all, you need to be patient and willing to learn new things. There will be a lot of new things, especially if you have not encountered the console before. The first thing you need to start with is choosing a distribution, and don’t rush to install Ubuntu, it will be of no use at all. I assure you that by installing it you will not master the console, Ubuntu is too friendly.

Paths of learning

The hard way

My learning experience began with Gentoo - it is difficult, tedious, interesting and gives a great experience. If you have a lot of time and desire to study how operating systems on the Linux kernel work, go ahead. Another distribution that will give you experience is Slackware. There is no point in studying both; it is worth stopping at one. They are similar in complexity, but Gentto is difficult to install and works with the best software installer - Portage, and Slackware has some difficulties with normal package installers.

Normal way

In industrial applications you are unlikely to see Gentoo or Slackware, most likely you will see Red Hat Enterprise Linux, Centos or sometimes Debian, less often these will be derivative distributions on rpm packages (OpenSuse). Actually, they need to be studied in a good way.

Useless way

In industrial use you won't find Fedora, Ubuntu or other custom distributions. And in general I don’t recommend starting to study with them, they are not for servers. Fedora, for example, may stop working after an update, and Ubuntu may freeze, but then comes next update and the bug is fixed. Now I'm faced with 16.04, no, it's not worth it.

How to study

First you need to install the selected distribution, preferably on real hardware. After installation (and if this is a Gentoo distribution in the process), configure the kernel for your hardware, this will give you an understanding of how the kernel is assembled and why. You will remember what the lspci and lsusb commands do, and many others. This will also allow you to master working in the console. It is best if you have an operating system on your computer for everyday use.

Errors

Collecting materials

Don't do this, you won't read any of the downloaded books. Very often, people starting to study something download “100 books on Linux”.

How Linux beginners can start using the Linux terminal

Don't repeat this mistake.

Courses

No. If you go to a course for 50,000 rubles, this does not mean that they will teach you something. The only thing you will take away from them is a diploma. And yes, no one will care about him.

Perhaps the article will be filled with more, I don’t know yet.

Learning commands

Wastes a lot of time and is of little use, to put it briefly.

Conclusion

Only practice and experience of use operating system will allow you to successfully use it and apply it in life. Over time, you will learn a lot, you will even encounter situations where Linux cannot be used, but only Windows.

Learn new things every day, it's useful.

The operation of the computer from the moment you press the power button until the system exits regular mode work is called bootstrapping. Initial loading occurs in two stages: first it boots core operating system, which then configures itself and starts system services.

The first stage - loading the kernel - does not depend on the type of operating system. The selection of the device from which to boot (hard disk, laser disk, disk drive) is performed by subroutines from the computer ROM - BIOS. Searches for the system kernel (possibly several) and configures kernel parameters loader, located on the device selected for downloading. Neither one nor the other requires additional configuration until an emergency situation arises. The loader (LInux LOader, LILO) recognizes several boot methods and several options for configuring the kernel, so at startup it offers to choose one option from several. From the LILO menu, select "linux-up".

The system boots automatically based on the parameters passed by the bootloader and information received during self-configuration. Each system service, when started, displays console diagnostics (“ready”), (“skipped”) and (“failure”). If everything is in order, all messages should look like this. Messages occur when the system decides that this service there is no reason to launch it: for example, when trying to load a driver for a non-existent device. The message means that the system service could not be started for some reason.

The messages do not indicate that the operating system is “corrupt,” but rather that the computer’s settings or environment have changed in an unexpected way. For example, if the system is configured to receive network address automatically, but the server issuing addresses is not on the network, the network service will display a message, and the system will continue to boot normally. You can monitor the system load by examining system logs, first of all, the one issued by the command dmesg.

In the process of work several are active virtual consoles. Each virtual console is accessible by clicking Alt And function key with the number of this console. Yes, in ALT Linux after When the system boots, the functions of the system console are taken over by the 12th virtual console ( AltF12). If running graphics subsystem X11, it occupies the seventh console, and to switch to text mode the described keys must be pressed together with Ctrl: CtrlAltF1, CtrlAltF2 etc.

it is forbidden turn it off by simply depriving the computer of power. The system keeps a lot of information that should be located on the disk. random access memory to improve performance. An unexpected power outage results in the loss of this information. You can stop the system using the command shutdown -h now. This will first stop system services, then unmount file systems, and then (if possible) shut down the computer. If software shutdown impossible, a corresponding message will be displayed on the screen, and the power can be turned off with the button Power.

If the computer supports the ACPI protocol, pressing the button Power does not turn off the power, but rather sends an ACPI message to the system that the button Power was pressed. When receiving such a message, the system performs the same actions as shutdown. Only in this case acceptable switch off with button Power.

The third option is to press on the keyboard CtrlAltDel, after which the system will go to reboot(stop and reboot immediately). These keys have no own action on the system, such a reaction is a kernel property that can be disabled. After waiting for the download to begin (for example, the LILO menu), you can turn off the computer.

Stopping the system and turning off the computer

Turning your computer on and off

In exists exactly one a user whose rights are significantly higher than the rights of other users of the system. It is called ("root"), or superuser. It corresponds to an account with name and user ID 0. To perform administrative actions, you must register in the system under this name. It is not recommended to perform any other work, except administrative work, on behalf of the user, since the cost of an error increases several times.

Per superuser no access restrictions apply files, so the right to exercise privileges requires great ethical and professional responsibility. This means that the superuser password must be known only person responsible in every sense. Better don't write down superuser password, and if such a need arises, keep the records in an inaccessible place, for example, in a safe.

For temporary perform actions with rights there is a command su —. Only group members (“steering wheel”) can execute this command. Group membership is determined by the contents of the file. In cases where you only need to transfer to the user Part permissions, it is recommended to use the sudo package.

You can add a new user using the command useradd login_name with optional additional parameters. The result of this command can be quite different depending on the account storage scheme. ALT Linux uses a TCB scheme in which when adding a new account a new line is added to the file, a new subdirectory and shadow file in him. For compatibility with other schemes, it can contain only Latin letters, numbers and underscores. You can use a key to set the user's full name.

Either the user himself or a superuser can change a user's password. Do not set a password that is easy to guess or guess! ALT Linux has a fairly strict password checking system. This scheme distinguishes between lowercase and uppercase Latin letters, numbers, and other symbols.

Newbie about Linux. FAQ

A good password should be no shorter than eight characters, contain at least three types of characters, and capital letters at the beginning and numbers at the end do not count. So, for example, a password is considered weak, but a password is considered strong.

Of course, the password should not include English words. However, if there are at least three of these words and they are separated by more than just spaces, the password - such as - is also considered strong. When you enter your password, nothing is displayed on the screen. Example:

teacher# useradd -c “Aksyon Vikulovich Ommetrov” axen teacher# passwd axen Enter new password: Re-type new password: passwd: all authentication tokens updated successfully.

You can delete a user's account, home directory, and mailbox using the command userdel -r login_name. If omitted, the home directory and mailbox are not deleted.

To change the settings of an existing account, use the utility usermod. In particular usermod -L login_name temporarily prohibits the use of the relevant account, and usermod -U login_name— cancels the ban.

Direct installation and removal of software products ( packages) in ALT Linux is handled by the rpm utility. However, it is inconvenient for an administrator to use because most packages cannot work properly unless some others are installed on the system, so they must be installed first. Those, in turn, may depend on some other packages, and so on. The apt family of utilities solve this problem: when installing one package, all the packages on which it depends are also calculated, after which it is added to the system kit packages required for work.

In addition, apt can take packages for installation from several sources. All sources are listed in the file. To add each distribution CD to the list of sources, use the command apt-cdrom add. Searching the sources for a package whose description contains a specific substring is carried out with the command apt-cache search. It is better not to perform the search on behalf of the superuser, since, for compatibility with system scripts, the user is set to only English interface language. To install a package on the system, use the command apt-get install package_name. Example:

teacher$ apt-cache search CDR cdda2wav - Utility for copying tracks from Audio CD cdrecord - Console utility for recording CD/DVD k3b - CD burning program mkisofs - Utility for creating ISO9660 images xcdroast - Graphical program for creating CDs teacher$ su - Password: teacher# apt-get install xcdroast Reading Package Lists… Done Building Dependency Tree… Done The following extra packages will be installed: cdda2wav The following NEW packages will be installed: cdda2wav xcdroast 0 upgraded, 2 newly installed, 0 removed and 1 not upgraded. Need to get 0B/2056kB of archives. After unpacking 4749kB of additional disk space will be used. Do you want to continue? Get:1 cdrom://Junior2.3 ALT/main cdda2wav 5:2.0-alt4 Get:2 cdrom://Junior2.3 ALT/main xcdroast 6:0.98alpha15-alt2 Fetched 2056kB in 0s (11.8MB/s) Committing changes... Preparing... ############################################## ######## 1: cdda2wav ######################################## ################ [50%] 2: xcdroast ############################ ############################ Done.

To work with packages using GUI You can use the synaptic program.

When using a system with a profile, before performing any administrative actions, you must stop using the remote using a system script /etc/init.d/etcmount stop.

Installation of software products

If users' home directories (especially network directories) accumulate too many unnecessary files, there may not be enough space for the files they need. Information on the fullness of file systems is displayed by the command df (disk free, free disk space). If the or field contains a zero or negative value, only the superuser is allowed to modify such a file system. It is recommended to identify which subdirectory contains the most unnecessary data and ask the owner to clean it up (or else do it by order, using superuser rights). To determine the size of directories, you can use the utility df.

Example of file system analysis:

teacher$ df File system Size Use Access Use% mounted on /dev/hda1 2.3G 1.5G 728M 67% / /dev/hda3 1.5G 1.4G 48M 96% /home $ su — Password: # du —max -depth=1 /home/chroot/nethome 5.4M /home/chroot/nethome/alex 2.7G /home/chroot/nethome/greedy 4.0M /home/chroot/nethome/netuser 2.7G /home/chroot/nethome # du --max-depth=1 -k /arc/home/george | sort -n | tail -4 25314 /home/chroot/nethome/greedy/Pass 56106 /home/chroot/nethome/greedy/.phoenix 2608536 /home/chroot/nethome/greedy/pictures 2764538 /home/chroot/nethome/greedy

In the above example, the obvious eater of free space is the owner of the directory (2.7 gigabytes) - most likely the user - with more than 2.5 gigabytes accounted for by a single subdirectory.

File systems full

The system installed and running on the machine needs to be updated only if updates correct security flaws (so-called security updates). Additionally, a fairly old system may need to be updated to be compatible with new file formats or network protocols. Update list packages are produced using the command apt-get update, and updating the system itself in accordance with the updated list - using apt-get dist-upgrade.

Linux: basics of working in Linux

What is the course about?

The LINUX course for beginners will help you master it in a short time Ubuntu distribution, will give information about the entire family of Linux distributions. You will learn how to quickly and efficiently configure your server using only the command line.

During the classes it will be suggested a large number of practical examples.

After completing the LINUX for Beginners course, you will gain the following knowledge and skills:

  • Learn to install Linux.
  • Learn console commands for Unix-like operating systems.
  • Learn to manage Linux system services.
  • Write small programs(scripts) on the BASH shell
  • Read and understand system logs, configure the logging service.
  • Launch WINDOWS applications on Linux using the wine emulator

Knowledge of LINUX will help you create and maintain high-performance and reliable servers. Servers that can work as in local network, and on the Internet

Linux operating system is worthy analogue Windows. If you have not worked in its environment before, then you should take into account several nuances that are unique to it.
During the check-in procedure in the operating room Linux system, it automatically performs the following operations:
the process begins as standard with checking the user login and password;
then the entire palette of the set consisting of environment variables is defined;
This process is completed by launching the command interpreter. This is what is called the operating system shell.
The majority of Linux distributions use two types of shells by default:
sh;
bash.
In fact, the palette of shells is much wider, but they are used much less frequently than those described above. Changing the default one is not difficult, and you can simply run it using the command line.
A command in the Linux operating system is a string of characters. It consists of the command name and required arguments, separated by spaces. Arguments allow a command to use additional parameters that dictate its behavior. For example, here is a standard command:
echo 12345
A chain of characters 12345 will appear on the screen, which are the argument of this command.
Commands that are part of the shell itself are defined as built-ins. They are:
are common;
specific.
General ones are characteristic of any. Specific ones will not work within a non-native OS.
There is a whole range of commands that are independent of the current shell. They are implemented in the form individual programs nal modules that are standard only for the one you select Linux distribution. Arguments can also be options or keys. These character strings consist of a dash and one or more symbols. An example is the following:
ls -l
Keys allow you to combine different arguments. As a result, you will receive identical commands:
ls -l -d
ls -ld
Working on the Linux command line requires strict adherence to a number of rules that are relevant only in information environment this operating system:
lowercase and capital letters for Linux these are different symbols. On Windows, the TEMP directory and Temp directory- the same thing, in Linux - no. These rules apply to everything: commands, their keys, usernames, passwords, etc. Console commands:
ps -a
And
ps-A
will give you different results;
By entering the –help switch on the command line you can get help on most commands:
1. ps –help: will give you help for the ps command, it is the one that has complete information and works with the complete list of processes you are running;
2. built-in system for receiving man help - will provide additional certificate;
3. man ps - will display the complete ps command on the screen;
Do not forget that the result of individual programs directly depends on your rights within the OS. The su command is responsible for root rights in the operating system. It is responsible for changing the user in the current session with the OS. If the user is not specified, then root is automatically selected.
For all Linux OS users, the mc file manager will be of great help. This is an analogue of FAR or Norton Commander. Currently, this useful module is included in all Linux distributions. There is one thing: it is not installed by default everywhere. It will help you solve many recurring problems.
Displaying information on the screen in Linux OS also has its own characteristics. Let's look at the main ones:
if the text has gone off the screen, you can easily correct the position using the key combination SHIFT and PAGE UP or PAGE DOWN;
if you want to pause the display of information on the screen – CTRL-S;
if suspension is required, cancel – CTRL-Q;
if you need to display a large amount of text in page-by-page mode, then use the less command, which is added to the main command:
we have in stock text file mytxt is 12 screens wide. To standardly display text on the screen, you can use the cat command< имя файла>
cat mytxt
After executing this command, you will see text flash quickly and
the last (twelfth) output screen. You can apply keyboard shortcuts
SHIFT-PAGEDOUN or SHIFT-PAGEUP to view text, but you can
take advantage of and less. We get the chain:
cat mytxt | less
Symbol | means combining the execution chain of the command for issuing text cat and the command for controlling paged output less. After the first page of text is displayed on the screen, output will be paused until PAGE DOWN or ENTER is pressed. Last combination will result in page movement;
The Q key is responsible for completing page output.
Linux allows you to chain multiple commands. If you want to display in page mode all lines containing the word mail. To search you can use the command
grep<строка поиска>
We get an alliance of three teams:
cat mytxt | grep mail | less
Many Linux distributions allow you to use more instead of less.
If you need to use several distributions at the same time, then there are key combinations assigned for switching: CTRL - ALT - F1...F6. To go to the graphical shell, feel free to press CTRL-ALT-F7.
If you need to start a second graphical server in Linux OS on one computer, use the startx 1 -- :1 command.
The combination Alt+F8 is responsible for moving to the second graphic terminal, and Alt+F7 returns to the first. Linux allows you to work with up to 64 graphic terminals at a time (startx 2 -- :2, etc.).
exit will end the current terminal session.
Linux allows you to create a special log of the current console session. It will print everything that you entered during a separate session. You can check what was entered via the keyboard and what was ultimately displayed on the screen.
Used next command:
script< имя файла журнала >
exit will stop logging.
If you need to shut down or restart your computer in Linux OS, then this procedure can be done in different ways:
shutdown: it boasts a wide range of options, allowing you to:
1. quick reboot without checking the file system;
2. reboot procedure at the required time;
3. simulate and cancel an already running or previously postponed reboot process;
shutdown --help will display the entire list of options;
restart will reboot the OS immediately:
shutdown -r now;
halt – power off:
shutdown -h now.
For the majority of distributions there is whole line short commands:
reboot – reboot;
halt – shutdown;
init – changes the current OS run level with the command responsible for starting and ending processes in Linux; Special scripts have also been developed for the same purposes. They are stored in /etc/inittab. Level 0 will provide a shutdown, and level 6 will reboot. Respectively:
to turn off:
init 0;
to reboot:
init 6;
init is also used to change the OS run level. Let's look at the levels in more detail:
1 – single-user mode. Access is granted to the root user;
2 – multi-user mode without support for network functions;
3 – with network support;
4 – reserved;
5 – using a graphical shell.
init 3 will terminate the graphical shell. Eventually it will close and the system will go to runlevel 3. To return you need to enter:
init 5
The default runlevel is determined by initdefault from /etc/inittab. To start the system if you need to support a graphical shell, use the command:
id:5:initdefault:
If 5 is replaced by 3, then graphical shell It will not start when the system starts. Never set the default system startup level to values ​​between 0 and 6.
In Linux OS, you can view the list of tasks using the ps command. Without specifying parameters, it will display a list of processes running during the current session. ps --help will output a full list of options as standard.
Example:
List of all processes running in the system:
ps -A - will display a list of processes with identifiers (PIDs) and their names
or:
ps -ax - will give the same list of processes, but with the full launch line
list of tasks generated by user:
ps -U user
list of tasks associated with the current terminal:
PS T
list of tasks related to terminal N:
ps tttyN
If the list of tasks is large, and we are interested in the status of one or more tasks, we can use grep:
ps -U root | grep ppp - list tasks containing "ppp" in the name
top displays computer resource usage data on the screen.


The upper part of the window will tell you the summary of the system state:
current time;
time since system boot;
number of users in the system;
number of processes in different states;
Memory and CPU usage data.
Below is a table describing individual processes. The number of rows displayed in this table is determined by the size of the window. The contents of the window are updated every 3 seconds. Pressing the h key displays help for commands that allow you to change the format of the displayed data and control some process parameters in the system:
s or d - change the window refresh interval.
z - color/black and white display
n or # - number of processes displayed
You can sort the list of processes by CPU usage (P), memory usage (M), execution time (T), and so on.
However, there is more useful commands, which allow you to manage processes interactively:
k - kill the task. This command will ask for a process identifier (PID), after entering which the process will be terminated.
r - change the current task priority (renice). As with the previous command, the PID will be requested, and then the new priority value (displayed in the NI column). The range of priority values ​​is from minus 20 (highest) to plus 19. Negative values ​​and 0 can only be set by the root user.
To exit top press q
kill command
Terminating a process and changing its priority can be done without the top command.
Processes in Linux allow you to exchange "signals" with the kernel and other processes. When a process receives a signal, the control runs a subroutine to process it. If it is not there, then either the kernel. Linux operates with a special kill command. It is this that makes it possible to send any signal to a given process. The list of signals can be obtained using the command:
kill -l
As a result of executing this command, you will see a list of signal numbers and names. Send a specific signal to the selected process using the command line input:
kill<-номерсигнала>PID number of the selected process
For example, we need to shut down the Midnight Commander (mc) application.
Let's define the process identifier mc:
ps -A | grep mc
Let PID= 11597.
We send the SIGQUIT signal (number 3):
kill -3 11597
After which the mc process will process the GIGQUIT signal and exit normally. However, if mc is stuck, then, naturally, it will not be able to complete, since the SIGQUIT signal processing subroutine will not receive control. In such cases, signal number 9 (SIGKILL) is used, processed by the operating system kernel, and forcefully terminating the specified process:
kill -9 11597
If the signal number is not specified in the kill command, then SIGKILL is used, the previous command could be entered as kill PID:
kill 11597
Terminating a process also terminates the processes running in it.
To terminate a process by name, use the killall command:
killall mc - kill a process whose name contains "mc";
killall -u user - kill processes spawned by user user.
The nice and renice commands change the priority of processes. When a process starts, its priority is set by the value of the parent process, such as an xterm terminal or command line shell. The nice command allows you to run a process with a priority equal to the sum of its parent (for example, 8) and the number specified as an option to the nice command:
nice -<число>team
nice -4 mc - will launch mc with priority = 8+4=12
The renice command is used to change the priority of an already running process:
renice<число>-p PID
renice 4 -p 11597 - set the priority value for the mc process (PID=11597) to 4.
After execution, renice will produce the result line:
11597: old priority 12, new priority 4 - old priority 12, new priority 4
Setting zero and negative number priority is only valid for a user with root rights.

The best way to understand how an operating system works is to follow it step by step as it boots. It is during boot that all the mechanisms that set the OS in motion are launched. This process is complex, multi-stage and sometimes confusing. It is interesting to study it, and the discoveries that you will make may greatly surprise you.

In general, booting the average Linux distribution can be divided into five stages:

  1. Loader.
  2. Launch and initial initialization of the kernel.
  3. Detecting hardware, loading drivers and mounting file systems.
  4. Launch system services(demons).
  5. Start a graphical or console user session.

We'll go through each stage and find out what happens during boot of a typical Linux distribution, veering a little towards BSD, macOS and Android along the way. In many cases, this will provide insight into why the Linux boot process is the way it is.

1. Bootloader

It all starts with the bootloader, to which the BIOS transfers control when the machine starts. In the old days, when Linux was not so popular, LILO (Linux Loader) was used as a bootloader - simple, very primitive and did not allow changing the boot configuration on the fly. In fact, the configuration file was built into the bootloader itself, and you had to reinstall it after each change of settings: you updated the kernel, forgot to reinstall, and your laptop no longer boots.

Today, loading Linux in almost any distribution is handled by Grub, originally developed for the GNU/Hard operating system. Grub is much more complex than LILO and is actually a full-fledged OS itself. It not only reads the boot config (usually /boot/grub/grub.cfg) directly from disk, but also allows you to correct this config in place. Grub has a built-in command line, works with a dozen different file systems, and allows you to create complex boot chains.

As soon as the user selects the desired menu item (or after a timeout), Grub finds the Linux kernel image associated with this menu item on disk (usually the file /boot/vmlinuz), as well as the initramfs image associated with it (more on that later ), loads them into memory and transfers control to the kernel.


Why vmlinuz?

The name of the kernel image file is historical roots. Initially, the classic UNIX kernel image was simply called unix, but when a version of the kernel for processors with memory protection appeared, the name was changed to vmunix to avoid confusion. The letter z instead of x at the end, in turn, means that the image is compressed using the gzip utility (Deflate algorithm, the same as in classic ZIP).

2. Kernel and initramfs

Having received control, the kernel begins primary initialization: the memory management subsystem is launched, the interrupt handler is configured, and the data structures necessary for further operation of the kernel are initialized. When this work is completed, the kernel unpacks the archive initramfs(usually it has a name like /boot/initramfs-linux.img and is a cpio archive compressed with gzip) to the in-memory file system (tmpfs), makes it the root file system and runs the /init script (name in various distributions may differ).

Initramfs includes basic set components of a Linux distribution: standard system directories /bin, /lib, /etc and so on, the simplest command interpreter(usually ash), a set of BusyBox commands, several auxiliary libraries and a set of kernel modules (drivers) designed to work with various drives and file systems.



The raison d'être of initramfs is to solve the chicken-and-egg problem: load drivers to mount the actual root filesystem before it is mounted. This is exactly what happens when the system runs the /init script. It detects the drives installed in the system, loads drivers into the kernel to work with them, and then connects the required partition of the desired drive (the kernel knows which one thanks to the root parameter passed at boot) to the root, thus overriding the contents of the initramfs. The script then runs /sbin/init , which is where it starts next step OS loading.



Continuation is available only to subscribers

Option 1. Subscribe to Hacker to read all materials on the site

Subscription will allow you to read EVERYTHING within the specified period paid materials site. We accept payments by bank cards, electronic money and transfers from mobile operator accounts.