the Internet Windows Android

Linux Basics - Command String and File System. History and Standards UNIX Standard Hierarchy File System

Operating system UNIX.

Official date of birth of the operating system Unix They consider January 1, 1970. From now on, any UNIX system counts its system time. This is a very long time for the operating system. Today, despite the emergence of many other operating systems built on other principles, UNIX firmly occupies a place among leaders.

To the main characteristics of UNIX, which makes it possible to understand the causes of the long-life of this system, the following can be attributed.

The code code is written in the high level of C, which made it simple for understanding, changes and transfer to other hardware platforms.

Despite the manifold of UNIX versions, the basis of the entire family is fundamentally the same architecture and a number of standard interfaces.

UNIX has a simple but powerful set of standard user interfaces.

Unified UNIX file system interface implements access not only to data stored on disks, but also to terminals, printers, magnetic tapes, CDs, networks, and even to memory.

For the UNIX system, a large number of different applications have been developed - from the simplest text editors to powerful database management systems.

In general, the UNIX operating system can be represented by a two-level model, as shown in Fig. 8.1
.

In the center is located system kernel (kernel). The kernel directly interacts with the hardware part of the computer, isolating the applied programs from the features of its architecture. The kernel includes programs that implement a set of services provided to applications. The kernel includes I / O operations, process creation and process management, processes synchronization, etc. The following model level is system services that ensure UNIX User Interface. Scheme of interaction with the kernel and applications, and system tasks are the same.

Functions of the operating system UNIX

UNIX operating system interacts with hardware and computer software resources, performing the following functions:

    equipment management;

    resource management;

    system monitoring;

Equipment management

Application programs do not have the ability to manage the computer equipment directly. Only the operating system performs equipment management functions, providing access to applications and other programs to peripheral devices (it eliminates the need to know the specifics of controlling such a device). The concept of independence of programs from a particular hardware implementation is one of the important elements of ensuring the mobility of the UNIX operating system, which allows you to widely use it in a variety of hardware configurations.

Resource management

UNIX OS manages the distribution of computer resources between a plurality of users performing simultaneously a plurality of tasks that are often working with different objects, supporting multi-tasking and multiplayer modes of operation. Multitasking mode allows one user to perform several programs at the same time, while the central processor and the RAM are separated between the multiple processes.

Multiplayer mode supports the ability to simultaneously work multiple users, sharing the computer resources between them, including expensive peripherals, such as printers or plotters. Such a mode of operation turns out to be more efficient than combining multiple machines on which one user works.

Support user interfaces

This is a means of providing an interactive (providing dialogue) of user interaction with a computing system.

Modern versions of the UNIX operating system support several types of interfaces: Command line, menu and graphical user interface.

Command line Usually convenient for users familiar with features and teams Systems. When working with such a type of interface, the user on the "invitation" (default for the user is a dollar sign) enters each command from the keyboard. This interface does not provide a "review" system, however allows you to execute any system system. Programs providing such an interface are called command shells (Shell). Command Shells There is a lot: Bourne Shell (SH), Bourne Again Shell (Bash), Korn Shell (KSH), C Shell (CSH), Debian Almquist Shell (Dash), ZSH, etc. The most common is Bash.

Usually used beginners or users who need to make some settings in the operating system. Often this interface performs a guide function: it allows the user to select some function from the list (menu), which will be performed by the system. Usually, the menu is organized as a multi-level text, offering the user a few choices. An example of such an interface can serve as a SYSADM program that helps the system administrator to configure and configure the system.

Graphic user interface focused on both newcomers and qualified users. It provides several ways to interact with a computer: an overview of the system objects depicted by icons, executing commands by selecting a graphic image (icons) on the display screen using the "mouse" or Tracking Ball device. UNIX OS provides X.Desktop as a graphical user interface to work with special X-terminals or X Window system to work with conventional graphic terminals.

Providing remote access in the computer network

UNIX provides user access to resources of other computers operating in the computer network. As part of the operating system, there is a set of network applications that allow you to communicate with a remote computer, register in a remote system, transmit data between network computers, use email. UNIX supports networking file system NFS. (Network File System), allowing you to use the commands of the operating system to access the remote computer file system.

Components of the UNIX operating system

As already mentioned above, the operating system is a set of programs that provides process management functions in the system and implements the interface between users and the system equipment. UNIX system contains three main components: System of teams, shell and kernel.

The UNIX system has several hundreds of commands that perform the tasks of the organization and data processing and control the environmental environment. The commands themselves are programs that perform certain functions, requiring, as a rule, minimal data entry, and are performed relatively quickly. Most of them are available to all users, however there are commands that are only available to the system administrator, which is a privileged user. Some commands, in which there is an interactive input of information, is sometimes called utilities. An example of utilities can be the Editor of the VI text editor and the email control command Mail.

Shell. Shells are usually called interactive programs that provide a user interface with the operating system core. The shell becomes the active user process from the moment it is recorded in the system and before its exit from the system. These programs are command interpreters (sometimes they are called command processors).

As noted above, a few shells are usually used as part of the UNIX OS.

RESTRICTED SHELL - RSH and KSH - subsets of Bourne Shell and Korn Shell) are designed for users who need to restrict access to the system.

Core. The system kernel is the core of the operating system, which provides basic functions: Creates processes and controls them, distributes memory and provides access to files and peripheral devices.

The interaction of applied tasks with the kernel occurs through the standard system call interface. The system call interface defines the format of requests for basic services. The process requests the basic function of the kernel by means of a system call to a certain nucleus procedure. The kernel performs a request and returns the necessary data to the process.

