Christopher Negus - Linux Bible

Здесь есть возможность читать онлайн «Christopher Negus - Linux Bible» — ознакомительный отрывок электронной книги совершенно бесплатно, а после прочтения отрывка купить полную версию. В некоторых случаях можно слушать аудио, скачать через торрент в формате fb2 и присутствует краткое содержание. Жанр: unrecognised, на английском языке. Описание произведения, (предисловие) а так же отзывы посетителей доступны на портале библиотеки ЛибКат.

Linux Bible: краткое содержание, описание и аннотация

Предлагаем к чтению аннотацию, описание, краткое содержание или предисловие (зависит от того, что написал сам автор книги «Linux Bible»). Если вы не нашли необходимую информацию о книге — напишите в комментариях, мы постараемся отыскать её.

The industry favorite Linux guide
Linux Bible, 10th Edition This useful guide assumes a base of little or no Linux knowledge, and takes you step by step through what you need to know to get the job done.
Get Linux up and running quickly Master basic operations and tackle more advanced tasks Get up to date on the recent changes to Linux server system management Bring Linux to the cloud using Openstack and Cloudforms Simplified Linux administration through the Cockpit Web Interface Automated Linux Deployment with Ansible Learn to navigate Linux with Amazon (AWS), Google (GCE), and Microsofr Azure Cloud services 
 is the one resource you need, and provides the hands-on training that gets you on track in a flash.

Linux Bible — читать онлайн ознакомительный отрывок

Ниже представлен текст книги, разбитый по страницам. Система сохранения места последней прочитанной страницы, позволяет с удобством читать онлайн бесплатно книгу «Linux Bible», без необходимости каждый раз заново искать на чём Вы остановились. Поставьте закладку, и сможете в любой момент перейти на страницу, на которой закончили чтение.

Тёмная тема
Сбросить

Интервал:

Закладка:

Сделать

When you log in to a Linux system, Linux views you as having a particular identity, which includes your username, group name, user ID, and group ID. Linux also keeps track of your login session: It knows when you logged in, how long you have been idle, and where you logged in from.

To find out information about your identity, use the idcommand as follows:

$ id uid=1000(chris) gid=1000(chris) groups=1005(sales), 7(lp)

In this example, the username is chris, which is represented by the numeric user ID (uid) 1000. The primary group for chris also is called chris, which has a group ID (gid) of 1000. It is normal for Fedora and Red Hat Enterprise Linux users to have the same primary group name as their username. The user chrisalso belongs to other groups called sales(gid 1005) and lp(gid 7). These names and numbers represent the permissions that chrishas to access computer resources.

NOTE

Linux distributions that have Security Enhanced Linux (SELinux) enabled, such as Fedora and RHEL, show additional information at the end of the idoutput. That output might look something like the following:

context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023

SELinux provides a means of tightly locking down the security of a Linux system. See Chapter 24, “Enhancing Linux Security with SELinux,” if you want to learn about SELinux.

You can see information about your current login session by using the whocommand. In the following example, the -uoption says to add information about idle time and the process ID and -Hasks that a header be printed:

$ who -uH NAME LINE TIME IDLE PID COMMENT chris tty1 Jan 13 20:57 . 2019

The output from this whocommand shows that the user chrisis logged in on tty1(which is the first virtual console on the monitor connected to the computer) and his login session began at 20:57 on January 13. The IDLEtime shows how long the shell has been open without any command being typed (the dot indicates that it is currently active). PIDshows the process ID of the user's login shell. COMMENTwould show the name of the remote computer from which the user had logged in, if that user had logged in from another computer on the network, or the name of the local X display if that user were using a Terminal window (such as :0.0).

Locating commands

Now that you have typed a few commands, you may wonder where those commands are located and how the shell finds the commands you type. To find commands you type, the shell looks in what is referred to as your path . For commands that are not in your path, you can type the complete identity of the location of the command.

