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», без необходимости каждый раз заново искать на чём Вы остановились. Поставьте закладку, и сможете в любой момент перейти на страницу, на которой закончили чтение.

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

Интервал:

Закладка:

Сделать

Exiting the shell

To exit the shell when you are finished, type exitor press Ctrl+D. If you go to the shell from a Terminal window and you are using the original shell from that window, exiting causes the Terminal window to close. If you are at a virtual console, the shell exits and returns you to a login prompt.

If you have multiple shells open from the same shell session, exiting a shell simply returns you to the shell that launched the current shell. For example, the sucommand opens a shell as a new user. Exiting from that shell simply returns you to the original shell.

Creating Your Shell Environment

You can tune your shell to help you work more efficiently. You can set aliases to create shortcuts to your favorite command lines and environment variables to store bits of information. By adding those settings to shell configuration files, you can have the settings available every time you open a shell.

Configuring your shell

Several configuration files support how your shell behaves. Some of the files are executed for every user and every shell, whereas others are specific to the user who creates the configuration file. Table 3.6shows the files that are of interest to anyone using the bash shell in Linux. (Notice the use of ~in the filenames to indicate that the file is located in each user's home directory.)

To change the /etc/profileor /etc/bashrcfiles, you must be the root user. It is better to create an /etc/profile.d/custom.shfile to add system-wide settings instead of editing those files directly, however. Users can change the information in the $HOME/.bash_profile, $HOME/.bashrc, and $HOME/.bash_logoutfiles in their own home directories.

TABLE 3.6 Bash Configuration Files

File Description
/etc/profile This sets up user environment information for every user. It is executed when you first log in. This file provides values for your path in addition to setting environment variables for such things as the location of your mailbox and the size of your history files. Finally, /etc/profilegathers shell settings from configuration files in the /etc/profile.ddirectory.
/etc/bashrc This executes for every user who runs the bash shell each time a bash shell is opened. It sets the default prompt and may add one or more aliases. Values in this file can be overridden by information in each user's ~/.bashrcfile.
~/.bash_profile This is used by each user to enter information that is specific to his or her use of the shell. It is executed only once—when the user logs in. By default, it sets a few environment variables and executes the user's .bashrcfile. This is a good place to add environment variables because, once set, they are inherited by future shells.
~/.bashrc This contains the information that is specific to your bash shells. It is read when you log in and also each time you open a new bash shell. This is the best location to add aliases so that your shell picks them up.
~/.bash_logout This executes each time you log out (exit the last bash shell).

Until you learn to use the vieditor, described in Chapter 5, “Working with Text Files,” you can use a simple editor called nanoto edit plain-text files. For example, enter the following to edit and add stuff to your $HOME/.bashrcfile:

$ nano $HOME/.bashrc

With the file open in nano, move the cursor down to the bottom of the file (using the down arrow key). Type the line you want (for example, you could type alias d='date +%D'). To save the file, press Ctrl+O (the letter O ); to quit, press Ctrl+X. The next time you log in or open a new shell, you can use the new alias (in this case, just type d). To have the new information you just added to the file available from the current shell, type the following:

$ source $HOME/.bashrc $ d 06/29/19

The following sections provide ideas about items to add to your shell configuration files. In most cases, you add these values to the .bashrcfile in your home directory. However, if you administer a system, you may want to set some of these values as defaults for all your Linux system's users.

Setting your prompt

Your prompt consists of a set of characters that appear each time the shell is ready to accept a command. The PS1environment variable sets what the prompt contains and is what you will interact with most of the time. If your shell requires additional input, it uses the values of PS2, PS3, and PS4.

When your Linux system is installed, often a prompt is set to contain more than just a dollar sign or pound sign. For example, in Fedora or Red Hat Enterprise Linux, your prompt is set to include the following information: your username, your hostname, and the base name of your current working directory. That information is surrounded by brackets and followed by a dollar sign (for regular users) or a pound sign (for the root user). The following is an example of that prompt:

[chris@myhost bin]$

If you change directories, the binname would change to the name of the new directory. Likewise, if you were to log in as a different user or to a different host, that information would change.

You can use several special characters (indicated by adding a backslash to a variety of letters) to include different information in your prompt. Special characters can be used to output your Terminal number, the date, and the time as well as other pieces of information. Table 3.7provides some examples (you can find more on the bash man page).

TABLE 3.7 Characters to Add Information to Bash Prompt

Special Character Description
\! This shows the current command history number. This includes all previous commands stored for your username.
\# This shows the command number of the current command. This includes only the commands for the active shell.
\$ This shows the user prompt ( $) or root prompt ( #), depending on which type of user you are.
\W This shows only the current working directory base name. For example, if the current working directory was /var/spool/mail, this value simply appears as mail.
\[ This precedes a sequence of nonprinting characters. This can be used to add a Terminal control sequence into the prompt for such things as changing colors, adding blink effects, or making characters bold. (Your Terminal determines the exact sequences available.)
\] This follows a sequence of nonprinting characters.
\\ This shows a backslash.
\d This displays the day name, month, and day number of the current date, for example, Sat Jan 23.
\h This shows the hostname of the computer running the shell.
\n This causes a newline to occur.
\nnn This shows the character that relates to the octal number replacing nnn .
\s This displays the current shell name. For the bash shell, the value would be bash.
\t This prints the current time in hours, minutes, and seconds, for example, 10:14:39.
\u This prints your current username.
\w This displays the full path to the current working directory.

TIP

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

Интервал:

Закладка:

Сделать

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

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


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

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

x