The kernel consists of three main subsystems:

    1) the processes and memory management subsystem;

    2) file subsystem;

    3) I / O subsystem.

Performs the following functions:

    creating and deleting processes;

    distribution of system resources between processes;

    synchronization of processes;

    interaction of processes.

The special function of the kernel, executed by the planner of processes (Scheduler), permits conflicts between processes in the competitive struggle for system resources.

Provides memory distribution between processes. If there are not enough memory for all processes, the kernel moves a part of the process or several processes (more often passive, waiting for any events in the system) in a special area of \u200b\u200bthe disk (pumping area), freeing resources for running (active) processes.

File subsystem Provides a unified data access interface located on disk drives, and peripheral devices. It performs the placement and deletion of files, performs write / read file data operations, and also controls the access rights to the file.

Requests the file subsystem and the process management subsystem for access to peripheral devices. It interacts with device drivers - special kernel programs serving external devices.

Access to unix system

To establish contact with the Unix system, you need to have:

    terminal;

Receipt of the Registration Name

Registration name - This is a name with which the UNIX system checks whether you are the authorized user of the system during the request to access it.

Registration name You must enter each time you want to log in.

There are several rules for choosing a registered name. Typically, the name of the name is from 3 to 8 characters. It may consist of large or small letters, numbers, an underscore character, but cannot start with the numbers.

However, your registration name may be determined by specific application. Examples of permissible names:

Communication with UNIX system

If UNIX is installed on a personal computer, you can register directly on it through the text virtual console. But other access options are possible.

Suppose that the terminal is directly or through a telephone line is associated with a computer. Although this subsection describes a typical login procedure, these instructions may not come up for your system, because There are several ways to register in the UNIX system via the telephone line.

To communicate with the system, you must enable the terminal.

If it is directly connected to the computer, then a hint will immediately appear in the upper left corner:

If a personal computer configured to work on a network is used as a terminal using the TCP / IP protocol family, you must connect to the computer on which UNIX OS is installed. This can be done in several ways, for example, using the Telnet network application, which is available in Windows operating systems or using Internet access tools. Please note that this is an unprotected protocol, which is currently almost applicable. Modern alternative is Secure Shell (SSH).

Example.

As a terminal uses a personal computer with Windows NT, configured to work on the network. You must register with the UNIX system.

Required source data and actions:

    to establish communication with UNIX, you need to know the network name of the remote computer or its IP address (for example, 192.168.2.19);

    find in the personal computer Telnet application and run it on execution;

    in the application window that opens, select the Connection menu item;

    enter the IP address of the remote UNIX system (for example, 192.168.2.19);

    install at the request of the characteristics of the terminal.

Registration procedure

When the login hint appears:, enter the login name and press the key . For example, if your login name is ALL30123, then the registration string will look like this:

    login: All30123.

If you make an error when entering your registration name, you can fix it with the symbol @ or keys .

Remember that the register of entered characters is important. Names All30123 and all30123 belong to two different users.

Now the system gives you a hint to enter a password. Enter the password and press the key. . If you enter an error when you enter, you can fix it with the key or @ symbol. UNIX does not display your password on the screen for security purposes.

If the login name and password are permissible in the UNIX system, the system can display current information and then prompt command line.

When you enter the system, the terminal screen will look like this:

    login: All30123.

If you make an error when logging in, UNIX will display a message:

    login Incorrect.

Then give you a second chance to enter the system by issuing a prompt Login:. The screen will look like this:

    login: All30123.

If you have never been registered in the UNIX system, your registration procedure may differ from the above. This may occur if the system administrator has provided a procedure for appointing temporary passwords to new users. If you have a temporary password, the system will make you choose a new password before you allow you to register.

Forcing you to choose a new password exclusively for your use, the system takes care of greater security.

Login procedure:

    You are installing contact; UNIX displays the Login: Tips. Enter your registration name and press the key. .

    The UNIX system displays Password:. Enter your temporary password and press the key. .

    The system will report that your temporary password is no longer valid, and will suggest choosing a new password.

    The system will propose to enter your old password. Enter a temporary password.

    The system will propose to enter your new password. Enter your selected password.

Password must match the following requirements:

    each password should consist of at least 6 characters;

    each password must contain at least 2 letter symbols and one digit or a special symbol. The letter symbol can be dialed in the register or large characters or small;

    each password should differ from your registration name. Large letters and corresponding small letters are equivalent;

    the new password should differ from the old, at least three symbols.

Examples of permissible passwords:

To check the system asks you to re-enter the password. Enter the password again.

If you enter a new password for the second time not as in the first, then the system will report that passwords do not coincide, and will offer to repeat the registration procedure again. When passwords match, the system will display the prompt.

The following screen displays the described procedure:

    login: DKO30123.

    password:

    Your Password Has Expired

    Choose a New One

    OLD PASSWORD:

    NEW PASSWORD:

    Re-ENTER NEW PASSWORD:

User Identification

When the system administrator registers a user in the system, two components of identification are associated with the registration name: user ID (User ID - UID) and group identifierto which he belongs (group ID - GID).

The username is associated with a unique number. The system uses it as a tool in various UNIX OS mechanisms, for example, when protected files or when performing privileged commands.

In any UNIX, there is one special superuser with an UID \u003d 0 identifier, which is usually associated with the name root. This means that the user has all system privileges.

The name of the group is also associated with a number that usually refers to a group of users united by common tasks, such as the staff of the department, students of one stream, etc. This number is also used by protection mechanisms in the system. If the user should work with other groups data, this identifier binds to the names of other groups.

All register information about users of the system is stored in the / etc / passwd file.