If you know the directory that contains the command that you want to run, one way to run it is to type the full, or absolute, path to that command. For example, you run the datecommand from the /bindirectory by entering the following:

$ /bin/date

Of course, this can be inconvenient, especially if the command resides in a directory with a long pathname. The better way is to have commands stored in well-known directories and then add those directories to your shell's PATHenvironment variable. The path consists of a list of directories that are checked sequentially for the commands you enter. To see your current path, enter the following:

$ echo $PATH /usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:↵ /home/chris/bin

The results show a common default path for a regular Linux user. Directories in the path list are separated by colons. Most user commands that come with Linux are stored in the /bin, /usr/bin, or /usr/local/bindirectory. The /sbinand /usr/sbindirectories contain administrative commands (some Linux systems don't put those directories in regular users' paths). The last directory shown is the bindirectory in the user's homedirectory ( /home/chris/bin).

TIP

If you want to add your own commands or shell scripts, place them in the bindirectory in your home directory (such as /home/chris/binfor the user named chris). This directory is automatically added to your path in some Linux systems, although you may need to create that directory or add it to your PATHon other Linux systems. So, as long as you add the command to your binwith execute permission, you can begin using it by simply typing the command name at your shell prompt. To make commands available to all users, add them to /usr/local/bin.

Unlike some other operating systems, Linux does not, by default, check the current directory for an executable before searching the path. It immediately begins searching the path, and executables in the current directory are run only if they are in the PATHvariable or you give their absolute (such as /home/chris/scriptx.sh) or relative (for example, ./scriptx.sh) location.

The path directory order is important. Directories are checked from left to right. So, in this example, if there is a command called foolocated in both the /usr/binand /bindirectories, the one in /usr/binis executed. To have the other foocommand run, you either type the full path to the command or change your PATHvariable. (Changing your PATHand adding directories to it are described later in this chapter.)

Not all of the commands you run are located in directories in your PATHvariable. Some commands are built into the shell. Other commands can be overridden by creating aliases that define any commands and options that you want the command to run. There are also ways of defining a function that consists of a stored series of commands. Here is the order in which the shell checks for the commands you type:

1 Aliases. These are names set by the alias command that represent a particular command and a set of options. Type alias to see what aliases are set. Often, aliases enable you to define a short name for a long, complicated command. (I describe how to create your own aliases later in this chapter.)

2 Shell reserved word. These are words reserved by the shell for special use. Many of these are words that you would use in programming-type functions, such as do, while, case, and else. (I cover some of these reserved words in Chapter 7, “Writing Simple Shell Scripts.”)

3 Function. This is a set of commands that is executed together within the current shell.

4 Built-in command. This is a command built into the shell. As a result, there is no representation of the command in the filesystem. Some of the most common commands that you will use are shell built-in commands, such as cd (to change directories), echo (to output text to the screen), exit (to exit from a shell), fg (to bring a command running in the background to the foreground), history (to see a list of commands that were previously run), pwd (to list the present working directory), set (to set shell options), and type (to show the location of a command).

5 Filesystem command. This command is stored in and executed from the computer's filesystem. (These are the commands that are indicated by the value of the PATH variable.)

To determine the location of a particular command, you can use the typecommand. (If you are using a shell other than bash, use the whichcommand instead.) For example, to find out where the bash shell command is located, enter the following:

Читать дальше
Тёмная тема
Сбросить

Интервал:

Закладка:

Сделать

Похожие книги на «Linux Bible»

Представляем Вашему вниманию похожие книги на «Linux Bible» списком для выбора. Мы отобрали схожую по названию и смыслу литературу в надежде предоставить читателям больше вариантов отыскать новые, интересные, ещё непрочитанные произведения.


Отзывы о книге «Linux Bible»

Обсуждение, отзывы о книге «Linux Bible» и просто собственные мнения читателей. Оставьте ваши комментарии, напишите, что Вы думаете о произведении, его смысле или главных героях. Укажите что конкретно понравилось, а что нет, и почему Вы так считаете.

x