In modern versions of UNIX, encrypted passwords and related system information are stored in the / etc / shadow file, the structure and purpose of whose fields is presented in Fig. 8.2.
.

The data records of each installed group are contained in the / etc / group file, the structure and purpose of the fields of which are presented in Fig. 8.3. .

The structure and purpose of the File / ETC / PASSWD fields are presented in Fig. 8.4.
.

Input agreements

When interacting with the UNIX system, you must be aware of the input agreements. The UNIX system requires you to enter the commands with small letters (with the exception of some commands in which there are large letters). Other agreements allow you to perform tasks, such as erase letters or delete a string by pressing one or two keys.

Table 8.1.
Input agreements

Key

Function

Tip the system team (invites you to enter your command)

or<^h>

Erase

Stop executing a program or command

Delete the current command line

When used with another symbol, it means performing a special function (called code switching sequence). When used in editing mode VI, it means the end of the text entry mode and return to the command mode

Means the end of the input row and puts the cursor to the new string

Stop input to the system or exit the system (complete the work)

Return to one character (for terminals that do not have a key )

Temporarily stop displaying the screen

Continue the output to the information screen that was stopped with<^s>

Note. In tab. 2.1 Symbol ^ means managing symbol . That is, you must in this case press the two keys at the same time: the control character key and the specified letter.

Tip Team

The standard invitation of the command line for the user in the UNIX system is a dollar sign. For the root - # user. When an invitation appears on the screen of your terminal, it means that the UNIX system expects instructions from you. The corresponding response to the hint on your part is the issuance of the command followed by pressing the key .

Correction of input errors

There are several ways to correct input errors. The @ symbol erases the current string, and the keys and<^h> The last introduced symbol is erased. These keys and signs are default values. The functions that they perform can be reassigned to other keys.

Stop execution of commands

To stop the execution of most commands, simply press the key combination . The UNIX system will stop executing the program and displays a hint on the screen. This tip serves as a signal that the launched command is stopped and the system is ready for receiving the next command.

The appearance on the tip screen means that the UNIX system recognized you as a powerful user and waits for the command entry from you.

In general, the command line has the following structure:

    [Options] [Arguments]

The name of the team, options and arguments must be separated from each other a space or tab of the tab. Command line processing Interpreter starts only after pressing the key .

In the future, the setting of command functions is assumed:

Options (parameters):

    are a sign of a command modification and, as a rule, consist of one symbol; Large and small letters mean different modifications;

    as a rule, begin with the symbol "-" ("minus"), which is not separated by a space from other symbols;

    can be combined in any way, with a minus sign can only be used once.

Arguments indicate objects that must be processed by a command, for example:

    file name;

    process number;

If you know what the called program must do, but are not sure of the correct use of the syntax, you can specify the option --help option after the command name:

    $ Cal --help.

In order to be able to get more detailed information, the UNIX OS has a built-in manual (on-line), access to which MAN and AproPOS commands provide access.

In the simplest case, to obtain information about any command, you must specify its name as the Manual command argument:

    mAN name_name

aproPOS displays a list of commands in accordance with the keyword (template) specified as the command argument:

    apropos template

Examples.

If you run the Date command and press the key The UNIX system refers to the program called Date will execute it and displays the result on the screen:

    $ Date.

    Tues Sep 18 14:49:07 2000

The Date command displays the date and time.

If you start the WHO command and press the key , the screen will look like this:

    $ who

    DKO30024

    OCT18 8:30

    dKO30001.

    OCT18 8:34

    dKO30020.

    OCT18 8:32.

    OCT18 8:00

wHO displays a list of user registration names currently working on your system. TTY designation (second column) makes a link to special files that match each user terminal. The third and fourth columns indicate the date and time of registration of each user. .

This means that you have successfully completed the system and it is ready to register a new user.

If you were registered with a remote terminal, the connection will be rupture, which will notify you, for example, the Telnet application.

Note. Before you turn off the terminal, be sure to complete the system.

Main conclusions

    UNIX is a multi-tasking multiplayer system. One powerful server can serve the queries of a large number of users. The system can perform a variety of functions: work as a computing server serving hundreds of users as a database server as a network server or a network router.

    In general, the UNIX operating system can be represented by a two-level model. The center is the kernel of the system (Kernel). The kernel directly interacts with the hardware part of the computer, isolating the applied programs from the features of its architecture. The kernel includes programs that implement a set of services provided to applications. The kernel includes I / O operations, process creation and process management, processes synchronization, etc. The following model level is system services that ensure UNIX User Interface. Scheme of interaction with the kernel and applications, and system tasks are the same.

    The UNIX operating system interacts with hardware and computer software resources, performing the following functions:

    • equipment management;

      resource management;

      support user interfaces;

      implementation of the input and output of information;

      system monitoring;

      providing remote access in the computer network.

    The UNIX system contains three main components: the system of teams, shell and core.

    The UNIX system has several hundreds of commands that perform the tasks of the organization and data processing and control the environmental environment. Commands themselves are small programs that perform certain functions, requiring, as a rule, minimal data entry, and are performed relatively quickly.

    Shells are usually called interactive programs that provide a user interface with the operating system core. The shell becomes the active user process from the moment it is recorded in the system and before its exit from the system. These programs are command interpreters (sometimes they are called command processors).

    The system kernel is the core of the operating system, which provides basic functions: Creates processes and controls them, distributes memory and provides access to files and peripheral devices.

    The kernel consists of three main subsystems:

    • processes and memory management subsystem;

      file subsystem;

      i / O subsystem.

    To establish contact with the UNIX system, you need to have:

    • terminal;

      registration name that identifies you as a powerful user;

      password that checks you for identity;

      instructions for dialogue and access to the UNIX system if your terminal is not directly connected to the computer.

Control questions

    To solve what tasks is the UNIX operating system class?

    What opportunities should the UNIX class operating system?

    What are UNIX OS kernel tasks?

    What are UNIX OS core functions?

    What is the purpose of the component of the operating system "Team System"?

    Is it possible to argue that the shell provides the user with an interactive interface of interaction with the operating system?

    How does the user identification in UNIX OS?

To begin with, it would be nice to draw up a general idea of \u200b\u200bwhat Linux is and how it works.

And you can start with Introduction to Linux (SXW). Although there are other administration. For example, it is. Here is the dock R.S. Klochkova and N.A. Korshenin Basics of UNIX and Linux (SXW), (PDF).

Basics of UNIX OS. Training course. (SXW) (PDF)
Copyleft (No C) - Fuck Copyright! 1999-2003 V. Kravchuk, OpenXs Initiative
This short (presumably, 16 hours, of which 6 - practical classes) The introductory course is intended to familiarize themselves with the architecture, features and fixed assets of UNIX OS. Upon successful development, the course will allow free and productively work in UNIX as a user and continue learning the administration or programming of this operating system.
The presentation is mainly carried out without binding to the features of any version of UNIX, but if necessary, it is done for SVR4 systems, in particular, OS Solaris 8.
Also offer a book Andrei Robachevsky "Operating system UNIX"
This is what the author writes: "This book is not a replacement of reference books and various manuals on the UNIX operating system. Moreover, the information presented in the book is sometimes difficult to find in the documentation supplied with the operating system. These editions are saturated with practical recommendations, a scrupulous description of the settings of certain subsystems, teams call formats, etc. At the same time, such questions as the internal architecture of individual system components, their interaction and principles of operation often remain behind the scenes. Without the knowledge of this "anatomy", work in the operating system turns into use of learned commands, and inevitable errors lead to inexplicable consequences. On the other hand, in this book, the UNIX administration issues, configuring specific subsystems and the commands used significantly less attention. The purpose of this book is to present the basics of the organization of the UNIX operating system. It should be borne in mind that the UNIX name is denoted by a significant family of operating systems, each of which has its own name and inherent in it features. In this book, an attempt was made to allocate something in common, which is the "genotype" Unix, a exactly: basic user and programming interfaces, the purpose of the main components, their architecture and interaction, and on the basis of this submitting the system as a whole. At the same time, where it matters, references to the specific version of UNIX are given.

Personally, I am very helpful to reading the wonderful book of Viktor Alekseevich Kostromin Linux for the user"I can offer you (kos1, kos2, kos3, kos4, kos5, kos6, kos7, kos8, kos9, kos0, kos11, kos15, kos13, kos14, kos15, kos16, kos17, kos18).
But the same book, but already in PDF (KOS1, KOS2, KOS3, KOS4, KOS5, KOS6, KOS7, KOS8, KOS9, KOS10, KOS11, KOS15, KOS13, KOS14, KOS15, KOS16, KOS17, KOS18).
And now also in SXW (KOS1, KOS2, KOS3, KOS4, KOS5, KOS6, KOS7, KOS8, KOS9, KOS10, KOS11, KOS12, KOS13, KOS14, KOS15, KOS16, KOS17, KOS18).
If you prefer documents in HTML format, then on the links above, you can get to the page, from where it is proposed to download the archives of the book heads in this format.

From fundamental books I can also advise the wonderful leadership of Karl Schröder "Linux. Collection of recipes ». I immediately warn that on this link the book in format.pdf, and it weighs 50 mV. But an alternative version is possible - the same book, only in

Format.tkhtAnnotation to the book Next: "The proposed edition contains a unique collection of tips, tools and scenarios; You will find a number of ready-made allocated solutions for complex problems faced by any administrator, setting up a Linux server; These solutions will also be useful when setting up small networks, and when creating powerful distributed data warehouses. The book was written in the popular form of the books of the recipes O'Reilly in the format "Problem-decision-discussion". For experienced users, programmers, system administrators, university students, graduate students and teachers. " If suddenly the link will stop existence, please inform - it will be possible to lay out the file.pdf and on your website.

I really like a series of articles and notes Alexey Fedorchuk, Vladimir Popova and a number of other authors that I take from here: http://unix.ginras.ru/. Here are the most interesting materials about Linux as a whole and its individual components in particular (Linux-All.zip, Linux-All2.zip, Linux-All3.zip, Linux-All4.zip).
SXW - (Linux-all. Zip, linux-all2.zip, linux-all3.zip, linux-all4.zip),
As well as the book of Alexey Fedorchuk " POSIX Saga or Introduction to Posix'ivism"In which the general issues of a number of systems are highlighted, primarily about UNIX-like. The name speaks for itself. According to the authors, the book is intended for users (including beginners). Here are files - Part 1, Part 2, Part 3., Part 4..
AND SXW. - Part1, part2, part3, part4.

And if the history of free systems is interesting, you can read the selection of articles, under the general name All"(SXW) and, according to the author, highlights general questions Open Sources, POSIX-systems, the history of Unix, BSD, Linux

Also, to understand the principles of the operation of the OS, the concept of the process, along with the concept of the file, is definitely one of the most important concepts. This is dedicated to the article V.A. Kostromin Processes and demons in Linux"(SXW.

TEXT-TERMINAL-HOWTO (SXW) v 0.05, June 1998
This document explains what text terminals are how they work, how to install and configure them and gives some information about their repair. It can be partly used, even if you do not have a terminal manual. Although this work is written for real terminals on the Linux system, part of it is also applicable for terminal emulators and / or other UNIX-like systems.

It is also very useful, for faster and easy console development to read perfectly illustrated management - We work with the history of teams (SXW).

Here are the materials dedicated to the command shells, or command interpreters, called just Shell (Shell). First of all, a selection of articles that are combined by Shell and utilities (SXW), (PDF).

The most popular shell today is Bash - ZTO abbreviations of Bourne Again Shell (another born shell). I advise you to read Bash Abstract, (SXW), (PDF)
Creation date: 16.12.97.

As well as Work Features Bash Shell (SXW), (PDF).
The document summarizes the fact that Bash inherited from the Born shell: shell control structures, built-in teams, variables and other features. It also lists the most significant differences between Bash and the Born shell.

Shell Shell Command Language Interpreter (SXW), (PDF) - a command language that can perform both commands entered from the terminal and commands stored in the file.

Programming on Shell. (UNIX) (SXW), (PDF)

If Windows hangs, the user makes some television, and then, making sure the "Tanning and the vanity of this world" is pressed with a calm heart. In Linux, everything is different. About this article - Hanging? Remove! (SXW)

Questions and Answers by KPPP (SXW)

Article V.A. Kostromin " Hierarchy of directories and file systems in Linux"(SXW) in which it is described about the standard developed as part of the Open Source project on the structure of the UNIX-like operating systems directory (implies Linux and BSD systems).

About files (koim in Linux, in fact, are catalogs, even devices) but in a somewhat different perspective tells Files and access rights to them (SXW).
Highly recommend. Miscellaneous wonderful.

Teams and Reduced Linux (SXW).
This is a practical selection of programs that we use most often consider useful, and which are present in our Linux distributions (RedHat or Mandrake).

Console Unix. (SXW) - Notes on various consoles.

But a stupid guide MANDRAKE LINUX 9.0 Command Line Guide (SXW).

Mounting file systems from devices and files (SXW) (PDF)
Document creation date: 26.07.2004
Last change date: 08/20/2004
Author: Knyazev Alexey.

Basics of Linux

Linux is inspired by the UNIX operating system, which appeared in 1969 and is still used and develops. Much of the Unix internal device exists in Linux, which is the key to understanding the basics of the system.

Unix focused, first of all, on the command line interface, it also got a Linux to inheritance. Thus, the graphical user interface with its windows, images and menus is located above the main interface - the command line. In addition, this means that, and the Linux file system is built to be easily controlled and accessible from the command line.

Catalogs and file system

File systems in Linux and UNIX are organized on the principle of hierarchical, tree structure. Top level file system - / or root directory . This means that all other files and directories (including other discs and sections) are inside the root directory. In UNIX and Linux, the file is considered to be all - including hard drives, their sections and removable media.

For example, /home/jebediah/cheeses.odt shows the full path to the cheesees.odt file. The file is located in the Jebediah catalog, which is located in the home catalog, which, in turn, is located in the root directory (/).

Inside the root directory (/) there are a number of important system directories that are present in most Linux distributions. The following is a list of common directories that are located directly in the root directory (/):

Access rights

All files in Linux have access rights that allow or prohibit reading, modifying or performing them. Super user "root" has access to any file in the system.

Each file has the following three access set, in order of their significance:

    owner

    refers to the user who is the owner of the file

    group

    refers to a group associated with a file

    others

    refers to all other system users

Each of the three sets determines the access rights. Rights, as well as ways to apply them to various files and catalogs, are shown below:

    reading

    files can be displayed and open to read.

    catalog content Available for viewing

    record

    files can be changed or deleted

    content Hallows Available For Changes

    performance

    executable files can be launched as programs

    catalogs can be open

To view and Edit The Permissions on Files and Directories, Open The Applications → ACCESSORIES → HOME FOLDER And Right-Click on a file or directory. Then Select Properties. THE PERMISSIONS EXIST UNDER THE Permissions Tab and Allow for the Editing of All Permission Levels, If You Are The Owner of the File.

To Learn More about File Permissions in Linux, Read The File Permissions Page in The Ubuntu Wiki.

Terminals

Working AT The Command Line Is Not As Daunting A Task As You Would Think. There Is No Special Knowledge Needed to Know How to Use the Command Line. IT IS A PROGRAM LIKE EVERYTHING ELSE. Most Things In Linux Can Be Done using the Command Line, Although There Are Graphical Tools for Most Programs. Sometimes They Are Just Not Enough. This Is Where The Command Line Comes in Handy.

Their Terminal IS Located in Applications → Terminal. The Terminal Is Often Called the Command Prompt Or The Shell. In Days Gone By, This Was The Way The User Interacted with the Computer. HOWEVER, Linux Users Have Found That The Use of the Shell Can Be Quicker Than A Graphical Method and Still Holds Some Merit Today. Here You Will Learn How to Use the Terminal.

Initially, the terminal was used to manage files, and indeed it is still used as a file browser if the graphic environment does not work. You can use the terminal as a browser to manage files and cancel the changes that have been made.

Main teams

View Catalog Content: Ls

Team ls. Shows a list of files with different colors with full text formatting

Creating directories: mkdir (catalog name)

Team mkdir. Creates a new directory.

Go to the catalog: CD (/ address / directory)

Team cD Allows you to go to any directory you specified.

Copying a file or directory: CP (what is the file name or directory) (where - the catalog or file name)

Team cP. Copies any selected file. Team cP -R. Copies any selected directory with all content.

Deleting Files or Directory: RM (File Name or Folder)

Team rM Deletes any selected file. Team rm -Rf. Deletes any selected directory with all content.

Rename a file or directory: MV (file name or directory)

Team mV Rename or moves the selected file or directory.

Search for catalogs and files: Locate (directory or file name)

Team locate. Allows you to find a specified file on your computer. File indexing is used to speed up the work. To update the index, enter the command updatedB. . It starts automatically every day if the computer is turned on. To start this command, you need a super user rights (see "Root and Commander Sudo").

You can also use the masks to specify more than one file, such as "*" (coincidence with all the characters) or "?" (coincidence with one character).

For a more Thorough Introduction To the Linux Command Line, Please read the Command Line Introduction on the Ubuntu Wiki.

Editing text

All of the Configurations and Settings in Linux Are Saved in Text Files. Even Though You Most Often Can Edit Configurations Through the Graphical Interface, You May Occasionally Have to Edit Them by Hand. MousePad. IS The Default Xubuntu Text Editor, Which You Can Launch by Clicking Applications → Accessories → Mousepad on the Desktop Menu System.

Sometimes, MousePad. Starts from the command line using the application gksudo. that runs MousePad. With administrative privileges, which allows you to change the configuration files.

If you need a text editor on the command prompt, you can use nano. - Easy to use text editor. When starting from the command line, always use the following command to disable automatic word transfer:

Nano -w.

For more information about how to use x nano. , REFER TO THE GUIDE ON THE WIKI.

There Are Also Quite A Few Other Terminal-Based Editors Available in Ubuntu. Popular Ones Include. Vim. And. Emacs. (The Pros and Cons of Each Are Cause for Much Friendly Debate Within The Linux Community). These Are Often More Complex To Use Than nano. , But ARE Also More Powerful.

Root and Commander Sudo

The root user in GNU / Linux Is The User Which Has Administrative Access To Your System. Normal Users Do Not Have This Access For Security ReaSons. However, Ubuntu Does Not Enable The Root User. Instead, Administrative Access IS Given to Individual Users, Who May Use the "sudo" Application to Perform Administrative Tasks. The First User Account You Created on Your System During Installation Will, by Default, Have Access to Sudo, The First User ACCOUNT YOU CREATED ON YOUR SYSTEM DURING INSTALLATION WILL. You can Restrict and Enable Sudo Access to Users with the Users and Groups. Application (SEE "Manage users and groups" for more information).

When you open a program that requires a super user license, Sudo will need to enter your password. This ensures that malicious applications will not be able to damage your system, and will also remind you that you are going to perform actions that require special caution!

To use sudo on the command prompt, simply type "sudo" before the command you want to execute. After that, you will need to enter your password.

Sudo Will Remember Your Password for 15 Minutes (by Default). This feature Was Designed to Allow Users to Perform Multiple Administrative Tasks Worthout Being Asked for a Password Each Time.

Be Careful When Doing Administrative Tasks - You Might Damage Your System!

Some Other Tips For Using Sudo Include:

    To use the terminal with super user rights (root), dial "sudo -i" on the command prompt

    The Entire Suite Of Default Graphical Configuration Tools in Ubuntu Already Use Sudo, So The Will Prompt You for Your Password If Needed.

    When you start graphic applications, "GKSUDO" is used instead of "sudo". This allows you to request a password for a user in a small graphic window. The "GKSUDO" command is convenient if you want to set the start button Synaptic On your panel or something like that.

    For more information on the sudo. Program And The Absence of a Root User in Ubuntu, Read The Sudo Page on The Ubuntu Wiki.

Before you can master, you must freely navigate in the basic concepts of the Linux system. The ability to work with Linux will be a very useful skill, because there are a large number of websites, emails and other Internet services on Linux servers.

In this section, we are going to clarify the basic concepts associated with Linux. Fulfilling the task we believe that you already have an idea of \u200b\u200bcomputer systems in general, including components such as a central processor (CPU), RAM (RAM), motherboard, hard disk, as well as other controllers and devices associated with with them.

3.1

The term "Linux" is often used to designate the entire operating system, but in fact Linux is the kernel of the operating system, which is started by the initial loader, started by Bios / UEFI. The kernel assumes the role of the role of the conductor in the orchestra, it provides a coordinated work of hardware and software. This role implies control of equipment, users and file systems. The core is a common database for other programs running in this system, and most often launches ring Zero,also known as Kernel Space.

Custom space

We use the term "user space" to combine everything that occurs outside the kernel.

Among programs running in the user space, many major utilities from the GNU project, most of which are intended to run from the command line. You can use them in scripts to automate various tasks. For more information about the most important commands, see section 3.4 ".

Let's quickly consider various tasks performed by the Linux kernel.

3.1.1 Running equipment

The prescribing of the kernel is primarily the management and control over the main components of the computer. It detects and configures them when the computer turns on, as well as when the device is mounted or retrieved (for example, USB device). It also makes them available for higher-level software thanks to a simplified program interface, so applications can use the benefits of devices without referring to details, for example, to the expansion slot, in which the board is inserted. The program interface also provides a certain level of abstraction; This allows the use of video conferencing equipment, for example, to use a webcam independently of its model and manufacturer. Software can use the interface Video for Linux(V4L) and the kernel will translate the interface calls to the real hardware commands necessary for the specific webcam.

The kernel exports data on detected equipment through virtual systems / Proc / and / SYS /. Applications often get access to devices using files created by / Dev /. Special files representing wheels (for example, / dev / sda), sections (/ dev / sdal), mice (/ dev / input / mouse0), keyboard (/ dev / input / event0), sound cards (/ dev / SND / *), serial ports (/ dev / ttys *) and other components.

There are two types of devices files: block and symbolic. The first have the characteristics of the data block: they have a final size, and you can access bytes in any position of the block. The latter behave like a stream of characters. You can read and write characters, but you cannot search for a given position and change arbitrary bytes. To find out the device file type, check the first IS -1 command output letter. This may be either b, for block devices, or C, for character devices:

As you may already have guessed, discs and partitions use block files of devices, while the mouse, keyboard and serial ports use symbolic device files. In both cases, the software interface includes special commands that can be activated through a system call. ioctl.

3.1.2 Combining file systems

File systems are an important aspect of the kernel. UNIX based systems combine all file repositories to one hierarchy, allowing users and applications to access data, knowing their location within this hierarchy.

The starting point of this hierarchical tree is called root represented by the "/" symbol. This directory may contain named sub-directories. For example, the home sub-directory "/" is called / HOME /. This sub-directory, in turn, may contain other sub-directories, etc. Each directory can also contain files in which files will be stored. Thus, the home / buxy / desktop / hello.txt refers to the file called Hello.txt, which is stored in the Desktop sub-directory located in the Buxy sub-directory of the home directory, which is present in root. The kernel compiles between this naming system and the storage location on the disk.

Unlike other systems, Linux has only one such hierarchy and can integrate data from multiple disks. One of these discs becomes root, and others mounted On the directory in the hierarchy (this command in Linux is called Mount). These other discs are then available under the mount points ( mount Points. ) This allows you to store custom home directories (which are usually stored on / HOME /) on a separate hard disk that will contain the BUXY directory (along with home directories of other users). After you installed the / Home / disc drive, these directories become available in their usual place, and different ways, such as /home/buxy/desktop/hello.txt, continue to work.

There are many file system formats in accordance with a multitude of physical storage methods on disks. The most widely known EXT2, EXT3 and EXT4, but there are others. For example, VFAT. It is a file system that has historically used DOS and Windows operating systems. Support VFAT operating system Linux allows hard disks to be accessible both under Kali and under Windows. In any case, you must prepare the file system on the disk before mounting it, and this operation is called formatting.

Commands such as mkfs.ext3 (where mkfs. deciphered as Make Filesystem) Processes formatting. As a parameter, these commands require a device file that represents a partition that should be formatted (for example, / dev / sdal, first partition on the first disk). This operation destroys all the data and must start only once, unless of course you do not want to erase the file system and start a new job.

There are also network file systems such as Nfs.that do not store data on the local disk. Instead, the data is transmitted via the network to the server that stores them and gives it to the first requirement. Thanks to the abstraction of the file system, you do not need to worry about how this disk is connected, as the files remain available according to their usual hierarchical path.

3.1.3 Process management

The process is an executable instance of the program for which you want to store memory as the program itself and its working data. The kernel is responsible for creating and tracking processes. When the program starts, the kernel first highlights some memory, loads the executable code from the file system to this memory, and then starts the code. It contains information about this process, the most notable of which is the identification number known as process Identifier (process Identifier (PID)).

Most of the modern operating systems, namely those that work on the basis of the UNIX core, including Linux, are able to perform many tasks. In other words, they allow the system to run a lot of processes at the same time.

In fact, there is only one running process at any time, but the kernel divides the processor time to small fragments and starts each process in turn. Since these temporary sections are very short (in milliseconds), they create an appearance of processes working in parallel, although they are active only during their time interval and inactivity during the rest of the time. The main task of the kernel is to configure scheduling mechanisms in such a way as to maintain this appearance while at the same time increasing the system performance. If the segment of time is too long, it can stop responding properly. Well, if they are too short, the system will lose too much time on switching between them.

Such solutions can be adjusted using processes priorities when high-priority processes will be performed for longer periods of time and with more frequent temporary sections than low priority processes.

Multiprocessor systems (and other options)

The limitations described above that only one process can work at the same time, not applicable in all situations. It will surely say that one kernel It can only work with one process. Multiprocessor, multi-core or hyper-flow systems allow multiple processes to work in parallel. However, the same time reduction system is used to process situations when there are more active processes than the available processor kernels. This is not an unusual: basic system, even completely inactive, almost always has dozens of running processes.

The kernel allows you to run multiple independent instances of the same program, but everyone is allowed only to its own temporary sections and memory. Thus, their data remain independent.

3.1.4 Rights Management

UNIX systems support multiple users and groups and allow you to control the permissions. In most cases, the process is determined by the user who launches it. This process can only be performed by the actions that are permitted by its owner. For example, the opening of the file requires the kernel to check the process for the presence of the necessary rights (for more information specifically for example, see section 3.4.4, "Right Management")

3.2 Linux Command Line

Under the "Command Line" we mean the text interface that allows you to enter commands, perform them and view the results. You can run the terminal (text screen inside the graphic desktop or text console outside of any graphical interface) and interpreter of commands inside it ( shell).

3.2.1

When your system works correctly, the easiest way to get access to the command line is to start the terminal in the desktop graphics session.


Figure 3.1 Running the GNOME terminal

For example, in the Kali Linux system by default, the GNOME terminal can be run from the list of favorite applications. You can also enter "Terminal" in the Activities window (window that is activated when you move the mouse to the upper left side) and click on the application icon you need (Figure 3.1, ").

In case of any violations or incorrect work of your graphical interface, you can still run the command line on virtual consoles (up to six of them can be accessible through six key combinations, starting with Ctrl + Alt + F1 and ending with Ctrl + Alt + F6 - The Ctrl key can not be pressed if you are already in text mode outside the graphical interface. Xorg. or Wayland.).

You get a regular input screen where you enter your username and password before you access the command line with its shell:

The program processing the data you entered and the execution of your teams is called sheath(shell.or command line interpreter). The default shell provided in Kali Linux is Bash (it means Bourne Again Shell.). The end symbol "$" or "#" indicates that the shell awaits your input. These characters also indicate how the bash perceives you as a regular user (first case with a dollar icon) or as a superuser (the last case with hash).

3.2.2

This section provides only a brief overview of some commands, each of which has many different options and capabilities not described here, so please refer to extensive documentation available in the respective pages of the manual. In penetration tests, most often you will access the system through the shell, after successful exploitation, and not through the user graphical interface. The skill competently use the command line is necessary for you if you want to achieve success as a security specialist.

As soon as the session is running, the PWD command (which is decrypted as pRINT WORKING DIRECTORY (Display working directory)) Will display your current location in the file system. Your current location can be changed using the CD command. directory name(where CD means (change the directory)). In the event that you did not indicate the directory where you want to go, you will automatically return to your home directory. If you enter a CD - you will return to the previous working directory (in the one in which you were in front of the introduction of the last CD command). The parent directory is always called .. (two points), while the current catalog is indicated. (one point). The LS command allows you transfer The contents of the directory. If you do not specify additional parameters the LS command, displays the contents of the current directory.

You can create a new directory using the mkdir command. directory name,and also delete an existing (empty) directory using the RMDIR command directory name. MV command will allow you move and rename files and directories; delete You can use the file using RM file nameand copying a file is performed using CP the source file is a target file.

The shell performs each command, running the first program with this name, which it finds in the directory specified in the variable environment Path.. Most often these programs are in / bin, / sbin, / usr / bin or / usr / sbin. For example, the LS command is located in / bin / ls; Sometimes the team is directly processed by the shell, and in this case it is called the built-in shell team (among them - CD and PWD); The Type command allows you to request the type of each command.

Pay attention to the use of the echo command, which simply displays the string in the terminal. In this case, it is used to display the contents of the environment variable, because The shell automatically replaces the variables with their values \u200b\u200bof the command line.

Environment Variables

Environment variables allow you to store global settings for the shell or other programs. They are contextual but inherited. For example, each process has its own set of environment variables (they are contextual). Shells such as entry shells can declare variables that will be transferred to other executable programs (they are inherited).

These variables can be defined for both the system in / etc / profile and for the user in ~ / .profile, but variables that are not characteristic of command line interpreters, it is better to insert in / etc / environment, since these variables will be entered into all Custom sessions Thanks to the authentication connected module (PLUGGABLE Authentication Module (PAM)) - even if no shell is performed.

3.3 File system Linux

3.3.1 File System Hierarchy Standard

Like other Linux distributions, Kali Linux is organized in accordance with the standard FileSystem Hierarchy Standard. (FHS), which allows users of other Linux distributions with ease to navigate in Kali. FHS defines the assignment of each directory. The top level directory is described as follows.

  • / BIN /: Basic programs
  • / boot /: Kali Linux kernel and other files required for its early download process
  • / Dev / device files
  • / etc / configuration files
  • / HOME /: Personal user files
  • / LIB /: Main libraries
  • / Media / *: Mounting points for removable devices (CD-ROM, USB drives, etc.)
  • / MNT /: Time Mounting Points
  • / OPT /: Additional applications provided by third parties
  • / root /: Personal Administrator Files (ROOT Files)
  • / RUN /: non-permanent workflow files that are not saved after rebooting (not yet included in FHS)
  • / SBIN /: Systems Systems
  • / SRV /: data used by servers located in this system
  • / TMP /: temporary files (this directory is often empty after rebooting)
  • / USR /: Applications (this directory is subsequently divided into BIN, SBIN, LIB according to the same logic as in the root directory). In addition, / usr / share / contain data with independent architecture. Catalog / USR / Local / is intended for use by the administrator to install applications manually without overwriting files processed by the packet system. (DPKG).
  • / VAR /: variables data processed by a demon. This includes log files, queues, buffers and keachi.
  • / Proc / and / SYS / are characteristic of the Linux kernel (and are not part of FHS). They are used by the kernel to export data to the user space.

3.3.2 Home directory

The contents of the user directory is not standardized, but, nevertheless, there are several deserved conventions. One of them is that the user home directory is often denoted by Tilda ("~"). It is very useful to know, because command interpreters automatically replace the Tilda of the right directory (which is in the variable environment HOME. And whose common value is / home / user /).

Traditionally, the application configuration files are often stored directly in your home directory, but their file names are usually starting from the point (for example, an email client mutt. Stores the configuration in ~ / .muttrc). Please note that the file names starting from the point are hidden by default; The LS command lists them only if the option is specified, and the graphic file managers must be explicitly configured to display hidden files.

Some programs also use multiple configuration files organized in one directory (for example, ~ / .ssh /). Some applications (for example, a Firefox web browser) also use their directory to store the loaded data cache. This means that these directories may ultimately consume a lot of disk space.

These configuration files that are stored directly in your home directory are often collectively called Dotfiles,for a long time expand to such an extent that these directory can be cluttered with them. Fortunately, collaboration under the auspices of Freedesktop.org led to the creation of the XDG base directory specification (XDG Base Directory Specification) of the Convention, the purpose of which is to clean these files and directories. This specification states that configuration files should be stored in ~ / .config, cache files in /. Cache, and application data files in /. Local (or sub-directories). This convention is gradually gaining momentum.

The graphics desktop most often uses shortcuts to display the contents of the / desktop / (or any other word, which is the exact translation of this, in systems that do not use English). Finally, the email system sometimes stores incoming letters in the directory - / mail /.

It is interesting: