<?xml version="1.0" encoding="utf-8" ?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:tt="http://teletype.in/" xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/"><title>@it255ru</title><author><name>@it255ru</name></author><id>https://teletype.in/atom/it255ru</id><link rel="self" type="application/atom+xml" href="https://teletype.in/atom/it255ru?offset=0"></link><link rel="alternate" type="text/html" href="https://teletype.in/@it255ru?utm_source=teletype&amp;utm_medium=feed_atom&amp;utm_campaign=it255ru"></link><link rel="next" type="application/rss+xml" href="https://teletype.in/atom/it255ru?offset=10"></link><link rel="search" type="application/opensearchdescription+xml" title="Teletype" href="https://teletype.in/opensearch.xml"></link><updated>2026-04-24T14:32:52.203Z</updated><entry><id>it255ru:-Irl73A3Lgb</id><link rel="alternate" type="text/html" href="https://teletype.in/@it255ru/-Irl73A3Lgb?utm_source=teletype&amp;utm_medium=feed_atom&amp;utm_campaign=it255ru"></link><title>Что такое инфраструктура как код?</title><published>2023-04-25T08:04:34.054Z</published><updated>2023-04-25T08:04:34.054Z</updated><summary type="html">&lt;img src=&quot;https://static.1cloud.ru/img/blog/552.png&quot;&gt;Инфраструктура как код (IaC) — это подход к созданию и настройке инфраструктуры аналогичный процессу разработки ПО. То есть продумывается архитектура, прописываются процессы, устанавливается взаимодействие инфраструктурных элементов между собой. Всё это описывается в специальных форматах, предназначенных для описания иерархических систем: yaml, json, xml и аналогичные им форматы.</summary><content type="html">
  &lt;figure id=&quot;Yyln&quot; class=&quot;m_original&quot;&gt;
    &lt;img src=&quot;https://static.1cloud.ru/img/blog/552.png&quot; width=&quot;600&quot; /&gt;
  &lt;/figure&gt;
  &lt;p id=&quot;x9Kp&quot;&gt;&lt;strong&gt;Инфраструктура как код&lt;/strong&gt; (IaC) — это подход к созданию и настройке инфраструктуры аналогичный процессу разработки ПО. То есть продумывается архитектура, прописываются процессы, устанавливается взаимодействие инфраструктурных элементов между собой. Всё это описывается в специальных форматах, предназначенных для описания иерархических систем: yaml, json, xml и аналогичные им форматы.&lt;/p&gt;
  &lt;p id=&quot;e5AU&quot;&gt;&lt;strong&gt;Философия IaC&lt;/strong&gt; основывается на принципах «единого источника правды», согласно которому — исполнение одного и тот же кода формирует одну и ту же исполняемую среду. Благодаря такому подходу достигается единообразие элементов инфраструктуры и их ожидаемое поведение, а также идемпотентность, как свойство системы принимать одно и то же состояние при одинаковых условиях вызова.&lt;/p&gt;
  &lt;p id=&quot;wp6Y&quot;&gt;&lt;strong&gt;Ключевое в IaC&lt;/strong&gt; — это то, что все взаимодействия с инфраструктурой осуществляются через конфигурационные файлы системой, а не системными администраторами или девопсами в ручном режиме. Человеческий фактор максимально исключается из условий взаимодействий с системой.&lt;/p&gt;
  &lt;p id=&quot;IlT2&quot;&gt;Из главных преимуществ использования IaC можно отметить следующие:&lt;/p&gt;
  &lt;ul id=&quot;SnHj&quot;&gt;
    &lt;li id=&quot;UWc7&quot;&gt;нет уникальных конфигураций серверов, они не превращаются в «серверы снежинки», а значит нет проблем с их поддержкой и обслуживанием;&lt;/li&gt;
    &lt;li id=&quot;a5ot&quot;&gt;тестовые и продакшн среды теперь одинаковы, приложения себя ведут идентично везде;&lt;/li&gt;
    &lt;li id=&quot;zs9R&quot;&gt;быстрая доставка и масштабирование приложений из тестовых сред в продакшн.&lt;/li&gt;
  &lt;/ul&gt;
  &lt;p id=&quot;1gwx&quot;&gt;Сейчас IaC — это одна из доминирующих концепций в DevOps. Она стала так популярна в первую очередь благодаря повышению скорости разработки, тестирования и возможности внедрения непрерывного развертывания (CI/CD). Сама концепция IaC проста и прозрачна, а многие инструменты работы с ней имеют невысокий порог вхождения, например — Ansible (Linux) или Octopus deploy (Windows).&lt;/p&gt;
  &lt;hr /&gt;
  &lt;p id=&quot;XNDZ&quot;&gt;Инфраструктура как код позволяет управлять виртуальными машинами на программном уровне. Это исключает необходимость ручной настройки и обновлений для отдельных компонентов оборудования. Инфраструктура становится чрезвычайно &amp;quot;эластичной&amp;quot;, то есть воспроизводимой и масштабируемой. Одни оператор может выполнять развертывание и управление как одной, так и 1000 машинами, используя один и тот же набор кода. Среди гарантированных преимуществ инфраструктуры как кода — скорость, экономичность и уменьшение риска.&lt;/p&gt;
  &lt;p id=&quot;iSoQ&quot;&gt;Чем больше проектов, тем больше однотипной инфраструктуры приходится поднимать. Поскольку проекты зачастую высоконагруженные, то мы применяем микросервисную архитектуру. Поэтому в одном проекте содержится еще много-много маленьких подпроектов.&lt;/p&gt;
  &lt;hr /&gt;
  &lt;p id=&quot;di4u&quot;&gt;Каждое приложение работает в каком-то окружении. Давайте посмотрим, из чего это все состоит. У нас как минимум должна быть &lt;strong&gt;операционная система&lt;/strong&gt;, ее нужно сконфигурировать, есть какие-то &lt;strong&gt;сторонние приложения&lt;/strong&gt;, которые тоже нужно сконфигурировать, &lt;strong&gt;само приложение&lt;/strong&gt; должно получить конфигурации, но чтобы весь продукт заработал, должно запуститься само приложение, которое во всей этой системе функционирует. Есть еще &lt;strong&gt;сеть&lt;/strong&gt;, которую тоже нужно настраивать, но про сеть мы сегодня говорить не будем, потому что у нас разные заказчики, разные сетевые устройства. Мы пытались тоже автоматизировать конфигурирование сети, но поскольку устройства разные, никакого особо толку от этого не было, больше тратили ресурсов на это. Но операционные системы, сторонние приложения и передачу конфигурационных параметров в сами приложения мы автоматизировали.&lt;/p&gt;
  &lt;hr /&gt;
  &lt;p id=&quot;HHW7&quot;&gt;Два подхода как вы можете конфигурировать сервера: &lt;/p&gt;
  &lt;ul id=&quot;Y1Do&quot;&gt;
    &lt;li id=&quot;2Xw4&quot;&gt;&lt;strong&gt;руками&lt;/strong&gt; — если вы конфигурируете их руками, у вас соответственно может получиться такая ситуация, что у вас production настроен одним образом, тест другим, на тесте все зеленое, тесты зеленые. Вы деплоите на production, а там не стоит какой-то фреймворк — у вас ничего не работает.&lt;/li&gt;
    &lt;li id=&quot;LAJz&quot;&gt;Другой пример: три Application сервера настроены &lt;strong&gt;руками&lt;/strong&gt;. Один Application сервер настроили одним образом, другой Application сервер другим образом. Сервера могут работать по-разному.&lt;/li&gt;
    &lt;li id=&quot;UX3a&quot;&gt;Еще пример: была ситуация, когда у нас один Stage сервер полностью перестал работать. &lt;strong&gt;Запустили создание нового сервера&lt;/strong&gt; используя и через 30 сервер был готов.&lt;/li&gt;
    &lt;li id=&quot;n2oo&quot;&gt;Еще пример: сервер просто перестал работать. Если &lt;strong&gt;настраивали руками&lt;/strong&gt;, то нужно искать человека, который знает как его настраивать, нужно поднимать документацию. Как мы знаем, документация вряд ли бывает актуальной. Это большие проблемы.&lt;/li&gt;
    &lt;li id=&quot;jvX1&quot;&gt;И, самое главное, — это аудит, то есть грубо говоря, у вас есть десять администраторов, каждый из них &lt;strong&gt;что-то руками настраивает&lt;/strong&gt;, то не особо понятно корректно они это настроили или некорректно, и как вообще понять, нужно ли делать какие-то настройки, могли что-то лишнее поставить, открыть какие-то ненужные порты.&lt;/li&gt;
    &lt;li id=&quot;qzfG&quot;&gt;Есть &lt;strong&gt;альтернативный вариант&lt;/strong&gt; — это как раз то, про что мы сегодня говорим — это &lt;strong&gt;конфигурирование из кода&lt;/strong&gt;. То есть у нас есть &lt;strong&gt;git репозиторий&lt;/strong&gt;, в котором &lt;strong&gt;вся инфраструктура хранится&lt;/strong&gt;. Там хранятся &lt;strong&gt;все скрипты&lt;/strong&gt;, с помощью которых мы будем это настраивать. Поскольку это все в git, мы получаем все преимущества от управления кодом, как в разработке, то есть мы &lt;strong&gt;можем делать ревью&lt;/strong&gt;, &lt;strong&gt;аудит&lt;/strong&gt;, &lt;strong&gt;историю изменений&lt;/strong&gt;, &lt;strong&gt;кто сделал&lt;/strong&gt;, &lt;strong&gt;почему сделал&lt;/strong&gt;, &lt;strong&gt;комментарии&lt;/strong&gt;, &lt;strong&gt;можем откатываться&lt;/strong&gt;. Чтобы работать с кодом нужно использовать конвейер непрерывной сборки — конвейер развертывания. Чтобы какая-то система именно вносила изменения в сервера, то есть не человек что-то руками делал, а исключительно делала это система.&lt;/li&gt;
  &lt;/ul&gt;
  &lt;hr /&gt;
  &lt;p id=&quot;jd9v&quot;&gt;В качестве системы, которая вносит изменения, мы используем Ansible. Поскольку у нас нет огромного количества серверов, он нам вполне подходит. &lt;/p&gt;
  &lt;blockquote id=&quot;s2zP&quot;&gt;Если у вас там 100-200 серверов, то у вас будут небольшие проблемы, потому что он (т.е. Ansible) все-таки соединяется с каждым и по очереди их настраивает — это проблема. Лучше другие средства использовать, которые не пушат (push), а пулят (pull). Но для нашей истории, когда у нас много проектов, но серверов не больше 20 — нам это вполне подходит. &lt;/blockquote&gt;
  &lt;p id=&quot;af1s&quot;&gt;Очень важный момент — если вы катите инфраструктуру через какие-то скрипты, через код, то если у вас все же остаются ручные манипуляции серверами, то это потенциальная уязвимость. Потому что допустим, вы на тестовый сервер поставили java, написали роль ELK, накатили ее. Деплой в тест прошел успешно. Деплоите в production, а там java нет. А java в скрипте вы не указали — деплой в production упал. Поэтому нужно забрать права со всех серверов у администраторов, чтобы они руками туда не залезали и все изменения вносили через git. Весь этот конвейер мы сами проходили. Здесь есть одно но — не надо сильно закручивать гайки. То есть нужно внедрять такой процесс постепенно. Потому что он все еще необкатанный. В нашем случае мы оставили доступ до всех систем у самого главного руководителя администраторов на случай непредвиденных инцидентов. Доступ выдан с условием, что он не будет ничего руками настраивать.&lt;/p&gt;
  &lt;p id=&quot;qqrQ&quot;&gt;&lt;strong&gt;Выводы&lt;/strong&gt;&lt;/p&gt;
  &lt;p id=&quot;jNKw&quot;&gt;Во-первых, мы получили документацию, то есть когда приходит менеджер и меня спрашивает: на каком порту у нас слушает база данных, я открываю Ansible скрипт в git репозитории, говорю: “Вот смотри, вот на таком-то порту”. Какие у нас здесь настройки? Все это видно в git репозитории. Это можно аудировать, показывать менеджерам и так далее. Это 100% достоверная информация. Документация устаревает. А в данном случае ничего не устаревает.&lt;/p&gt;
  &lt;p id=&quot;0I2F&quot;&gt;Важный момент, про который мы не говорили. Про него косвенно скажу. Есть команды разработки, которым локально тоже нужно поднимать RabbitMQ, ELK, чтобы протестироварь различные идеи. Если они будут делать руками, то поднятие ELK может занять больше часа. При использовании подхода инфраструктура как код разработчик поднимает виртуалку, нажимает кнопку, и у него устанавливается ELK. Если разработчик сломал ELK, то он может удалиль, запустить снова установку ELK на виртуалку.&lt;/p&gt;
  &lt;p id=&quot;k8vX&quot;&gt;Как мы уже говорили, это все дешевле только, когда у вас либо много проектов, либо много сред, либо много машин. Если у вас такого нет, то, соответственно, это не дешевле, это дороже. В нашей перспективе в наших проектах это получилось так, что становится дешевле со временем. Поэтому здесь как плюсы так и минусы.&lt;/p&gt;
  &lt;p id=&quot;azuZ&quot;&gt;Быстрое восстановление после аварии. Если вы упали, вам нужно искать человека, который может эту машину настроить, который знает, как ее настроить, который помнит, как ее настроить. В данном случае все настройки и скрипты развертывания находятся в git. Даже если человек уволился, перешел в другой проект — все находится в git, все в комментариях, все видно: почему он открывал такой порт, почему ставил такие-то настройки и так далее. Вы все можете легко восстановить.&lt;/p&gt;
  &lt;p id=&quot;n6JB&quot;&gt;Количество ошибок снизилось, потому что у нас появились разные барьеры, локальные среды для отслеживания, для разработки и плюс code review. Это тоже немаловажно, потому что разработчики просматривают то, что они делают. Таким образом, они еще продолжают обучаться. Возросла сложность, потому что это, соответственно, новая система, это конвейеры, людям нужно обучаться. Это не то, что как обычно привыкли: прочитали статью и по статье сделали. Здесь немножко другое. Но тем не менее со временем это достаточно легко осваивается. Если полностью посмотреть на освоение, то это где-то три-четыре месяца.&lt;/p&gt;

</content></entry><entry><id>it255ru:HeQgObCelNV</id><link rel="alternate" type="text/html" href="https://teletype.in/@it255ru/HeQgObCelNV?utm_source=teletype&amp;utm_medium=feed_atom&amp;utm_campaign=it255ru"></link><title> Kubernetes. Cобеседование</title><published>2023-04-25T08:02:14.480Z</published><updated>2023-04-25T08:02:14.480Z</updated><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://img4.teletype.in/files/36/f8/36f8836a-d9cd-42e5-8e74-3117b2cbe619.png"></media:thumbnail><summary type="html">&lt;img src=&quot;https://habrastorage.org/getpro/habr/upload_files/175/ae4/95b/175ae495b1d85aba6926c193fe197bae.png&quot;&gt;https://habr.com/ru/company/southbridge/blog/713884/</summary><content type="html">
  &lt;p id=&quot;2KQk&quot;&gt;&lt;a href=&quot;https://habr.com/ru/company/southbridge/blog/713884/&quot; target=&quot;_blank&quot;&gt;https://habr.com/ru/company/southbridge/blog/713884/&lt;/a&gt;&lt;/p&gt;
  &lt;p id=&quot;J6Sp&quot;&gt;&lt;/p&gt;
  &lt;p id=&quot;nHVO&quot;&gt;Что такое Kubernetes?&lt;br /&gt; Расскажите об основных компонентах kubernetes&lt;br /&gt; Чем полезна оркестровка контейнеров?&lt;br /&gt; Как связаны Kubernetes и Docker?&lt;br /&gt; Что такое node в Kubernetes?&lt;br /&gt; Что такое pod в Kubernetes?&lt;br /&gt; Что такое Kubernetes deployment?&lt;br /&gt; Опишите набор действий необходимых для запуска deployment?&lt;br /&gt; Объясните разницу между pod и deployment&lt;br /&gt; Что такое service?&lt;br /&gt; что такое namespace&lt;br /&gt; что такое controller-manager&lt;br /&gt; какие типы controller-manager вы знаете?(endpoints controller, service accounts controller, namespace controller, node controller, token controller, and replication controller)&lt;br /&gt; для чего etcd в kubernetes?&lt;br /&gt; что такое clusterIP?&lt;br /&gt; что такое NodePort?&lt;br /&gt; что такое kubelet?&lt;br /&gt; что такое kube-proxy?&lt;/p&gt;
  &lt;p id=&quot;dzDX&quot;&gt;&lt;/p&gt;
  &lt;ol id=&quot;c88T&quot;&gt;
    &lt;li id=&quot;2eZt&quot;&gt;Какие компоненты мастер-узла (Control Plane) Kubernetes и каково их назначение?&lt;/li&gt;
    &lt;li id=&quot;xY9M&quot;&gt;Каковы компоненты рабочего узла (worker node) и их назначение?&lt;/li&gt;
    &lt;li id=&quot;ZIcA&quot;&gt;В чем разница между Init- и Sidecar-контейнерами?&lt;/li&gt;
    &lt;li id=&quot;qMSh&quot;&gt;В чем разница между Deployment и StatefulSet?&lt;/li&gt;
    &lt;li id=&quot;tumr&quot;&gt;Перечислите различные типы сервисов и для чего они используются.&lt;/li&gt;
  &lt;/ol&gt;
  &lt;p id=&quot;4BXi&quot;&gt;&lt;/p&gt;
  &lt;h3 id=&quot;AIhn&quot;&gt;&lt;strong&gt;Какие компоненты мастер-узла (Control Plane) Kubernetes и каково их назначение?&lt;/strong&gt;&lt;/h3&gt;
  &lt;figure id=&quot;RlsP&quot; class=&quot;m_original&quot;&gt;
    &lt;img src=&quot;https://habrastorage.org/getpro/habr/upload_files/175/ae4/95b/175ae495b1d85aba6926c193fe197bae.png&quot; width=&quot;881&quot; /&gt;
    &lt;figcaption&gt;&lt;strong&gt;компоненты мастер-узла (Control Plane) Kubernetes&lt;/strong&gt;&lt;/figcaption&gt;
  &lt;/figure&gt;
  &lt;p id=&quot;GELA&quot;&gt;Узлы Control Plane Kubernetes являются “мозгом” кластера k8s. Узлы Control Plane управляют pod’ами в кластере и рабочими узлами, которые участвуют в кластере.&lt;/p&gt;
  &lt;p id=&quot;QhlC&quot;&gt;Control Plane Kubernetes состоит из четырех компонентов в кластере on-prem и пяти в кластерах cloud/hybrid Kubernetes. Как администраторы кластера, мы хотели бы иметь по крайней мере три узла Control Plane в производственной среде по соображениям отказоустойчивости.&lt;/p&gt;
  &lt;p id=&quot;pJi3&quot;&gt;&lt;strong&gt;Kube-api-server&lt;/strong&gt; — API-сервер Kubernetes проверяет и настраивает данные для API-объектов, включая pod’ы, сервисы, контроллеры репликации и другие. API-сервер обслуживает REST-операции и предоставляет фронтэнд для общего состояния кластера, через которое взаимодействуют все остальные компоненты.&lt;/p&gt;
  &lt;p id=&quot;gRhU&quot;&gt;&lt;strong&gt;Kube-controller-manager&lt;/strong&gt; — Kubernetes controller manager - демон, который реализует основные контуры управления, поставляемые с Kubernetes. В робототехнике и автоматизации контур управления - это непрерывный контур, регулирующий состояние системы. Примерами контроллеров, которые сегодня поставляются с Kubernetes, являются контроллеры replication, endpoints, namespace и serviceaccounts.&lt;/p&gt;
  &lt;p id=&quot;duGc&quot;&gt;&lt;strong&gt;Kube-scheduler&lt;/strong&gt; — Планировщик Kubernetes - это процесс Control Plane, который назначает pod’ы узлам. Планировщик определяет, какие узлы являются допустимыми местами размещения для каждого pod’а в очереди планирования в соответствии с ограничениями и доступными ресурсами. Затем планировщик ранжирует каждый допустимый узел и привязывает pod к подходящему узлу. Планировщиков может быть несколько.&lt;/p&gt;
  &lt;p id=&quot;QL3e&quot;&gt;&lt;strong&gt;Etcd&lt;/strong&gt; — распределенное целостное хранилище ключей и данных с открытым исходным кодом, используемое для совместной конфигурации, обнаружения сервисов и координации планировщика распределенных систем или кластеров машин. В Control Plane Kubernetes Etcd используется для хранения и репликации всех состояний кластера k8s.&lt;/p&gt;
  &lt;p id=&quot;ECO3&quot;&gt;&lt;strong&gt;Cloud-controller-manager&lt;/strong&gt; (используется в облачных провайдерах) — Cloud-controller-manager обеспечивает интерфейс между кластером Kubernetes и облачными API-сервисами. Диспетчер облачных контроллеров позволяет кластеру Kubernetes обеспечивать, отслеживать и удалять облачные ресурсы, необходимые для рабочих операций кластера.&lt;/p&gt;
  &lt;p id=&quot;C9MO&quot;&gt;В сценарии, при котором большинство узлов Control Plane не работает, кластер не сможет обслуживать API-запросы, поэтому кластер будет недоступен. Хотя, если рабочие узлы исправны, pod’ы будут в рабочем состоянии, но не смогут быть перераспределены.&lt;/p&gt;
  &lt;p id=&quot;JSJy&quot;&gt;&lt;/p&gt;
  &lt;p id=&quot;EEw5&quot;&gt;&lt;/p&gt;
  &lt;p id=&quot;SuWG&quot;&gt;Каковы компоненты рабочего узла (worker node) и их назначение?&lt;/p&gt;
  &lt;figure id=&quot;OUF8&quot; class=&quot;m_original&quot;&gt;
    &lt;img src=&quot;https://habrastorage.org/getpro/habr/upload_files/035/d71/4cc/035d714cc94b1f4bb6aad2ec21b0c908.png&quot; width=&quot;793&quot; /&gt;
  &lt;/figure&gt;
  &lt;p id=&quot;KS8R&quot;&gt;Рабочие узлы (worker nodes) отвечают за размещение прикладных pod’ов в кластере. Хотя прикладные pod’ы можно размещать в узлах Control Plane, наилучшей практикой является размещение pod’ов на рабочих узлах по соображениям безопасности.&lt;/p&gt;
  &lt;p id=&quot;J4V1&quot;&gt;Рабочие узлы содержат компоненты, которые позволяют им выполнять запросы Control Plane.&lt;/p&gt;
  &lt;p id=&quot;xPB3&quot;&gt;&lt;strong&gt;Kube-proxy&lt;/strong&gt; — kube-proxy отвечает за поддержание сетевых правил на ваших узлах. Сетевые правила позволяют осуществлять сетевую связь с вашими pod’ами как внутри, так и за пределами вашего кластера.&lt;/p&gt;
  &lt;p id=&quot;a6Sh&quot;&gt;&lt;strong&gt;Kubelet&lt;/strong&gt; — Kubelet является агентом, который запускается на каждом у зле. Он отвечает за создание pod’ов в соответствии с предоставленной спецификацией YAML, отправку на API-сервер состояния работоспособности pod’ов и предоставление информации о состоянии узла, такой как сеть, дисковое пространство и многое другое.&lt;/p&gt;
  &lt;figure id=&quot;iEF2&quot; class=&quot;m_custom&quot;&gt;
    &lt;img src=&quot;https://habrastorage.org/getpro/habr/upload_files/dba/2a4/c72/dba2a4c723e6d1f1472778ac10d9b4f9.png&quot; width=&quot;691.5238095238095&quot; /&gt;
  &lt;/figure&gt;
  &lt;figure id=&quot;9s0X&quot; class=&quot;m_custom&quot;&gt;
    &lt;img src=&quot;https://habrastorage.org/getpro/habr/upload_files/0f9/186/3f6/0f91863f67a53bd82bcfd82f71c1cc05.png&quot; width=&quot;619&quot; /&gt;
  &lt;/figure&gt;
  &lt;p id=&quot;RHLG&quot;&gt;&lt;strong&gt;В чем разница между Init- и Sidecar-контейнерами?&lt;/strong&gt;&lt;/p&gt;
  &lt;p id=&quot;LtFC&quot;&gt;Самый простой pod — это pod, состоящий из одного контейнера. Этот контейнер обеспечивает основные функции приложения, но что, если вы хотите расширить существующую функциональность, не изменяя и не усложняя основной контейнер?&lt;/p&gt;
  &lt;p id=&quot;ypAp&quot;&gt;По этой причине pod’ы могут включать в себя несколько контейнеров. Существует шаблон проектирования контейнера, который полезен для различных сценариев, но строительные блоки для этих шаблонов проектирования реализуются с помощью Init-контейнера и sidecar-контейнера.&lt;/p&gt;
  &lt;figure id=&quot;21DY&quot; class=&quot;m_original&quot;&gt;
    &lt;img src=&quot;https://habrastorage.org/getpro/habr/upload_files/5e2/314/e63/5e2314e6372a7439225a0415ffabd30b.png&quot; width=&quot;845&quot; /&gt;
  &lt;/figure&gt;
  &lt;p id=&quot;ko2G&quot;&gt;&lt;strong&gt;Init-контейнер&lt;/strong&gt; — всегда запускается перед Sidecar-контейнером и основным контейнером приложения. Init-контейнер должен быть запущен до успешного завершения, прежде чем смогут начать работу остальные контейнеры. Причиной использования Init-контейнера могут быть разнообразные применения. Например, его можно использовать для проверки наличия зависимостей приложения, настройки основной среды или среды контейнера Sidecar-контейнера, а также многого другого.&lt;/p&gt;
  &lt;p id=&quot;9TJ1&quot;&gt;&lt;strong&gt;Sidecar-контейнер&lt;/strong&gt; — запускается параллельно основному контейнеру приложения. Существуют различные причины для использования сайдкар контейнеров. Например, в Istio Sidecar-контейнер используется в качестве прокси-сервера для управления входящим трафиком на основной контейнер, его также можно использовать для логгирования, целей мониторинга и многого другого.&lt;/p&gt;
  &lt;p id=&quot;V2vY&quot;&gt;Пример контейнеров для Istio для инициализации среды и перехвата контейнерного трафика:&lt;/p&gt;
  &lt;pre id=&quot;3FsY&quot;&gt;apiVersion: v1
kind: Pod
metadata:
name: example
spec:
# init container section where you can setup your init containers
 initContainers:
 - name: istio-init
   image: istio/proxyv2:1.11.2
 containers:
 - name: hello
   image: alpine
# our sidecar container which will intercept the pod network tarffic
 - name: istio-proxy
   image: istio/proxyv2:1.11.2
   volumeMounts:
   - mountPath: /etc/certs
     name: certs
 volumes:
 - name: certs
   secret:
     secretName: istio-certs&lt;/pre&gt;
  &lt;p id=&quot;HFzl&quot;&gt;&lt;/p&gt;
  &lt;p id=&quot;0g9K&quot;&gt;&lt;strong&gt;В чем разница между Deployment и StatefulSet?&lt;/strong&gt;&lt;/p&gt;
  &lt;p id=&quot;6CQY&quot;&gt;Один из самых распространенных вопросов, с которым мы столкнемся на собеседовании. Чтобы ответить на этот вопрос, нам нужно будет рассмотреть каждый ресурс и понять их различия.&lt;/p&gt;
  &lt;figure id=&quot;lhaa&quot; class=&quot;m_custom&quot;&gt;
    &lt;img src=&quot;https://habrastorage.org/r/w1560/getpro/habr/upload_files/a28/09a/818/a2809a8185f6a43e6f512e95833133b9.png&quot; width=&quot;860&quot; /&gt;
  &lt;/figure&gt;
  &lt;p id=&quot;KflX&quot;&gt;&lt;strong&gt;Deployment&lt;/strong&gt; — является самым простым и наиболее часто используемым ресурсом для развертывания приложений в кластере Kubernetes. &lt;strong&gt;Deployment&lt;/strong&gt; обычно используются для приложений без состояния, что означает, что данные, находящиеся в pod’е, будут удалены вместе с pod’ом. Если мы используем постоянное хранилище с &lt;strong&gt;Deployment,&lt;/strong&gt;, у нас будет одинPersistence volume claim для всех pod’ов, которые принимают участие в развертывании. &lt;strong&gt;Deployment&lt;/strong&gt; порождает ресурс ReplicaSet, через который идут переключения между разными версиями нашего приложения. Pod’ы, принадлежащие Deployment всегда именуются по следующей схеме: &lt;code&gt;&amp;lt;deployment-name&amp;gt;-&amp;lt;replicaset-id&amp;gt;-&amp;lt;pod-id&amp;gt;&lt;/code&gt;.&lt;/p&gt;
  &lt;p id=&quot;Zuxc&quot;&gt;&lt;strong&gt;StatefulSet&lt;/strong&gt; — StatefulSet не использует ReplicaSet в качестве вторичного контроллера, но он управляет pod’ами самостоятельно. Pod’ы StatefulSet’а именуются по следующему шаблону: &lt;code&gt;&amp;lt;Statefulset-name&amp;gt;-0, &amp;lt;Statefulset-name&amp;gt;-1&lt;/code&gt;. Соглашение об именовании используется для сетевых идентификаторов и управления обновлением. StatefulSet требует headless-сервис, позволяя обеспечить идентифицкацию в сети и разрешение DNS имен для pod’ов, участвующих в StatefulSet. Каждая реплика в развертывании StatefulSet получает собственную persistent volume clain, так что каждый pod будет иметь свое собственное состояние.&lt;/p&gt;
  &lt;p id=&quot;mgX4&quot;&gt;Наконец, эмпирическое правило заключается в том, что приложения без состояния должны разворачиваться через Deployment. Deployment включают в себя другой контроллер, называемый ReplicaSet, для упрощения обновлений и откатов. StatefulSet был создан на основе потребностей сообщества и обычно используется для приложений с состоянием таких как, например, баз данных, где определение других реплик в кластере имеет решающее значение, а обновления должны выполняться корректно.&lt;/p&gt;
  &lt;p id=&quot;VW1O&quot;&gt;&lt;/p&gt;
  &lt;p id=&quot;Dwup&quot;&gt;&lt;strong&gt;Перечислите различные типы сервисов и для чего они используются?&lt;/strong&gt;&lt;/p&gt;
  &lt;p id=&quot;qidf&quot;&gt;Сервис Kubernetes — это логическая абстракция группы pod’ов, выбранных селектором. Service используется для настройки политики, с помощью которой можно получить доступ к нижележащим pod’ам.&lt;/p&gt;
  &lt;p id=&quot;YaIr&quot;&gt;В вашем интервью вас, вероятно, спросят о четырех наиболее распространенных типах сервисов, описанными далее:&lt;/p&gt;
  &lt;p id=&quot;Gpvs&quot;&gt;&lt;strong&gt;ClusterIP&lt;/strong&gt; — ClusterIP является типом сервиса по умолчанию и наиболее распространенным сервисом в экосистеме Kubernetes. Сервис типа ClusterIP имеет внутрикластерный IP-адрес и доступен только в рамках кластера.&lt;/p&gt;
  &lt;figure id=&quot;aTVW&quot; class=&quot;m_custom&quot;&gt;
    &lt;img src=&quot;https://habrastorage.org/r/w1560/getpro/habr/upload_files/5dd/6a7/0f1/5dd6a70f18320b6bf55c6016afed55fd.png&quot; width=&quot;741&quot; /&gt;
  &lt;/figure&gt;
  &lt;p id=&quot;hTtc&quot;&gt;&lt;strong&gt;LoadBalancer&lt;/strong&gt; — тип сервиса LoadBalancer используется для обеспечения доступа внешнего трафика путем выделения loadbalancer. Чтобы использовать этот тип сервиса, необходима поддерживающая это платформа, которая сможет распределять loadbalancer. Loadbalancer будет создан асинхронно, и информация о балансировщике нагрузки будет доступна в сервисе только тогда, когда он будет доступен и присвоен сервису. Тип службы loadbalancer также имеет ClusterIP и выделяет NodePort для доступа к сервису.&lt;/p&gt;
  &lt;figure id=&quot;MDfU&quot; class=&quot;m_custom&quot;&gt;
    &lt;img src=&quot;https://habrastorage.org/r/w1560/getpro/habr/upload_files/c5d/9aa/f02/c5d9aaf0202b7b8e7316c55079dc751d.png&quot; width=&quot;702&quot; /&gt;
  &lt;/figure&gt;
  &lt;p id=&quot;Gprq&quot;&gt;&lt;strong&gt;NodePort&lt;/strong&gt; — тип сервиса NodePort обычно используется, когда сервису предоставляется доступ к внешнему трафику, а тип Service LoadBalancer недоступен. С типом Service NodePort вы выбираете порт (в пределах допустимого диапазона от 30000 до 32767), который каждый узел в кластере откроет для приема трафика и переадресации на сервис. Тип службы NodePort также имеет ClusterIP, который позволяет сервису быть доступным из кластера.&lt;/p&gt;
  &lt;figure id=&quot;FzU9&quot; class=&quot;m_custom&quot;&gt;
    &lt;img src=&quot;https://habrastorage.org/r/w1560/getpro/habr/upload_files/9a9/47f/b58/9a947fb585eb0571d7c747a5aa4a1880.png&quot; width=&quot;739&quot; /&gt;
  &lt;/figure&gt;
  &lt;p id=&quot;mUaA&quot;&gt;&lt;strong&gt;Headless&lt;/strong&gt; — тип сервиса Headless используется, когда требуется прямая связь с pod’ом. В приложениях с состоянием, например, баз данных вторичные pod’ы должны напрямую взаимодействовать с первичными pod’ами для репликации данных между репликами. Headless позволяет DNS разрешать pod’ы и получать к ним доступ по имени pod’а. Headless - это сервис, который настроен иным образом, чем ClusterIP и не имеет отдельного внутрикластерного IP адреса. Для доступа к pod’у через Headless-сервис необходимо будет воспользоваться следующим доменным именем: &lt;code&gt;&amp;lt;pod-name&amp;gt;.&amp;lt;service-name&amp;gt;&lt;/code&gt;.&lt;code&gt;&amp;lt;namespace&amp;gt;.svc.cluster.local&lt;/code&gt;.&lt;/p&gt;

</content></entry><entry><id>it255ru:JkRgD5lor2D</id><link rel="alternate" type="text/html" href="https://teletype.in/@it255ru/JkRgD5lor2D?utm_source=teletype&amp;utm_medium=feed_atom&amp;utm_campaign=it255ru"></link><title>Linux. Собеседование</title><published>2023-02-16T15:18:41.950Z</published><updated>2023-02-16T15:18:41.950Z</updated><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://img4.teletype.in/files/33/f6/33f699f0-117c-40bc-9ffc-fc3f44b3c8b8.png"></media:thumbnail><summary type="html">&lt;img src=&quot;https://cdn.hackr.io/uploads/posts/large/1570190199727DINLouL.jpg&quot;&gt;Что такое LA? В каких единицах измеряется?

LA (load average) - параметр, определяющий среднюю нагрузку на систему за период времени (1 мин, 5 минут, 15 минут). Изменяется в количестве задач на одно ядро процессора. На нагрузку системы также влияет количество задач ввода-вывода и задержка сети. Также влияние на расчета LA оказывает: </summary><content type="html">
  &lt;figure id=&quot;zn8s&quot; class=&quot;m_column&quot;&gt;
    &lt;img src=&quot;https://cdn.hackr.io/uploads/posts/large/1570190199727DINLouL.jpg&quot; width=&quot;960&quot; /&gt;
  &lt;/figure&gt;
  &lt;h1 id=&quot;60n6&quot;&gt;Linux. Собеседование&lt;/h1&gt;
  &lt;p id=&quot;40YG&quot;&gt;&lt;strong&gt;Что такое LA? В каких единицах измеряется?&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;LA (load average) - параметр, определяющий среднюю нагрузку на систему за период времени (1 мин, 5 минут, 15 минут). Изменяется в количестве задач на одно ядро процессора. На нагрузку системы также влияет количество задач ввода-вывода и задержка сети. Также влияние на расчета LA оказывает: &lt;/p&gt;
  &lt;ul id=&quot;69GM&quot;&gt;
    &lt;li id=&quot;jqSo&quot;&gt;Технология Hyper-Threading, которая делит одно физическое ядро на 2 логических, &lt;/li&gt;
    &lt;li id=&quot;8yQT&quot;&gt;Технология Turbo Bust, которая позволяет разгонять тактовую частоту процессора и работать на частоте выше заявленной, т.е. выше номинальной частоты (время на обработку одной задачи уменьшается). &lt;/li&gt;
  &lt;/ul&gt;
  &lt;p id=&quot;U5W0&quot;&gt;&lt;strong&gt;Что будет если на сервере LA = 200? &lt;/strong&gt;&lt;br /&gt;Вероятно, что на сервере будет наблюдаться замедленная работа сервисов, но если параметр LA равен количеству ядер в системе или количеству потоков в системе, то данная нагрузка является нормальной.&lt;/p&gt;
  &lt;p id=&quot;Jayw&quot;&gt;&lt;strong&gt;Почему при высоких показателях значения LA на сервере может не наблюдаться проблем (консоль ssh отзывается, сервисы работают в обычном режиме)?&lt;/strong&gt;&lt;/p&gt;
  &lt;p id=&quot;gWiB&quot;&gt;На параметр нагрузки LA влияет также и ожидание ввода-вывода (параметр &lt;strong&gt;wa&lt;/strong&gt; в утилите &lt;strong&gt;top&lt;/strong&gt;) в дисков и задержка сети. Данные параметры могут не влиять на работу основных сервисов в системе, но учитываются при расчете общей нагрузки на систему. &lt;/p&gt;
  &lt;p id=&quot;t7bh&quot;&gt;uptime - load average&lt;/p&gt;
  &lt;p id=&quot;gsGi&quot;&gt;We can get the load average from commands like &lt;strong&gt;top&lt;/strong&gt; or &lt;strong&gt;uptime&lt;/strong&gt;.&lt;/p&gt;
  &lt;p id=&quot;sXu4&quot;&gt;If &lt;strong&gt;load&lt;/strong&gt; &amp;gt; # of CPUs, it may mean CPU saturation.&lt;/p&gt;
  &lt;pre id=&quot;k0Dj&quot;&gt;$ uptime
 16:48:25 up 32 min,  2 users,  load average: 0.58, 1.13, 2.46
&lt;/pre&gt;
  &lt;p id=&quot;YhRy&quot;&gt;From left to right, these numbers show us the average load over the last 1 minute, the last 5 minutes, and the last 15 minutes. In other words, the above output indicates:&lt;/p&gt;
  &lt;pre id=&quot;FFyz&quot;&gt;load average over the last 1 minute: 0.58
load average over the last 5 minutes: 1.13
load average over the last 15 minutes: 2.46
&lt;/pre&gt;
  &lt;p id=&quot;QuxR&quot;&gt;Assuming 1 cpu machine, it means:&lt;/p&gt;
  &lt;pre id=&quot;YvB5&quot;&gt;load average over the last 1 minute: 0.58 =&amp;gt; The CPU idled for 42% of the time
load average over the last 5 minutes: 1.13 =&amp;gt; .13 processes were waiting for the CPU
load average over the last 15 minutes: 2.46 =&amp;gt; On average, 1.46 processes were waiting for the CPU
&lt;/pre&gt;
  &lt;p id=&quot;LfND&quot;&gt;Actually, if the machine has 2 CPUs, then it would mean:&lt;/p&gt;
  &lt;pre id=&quot;jpvL&quot;&gt;load average over the last 1 minute: 0.58 =&amp;gt; The CPU idled for 142% of the time
load average over the last 5 minutes: 1.13 =&amp;gt; .87 processes were waiting for the CPU
load average over the last 15 minutes: 2.46 =&amp;gt; On average, 0.46 processes were waiting for the CPU
&lt;/pre&gt;
  &lt;p id=&quot;bn1T&quot;&gt;&lt;/p&gt;
  &lt;p id=&quot;2YwF&quot;&gt;&lt;strong&gt;Что такое системный вызов, какие они бывают?&lt;/strong&gt;&lt;/p&gt;
  &lt;p id=&quot;eT3m&quot;&gt;Системный вызов - обращение программы к ядру операционной системы для выполнения какой-либо операции.&lt;/p&gt;
  &lt;p id=&quot;YO4T&quot;&gt;В Unix, Unix-like и других POSIX-совместимых операционных системах популярными системными вызовами являются:&lt;br /&gt;- open,&lt;br /&gt;- read,&lt;br /&gt;- write,&lt;br /&gt;- close,&lt;br /&gt;- wait,&lt;br /&gt;- exec, &lt;br /&gt;- fork,&lt;br /&gt;- exit,&lt;br /&gt;- kill.&lt;/p&gt;
  &lt;p id=&quot;Glr2&quot;&gt;&lt;/p&gt;
  &lt;p id=&quot;fFBo&quot;&gt;&lt;strong&gt;Что такое сигнал в Unix, зачем они нужны и разница между 9 и 15 сигналами?&lt;/strong&gt;&lt;/p&gt;
  &lt;p id=&quot;6xWH&quot;&gt;Сигнал - в Unix-like операционных системах - асинхронное (в случайное время) уведомление процесса для обработки какого-либо события. Один из основных способов взаимодействия между процессами.&lt;/p&gt;
  &lt;p id=&quot;Iso7&quot;&gt;Посылка сигналов от одного процесса к другому обычно осуществляется при помощи системного вызова *kill*. Его первый параметр – PID процесса, которому посылается сигнал; второй параметр – номер сигнала.&lt;br /&gt;&lt;strong&gt;kill(1111, SIGTERM);&lt;/strong&gt;&lt;br /&gt;&lt;/p&gt;
  &lt;p id=&quot;DSJE&quot;&gt;&lt;strong&gt;Стандарт POSIX определяет 28 сигналов. Некоторые из них:&lt;/strong&gt;&lt;/p&gt;
  &lt;p id=&quot;Kix4&quot;&gt;| Сигнал | Код | Описание |&lt;br /&gt;&lt;br /&gt;| SIGTERM | 15 | Сигнал завершения (сигнал по умолчанию для утилиты kill) |&lt;br /&gt;| SIGKILL | 9 | Безусловное завершение |&lt;br /&gt;| SIGSTOP | 23 | Остановка выполнения процесса |&lt;br /&gt;| SIGHUP | 1 | Закрытие терминала (перечитать конфигурацию) |&lt;br /&gt;| SIGINT | 2 | Сигнал прерывания (Ctrl-C) с терминала |&lt;/p&gt;
  &lt;p id=&quot;r4r9&quot;&gt;&lt;/p&gt;
  &lt;p id=&quot;v3fh&quot;&gt;&lt;strong&gt;Что такое inode? Какая информация там хранится?&lt;/strong&gt;&lt;/p&gt;
  &lt;p id=&quot;2QU2&quot;&gt;Inode (индексный дескриптор) - структура данных, в которой хранятся метаданные файла и перечислены блоки с данными файла. Хранит всю информацию, кроме имени файла и данных. Каждый файл в данном каталоге является записью с именем файла и номером индекса. Вся остальная информация о файле извлекается из таблицы индексов путем ссылки на номер индекса. Номера inodes уникальны на уровне раздела. Каждый раздел как собственная таблица индексов. Если у вас закончились inode, вы не можете создавать новые файлы, даже если у вас есть свободное место на данном разделе.&lt;/p&gt;
  &lt;p id=&quot;kBuk&quot;&gt;Inodes хранит метаданные о файле, к которому он относится. Эти метаданные содержат всю информацию об указанном файле.&lt;br /&gt;- Размер.&lt;br /&gt;- Разрешение.&lt;br /&gt;- Владелец/группа.&lt;br /&gt;- Расположение жесткого диска.&lt;br /&gt;- Дата/время.&lt;br /&gt;- Любая другая необходимая информация.&lt;/p&gt;
  &lt;p id=&quot;qlxY&quot;&gt;&lt;/p&gt;
  &lt;p id=&quot;OXlN&quot;&gt;&lt;strong&gt;Что такое hard link? В чем разница между hard link и soft link? Примеры их практического применения.&lt;/strong&gt;&lt;/p&gt;
  &lt;p id=&quot;ZNYY&quot;&gt;&lt;strong&gt;Hard link:&lt;/strong&gt;&lt;br /&gt;Ссылка на файл в файловой системе с использованием такого же inode идентификатора, как у файла, на который ссылаемся.&lt;br /&gt;Создадим файл *realFile*.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;touch realFile&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Создадим hard link командой &amp;#x60;ln &amp;lt;целевой_файл&amp;gt; &amp;lt;файл_ссылка&amp;gt;&amp;#x60;:&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;ln realFile hardLink&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Проверим, что inode у файла *realFile* и hard ссылке *hardLink* имеют одинаковый идентификатор.&lt;br /&gt;&lt;br /&gt;$ ls -li&lt;br /&gt;итого 0&lt;br /&gt;2359720 -rw-r--r-- 2 rmntrvn rmntrvn 0 апр 25 23:24 hardLink&lt;br /&gt;2359720 -rw-r--r-- 2 rmntrvn rmntrvn 0 апр 25 23:24 realFile&lt;br /&gt;&lt;br /&gt;Как видно realFile и hardLink имеют одинаковый идентификатор inode.&lt;/p&gt;
  &lt;p id=&quot;SB78&quot;&gt;&lt;strong&gt;Soft link:&lt;/strong&gt; &lt;br /&gt;Создадим soft ссылку на файл *realFile*.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;ln -s realFile softLink&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Проверим, что чистовой идентификатор *softLink* отличается от числового идентификатора *realFile*.&lt;br /&gt;&lt;br /&gt;$ ls -li&lt;br /&gt;итого 0&lt;br /&gt;2359720 -rw-r--r— 2 rmntrvn rmntrvn 0 апр 25 23:24 hardLink&lt;br /&gt;2359720 -rw-r--r— 2 rmntrvn rmntrvn 0 апр 25 23:24 realFile&lt;br /&gt;2366763 lrwxrwxrwx 1 rmntrvn rmntrvn 8 апр 25 23:29 softLink -&amp;gt; realFile&lt;/p&gt;
  &lt;p id=&quot;r4ch&quot;&gt;Некоторые нюансы:&lt;br /&gt;- Soft ссылки используют различные номера inode, чем основные файлы.&lt;br /&gt;- Soft ссылки становятся полезными, если исходный файл был удален.&lt;br /&gt;- Soft ссылки могут быть созданы из каталогов.&lt;br /&gt;- Soft ссылка может быть создана на пересечении файловых систем.&lt;/p&gt;
  &lt;p id=&quot;lM7p&quot;&gt;- Hard ссылка может размещаться только на том же логическом разделе, что и оригинальный файл. Это связано с независимой идентификацией файлов на разных разделах.&lt;br /&gt;- Создание жестких ссылок не поддерживается для папок — только для файлов.&lt;br /&gt;- Файловая система должна поддерживать работу с hard ссылками.&lt;/p&gt;
  &lt;figure id=&quot;VMlE&quot; class=&quot;m_column&quot;&gt;
    &lt;img src=&quot;https://s3.ap-south-1.amazonaws.com/myinterviewtrainer-domestic/public_assets/assets/000/000/311/original/soft_link_vs_hard_link.png?1618833491&quot; width=&quot;6700&quot; /&gt;
  &lt;/figure&gt;
  &lt;figure id=&quot;poKU&quot; class=&quot;m_original&quot;&gt;
    &lt;img src=&quot;https://img4.teletype.in/files/74/7b/747b6af8-01a9-46c8-a540-8959346c53a6.png&quot; width=&quot;565&quot; /&gt;
  &lt;/figure&gt;
  &lt;h3 id=&quot;G8gX&quot;&gt;What are an Inode and PID?&lt;/h3&gt;
  &lt;p id=&quot;HGT4&quot;&gt;An inode is a file structure that stores metadata for files in Linux. The metadata includes file size, permissions needed to access the file, user and group ID, creation timestamp, and the path to the file.&lt;/p&gt;
  &lt;p id=&quot;rTQd&quot;&gt;An inode number is a unique number or integer given to each file on a Linux system.&lt;/p&gt;
  &lt;pre id=&quot;ox8z&quot;&gt;$ ls -li ravi.txt 

1594567 -rwxrwxr-x 1 tecmint tecmint 0 Oct 28 10:58 ravi.txt
&lt;/pre&gt;
  &lt;p id=&quot;oXZt&quot;&gt;&lt;strong&gt;1594567&lt;/strong&gt; is the inode number and the &lt;code&gt;-i&lt;/code&gt; flag shows the inode of the &lt;strong&gt;ravi.txt&lt;/strong&gt; file.&lt;/p&gt;
  &lt;p id=&quot;mmBF&quot;&gt;A &lt;strong&gt;PID&lt;/strong&gt; (&lt;strong&gt;Process ID&lt;/strong&gt;) is a unique ID given to each running process on a Linux system. We can use the &lt;a href=&quot;https://www.tecmint.com/find-process-name-pid-number-linux/&quot; target=&quot;_blank&quot;&gt;pidof command&lt;/a&gt; to find the process ID of any running program.&lt;/p&gt;
  &lt;pre id=&quot;gjTc&quot;&gt;$ pidof firefox

40982&lt;/pre&gt;
  &lt;p id=&quot;MbSv&quot;&gt;&lt;/p&gt;
  &lt;p id=&quot;orZl&quot;&gt;&lt;strong&gt;Какие состояния процессов существуют? Что значит состояние процесса D?&lt;/strong&gt;&lt;/p&gt;
  &lt;p id=&quot;KmEC&quot;&gt;&lt;/p&gt;
  &lt;p id=&quot;SWjg&quot;&gt;|                   **Статус**                   |               **Описание**              |&lt;br /&gt;|:----------------------------------------------:|:---------------------------------------:|&lt;br /&gt;|             R (running or runnable)            |    Выполняется или готов к выполнению   |&lt;br /&gt;|           D (uninterruptible  sleep)           |          Ожидает записи на диск         |&lt;br /&gt;|             S (interruptible sleep)            |            Неактивен (&amp;lt; 20 s)           |&lt;br /&gt;|        T (stopped by job control signal)       |  Остановлен или трассируется отладчиком |&lt;br /&gt;|                   Z (zombie)                   |                  зомби                  |&lt;br /&gt;| W (paging (not valid since the 2.6.xx kernel)) |         Процесс выгружен на диск        |&lt;br /&gt;|                        &amp;lt;                       | Процесс имеет повышенный приоритет nice |&lt;br /&gt;|                        N                       | Процесс имеет пониженный приоритет nice |&lt;br /&gt;|                   L (locked)                   |  Некоторые страницы блокированы в ядре  |&lt;br /&gt;|                        s                       |     Процесс является лидеров сеанса     |&lt;/p&gt;
  &lt;p id=&quot;lHqP&quot;&gt;Linux Process is a type of process that can be in a number of different states. The process enters these states from start till end. Process states in Linux are as follows:&lt;/p&gt;
  &lt;figure id=&quot;0mba&quot; class=&quot;m_column&quot;&gt;
    &lt;img src=&quot;https://s3.ap-south-1.amazonaws.com/myinterviewtrainer-domestic/public_assets/assets/000/000/306/original/linux_process_states.png?1618828562&quot; width=&quot;5693&quot; /&gt;
  &lt;/figure&gt;
  &lt;ul id=&quot;OndA&quot;&gt;
    &lt;li id=&quot;IX1b&quot;&gt;&lt;strong&gt;New/Ready:&lt;/strong&gt; In this state, a new process is created and is ready to run.&lt;/li&gt;
    &lt;li id=&quot;KIjc&quot;&gt;&lt;strong&gt;Running:&lt;/strong&gt; In this state, the process is being executed.&lt;/li&gt;
    &lt;li id=&quot;lFpu&quot;&gt;&lt;strong&gt;Blocked/Wait: &lt;/strong&gt;In this state, the process is waiting for input from the user and if doesn&amp;#x27;t have resources to run such as memory, file locks, input, then it can remain in a waiting or blocked state.&lt;/li&gt;
    &lt;li id=&quot;FM7E&quot;&gt;&lt;strong&gt;Terminated/Completed:&lt;/strong&gt; In this state, the process has completed the execution or terminated by the OS.&lt;/li&gt;
    &lt;li id=&quot;KDCm&quot;&gt;&lt;strong&gt;Zombie: &lt;/strong&gt;In this state, the process is terminated but information regarding the process still exists and is available in the process table&lt;/li&gt;
  &lt;/ul&gt;
  &lt;p id=&quot;ibSH&quot;&gt;&lt;/p&gt;
  &lt;p id=&quot;YaGz&quot;&gt;&lt;strong&gt;Что такое процесс-зомби и процесс-сирота? Можно ли самостоятельно сделать зомби?&lt;/strong&gt;&lt;/p&gt;
  &lt;p id=&quot;zbVY&quot;&gt;Зомби-процесс, также называемый в Linux несуществующим или мертвым процессом, представляет собой процесс, который завершил выполнение, но его запись остается в таблице процессов. Обычно это происходит из-за отсутствия соответствия между родительским и дочерним процессами. Этот процесс происходит для дочернего процесса, поскольку родительскому процессу необходимо прочитать состояние дочернего процесса. После завершения с помощью системного вызова wait этот процесс удаляется из таблицы процессов.&lt;/p&gt;
  &lt;figure id=&quot;u5AQ&quot; class=&quot;m_column&quot;&gt;
    &lt;img src=&quot;https://s3.ap-south-1.amazonaws.com/myinterviewtrainer-domestic/public_assets/assets/000/000/310/original/zombie_process.png?1618831850&quot; width=&quot;5692&quot; /&gt;
  &lt;/figure&gt;
  &lt;p id=&quot;VlH5&quot;&gt;&lt;strong&gt;Процесс-зомби&lt;/strong&gt; - дочерний процесс в Unix-системе, завершивший своё выполнение, но ещё присутствующий в списке процессов операционной системы, чтобы дать родительскому процессу считать код завершения.&lt;/p&gt;
  &lt;p id=&quot;8HsM&quot;&gt;Удаление зомби возлагается на родительский процесс или системный вызов &amp;#x60;wait()&amp;#x60; также может это выполнить, поэтому перед ее вызовом не нужно проверять, продолжает ли выполняться требуемый дочерний процесс. Если родительский процесс не удалит своих потомков, то они останутся в состоянии зомби.&lt;/p&gt;
  &lt;p id=&quot;BuUm&quot;&gt;Убить зомби-процесс невозможно. Чтобы убить зомби-процесс нужно найти родительский процесс и завершить его или перезапустить. Найти зомби-процессы и их родителей можно следующей командой:&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;ps ajx | grep -w Z&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;PID&amp;#x27;ы процессов родителей в 3 колонке. Убить процесс следующей командой:&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;kill -9 &amp;lt;PID процесса родителя&amp;gt;&lt;/strong&gt;&lt;br /&gt;&lt;/p&gt;
  &lt;p id=&quot;8Kd5&quot;&gt;&lt;strong&gt;Процесс-сирота&lt;/strong&gt; — в семействе операционных систем UNIX вспомогательный процесс, чей основной процесс (или связь с ним) был завершен нештатно (не подав сигнала на завершение работы).&lt;/p&gt;
  &lt;p id=&quot;pB3p&quot;&gt;Отличие в том, что процесс-сирота (orphan process) всё еще активен. Его родительский процесс был по какой-либо причине прерван, и сирота теперь переходит под руководство init, чей ID процесса равен 1. PPID orphan процесса получит значение 1. Пользователь также может создать подобный процесс, отсоединив его от терминала. Сиротские процессы используют много ресурсов, их легко найти с помощью top или htop.&lt;/p&gt;
  &lt;p id=&quot;JrWP&quot;&gt;В отличии от процесса-сироты, зомби-процесс неактивен, но контролируется родительским процессом, пока тот не решит, что статус выхода дочерних процессов больше не нужен. Он не использует ресурсы и не может быть запланирован для выполнения. Иногда родительский процесс удерживает дочерний процесс в состоянии зомби, чтобы гарантировать, что будущие дочерние процессы не получат тот же PID. Если вы уничтожите родителя зомби-процесса, зомби-процесс тоже умрет. Для этого найдите родительский PID (PPID) зомби и отправьте ему сигнал SIGCHLD (17): kill -17 ppid.&lt;/p&gt;
  &lt;p id=&quot;GKNT&quot;&gt;&lt;/p&gt;
  &lt;p id=&quot;6jVb&quot;&gt;&lt;strong&gt;Что такое файловый дескриптор? Какая информация там хранится?&lt;/strong&gt;&lt;/p&gt;
  &lt;p id=&quot;jfZX&quot;&gt;Файловый дескриптор - неотрицательное целое число, которое используется в интерфейсе между пространством пользователя и пространством ядра (kernel) для идентификации ресурсов файла / сокета. Когда создаётся новый поток ввода-вывода, ядро возвращает процессу, создавшему поток ввода-вывода, его файловый дескриптор. &lt;/p&gt;
  &lt;p id=&quot;VZ2G&quot;&gt;&lt;/p&gt;
  &lt;p id=&quot;qTLt&quot;&gt;&lt;strong&gt;Что такое buffer/cache память? Для чего нужна?&lt;/strong&gt;&lt;/p&gt;
  &lt;p id=&quot;TN4v&quot;&gt;buff/cache память - рассчитанная память, которая зарезервирована, но может быть освобождена при необходимости и используется для быстрого доступа программами к данным, которые находятся в оперативной памяти (быстрой памяти).&lt;/p&gt;
  &lt;p id=&quot;viwH&quot;&gt;buffers — буферы в памяти — страницы памяти, зарезервированные системой для выделения их процессам, когда они затребуют этого, так же известна как heap-memory;&lt;br /&gt;cached — файлы, которые недавно были использованы системой/процессами и хранящиеся в памяти на случай если вскоре они снова потребуются.&lt;/p&gt;
  &lt;p id=&quot;cpWI&quot;&gt;&lt;/p&gt;
  &lt;p id=&quot;H2Pf&quot;&gt;Представлен вывод команды &amp;#x60;free&amp;#x60;.&lt;br /&gt;&lt;br /&gt;$ free -m&lt;br /&gt;              total        used        free      shared  buff/cache   available&lt;br /&gt;Mem:           6930        3598         843         183        2489        2919&lt;br /&gt;Swap:         15999           4       15995&lt;br /&gt;&lt;br /&gt;Почему доступной (available) памяти сейчас 2919, если свободной (free) памяти 843?&lt;/p&gt;
  &lt;p id=&quot;b3XL&quot;&gt;- Total. Эта цифра представляет всю существующую память.&lt;br /&gt;- Used вычисление общего значения оперативной памяти системы за вычетом выделенной свободной, разделяемой, буферной и кэш-памяти.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;used = total - free - buff/cache&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;- Free – свободная память в системе.&lt;br /&gt;- Shared – память, используемая (преимущественно) в tmpfs&lt;br /&gt;- Buffer, и Cache идентифицируют память, используемую для нужд ядра / операционной системы. Буфер и кеш складываются вместе, а сумма указывается в разделе «buff/cache».&lt;br /&gt;- Available – примерное количество оперативной памяти, доступное для запуска новых приложений без использования ими раздела подкачки. В отличие от поля free, это поле принимает в расчёт страницу cache и также то, что не вся рекуперируемая (пригодная для повторного использования) память будет возвращена для рекуперации из-за того, что элементы используются в данный момент.&lt;/p&gt;
  &lt;p id=&quot;qENx&quot;&gt;&lt;/p&gt;
  &lt;p id=&quot;aWmY&quot;&gt;&lt;strong&gt;Порядок загрузки дистрибутива Linux.&lt;/strong&gt;&lt;/p&gt;
  &lt;p id=&quot;Jzge&quot;&gt;1. Включение компьютера кнопкой.&lt;br /&gt;2. Загрузить BIOS / UEFI из NVRAM.&lt;br /&gt;3. Собрать сведения об аппаратуре.&lt;br /&gt;4. Выбрать устройства для запуска (диск, сеть).&lt;br /&gt;5. Идентифицировать системный раздел EFI.&lt;br /&gt;6. Загрузить BIOS / UEFI из NVRAM.&lt;br /&gt;7. Определить какое ядро загрузить.&lt;br /&gt;8. Загрузить ядро.&lt;br /&gt;9. Создать структуры данных ядра.&lt;br /&gt;10. Запустить init / systemd как PID 1.&lt;br /&gt;11. Выполнить сценарии запуска.&lt;br /&gt;12. Запустить систему.&lt;/p&gt;
  &lt;p id=&quot;9ggl&quot;&gt;&lt;/p&gt;
  &lt;p id=&quot;4b2h&quot;&gt;&lt;strong&gt;What’s Run level 0?&lt;/strong&gt;&lt;br /&gt; The run level 0 denotes system halt. It means the system can be powered off without any activity.  &lt;/p&gt;
  &lt;p id=&quot;tujl&quot;&gt;&lt;strong&gt;What do you mean by a run level?&lt;/strong&gt;&lt;br /&gt; In Unix-based OSes, a Run level signifies the state of the computer after boot. Runlevel is previously set on various Linux distributions. There are seven Run levels, starting from zero to six. Run levels determine the programs to be executed after the operating system boots up. System admins assign a default run level as per their requirements. You can find out your computer’s current run level using the &lt;strong&gt;/sbin/runlevel&lt;/strong&gt; command.&lt;/p&gt;
  &lt;h2 id=&quot;Aqiz&quot;&gt;What is the name and path of the main system log?&lt;/h2&gt;
  &lt;p id=&quot;o6Za&quot;&gt;By default, the main system log is &amp;#x27;/var/log/messages&amp;#x27;. This file contains all the messages and the script written by the user. By default all scripts are saved in this file. This is the standard system log file, which contains messages from all system software, non-kernel boot issues, and messages that go to &amp;#x27;dmesg&amp;#x27;. dmesg is a system file that is written upon system boot.&lt;/p&gt;
  &lt;h4 id=&quot;mD1h&quot;&gt;What are the different layers of Linux?&lt;/h4&gt;
  &lt;p id=&quot;qFvK&quot;&gt;&lt;strong&gt;Answer:&lt;/strong&gt;&lt;/p&gt;
  &lt;p id=&quot;2Zsm&quot;&gt;Below are the different layers of Linux as following:&lt;/p&gt;
  &lt;ul id=&quot;M6QL&quot;&gt;
    &lt;li id=&quot;SoXw&quot;&gt;&lt;strong&gt;Hardware’s&lt;/strong&gt; – Innermost layer consists of physical devices like RAM, CPU, etc. There might be driver software to communicate with devices in some OS.&lt;/li&gt;
    &lt;li id=&quot;CC5T&quot;&gt;&lt;strong&gt;Kernel – &lt;/strong&gt;Kernel is a heart of an OS with hides the complexities of the underlying hardware and provides a high-level abstraction to upper layers. There are different types of kernels &lt;a href=&quot;https://www.educba.com/monolithic-kernel-vs-microkernel/&quot; target=&quot;_blank&quot;&gt;like a microkernel, Monolithic Kernel&lt;/a&gt;, etc. Linux kernel is a Monolithic type.&lt;/li&gt;
    &lt;li id=&quot;g6qg&quot;&gt;&lt;strong&gt;Shell&lt;/strong&gt; – Shell is a program running on top of the Kernel, which acts as a primary method of interaction between user and kernel. Simply saying it is a program that can run other programs. Nowadays GUI replaces shell to a large extent. Shell accepts commands and passes them for execution.&lt;/li&gt;
    &lt;li id=&quot;jdpj&quot;&gt;&lt;strong&gt;Utility Programs(Utilities)&lt;/strong&gt; – These programs or software running on a top layer of OS help users with day-to-day generic activities like schedule a cron job or a specific task like create text documents.&lt;/li&gt;
  &lt;/ul&gt;
  &lt;p id=&quot;XBWZ&quot;&gt;&lt;/p&gt;
  &lt;h3 id=&quot;praT&quot;&gt;What are file permissions in Linux? Name different types of file systems in Linux.&lt;/h3&gt;
  &lt;p id=&quot;6ozy&quot;&gt;There are three owners in the Linux System i.e., user, group, and others. These owners have three types of permissions defined as listed below:&lt;/p&gt;
  &lt;ul id=&quot;dVvF&quot;&gt;
    &lt;li id=&quot;OEWt&quot;&gt;&lt;strong&gt;Read (r):&lt;/strong&gt; It allows the user to open and read the file or list the directory.&lt;/li&gt;
    &lt;li id=&quot;hHZh&quot;&gt;&lt;strong&gt;Write (w):&lt;/strong&gt; It allows the user to open and modify the file. One can also add new files to the directory.&lt;/li&gt;
    &lt;li id=&quot;5Uyf&quot;&gt;&lt;strong&gt;Execute (x):&lt;/strong&gt; It allows the user to execute or run the file. One can also lookup a specific file within a directory.&lt;/li&gt;
  &lt;/ul&gt;
  &lt;figure id=&quot;w6h2&quot; class=&quot;m_column&quot;&gt;
    &lt;img src=&quot;https://www.tecmint.com/wp-content/uploads/2022/12/Linux-File-Permissions.jpg&quot; width=&quot;900&quot; /&gt;
  &lt;/figure&gt;
  &lt;p id=&quot;iEcM&quot;&gt;&lt;/p&gt;
  &lt;h3 id=&quot;aey0&quot;&gt;What is a “/proc” file system?&lt;/h3&gt;
  &lt;p id=&quot;DXRx&quot;&gt;Proc file system is a pseudo or virtual file system that provides an interface to the kernel data structure. It generally includes useful information about processes that are running currently. It can also be used to change some kernel parameters at runtime or during execution. It is also regarded as a control and information center for the kernel. All files under this directory are named virtual files.&lt;/p&gt;
  &lt;p id=&quot;vUho&quot;&gt;&lt;/p&gt;
  &lt;h3 id=&quot;QEUw&quot;&gt;Как в Linux найти, кто использует файл?&lt;/h3&gt;
  &lt;p id=&quot;UeB8&quot;&gt;&lt;strong&gt;Lsof&lt;/strong&gt; используется файловой системой, чтобы определить, кто использует какие-либо файлы в этой файловой системе. Вы можете запустить команду lsof в файловой системе Linux, и выходные данные идентифицируют владельца и информацию о процессах, использующих файл, как показано в следующем листинге выходных данных.&lt;/p&gt;
  &lt;p id=&quot;Sjcj&quot;&gt;&lt;em&gt;Список всех открытых в Linux файлов&lt;/em&gt;&lt;/p&gt;
  &lt;pre id=&quot;YJqx&quot;&gt;$ lsof /dev/null&lt;/pre&gt;
  &lt;pre id=&quot;gqCu&quot;&gt;COMMAND    PID    USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
systemd   1480 tecmint    0r   CHR    1,3      0t0    6 /dev/null
sh        1501 tecmint    0r   CHR    1,3      0t0    6 /dev/null&lt;/pre&gt;
  &lt;p id=&quot;28B7&quot;&gt;Чтобы вывести список файлов, открытых для конкретного пользователя, выполните следующую команду:&lt;/p&gt;
  &lt;p id=&quot;CuB8&quot;&gt;&lt;em&gt;Список файлов, открытых конкретным пользователем (при использовании в вашей системе замените &lt;code&gt;tecmint&lt;/code&gt; действительным именем пользователя)&lt;/em&gt;&lt;/p&gt;
  &lt;pre id=&quot;em8R&quot;&gt;$ lsof -u tecmint
COMMAND    PID    USER   FD      TYPE             DEVICE  SIZE/OFF       NODE NAME
systemd   1480 tecmint  cwd       DIR                8,3      4096          2 /
systemd   1480 tecmint  rtd       DIR                8,3      4096          2 /
systemd   1480 tecmint  txt       REG                8,3   1595792    3147496 /lib/systemd/systemd&lt;/pre&gt;
  &lt;p id=&quot;Nrcx&quot;&gt;Еще одно важный случай применения команды &lt;strong&gt;lsof&lt;/strong&gt; - &lt;a href=&quot;https://www.tecmint.com/find-out-which-process-listening-on-a-particular-port/&quot; target=&quot;_blank&quot;&gt;определение процесса, использующего определенный порт&lt;/a&gt;. Например, чтобы определить, какой процесс использует порт &lt;strong&gt;80&lt;/strong&gt;, можно воспользоваться следующим вариантом запуска команды &lt;strong&gt;lsof&lt;/strong&gt;.&lt;/p&gt;
  &lt;p id=&quot;zws2&quot;&gt;&lt;em&gt;Определение процесса, прослушивающего порт&lt;/em&gt;&lt;/p&gt;
  &lt;pre id=&quot;zG0m&quot;&gt;$ sudo lsof -i TCP:80
&lt;/pre&gt;
  &lt;pre id=&quot;djwZ&quot;&gt;COMMAND  PID   USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
httpd    903   root    4u  IPv6  20222      0t0  TCP *:http (LISTEN)
httpd   1320 apache    4u  IPv6  20222      0t0  TCP *:http (LISTEN)&lt;/pre&gt;
  &lt;p id=&quot;L4cz&quot;&gt;&lt;/p&gt;
  &lt;p id=&quot;YN7K&quot;&gt;&lt;/p&gt;
  &lt;p id=&quot;6KRu&quot;&gt;&lt;a href=&quot;https://github.com/mxssl/sre-interview-prep-guide/blob/master/README.md&quot; target=&quot;_blank&quot;&gt;https://github.com/mxssl/sre-interview-prep-guide/blob/master/README.md&lt;/a&gt;&lt;/p&gt;
  &lt;p id=&quot;j94B&quot;&gt;&lt;a href=&quot;https://www.brendangregg.com/USEmethod/use-linux.html&quot; target=&quot;_blank&quot;&gt;https://www.brendangregg.com/USEmethod/use-linux.html&lt;/a&gt;&lt;/p&gt;
  &lt;p id=&quot;ETS2&quot;&gt;&lt;a href=&quot;https://www.bogotobogo.com/DevOps/DevOps-Sys-Admin-Interview-Questions-Linux-Monitoring-System-Application-Performance-Tuning-Tools.php&quot; target=&quot;_blank&quot;&gt;https://www.bogotobogo.com/DevOps/DevOps-Sys-Admin-Interview-Questions-Linux-Monitoring-System-Application-Performance-Tuning-Tools.php&lt;/a&gt;&lt;/p&gt;
  &lt;p id=&quot;ZcvY&quot;&gt;&lt;/p&gt;
  &lt;h3 id=&quot;Kjia&quot;&gt;Explain ulimit VS umask.&lt;/h3&gt;
  &lt;p id=&quot;JZxA&quot;&gt;ulimit is a Linux built-in command that offers excellent control over available resources to shell or start processes. If needed, the user can choose to limit to a specific range by customizing the limits.conf file. They could also update system settings in the sysctl.conf file.&lt;/p&gt;
  &lt;p id=&quot;4sqq&quot;&gt;Talking about umask, it refers to using a file creation mask. umask determines the permissions of a file or directory when the user creates one.&lt;/p&gt;
  &lt;h3 id=&quot;o4NH&quot;&gt;What is SELinux?&lt;/h3&gt;
  &lt;p id=&quot;n6oM&quot;&gt;(One of the Red Hat Linux interview questions that you’ll most likely be asked).&lt;/p&gt;
  &lt;p id=&quot;t65u&quot;&gt;SELinux is Security-Enhanced Linux. As the name suggests, it’s a Linux program with enhanced security features. It protects the server from compromised daemons and misconfigurations. In addition, SELinux is used to access control implementation for the Linux kernel.&lt;/p&gt;
  &lt;p id=&quot;g1H7&quot;&gt;It also sets limits and instructs server programs to access specific permitted files and security policies, defining the action to be taken.&lt;/p&gt;
  &lt;p id=&quot;QecQ&quot;&gt;&lt;strong&gt;Представлен вывод команды top. Что означает каждая запись в выводе?&lt;/strong&gt;&lt;/p&gt;
  &lt;pre id=&quot;hB51&quot;&gt;   top - 21:29:24 up 14:18,  1 user,  load average: 0,78, 1,48,   1,10
   Tasks: 277 total,   3 running, 274 sleeping,   0 stopped,      0 zombie
   %Cpu(s): 12,4 us,  2,5 sy,  0,1 ni, 84,8 id,  0,1 wa,  0,0   hi,  0,1 si,  0,0 st
   KiB Mem :  7106404 total,   306972 free,  3127144 used,    3672288 buff/cache
   KiB Swap:  8191996 total,  8191996 free,        0 used.    3270520 avail Mem &lt;/pre&gt;
  &lt;p id=&quot;V2jI&quot;&gt;&lt;strong&gt;top&lt;/strong&gt; - название утилиты.&lt;/p&gt;
  &lt;p id=&quot;HyUe&quot;&gt;&lt;strong&gt;21:29:24&lt;/strong&gt; - текущее время системы.&lt;/p&gt;
  &lt;p id=&quot;O2l8&quot;&gt;&lt;strong&gt;up 14:18&lt;/strong&gt; - сколько часов:минут система работает с момента последнего запуска.&lt;/p&gt;
  &lt;p id=&quot;hc4y&quot;&gt;1 user - количество пользователей авторизованных в системе.&lt;/p&gt;
  &lt;p id=&quot;yOys&quot;&gt;&lt;strong&gt;load average: 0,78, 1,48, 1,10 &lt;/strong&gt;- параметр средней нагрузки на систему за период времени 1 минута, 5 минут, 15 минут.&lt;/p&gt;
  &lt;p id=&quot;ilv7&quot;&gt;&lt;strong&gt;277 total &lt;/strong&gt;- всего процессов в системе.&lt;/p&gt;
  &lt;p id=&quot;abCs&quot;&gt;&lt;strong&gt;3 running&lt;/strong&gt; - количество процессов в работе.&lt;/p&gt;
  &lt;p id=&quot;V1aY&quot;&gt;&lt;strong&gt;274 sleeping&lt;/strong&gt; - количество процессов в состоянии sleeping: ожидает какого-либо события или сигнала.&lt;/p&gt;
  &lt;p id=&quot;opPH&quot;&gt;&lt;strong&gt;0 stopped &lt;/strong&gt;- количество приостановленных процессов сигналом STOP или выполнением трассировки.&lt;/p&gt;
  &lt;p id=&quot;OpzR&quot;&gt;&lt;strong&gt;0 zombie&lt;/strong&gt; - количество зомби-процессов, которые завершили своё выполнение, но присутствующие в системе, чтобы дать родительскому процессу считать свой код завершения.&lt;/p&gt;
  &lt;p id=&quot;CqKg&quot;&gt;&lt;strong&gt;Параметр&lt;/strong&gt;&lt;br /&gt;us (user) - Использование процессора пользовательским процессами &lt;br /&gt;sy (system) - Использование процессора системным процессами&lt;br /&gt;ni (nice) - Использование процессора процессами с измененным приоритетом с помощью команды nice&lt;br /&gt;id (idle) - Простой процессора. Можно сказать, что это свободные ресурсы &lt;br /&gt;wa (IO-wait) - Говорит о простое, связанным с вводом/выводом &lt;br /&gt;hi (hardware interrupts) - Показывает сколько процессорного времени было потрачено на обслуживание аппаратного прерывания &lt;br /&gt;si (software interrupts) - Показывает сколько процессорного времени было потрачено на обслуживание софтверного прерывания &lt;br /&gt;st (stolen by the hypervisor) - Показывает сколько процессорного времени было «украдено» гипервизором &lt;/p&gt;
  &lt;p id=&quot;A4tW&quot;&gt;&lt;strong&gt;KiB Mem&lt;/strong&gt; - количество оперативной памяти в кибибайтах (кратно 1024):&lt;br /&gt;&lt;strong&gt;7106404 total&lt;/strong&gt; -- всего доступно оперативной памяти в системе,&lt;br /&gt;&lt;strong&gt;306972 free&lt;/strong&gt; -- свободно оперативной памяти для использования,&lt;br /&gt;&lt;strong&gt;3127144 used&lt;/strong&gt; -- использовано оперативной памяти,&lt;br /&gt;&lt;strong&gt;3672288 buff/cache&lt;/strong&gt; -- буферизовано/закешировано оперативной памяти.&lt;/p&gt;
  &lt;p id=&quot;rydT&quot;&gt;&lt;strong&gt;KiB Swap&lt;/strong&gt; - количество swap-памяти в кибибайтах (кратно 1024), которые выделено на диске:&lt;br /&gt;&lt;strong&gt;8191996 total&lt;/strong&gt; - всего выделено swap-памяти,&lt;br /&gt;&lt;strong&gt;8191996 free&lt;/strong&gt; - свободно swap-памяти&lt;br /&gt;&lt;strong&gt;0 used&lt;/strong&gt; - использовано swap-памяти,&lt;br /&gt;&lt;strong&gt;3270520 avail Mem&lt;/strong&gt; - доступно для использования swap-памяти.&lt;/p&gt;
  &lt;p id=&quot;9ooW&quot;&gt;&lt;/p&gt;
  &lt;p id=&quot;NYLB&quot;&gt;&lt;strong&gt;Как в утилите top в Linux посмотреть нагрузку на каждое ядро процессора?&lt;/strong&gt;&lt;/p&gt;
  &lt;p id=&quot;az0B&quot;&gt;В утилите top нажать &amp;#x60;1&amp;#x60;, чтобы отобразить все ядра в системе.&lt;/p&gt;
  &lt;p id=&quot;Ihe1&quot;&gt;&lt;/p&gt;
  &lt;p id=&quot;oPqd&quot;&gt;&lt;strong&gt;Как в утилите top в Linux посмотреть какой командой был запущен процесс?&lt;/strong&gt;&lt;/p&gt;
  &lt;p id=&quot;zkkL&quot;&gt;В утилите top нажать &amp;#x60;c&amp;#x60;, чтобы отобразить команды, которыми были запущены процессы.&lt;/p&gt;
  &lt;p id=&quot;q3Ce&quot;&gt;&lt;/p&gt;
  &lt;p id=&quot;akoR&quot;&gt;&lt;strong&gt;Где хранятся имена файлов/директорий?&lt;/strong&gt;&lt;/p&gt;
  &lt;p id=&quot;Yg8t&quot;&gt; - Inodes не содержат имён файлов, только другие метаданные файла. &lt;br /&gt; - Каталоги Unix представляют собой списки ассоциативных структур, каждая из которых содержит одно имя файла и один номер индекса.&lt;br /&gt; - Драйвер файловой системы должен найти каталог, ищущий определенное имя файла, а затем преобразовать имя файла в правильный соответствующий номер индекса.&lt;/p&gt;
  &lt;p id=&quot;pWN8&quot;&gt;Таким образом имя файла/директории хранится в информационной структуре директорий.&lt;br /&gt;&lt;/p&gt;
  &lt;p id=&quot;Tebi&quot;&gt;&lt;strong&gt;Как удалить файл с именем &amp;#x60;-rf&amp;#x60;?&lt;/strong&gt;&lt;/p&gt;
  &lt;pre id=&quot;ear7&quot;&gt;rm ./-rf&lt;/pre&gt;
  &lt;p id=&quot;JU6l&quot;&gt;&lt;/p&gt;
  &lt;p id=&quot;T6rp&quot;&gt;&lt;strong&gt;Как посмотреть описание дискриптора? Как посмотреть время последней модификации файла?&lt;/strong&gt;&lt;/p&gt;
  &lt;p id=&quot;cgQS&quot;&gt;Посмотреть полную информацию по дискриптору возможно командой &lt;strong&gt;stat &amp;lt;path_to_file&amp;gt;&lt;/strong&gt;.&lt;br /&gt;Время модификации:&lt;br /&gt;&lt;strong&gt;stat --format=%y dira&lt;/strong&gt;&lt;br /&gt;&lt;/p&gt;
  &lt;p id=&quot;NyVZ&quot;&gt;&lt;strong&gt;Для чего нужна переменная окружения &lt;em&gt;PATH&lt;/em&gt;?&lt;/strong&gt;&lt;/p&gt;
  &lt;p id=&quot;5CYc&quot;&gt;Переменная окружения &lt;em&gt;PATH &lt;/em&gt;содержит абсолютные пути директорий, в которых производится поиск исполняемых файлов при вводе команд&lt;/p&gt;
  &lt;p id=&quot;8wfZ&quot;&gt;&lt;/p&gt;
  &lt;p id=&quot;avEV&quot;&gt;&lt;strong&gt;Как посмотреть нагрузку на диски?&lt;/strong&gt;&lt;/p&gt;
  &lt;p id=&quot;RJzd&quot;&gt;Установить утилиту &amp;#x60;sysstat&amp;#x60;, проверить нагрузку на диски &amp;#x60;iostat -xtc&amp;#x60;.&lt;/p&gt;
  &lt;p id=&quot;gZnq&quot;&gt;&lt;/p&gt;
  &lt;p id=&quot;gZrq&quot;&gt;&lt;strong&gt;Что такое файл в понятиях Unix-like операционных системах?&lt;/strong&gt;&lt;/p&gt;
  &lt;p id=&quot;O9g0&quot;&gt;Файлы - это объекты, в которые мы записываем информацию и наши данные, исполняемые файлы, но кроме этих привычных нам понятий здесь есть файлы специального назначения - файлы устройств, файлы туннелей, сокетов и многое другое.&lt;/p&gt;
  &lt;p id=&quot;CEQv&quot;&gt;Типы файлов в Linux:&lt;br /&gt;- Обычные файлы, для хранения информации;&lt;br /&gt;- Специальные файлы - для устройств и туннелей;&lt;br /&gt;- Директории.&lt;/p&gt;
  &lt;p id=&quot;ggXq&quot;&gt;&lt;/p&gt;
  &lt;p id=&quot;ZhaT&quot;&gt;&lt;strong&gt;Что такое RAID? Какие массивы бывают?&lt;/strong&gt;&lt;/p&gt;
  &lt;p id=&quot;IWU1&quot;&gt;RAID (Redundant Array of Independent Disks) - избыточный массив независимых дисков, технология виртуализации данных для объединения нескольких физических дисковых устройств в логический модуль для повышения отказоустойчивости и производительности.&lt;/p&gt;
  &lt;p id=&quot;HTVJ&quot;&gt;В зависимости от количества дисков и класса отказоустойчивости существуют следующие основные типы RAID:&lt;br /&gt;RAID 0:&lt;br /&gt;RAID 1:&lt;br /&gt;RAID 5:&lt;br /&gt;RAID 6:&lt;br /&gt;RAID 10:&lt;/p&gt;
  &lt;p id=&quot;WSMz&quot;&gt;&lt;/p&gt;
  &lt;p id=&quot;vz1E&quot;&gt;&lt;strong&gt;При каком количестве одновременно вышедших из строя дисков обеспечивает работоспособность RAID 6?&lt;/strong&gt;&lt;/p&gt;
  &lt;p id=&quot;K9iY&quot;&gt;2 диска.&lt;/p&gt;
  &lt;p id=&quot;TNP5&quot;&gt;&lt;/p&gt;
  &lt;p id=&quot;83di&quot;&gt;&lt;strong&gt;В чем разница между объявлением переменной &amp;#x60;export VAR=&amp;quot;VALUE&amp;quot;&amp;#x60; и &amp;#x60;VAR=&amp;quot;VALUE&amp;quot;&amp;#x60; в bash?&lt;/strong&gt;&lt;/p&gt;
  &lt;p id=&quot;Hhik&quot;&gt;При объявлении переменной через export - переменная будет доступна в любых других процессах, при обычном объявлении переменной - переменная будет доступна только в запущенном процессе.&lt;/p&gt;
  &lt;p id=&quot;ywQJ&quot;&gt;&lt;/p&gt;
  &lt;p id=&quot;bmAE&quot;&gt;&lt;strong&gt;Как остановить выполнение скрипта в bash при возникновении ошибки в команде?&lt;/strong&gt;&lt;/p&gt;
  &lt;p id=&quot;L82U&quot;&gt;Команда &lt;strong&gt;set -e&lt;/strong&gt; завершит скрипт с ошибкой, в случае, если в нижеследующем bash коде будет обнаружена ошибка. По-умолчанию bash скрипт продолжает работу, если в ходе выполнения возникла ошибка.&lt;/p&gt;
  &lt;p id=&quot;2I5y&quot;&gt;&lt;/p&gt;
  &lt;p id=&quot;6B4r&quot;&gt;&lt;strong&gt;Что в bash скрипте означает команда &amp;#x60;set -euo pipefail&amp;#x60;?&lt;/strong&gt;&lt;/p&gt;
  &lt;p id=&quot;IN2q&quot;&gt;Команда &lt;strong&gt;set&lt;/strong&gt; устанавливает аттрибуты оболочки с опеределенных опций.&lt;br /&gt;Опция &lt;strong&gt;-e&lt;/strong&gt; - означает, что скрипт будет остановлен, когда произойдет ошибка в ходе его выполнения.&lt;br /&gt;Опция &lt;strong&gt;-u&lt;/strong&gt; - означает, что скрипт будет остановлен, если в ходе скрипта, будет обнаружена переменная, которая не определена.&lt;br /&gt;Опция &lt;strong&gt;-o pipefail&lt;/strong&gt; - означает, что скрипт будет остановлен, если в ходе пайплайна команд будет выявлена ошибка. &lt;/p&gt;
  &lt;p id=&quot;y1Om&quot;&gt;&lt;/p&gt;
  &lt;p id=&quot;jB47&quot;&gt;&lt;strong&gt;Как активировать debug режим в bash?&lt;/strong&gt;&lt;/p&gt;
  &lt;p id=&quot;bO1M&quot;&gt;Команда &lt;strong&gt;set -x&lt;/strong&gt; в начале скрипта активирует вывод в консоль debug информации.&lt;/p&gt;
  &lt;p id=&quot;UM99&quot;&gt;&lt;/p&gt;
  &lt;p id=&quot;H956&quot;&gt;&lt;strong&gt;Что значит $@ в bash?&lt;/strong&gt;&lt;/p&gt;
  &lt;p id=&quot;jOCH&quot;&gt;&lt;strong&gt;$@&lt;/strong&gt; - все параметры переданные скрипту.&lt;/p&gt;
  &lt;p id=&quot;OfP2&quot;&gt;&lt;/p&gt;
  &lt;p id=&quot;F6Fe&quot;&gt;&lt;strong&gt;Какой код сигнала будет выполнен при исполнении команды kill &amp;lt;PID&amp;gt;?&lt;/strong&gt;&lt;/p&gt;
  &lt;p id=&quot;f19V&quot;&gt;Сигнал SIGTERM (код 15) - это сигнал по-умолчанию отправляемый при вызове команды kill. Это указывает процессу на завершение работы и обычно считается сигналом для использования при чистом завершении работы.&lt;/p&gt;
  &lt;p id=&quot;hWib&quot;&gt;&lt;/p&gt;
  &lt;p id=&quot;9UjV&quot;&gt;&lt;strong&gt;Как выполнить фильтрацию вывода команды, чтобы на экран были выведены только ошибки (STDERR), игнорируя STDOUT?&lt;/strong&gt;&lt;/p&gt;
  &lt;p id=&quot;mMtc&quot;&gt;cmd 2&amp;gt;&amp;amp;1 &amp;gt;/dev/null | grep pattern&lt;br /&gt;&lt;/p&gt;
  &lt;p id=&quot;kJLY&quot;&gt;&lt;strong&gt;Какую команду необходимо выполнить, чтобы посмотреть какие пользователи вошли в систему в систему?&lt;/strong&gt;&lt;/p&gt;
  &lt;p id=&quot;AkbR&quot;&gt;Команда &lt;strong&gt;w&lt;/strong&gt; покажет список пользователей, которые вошли на сервер.&lt;/p&gt;
  &lt;p id=&quot;aGCq&quot;&gt;&lt;/p&gt;
  &lt;p id=&quot;e7cs&quot;&gt;&lt;strong&gt;Какой файл необходимо отредактировать, чтобы отключить ssh аутентификацию по паролю?&lt;/strong&gt;&lt;/p&gt;
  &lt;p id=&quot;1eFS&quot;&gt;Необходимо редактировать файл &lt;strong&gt;/etc/ssh/sshd_config&lt;/strong&gt;, отвечающий за конфигурацию сервиса ssh.&lt;/p&gt;
  &lt;p id=&quot;GYbV&quot;&gt;&lt;/p&gt;
  &lt;p id=&quot;izFI&quot;&gt;&lt;strong&gt;В каком файле находится информация о смонтированных каталогах в файловую систсему?&lt;/strong&gt;&lt;/p&gt;
  &lt;p id=&quot;iAHL&quot;&gt;Файл &lt;strong&gt;/etc/fstab&lt;/strong&gt; содержит информацию о смонтированных каталогах в файловую систему. &lt;/p&gt;
  &lt;p id=&quot;J3EA&quot;&gt;&lt;/p&gt;
  &lt;p id=&quot;GroI&quot;&gt;&lt;strong&gt;Что выведет команда cat a и почему?&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;mkdir /tmp/abc&lt;br /&gt;cd /tmp/abc&lt;br /&gt;ls &amp;gt;a 2&amp;gt;b&lt;br /&gt;cat a&lt;br /&gt;&lt;/p&gt;
  &lt;p id=&quot;z3fO&quot;&gt;&amp;#x60;cat a&amp;#x60; выведет&lt;br /&gt;a&lt;br /&gt;b&lt;br /&gt;&lt;br /&gt;Обработка команды идёт справа налево. Сначала создается файл *b*, потом создается файл *a*, команда &amp;#x60;ls&amp;#x60; отображает список файлов в текущей директории (файлы *a* и *b* уже созданы) в одну колонну и перенаправляет стандартный поток вывода (&amp;#x60;&amp;gt;&amp;#x60;) в файл *a*, а стандартный поток ошибок &amp;#x60;2&amp;#x60; в файл *b*. &lt;/p&gt;
  &lt;p id=&quot;yRsJ&quot;&gt;&lt;/p&gt;
  &lt;p id=&quot;IPYX&quot;&gt;&lt;strong&gt;В bash-скрипте указан аттрибут оболочки &amp;#x60;set -x&amp;#x60;. В одной из команд происходит ошибка и скрипт завершает свою работу. Как сделать, чтобы при возникновении ошибки в определенной команде скрипт продолжил свою работу?&lt;/strong&gt;&lt;/p&gt;
  &lt;p id=&quot;QiEg&quot;&gt;1 вариант: указать &lt;code&gt;|| true&lt;/code&gt; после выполнения команды с ошибкой.&lt;br /&gt;&lt;code&gt;&amp;lt;command with error&amp;gt; || true&lt;/code&gt;&lt;/p&gt;
  &lt;p id=&quot;YoPW&quot;&gt;2 вариант: до выполнения данной команды указать &amp;#x60;set +e&amp;#x60; для игнорирования ошибок, начиная со следующей строки и после выполнения команды указать &amp;#x60;set -e&amp;#x60; для завершения работы скрипта в случае ошибки, начиная со следующей строки.&lt;br /&gt;sh&lt;br /&gt;set -e&lt;br /&gt;&amp;lt;command 1&amp;gt;&lt;br /&gt;&amp;lt;command 2&amp;gt;&lt;br /&gt;set +e&lt;br /&gt;&amp;lt;command 3 wih error&amp;gt;&lt;br /&gt;set -e&lt;br /&gt;&lt;/p&gt;
  &lt;p id=&quot;kun0&quot;&gt;&lt;/p&gt;
  &lt;p id=&quot;eq9S&quot;&gt;&lt;/p&gt;
  &lt;p id=&quot;0cOc&quot;&gt;&lt;/p&gt;
  &lt;h3 id=&quot;iVkn&quot;&gt;Why is the tar command used?&lt;/h3&gt;
  &lt;p id=&quot;tDdU&quot;&gt;The tar command is used for extracting or creating an archived file. If you wish to extract all of the files from the sample.tar.gz package, use the following command:&lt;/p&gt;
  &lt;p id=&quot;CxCx&quot;&gt;$ tar -xvzf sample.tar.gz&lt;/p&gt;
  &lt;p id=&quot;AHXd&quot;&gt;&lt;br /&gt;&lt;/p&gt;
  &lt;p id=&quot;lI4q&quot;&gt;&lt;strong&gt;How to find logs older than seven days and remove them?&lt;/strong&gt;&lt;/p&gt;
  &lt;p id=&quot;TNkJ&quot;&gt;find /path/ -type f -mtime +7 -name ‘*.gz’ -execdir rm — ‘{}’ \;&lt;/p&gt;
  &lt;p id=&quot;Laro&quot;&gt;Details:&lt;/p&gt;
  &lt;p id=&quot;jgxA&quot;&gt;find: the UNIX command for finding files/directories/links etc.&lt;/p&gt;
  &lt;p id=&quot;iFT7&quot;&gt;/path/: the directory path where you are searching for old logs&lt;/p&gt;
  &lt;p id=&quot;ry3D&quot;&gt;-type f: specifying to check only for files.&lt;/p&gt;
  &lt;p id=&quot;FHAp&quot;&gt;-name ‘*.gz’: will find for the files that end with “.gz”.&lt;/p&gt;
  &lt;p id=&quot;otNp&quot;&gt;-mtime +7: only consider the ones with modification time older than 7 days.&lt;/p&gt;
  &lt;p id=&quot;16K5&quot;&gt;-execdir … \;: for each such result found, execute the following command.&lt;/p&gt;
  &lt;p id=&quot;KOk0&quot;&gt;rm — ‘{}’: remove the file; the {} part is where the output from previous command will be given as input.&lt;/p&gt;
  &lt;p id=&quot;jOtQ&quot;&gt;&lt;/p&gt;
  &lt;ol id=&quot;sGBc&quot;&gt;
    &lt;li id=&quot;mKcJ&quot;&gt;&lt;strong&gt;What is cron job and how to set it?&lt;/strong&gt;&lt;/li&gt;
  &lt;/ol&gt;
  &lt;p id=&quot;uHBK&quot;&gt;cron is a kind of a daemon that executes scripts or programs at specific time intervals.&lt;/p&gt;
  &lt;p id=&quot;gDn5&quot;&gt;These commands are called cron jobs.&lt;/p&gt;
  &lt;p id=&quot;pBwU&quot;&gt;This is like a scheduler for system admins and developers. Many use cases are present for which we can set cron jobs like log rotation,&lt;/p&gt;
  &lt;p id=&quot;HNvu&quot;&gt;emailing users to trigger any update for automatic data backup at any specified timings.&lt;/p&gt;
  &lt;p id=&quot;QC6B&quot;&gt;find the standard cron job writing style:-&lt;/p&gt;
  &lt;p id=&quot;FbBR&quot;&gt;* * * * * script1&lt;/p&gt;
  &lt;p id=&quot;Z3Jk&quot;&gt;please find the details below for all the description for every *:-&lt;/p&gt;
  &lt;p id=&quot;TLZH&quot;&gt;# +—————- minute (0 – 59)&lt;/p&gt;
  &lt;p id=&quot;n3kt&quot;&gt;# | +————- hour (0 – 23)&lt;/p&gt;
  &lt;p id=&quot;9iNI&quot;&gt;# | | +———- day of month (1 – 31)&lt;/p&gt;
  &lt;p id=&quot;TvFi&quot;&gt;# | | | +——- month (1 – 12)&lt;/p&gt;
  &lt;p id=&quot;OJX2&quot;&gt;# | | | | +—- day of week (0 – 6) (Sunday=0)&lt;/p&gt;
  &lt;p id=&quot;4l49&quot;&gt;# | | | | |&lt;/p&gt;
  &lt;p id=&quot;AfbH&quot;&gt;* * * * * command to be executed&lt;/p&gt;
  &lt;p id=&quot;moHO&quot;&gt;if you want to save the output of the cron job, you can execute the below command.&lt;/p&gt;
  &lt;p id=&quot;qYxs&quot;&gt;Timing Execute Path to script Output&lt;/p&gt;
  &lt;p id=&quot;Xk8j&quot;&gt;* * * * * /usr/bin/scripts /var/www/html/crontest/cron.sh &amp;gt; /dev/null 2&amp;gt;&amp;amp;1&lt;/p&gt;
  &lt;ol id=&quot;ckO3&quot;&gt;
    &lt;li id=&quot;fqso&quot;&gt;&lt;strong&gt;How to copy the files in Linux?&lt;/strong&gt;&lt;/li&gt;
  &lt;/ol&gt;
  &lt;p id=&quot;dHXm&quot;&gt;cp command&lt;/p&gt;
  &lt;p id=&quot;VhUR&quot;&gt;we can use cp command to copy any data from the current directory to a different directory.&lt;/p&gt;
  &lt;p id=&quot;TuHW&quot;&gt;For example:-the command cp test.txt /home/users/files would create a copy of test.txt at “/home/users/files”&lt;/p&gt;
  &lt;ol id=&quot;ouSQ&quot;&gt;
    &lt;li id=&quot;U21r&quot;&gt;&lt;strong&gt;How to move the files in Linux?&lt;/strong&gt;&lt;/li&gt;
  &lt;/ol&gt;
  &lt;p id=&quot;Bema&quot;&gt;mv command&lt;/p&gt;
  &lt;p id=&quot;8EQL&quot;&gt;mv command can be used to move files from one folder to another; This is also used to rename the files.&lt;/p&gt;
  &lt;p id=&quot;8WIV&quot;&gt;This works as cp command only. We need to type mv, the file’s name, and the destination’s directory.&lt;/p&gt;
  &lt;p id=&quot;51c2&quot;&gt;For example: mv file.txt /home/users/Docs.&lt;/p&gt;
  &lt;ol id=&quot;EZCr&quot;&gt;
    &lt;li id=&quot;xcJk&quot;&gt;&lt;strong&gt;What is sudo command?&lt;/strong&gt;&lt;/li&gt;
  &lt;/ol&gt;
  &lt;p id=&quot;sH8N&quot;&gt;sudo stands for “SuperUser Do”, this command enables you to perform tasks that require administrative or root permissions.&lt;/p&gt;
  &lt;p id=&quot;0rcx&quot;&gt;However, it is not recommended to use sudo command because most of the tasks would be performed as a particular user.&lt;/p&gt;
  &lt;ol id=&quot;ZPSF&quot;&gt;
    &lt;li id=&quot;OWgs&quot;&gt;&lt;strong&gt;Which command is used to check disk space and disk usage?&lt;/strong&gt;&lt;/li&gt;
  &lt;/ol&gt;
  &lt;p id=&quot;gc7H&quot;&gt;df command&lt;/p&gt;
  &lt;p id=&quot;DSoC&quot;&gt;df command is used to check the disk space, shown in percentage and KBs.&lt;/p&gt;
  &lt;p id=&quot;yIXL&quot;&gt;If you want to see the report in megabytes, type df -m.&lt;/p&gt;
  &lt;p id=&quot;EmNc&quot;&gt;du command&lt;/p&gt;
  &lt;p id=&quot;VjMj&quot;&gt;this is used to check Disk Usage.&lt;/p&gt;
  &lt;p id=&quot;0A3F&quot;&gt;However, the disk usage summary will show disk block numbers instead of the usual size format.&lt;/p&gt;
  &lt;p id=&quot;SdHJ&quot;&gt;If you want to see it in bytes, kilobytes, and megabytes, add the -h argument to the command line.&lt;/p&gt;
  &lt;ol id=&quot;DeSR&quot;&gt;
    &lt;li id=&quot;HHQp&quot;&gt;&lt;strong&gt;How to check first few and last few lines of any linux file?&lt;/strong&gt;&lt;/li&gt;
  &lt;/ol&gt;
  &lt;p id=&quot;n0Uj&quot;&gt;The head command is used to view the first lines of any text file. By default, it will show the first ten lines,&lt;/p&gt;
  &lt;p id=&quot;UgYg&quot;&gt;but you can change this number to your liking.&lt;/p&gt;
  &lt;p id=&quot;nJ96&quot;&gt;For example, if you only want to show the first five lines.&lt;/p&gt;
  &lt;p id=&quot;Oqel&quot;&gt;head -n 5 filename.ext.&lt;/p&gt;
  &lt;p id=&quot;3BLh&quot;&gt;tail command&lt;/p&gt;
  &lt;p id=&quot;k9dH&quot;&gt;This one has a similar function to the head command, but instead of showing the first lines,&lt;/p&gt;
  &lt;p id=&quot;rcD2&quot;&gt;the tail command will display the last ten lines of a text file.&lt;/p&gt;
  &lt;p id=&quot;pOEQ&quot;&gt;tail -n filename.ext.&lt;/p&gt;
  &lt;p id=&quot;d9RW&quot;&gt;&lt;strong&gt;10. How to check the difference between two Linux files?&lt;/strong&gt;&lt;/p&gt;
  &lt;p id=&quot;GxSt&quot;&gt;diff command&lt;/p&gt;
  &lt;p id=&quot;N6Fh&quot;&gt;the diff command compares the contents of two files line by line.&lt;/p&gt;
  &lt;p id=&quot;486J&quot;&gt;After analyzing the files, it will output the lines that do not match.&lt;/p&gt;
  &lt;p id=&quot;wxZ0&quot;&gt;Programmers often use this command when they need to make program alterations instead of rewriting the entire source code.The simplest form of this command&lt;/p&gt;
  &lt;p id=&quot;wl32&quot;&gt;diff file1.ext file2.ext&lt;/p&gt;
  &lt;p id=&quot;bfVX&quot;&gt;&lt;/p&gt;
  &lt;h3 id=&quot;19-which-command-is-used-to-execute-a-shell-file&quot;&gt;&lt;strong&gt;Which command is used to execute a shell file?&lt;/strong&gt;&lt;/h3&gt;
  &lt;p id=&quot;zkuA&quot;&gt;First Set execute permission on your script using chmod command:&lt;/p&gt;
  &lt;pre id=&quot;pGrq&quot;&gt;chmod +x script-name-here.sh&lt;/pre&gt;
  &lt;p id=&quot;sGAD&quot;&gt;&lt;strong&gt;To run your script:&lt;/strong&gt;&lt;/p&gt;
  &lt;pre id=&quot;56Fq&quot;&gt;./script-name-here.sh&lt;/pre&gt;
  &lt;p id=&quot;ZEUr&quot;&gt;&lt;strong&gt;Another option to execute shell script:&lt;/strong&gt;&lt;/p&gt;
  &lt;pre id=&quot;dfDj&quot;&gt;sh script-name-here.sh&lt;/pre&gt;
  &lt;p id=&quot;pSGm&quot;&gt;&lt;/p&gt;
  &lt;h3 id=&quot;1-what-is-interactive-and-non-interactive-shell&quot;&gt;&lt;strong&gt;What is interactive and non-interactive shell?&lt;/strong&gt;&lt;/h3&gt;
  &lt;p id=&quot;PrPP&quot;&gt;Interactive Shell&lt;/p&gt;
  &lt;pre id=&quot;4eHI&quot;&gt;/bin/bash and /bin/sh &lt;/pre&gt;
  &lt;p id=&quot;g5G3&quot;&gt;Non-interactive shell&lt;/p&gt;
  &lt;pre id=&quot;939M&quot;&gt;/sbin/nologin &lt;/pre&gt;
  &lt;p id=&quot;RBIc&quot;&gt;&lt;/p&gt;
  &lt;h3 id=&quot;2-what-is-the-absolute-and-relative-path&quot;&gt;&lt;strong&gt;What is the absolute and relative path?&lt;/strong&gt;&lt;/h3&gt;
  &lt;p id=&quot;niBe&quot;&gt;&lt;strong&gt;Absolute path&lt;/strong&gt; is the full path of the directory. It always starts with “/” .&lt;/p&gt;
  &lt;p id=&quot;4rqR&quot;&gt;Example:&lt;/p&gt;
  &lt;pre id=&quot;VVyl&quot;&gt;cd  /var/tmp/abrt/&lt;/pre&gt;
  &lt;p id=&quot;oiXH&quot;&gt;&lt;strong&gt;Relative path&lt;/strong&gt; is necessary from current location to reach particular directory doesn’t start with “/”.&lt;/p&gt;
  &lt;p id=&quot;E2d1&quot;&gt;Example:&lt;/p&gt;
  &lt;pre id=&quot;H5Wm&quot;&gt;cd .. ,   cd –&lt;/pre&gt;
  &lt;p id=&quot;6rWI&quot;&gt;&lt;/p&gt;
  &lt;h3 id=&quot;11-how-will-you-pass-and-access-arguments-to-a-script-in-linux&quot;&gt;&lt;strong&gt;How will you pass and access arguments to a script in Linux?&lt;/strong&gt;&lt;/h3&gt;
  &lt;p id=&quot;MypE&quot;&gt;For pass arguments in script &lt;strong&gt;“scriptname arg1 arg2 arg3 …” &lt;/strong&gt;&lt;/p&gt;
  &lt;p id=&quot;oeqC&quot;&gt;For access arguments in script can be accessed inside the script as &lt;strong&gt;“$1 , $2 .. $n”&lt;/strong&gt;&lt;/p&gt;
  &lt;p id=&quot;BUFg&quot;&gt;&lt;a href=&quot;https://www.mygreatlearning.com/blog/shell-scripting-interview-questions/&quot; target=&quot;_blank&quot;&gt;https://www.mygreatlearning.com/blog/shell-scripting-interview-questions/&lt;/a&gt;&lt;/p&gt;
  &lt;h3 id=&quot;5-how-to-create-multiple-text-files-and-directories&quot;&gt;&lt;strong&gt;How to create multiple text files and directories?&lt;/strong&gt;&lt;/h3&gt;
  &lt;p id=&quot;UVFK&quot;&gt;To create multiple text file touch file name {} command is used.&lt;/p&gt;
  &lt;p id=&quot;gOe2&quot;&gt;Example:&lt;/p&gt;
  &lt;p id=&quot;sevp&quot;&gt;Suppose we want create 4 files then we type:&lt;/p&gt;
  &lt;pre id=&quot;fjxy&quot;&gt;#touch filename{1..4}&lt;/pre&gt;
  &lt;p id=&quot;YJMe&quot;&gt;To create multiple directory mkdir filename {} command is used.&lt;/p&gt;
  &lt;p id=&quot;Oxkn&quot;&gt;Example:&lt;/p&gt;
  &lt;p id=&quot;HfXG&quot;&gt;Suppose we want to create 4 directory, then we type:&lt;/p&gt;
  &lt;pre id=&quot;c30f&quot;&gt;mkdir filename {1..4}&lt;/pre&gt;
  &lt;p id=&quot;tAgE&quot;&gt;&lt;/p&gt;
  &lt;h3 id=&quot;ydsv&quot;&gt;What are file permissions in Linux? Name different types of file systems in Linux.&lt;/h3&gt;
  &lt;p id=&quot;NoDk&quot;&gt;There are three owners in the Linux System i.e., user, group, and others. These owners have three types of permissions defined as listed below:&lt;/p&gt;
  &lt;ul id=&quot;dVvF&quot;&gt;
    &lt;li id=&quot;nwgP&quot;&gt;&lt;strong&gt;Read (r):&lt;/strong&gt; It allows the user to open and read the file or list the directory.&lt;/li&gt;
    &lt;li id=&quot;W1E5&quot;&gt;&lt;strong&gt;Write (w):&lt;/strong&gt; It allows the user to open and modify the file. One can also add new files to the directory.&lt;/li&gt;
    &lt;li id=&quot;c3XJ&quot;&gt;&lt;strong&gt;Execute (x):&lt;/strong&gt; It allows the user to execute or run the file. One can also lookup a specific file within a directory.&lt;/li&gt;
  &lt;/ul&gt;
  &lt;p id=&quot;jlT4&quot;&gt;&lt;/p&gt;
  &lt;h3 id=&quot;PVtW&quot;&gt;What is LVM and why is it required?&lt;/h3&gt;
  &lt;p id=&quot;PT2z&quot;&gt;LVM (Logical Volume Management) is basically a tool that provides logical volume management for the Linux kernel. It is being introduced simply to make physical storage device management easier. It also includes allocating disks, striping, mirroring, resizing logical volumes. Its main advantages are increased abstraction, flexibility, and control. It simply allows for flexible disk space management. It is especially required to resize the size of the file system online. In Linux, the size of the LVM partition can be extended using “lvextend” command and can be reduced using “lvreduce” commands, respectively.&lt;/p&gt;
  &lt;figure id=&quot;wmEP&quot; class=&quot;m_column&quot;&gt;
    &lt;img src=&quot;https://s3.ap-south-1.amazonaws.com/myinterviewtrainer-domestic/public_assets/assets/000/000/315/original/LVM-1.png?1618837155&quot; width=&quot;5692&quot; /&gt;
  &lt;/figure&gt;
  &lt;p id=&quot;ZWU9&quot;&gt;&lt;/p&gt;
  &lt;h3 id=&quot;41Os&quot;&gt;&lt;/h3&gt;
  &lt;p id=&quot;5tTC&quot;&gt;&lt;/p&gt;
  &lt;h3 id=&quot;SmF7&quot;&gt;What do you mean by the daemons?&lt;/h3&gt;
  &lt;p id=&quot;o0x4&quot;&gt;Daemons also referred to as the background process, is a long-running Linux program that runs in the background. They do not have any controlling terminal, therefore, they run in the background. These are the processes that are generally started when the system is bootstrapped and terminate or end only when the system is shut down. It is simply the way of extending the functionality of the base OS. It provides and offers several functions that are not available in OS. Its main purpose is to handle periodic requests and then forward the requests to the appropriate programs for execution&lt;/p&gt;
  &lt;p id=&quot;WGbY&quot;&gt;&lt;/p&gt;
  &lt;h3 id=&quot;PWzs&quot;&gt;Name the first process that is started by the kernel in Linux and what is its process id?&lt;/h3&gt;
  &lt;p id=&quot;xpEw&quot;&gt;The first process started by the kernel in Linux is “init” and its process id is 1&lt;/p&gt;
  &lt;p id=&quot;iPY3&quot;&gt;&lt;/p&gt;
  &lt;p id=&quot;O5V0&quot;&gt;&lt;/p&gt;
  &lt;p id=&quot;5KS2&quot;&gt;&lt;/p&gt;
  &lt;h2 id=&quot;f7sb&quot;&gt;Linux. Networking&lt;/h2&gt;
  &lt;section&gt;
    &lt;h3 id=&quot;Cz3C&quot;&gt;26. Why /etc/resolv.conf and /etc/hosts files are used?&lt;/h3&gt;
    &lt;p id=&quot;XbAa&quot;&gt;&lt;strong&gt;/etc/resolv.conf:&lt;/strong&gt; It is used to configure DNS name servers as it contains the details of the nameserver i.e., details of your DNS server. The DNS server is then used to resolve the hostname of the IP address. &lt;/p&gt;
    &lt;p id=&quot;DZ3L&quot;&gt;&lt;strong&gt;/etc/hosts:&lt;/strong&gt; It is used to map or translate any hostname or domain name to its relevant IP address.&lt;/p&gt;
  &lt;/section&gt;
  &lt;section&gt;
    &lt;h3 id=&quot;jSNJ&quot;&gt;27. What are the advantages of using NIC teaming?&lt;/h3&gt;
    &lt;p id=&quot;h5up&quot;&gt;NIC (Network Interface Card) teaming has several advantages as given below:&lt;/p&gt;
    &lt;ul id=&quot;Jg8P&quot;&gt;
      &lt;li id=&quot;I9QM&quot;&gt;Load Balancing&lt;/li&gt;
      &lt;li id=&quot;hTGc&quot;&gt;Failover&lt;/li&gt;
      &lt;li id=&quot;gmlF&quot;&gt;Increases uptime&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/section&gt;
  &lt;section&gt;
    &lt;h3 id=&quot;fYCT&quot;&gt;28. What do you mean by Network bonding?&lt;/h3&gt;
    &lt;p id=&quot;fQ8o&quot;&gt;Network Bonding, also known as NIC Teaming, is a type of bonding that is used to connect multiple network interfaces into a single interface. It usually improves performance and redundancy simply by increasing network throughput and bandwidth.&lt;/p&gt;
  &lt;/section&gt;
  &lt;section&gt;
    &lt;h3 id=&quot;60Jw&quot;&gt;29. What are different network bonding modes used in Linux?&lt;/h3&gt;
    &lt;p id=&quot;bpY7&quot;&gt;Different network bonding modes used in Linux are listed below:&lt;/p&gt;
    &lt;ul id=&quot;MbfP&quot;&gt;
      &lt;li id=&quot;3Vd5&quot;&gt;&lt;strong&gt;Mode-0 (balance-rr):&lt;/strong&gt; It is the default mode and is based on round-robin policy. It offers features like fault tolerance and load balancing.&lt;/li&gt;
      &lt;li id=&quot;hMtS&quot;&gt;&lt;strong&gt;Mode-1 (active-backup):&lt;/strong&gt; It is based on an active-backup policy. In this, only one node responds or works at the time of failure of other nodes.&lt;/li&gt;
      &lt;li id=&quot;qxtq&quot;&gt;&lt;strong&gt;Mode-2 (balance-xor):&lt;/strong&gt; It sets an XOR (exclusive-or) mode for providing load balancing and fault tolerance.&lt;/li&gt;
      &lt;li id=&quot;Xfi7&quot;&gt;&lt;strong&gt;Mode-3 (broadcast):&lt;/strong&gt; It is based on broadcast policy. It sets a broadcast mode for providing fault tolerance and can be used only for specific purposes.&lt;/li&gt;
      &lt;li id=&quot;jKvt&quot;&gt;&lt;strong&gt;Mode-4 (802.3ad):&lt;/strong&gt; It is based on IEEE 802.3ad standard also known as Dynamic Link Aggregation mode. It sets an IEEE 802.3ad dynamic link aggregation mode and creates aggregation groups that share the same speed and duplex settings.&lt;/li&gt;
      &lt;li id=&quot;RJqb&quot;&gt;&lt;strong&gt;Mode-5 (balance-tlb):&lt;/strong&gt; It is also known as Adaptive TLB (Transmit Load Balancing). It sets TLB mode for fault tolerance and load balancing. In this mode, traffic will be loaded based on each slave of the network.&lt;/li&gt;
      &lt;li id=&quot;ykFx&quot;&gt;&lt;strong&gt;Mode-6 (balance-alb):&lt;/strong&gt; It is also known as Adaptive Load Balancing. It sets ALB mode for fault tolerance and load balancing. It doesn’t need any special switch support.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/section&gt;
  &lt;h3 id=&quot;sFzw&quot;&gt;Name default ports used for DNS, SMTP, FTP, SSH, DHCP and squid.&lt;/h3&gt;
  &lt;p id=&quot;yr1o&quot;&gt;Default ports used for various services are as follows:&lt;/p&gt;
  &lt;figure id=&quot;gMLx&quot; class=&quot;m_original&quot;&gt;
    &lt;img src=&quot;https://img3.teletype.in/files/2b/43/2b43e89b-93c8-4b80-a0f7-8156d6f1ee8d.png&quot; width=&quot;497&quot; /&gt;
  &lt;/figure&gt;
  &lt;p id=&quot;cP32&quot;&gt;&lt;/p&gt;
  &lt;h3 id=&quot;dwBI&quot;&gt;Name three standard streams in Linux.&lt;/h3&gt;
  &lt;p id=&quot;7MxG&quot;&gt;Standard streams are basically I/O (Input and Output) communication channels between a program and its environment in Linux. Input and output in the Linux environment are distributed across three standard streams. Three standard streams in Linux are as follows:&lt;/p&gt;
  &lt;figure id=&quot;Y5t6&quot; class=&quot;m_column&quot;&gt;
    &lt;img src=&quot;https://s3.ap-south-1.amazonaws.com/myinterviewtrainer-domestic/public_assets/assets/000/000/312/original/standard_streams_in_linux.png?1618833817&quot; width=&quot;5217&quot; /&gt;
  &lt;/figure&gt;
  &lt;ol id=&quot;Vu5z&quot;&gt;
    &lt;li id=&quot;1xnQ&quot;&gt;Standard Input (stdin)&lt;/li&gt;
    &lt;li id=&quot;bHAw&quot;&gt;Standard Output (stdout)&lt;/li&gt;
    &lt;li id=&quot;xCzy&quot;&gt;Standard Error (stderr)&lt;/li&gt;
  &lt;/ol&gt;
  &lt;p id=&quot;khjI&quot;&gt;&lt;/p&gt;
  &lt;h2 id=&quot;RD84&quot;&gt;Linux Commands&lt;/h2&gt;
  &lt;section&gt;
    &lt;h3 id=&quot;q25R&quot;&gt;34. What is netstat command?&lt;/h3&gt;
    &lt;p id=&quot;tCTs&quot;&gt;netstat (Network statics) command is generally a networking tool being used for troubleshooting and configuration and used to display all network connections on a system. It simply provides a way to check whether various aspects of TCP/IP are working and what connections are present.&lt;/p&gt;
  &lt;/section&gt;
  &lt;section&gt;
    &lt;h3 id=&quot;6jXi&quot;&gt;35. What is the ping command?&lt;/h3&gt;
    &lt;p id=&quot;CWAL&quot;&gt;Linux ping (Packet Internet Groper) command is a command that is used to check connection status between source and destination. In simple words, this command is used to check whether a network is available and if the host is reachable. It can also be used to troubleshoot different connectivity issues, verify connectivity at an IP -level to a second TCP/IP device, and name resolution. One can use this command to test both the computer name and IP address of the computer.&lt;/p&gt;
  &lt;/section&gt;
  &lt;section&gt;
    &lt;h3 id=&quot;TstN&quot;&gt;36. Which command is used to check the default run level?&lt;/h3&gt;
    &lt;p id=&quot;BWGu&quot;&gt;The command used to check the default run level is “/etc/inittab”.&lt;/p&gt;
  &lt;/section&gt;
  &lt;section&gt;
    &lt;h3 id=&quot;WWds&quot;&gt;37. Which command is used to check the size of file or directory?&lt;/h3&gt;
    &lt;p id=&quot;h4iM&quot;&gt;The command used to check the size of the file or directory is “du”. Here “du” stands for disk usage that is used to check information of disk usage of files and directories on a machine. It is also used to display files and directory sizes in a recursive manner. &lt;/p&gt;
    &lt;p id=&quot;C7n4&quot;&gt;&lt;strong&gt;Example: &lt;/strong&gt;&lt;br /&gt;$ du -sh /var/log/*&lt;br /&gt;1.8M /var/log/anaconda&lt;br /&gt;384K /var/log/audit&lt;br /&gt;4.0K /var/log/boot.log&lt;br /&gt;0 /var/log/chrony&lt;br /&gt;4.0K /var/log/cron&lt;br /&gt;4.0K /var/log/maillog&lt;br /&gt;64K /var/log/messages&lt;/p&gt;
  &lt;/section&gt;
  &lt;section&gt;
    &lt;h3 id=&quot;YIMP&quot;&gt;38. Which command is used to count the number of characters in a file?&lt;/h3&gt;
    &lt;p id=&quot;2vvU&quot;&gt;The command that is used to count the number of characters in a file in Linux is “wc”. Here “wc” stands for word count. It is used to count the number of lines, words, and characters in a text file.&lt;/p&gt;
  &lt;/section&gt;
  &lt;section&gt;
    &lt;h3 id=&quot;OBQq&quot;&gt;39. What is the function of grep command?&lt;/h3&gt;
    &lt;p id=&quot;q5ni&quot;&gt;Grep (Global regular expression print) is a command that is used to the global search for a string of characters in a specified file. The text search pattern is generally known as a regular expression. It simply makes use of pattern-based searching. &lt;/p&gt;
    &lt;p id=&quot;PFcu&quot;&gt;&lt;strong&gt;Syntax: &lt;/strong&gt;grep [options] pattern [files] &lt;br /&gt;&lt;strong&gt;Example:&lt;/strong&gt; $ grep -c &amp;quot;linux&amp;quot; interview.txt &lt;/p&gt;
    &lt;p id=&quot;ZY3X&quot;&gt;The above command will usually print the total count of the word “Linux” in the file “interview.txt”.&lt;/p&gt;
  &lt;/section&gt;
  &lt;section&gt;
    &lt;h3 id=&quot;qPBk&quot;&gt;40. Explain working of env command.&lt;/h3&gt;
    &lt;p id=&quot;o255&quot;&gt;“env” command is basically a shell command that is used to print a list of current environmental variables. Here, “env” stands for the environment. It can also run another process in another environment without any modification of the current environment. It allows you to run programs in a modified environment. It is generally used by shell scripts to launch the correct interpreter. It can also be useful for checking if wrong environment variables prevent the application from starting during troubleshooting. &lt;/p&gt;
    &lt;p id=&quot;2Ucg&quot;&gt;&lt;strong&gt;Example: &lt;/strong&gt;&lt;/p&gt;
    &lt;p id=&quot;ks8Q&quot;&gt;$env&lt;br /&gt;PHYTHON_PIP_VERSION=9.0L1&lt;br /&gt;HOME=/root&lt;br /&gt;DB_NAME=test&lt;br /&gt;PATH=/usr/local/bin:/usr/local/sbin&lt;br /&gt;LAND=C.UTF=8&lt;br /&gt;PYTHON_VERSION=3.4.6&lt;br /&gt;PWD=/&lt;br /&gt;DB_URI=mongodb://database:27017/test&lt;/p&gt;
  &lt;/section&gt;
  &lt;section&gt;
    &lt;h3 id=&quot;bWze&quot;&gt;41. What is the pwd command?&lt;/h3&gt;
    &lt;p id=&quot;L6sl&quot;&gt;“pwd” command is basically a command that is used to print the complete path of the current working directory starting from the root (/). Here, “pwd” stands for Print Working Directory. It is considered one of the most basic and most used commands in Linux. This command is usually a built-in shell command and is also available in different shells such as bash, ksh, zsh, bourne shell, etc.&lt;/p&gt;
  &lt;/section&gt;
  &lt;section&gt;
    &lt;h3 id=&quot;XNF0&quot;&gt;42. Name the command that is used to check all the listening ports and services of your machine.&lt;/h3&gt;
    &lt;p id=&quot;JZRa&quot;&gt;# netstat -ntlp&lt;/p&gt;
  &lt;/section&gt;
  &lt;section&gt;
    &lt;h3 id=&quot;rWqX&quot;&gt;43. Which command is used to check the memory status?&lt;/h3&gt;
    &lt;p id=&quot;n0Wz&quot;&gt;The command used mostly to check memory status in Linux is “free”. Other commands that can be used are given below:&lt;/p&gt;
    &lt;ul id=&quot;EbS7&quot;&gt;
      &lt;li id=&quot;fjPR&quot;&gt;&lt;strong&gt;“cat” command:&lt;/strong&gt; It can be used to show or display Linux memory information. (cat/proc/meminfo)&lt;/li&gt;
      &lt;li id=&quot;VI7n&quot;&gt;&lt;strong&gt;“vmstat” command:&lt;/strong&gt; It can be used to report statistics of virtual memory.&lt;/li&gt;
      &lt;li id=&quot;GRLs&quot;&gt;&lt;strong&gt;“top” command:&lt;/strong&gt; It can be used to check the usage of memory.&lt;/li&gt;
      &lt;li id=&quot;zAHF&quot;&gt;&lt;strong&gt;“htop” command:&lt;/strong&gt; It can be used to find the memory load of each process.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/section&gt;
  &lt;section&gt;
    &lt;h3 id=&quot;HBVu&quot;&gt;44. What is pipe?&lt;/h3&gt;
    &lt;p id=&quot;WyRn&quot;&gt;In Linux, a pipe is basically a form of redirection that is used to send the output of one command to another command for further processing. It simply takes the output from one command and uses it as an input for another. It provides asynchronous execution of commands with help of buffered I/O routines.&lt;/p&gt;
  &lt;/section&gt;
  &lt;section&gt;
    &lt;h3 id=&quot;50mO&quot;&gt;45. What are Linux directory commands?&lt;/h3&gt;
    &lt;p id=&quot;xmTN&quot;&gt;There are basically five Linux directory commands that are used to work with files and directories as given below:&lt;/p&gt;
    &lt;ul id=&quot;JSxH&quot;&gt;
      &lt;li id=&quot;wSYl&quot;&gt;&lt;strong&gt;pwd: &lt;/strong&gt;It stands for “print working directory”. This command is generally used to display the path of the present or current working directory. &lt;br /&gt;&lt;strong&gt;&lt;u&gt;Syntax:&lt;/u&gt;&lt;/strong&gt; $ pwd&lt;/li&gt;
      &lt;li id=&quot;JNfY&quot;&gt;&lt;strong&gt;cd: &lt;/strong&gt;It stands for “change directory”. This command is generally used to change the present working directory to the directory that we want to work on. &lt;br /&gt;&lt;strong&gt;&lt;u&gt;Syntax:&lt;/u&gt;&lt;/strong&gt; $ cd &amp;lt;path to new directory&amp;gt;&lt;/li&gt;
      &lt;li id=&quot;9uZW&quot;&gt;&lt;strong&gt;Is: &lt;/strong&gt;It stands for “list”. This command is generally used to show the full list of content of files and directories in the present working directory. &lt;br /&gt;&lt;strong&gt;&lt;u&gt;Syntax:&lt;/u&gt;&lt;/strong&gt; $ ls&lt;/li&gt;
      &lt;li id=&quot;KUuT&quot;&gt;&lt;strong&gt;mkdir:&lt;/strong&gt; It stands for “make directory”. This command generally allows users to create directories in Linux. &lt;br /&gt;&lt;strong&gt;&lt;u&gt;Syntax:&lt;/u&gt;&lt;/strong&gt; $ mkdir &amp;lt;name (and path if required) of new directory&amp;gt;&lt;/li&gt;
      &lt;li id=&quot;Nm5Z&quot;&gt;&lt;strong&gt;rmdir:&lt;/strong&gt; It stands for “remove directory”. This command is used to remove/delete each directory that is specified on the command line. &lt;br /&gt;&lt;strong&gt;&lt;u&gt;Syntax:&lt;/u&gt;&lt;/strong&gt; $ rmdir &amp;lt;name (and path if required) of directory&amp;gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/section&gt;
  &lt;section&gt;
    &lt;h3 id=&quot;O7fM&quot;&gt;46. What do you mean by unmask?&lt;/h3&gt;
    &lt;p id=&quot;PmIv&quot;&gt;Umask, also known as user file-creation mask, is a Linux command that allows you to set up default permissions for new files and folders that you create. In Linux OS, umask command is used to set default file and folder permission. It is also used by other commands in Linux like mkdir, tee, touch, etc. that create files and directories. &lt;/p&gt;
    &lt;p id=&quot;hSji&quot;&gt;Syntax: &lt;code&gt;umask [-p] [-S] [mask]&lt;/code&gt;&lt;/p&gt;
    &lt;p id=&quot;RSMS&quot;&gt;Where, &lt;br /&gt;[mask]: It represents the permission masks that you are applying. &lt;br /&gt;[-S]: It displays the current mask as a symbolic value. &lt;br /&gt;[-p]: It displays the current mask along with umask command thus allowing it to be copied and pasted as a future input.&lt;/p&gt;
  &lt;/section&gt;
  &lt;section&gt;
    &lt;h3 id=&quot;Osqa&quot;&gt;47. Name the command used to review boot messages.&lt;/h3&gt;
    &lt;p id=&quot;pTRQ&quot;&gt;The command that is used to review boot messages is the “dmesg” command.&lt;/p&gt;
  &lt;/section&gt;
  &lt;p id=&quot;be5b&quot;&gt;&lt;/p&gt;
  &lt;h3 id=&quot;SPzl&quot;&gt;How to Run Multiple Commands in Single Command?&lt;/h3&gt;
  &lt;p id=&quot;yy2i&quot;&gt;To run multiple commands one after the other in a single command, you can use either the semi-colon &lt;code&gt;&amp;#x27;;&amp;#x27;&lt;/code&gt;, double ampersand &lt;code&gt;&amp;#x27;&amp;amp;&amp;amp;&amp;#x27;&lt;/code&gt;, or &lt;code&gt;&amp;#x27;||&amp;#x27;&lt;/code&gt; symbols.&lt;/p&gt;
  &lt;ul id=&quot;Jt0G&quot;&gt;
    &lt;li id=&quot;8KNz&quot;&gt;&lt;strong&gt;X Y&lt;/strong&gt; – This runs commands X and Y regardless of the success of X.&lt;/li&gt;
    &lt;li id=&quot;P20p&quot;&gt;&lt;strong&gt;X &amp;amp;&amp;amp; Y&lt;/strong&gt; – This runs Y if and only if X runs successfully.&lt;/li&gt;
    &lt;li id=&quot;w3lt&quot;&gt;&lt;strong&gt;X || Y&lt;/strong&gt; – This runs Y if and only if X failed.&lt;/li&gt;
  &lt;/ul&gt;
  &lt;figure id=&quot;OobC&quot; class=&quot;m_column&quot;&gt;
    &lt;img src=&quot;https://www.tecmint.com/wp-content/uploads/2022/12/Run-Multiple-Linux-Commands.png&quot; width=&quot;977&quot; /&gt;
    &lt;figcaption&gt;Run Multiple Linux Commands&lt;/figcaption&gt;
  &lt;/figure&gt;
  &lt;p id=&quot;Mmqy&quot;&gt;&lt;/p&gt;
  &lt;h3 id=&quot;GmPb&quot;&gt;What is the Grep Command?&lt;/h3&gt;
  &lt;p id=&quot;gCuW&quot;&gt;&lt;a href=&quot;https://www.tecmint.com/12-practical-examples-of-linux-grep-command/&quot; target=&quot;_blank&quot;&gt;Grep&lt;/a&gt; is a command line tool for searching and matching text files or lines in a text file. It takes options and parameters which are used to manipulate or enhance the search output.&lt;/p&gt;
  &lt;p id=&quot;DdgD&quot;&gt;It takes the following syntax:&lt;/p&gt;
  &lt;pre id=&quot;mp2N&quot;&gt;$ grep [options] pattern [files]
&lt;/pre&gt;
  &lt;p id=&quot;VEeG&quot;&gt;The following command counts the number of occurrences of the string ‘&lt;strong&gt;Unix&lt;/strong&gt;‘ in &lt;strong&gt;file1.txt&lt;/strong&gt;.&lt;/p&gt;
  &lt;pre id=&quot;BGgr&quot;&gt;$ grep -c &amp;quot;Unix&amp;quot; file1.txt&lt;/pre&gt;
  &lt;p id=&quot;MWMD&quot;&gt;&lt;/p&gt;
  &lt;h3 id=&quot;dsPw&quot;&gt;How do Change the Permissions of a File or Directory?&lt;/h3&gt;
  &lt;p id=&quot;czKM&quot;&gt;The &lt;strong&gt;chmod command&lt;/strong&gt; is the command that modifies the permissions of a file or directory.&lt;/p&gt;
  &lt;p id=&quot;RUm4&quot;&gt;It follows the syntax shown.&lt;/p&gt;
  &lt;pre id=&quot;fbEg&quot;&gt;# chmod [OPTIONS] [permissions] file&lt;/pre&gt;
  &lt;p id=&quot;F1ai&quot;&gt;For example. To assign octal permissions &lt;strong&gt;755&lt;/strong&gt; (all permissions to the owner and read and write permissions only for the group members and everyone else) to a file called &lt;strong&gt;file1.txt&lt;/strong&gt;, run the command.&lt;/p&gt;
  &lt;pre id=&quot;YCoH&quot;&gt;# chmod 755 file1.txt&lt;/pre&gt;
  &lt;p id=&quot;r7IQ&quot;&gt;&lt;/p&gt;
  &lt;p id=&quot;QHgQ&quot;&gt;&lt;/p&gt;
  &lt;h3 id=&quot;c7Ad&quot;&gt;&lt;/h3&gt;
  &lt;h3 id=&quot;1MMo&quot;&gt;What are Hidden Files in Linux?&lt;/h3&gt;
  &lt;p id=&quot;p4jw&quot;&gt;&lt;strong&gt;Hidden&lt;/strong&gt; files are files that are preceded by a dot or period. They mostly contain configuration files that hold important data or settings. To view hidden files, use the &lt;a href=&quot;https://www.tecmint.com/15-basic-ls-command-examples-in-linux/&quot; target=&quot;_blank&quot;&gt;ls command&lt;/a&gt; with the &lt;code&gt;-la&lt;/code&gt; option.&lt;/p&gt;
  &lt;pre id=&quot;UP1a&quot;&gt;$ ls -la&lt;/pre&gt;
  &lt;figure id=&quot;6gNA&quot; class=&quot;m_custom&quot;&gt;
    &lt;img src=&quot;https://www.tecmint.com/wp-content/uploads/2022/12/List-Hidden-Files-in-Linux.png&quot; width=&quot;664&quot; /&gt;
    &lt;figcaption&gt;List Hidden Files in Linux&lt;/figcaption&gt;
  &lt;/figure&gt;
  &lt;p id=&quot;VT9y&quot;&gt;&lt;/p&gt;
  &lt;h3 id=&quot;3xOZ&quot;&gt;What is an Alias?&lt;/h3&gt;
  &lt;p id=&quot;tDgx&quot;&gt;As the name suggests, &lt;a href=&quot;https://www.tecmint.com/create-and-use-bash-aliases-in-linux/&quot; target=&quot;_blank&quot;&gt;aliases&lt;/a&gt; are like custom shortcuts used to represent a command (or set of commands) executed with or without custom options.&lt;/p&gt;
  &lt;pre id=&quot;PH4P&quot;&gt;$ alias
&lt;/pre&gt;
  &lt;figure id=&quot;Ypuu&quot; class=&quot;m_column&quot;&gt;
    &lt;img src=&quot;https://www.tecmint.com/wp-content/uploads/2022/12/Linux-Aliases.png&quot; width=&quot;739&quot; /&gt;
    &lt;figcaption&gt;List Linux Aliases&lt;/figcaption&gt;
  &lt;/figure&gt;
  &lt;p id=&quot;KcBb&quot;&gt;&lt;/p&gt;
  &lt;h3 id=&quot;QaRG&quot;&gt;What are the Different Vim Modes?&lt;/h3&gt;
  &lt;p id=&quot;XfmS&quot;&gt;The &lt;a href=&quot;https://www.tecmint.com/vi-editor-usage/&quot; target=&quot;_blank&quot;&gt;vim editor&lt;/a&gt; provides the following main modes:&lt;/p&gt;
  &lt;ul id=&quot;P6H6&quot;&gt;
    &lt;li id=&quot;D6o7&quot;&gt;&lt;strong&gt;Normal mode / Command mode&lt;/strong&gt; – This is the default mode when you open a new file or an existing one. In this mode, you can run commands such as undo, redo, and paste.&lt;/li&gt;
    &lt;li id=&quot;lZBL&quot;&gt;&lt;strong&gt;Insert mode&lt;/strong&gt; – This mode allows you to type in the text.&lt;/li&gt;
    &lt;li id=&quot;0Pnr&quot;&gt;&lt;strong&gt;Visual mode&lt;/strong&gt; – This mode lets you select text so that you can perform other tasks with it such as cop, cut or paste.&lt;/li&gt;
  &lt;/ul&gt;
  &lt;p id=&quot;Fbtx&quot;&gt;&lt;/p&gt;
  &lt;h3 id=&quot;1A2k&quot;&gt;What is the Redirection Operator?&lt;/h3&gt;
  &lt;p id=&quot;SO2Y&quot;&gt;&lt;strong&gt;Redirection&lt;/strong&gt; is the process of sending the output of the first command to another file. In addition, it’s also used to direct an output as an input to another process.&lt;/p&gt;
  &lt;p id=&quot;i5FG&quot;&gt;In Linux, redirection is achieved using either the &lt;code&gt;&amp;quot;&amp;gt;&amp;quot;&lt;/code&gt; (greater-than symbol) or the &lt;code&gt;&amp;quot;|&amp;quot;&lt;/code&gt; (pipe) operator which sends the standard output of one command to another command as standard input.&lt;/p&gt;
  &lt;p id=&quot;qAqR&quot;&gt;&lt;/p&gt;
  &lt;figure id=&quot;Kauh&quot; class=&quot;m_custom&quot;&gt;
    &lt;img src=&quot;https://hackr.io/blog/uploads/images/1570190913MSgT8YbbVl.jpg&quot; width=&quot;370&quot; /&gt;
  &lt;/figure&gt;
  &lt;p id=&quot;hn5Z&quot;&gt;&lt;/p&gt;
  &lt;h4 id=&quot;question-what-command-would-you-use-for-editing-searching-and-replacing-text-in-linux&quot;&gt;&lt;strong&gt;What command would you use for editing, searching, and replacing text in Linux?&lt;/strong&gt;&lt;/h4&gt;
  &lt;p id=&quot;cFCG&quot;&gt;&lt;strong&gt;Answer&lt;/strong&gt;:&lt;/p&gt;
  &lt;p id=&quot;UvWE&quot;&gt;&lt;strong&gt;Editing:&lt;/strong&gt;&lt;/p&gt;
  &lt;p id=&quot;x9ET&quot;&gt;You can use the cd command followed by the name of the text editor, like vi, with which you need to edit the file.&lt;/p&gt;
  &lt;p id=&quot;oomN&quot;&gt;&lt;strong&gt;Searching:&lt;/strong&gt;&lt;/p&gt;
  &lt;p id=&quot;jtwW&quot;&gt;You can search a file in Linux by using the command:&lt;/p&gt;
  &lt;pre id=&quot;FHXK&quot;&gt;find –iname “filename”&lt;/pre&gt;
  &lt;p id=&quot;4CuJ&quot;&gt;For searching and printing text in a file in Linux, you can use the command grep.&lt;/p&gt;
  &lt;p id=&quot;xucA&quot;&gt;&lt;strong&gt;Replacing:&lt;/strong&gt;&lt;/p&gt;
  &lt;p id=&quot;XW6y&quot;&gt;This procedure involves using the Stream Editor (sed). You need to use the command:&lt;/p&gt;
  &lt;pre id=&quot;IYr9&quot;&gt;sed -i &amp;#x27;s/old-text/new-text/g&amp;#x27; input.txt&lt;/pre&gt;
  &lt;p id=&quot;7wxA&quot;&gt;Enter the text that needs to be replaced in place of the old-text and the new text that needs to be added in place of the new-text.&lt;/p&gt;
  &lt;p id=&quot;eyzH&quot;&gt;&lt;/p&gt;
  &lt;p id=&quot;qlcE&quot;&gt;&lt;strong&gt;How to reduce or shrink the size of the LVM partition?&lt;/strong&gt;&lt;/p&gt;
  &lt;p id=&quot;z2GD&quot;&gt;Follow these steps: &lt;br /&gt; unmount the file system for reducing.&lt;br /&gt; Check the file system after unmount.&lt;br /&gt; Reduce the file system.&lt;br /&gt; Reduce the Logical Volume size than Current size.&lt;br /&gt; Recheck the file system for error.&lt;br /&gt; Remount the file-system back to stage.&lt;/p&gt;
  &lt;p id=&quot;m2Ru&quot;&gt;&lt;/p&gt;
  &lt;p id=&quot;3qom&quot;&gt;&lt;strong&gt;What are the uses of head and tail commands?&lt;/strong&gt;&lt;/p&gt;
  &lt;p id=&quot;keOC&quot;&gt;&lt;strong&gt;Answer: &lt;/strong&gt;The head command is used for printing the first &lt;em&gt;n&lt;/em&gt; lines of a file onto the terminal:&lt;/p&gt;
  &lt;p id=&quot;IXCc&quot;&gt;head 7 test.txt&lt;/p&gt;
  &lt;p id=&quot;e6Uf&quot;&gt;By default (i.e., when you don’t specify a number), ten lines are printed.&lt;/p&gt;
  &lt;p id=&quot;r0EH&quot;&gt;The tail command prints the last &lt;em&gt;n &lt;/em&gt;lines of a file. By default, n is ten unless specified. We can specify more than one file, in which case the output is displayed along with the file name.&lt;/p&gt;
  &lt;p id=&quot;7WLZ&quot;&gt;tail 15 test.txt&lt;/p&gt;
  &lt;p id=&quot;A4vU&quot;&gt;&lt;/p&gt;
  &lt;h2 id=&quot;BQGA&quot;&gt;Linux.Networking&lt;/h2&gt;
  &lt;p id=&quot;PJgP&quot;&gt;&lt;strong&gt;How to check and verify the status of the bond interface?&lt;/strong&gt;&lt;/p&gt;
  &lt;p id=&quot;MMXa&quot;&gt;To check if bonding is enabled, check if the /etc/modprobe. conf has the bonding module loaded in it and then see if the ifcfg-bondZ, ifcfg-ethX and ifcfg-ethY etc. have the correct entries. To check if the bonding is working fine, check /var/log/messages. If you ever wanted to check the status of a bonded interface configure in Linux (esp RHEL), you can check the status by running the following command [root@serverxyz bin]# cat /proc/net/bonding/bond0. i.e. assuming the name of your bond interface is bond0.&lt;/p&gt;
  &lt;p id=&quot;QjI5&quot;&gt;&lt;/p&gt;
  &lt;p id=&quot;Uecd&quot;&gt;&lt;strong&gt;What are the different modes of Network Bonding in Linux?&lt;/strong&gt;&lt;/p&gt;
  &lt;p id=&quot;301s&quot;&gt;Linux network Bonding is a creation of a single bonded interface by combining 2 or more Ethernet interfaces. This helps in high availability of your network interface and offers performance improvements on your data traffic flow. Bonding is also referred as nic trunking or teaming.&lt;br /&gt; Different modes of bonding: &lt;br /&gt; Mode 0 (balance-rr) This mode transmits packets in a sequential order from the first available slave through the last&lt;br /&gt; Mode 1 (active-backup) &lt;br /&gt; Mode 2 (balance-xor) &lt;br /&gt; Mode 3 (broadcast) &lt;br /&gt; Mode 4 (802.3ad) &lt;br /&gt; Mode 5 (balance-tlb) &lt;br /&gt; Mode 6 (balance-alb)&lt;/p&gt;
  &lt;p id=&quot;nCzB&quot;&gt;&lt;/p&gt;
  &lt;p id=&quot;kLOy&quot;&gt;&lt;strong&gt;What will the following command do: $ grep “[^aeiou]” myfile&lt;/strong&gt;&lt;/p&gt;
  &lt;p id=&quot;y1LV&quot;&gt;&lt;strong&gt;Answer: &lt;/strong&gt;The command will match all lines that do not contain a vowel from the file ‘myfile’.&lt;/p&gt;
  &lt;p id=&quot;Dsio&quot;&gt;&lt;/p&gt;
  &lt;p id=&quot;s0pF&quot;&gt;&lt;strong&gt;Do you know how to make changes to a large file without opening it?&lt;/strong&gt;&lt;/p&gt;
  &lt;p id=&quot;DQ8h&quot;&gt;&lt;strong&gt;Answer: &lt;/strong&gt;For this, the sed command is used. For example, we want to replace the word ‘John’ with ‘Sam’. We can give the command as:&lt;/p&gt;
  &lt;p id=&quot;XNtG&quot;&gt;sed ‘s/John/Sam’ myfile.txt&lt;/p&gt;
  &lt;p id=&quot;8tKv&quot;&gt;&lt;strong&gt;44. What is the fork() system call? How is it different from vfork()&lt;/strong&gt;?&lt;/p&gt;
  &lt;p id=&quot;uneL&quot;&gt;&lt;strong&gt;Answer: &lt;/strong&gt;The fork() call creates a child process from an existing (parent) process. In the process, the kernel places a copy of the parent process’s address space into the child process. vfork() call is faster as it does not do the above.&lt;/p&gt;
  &lt;p id=&quot;jVLY&quot;&gt;&lt;strong&gt;45. Can you explain the page fault and kinds of page faults?.&lt;/strong&gt;&lt;/p&gt;
  &lt;p id=&quot;OgPX&quot;&gt;&lt;strong&gt;Answer: &lt;/strong&gt;It is a situation when a process tries to refer to a page. But the page is not there in the main memory. The two types are validity fault (whether the page is valid or not) and protection fault (whether it can be accessed).&lt;/p&gt;
  &lt;p id=&quot;26Y1&quot;&gt;&lt;strong&gt;Differentiate between the absolute and relative path.&lt;/strong&gt;&lt;/p&gt;
  &lt;p id=&quot;LVjI&quot;&gt;&lt;strong&gt;Answer: &lt;/strong&gt;The absolute path is the complete path of a file or directory starting from its root directory. For example, /users/local/system&lt;/p&gt;
  &lt;p id=&quot;tFgf&quot;&gt;A relative path is the path from the current user directory and is not the complete path. It is the present working directory (PWD).&lt;/p&gt;
  &lt;p id=&quot;f5E7&quot;&gt;&lt;/p&gt;
  &lt;h2 id=&quot;RxhG&quot;&gt;Linux.Security&lt;/h2&gt;
  &lt;h4 id=&quot;question-please-explain-the-checking-for-rootkit-infections-in-linux&quot;&gt;&lt;strong&gt;Please explain the checking for Rootkit infections in Linux.&lt;/strong&gt;&lt;/h4&gt;
  &lt;p id=&quot;TQ4K&quot;&gt;&lt;strong&gt;Answer&lt;/strong&gt;: A Rootkit is an advanced form of malware that can yield a range of security issues and in many cases go undetected by average antivirus programs. Hence, advanced anti-spyware tools need to be used for checking Rootkit infections in Linux. One such is the &lt;a href=&quot;https://en.wikipedia.org/wiki/Rkhunter&quot; target=&quot;_blank&quot;&gt;rkhunter&lt;/a&gt;.&lt;/p&gt;
  &lt;p id=&quot;ubzI&quot;&gt;Rkhunter can be installed from the software repository by following the instructions of your distribution’s package management. Debian and Ubuntu users can use the (sudo) apt-get install rkhunter command while Red Hat-based distributions can use either the dnf or yum command.&lt;/p&gt;
  &lt;p id=&quot;TwdH&quot;&gt;A few other notable security tools available for checking rootkit infections in Linux are:&lt;/p&gt;
  &lt;ul id=&quot;QYrG&quot;&gt;
    &lt;li id=&quot;ZKUK&quot;&gt;Chkrootkit&lt;/li&gt;
    &lt;li id=&quot;EDnm&quot;&gt;ClamAV&lt;/li&gt;
    &lt;li id=&quot;hMc3&quot;&gt;LMD (Linux Malware Detect)&lt;/li&gt;
    &lt;li id=&quot;09WR&quot;&gt;Lynis&lt;/li&gt;
  &lt;/ul&gt;
  &lt;h4 id=&quot;question-how-will-you-setup-password-aging-in-linux&quot;&gt;&lt;strong&gt;How will you setup Password Aging in Linux?&lt;/strong&gt;&lt;/h4&gt;
  &lt;p id=&quot;KNZP&quot;&gt;&lt;strong&gt;Answer&lt;/strong&gt;: The chage command allows the system administrators in Linux to enforce password aging. The command is used to change the number of days between mandatory password resets. The /etc/login.defs file is responsible for handling system-wide configuration. It can be edited for:&lt;/p&gt;
  &lt;ul id=&quot;5SVh&quot;&gt;
    &lt;li id=&quot;dCpr&quot;&gt;PASS_MAX_DAYS – Defines the maximum number of days a password may be used.&lt;/li&gt;
    &lt;li id=&quot;CMlK&quot;&gt;PASS_MIN_DAYS – Defines the minimum number of days allowed between password changes.&lt;/li&gt;
    &lt;li id=&quot;dwQL&quot;&gt;PASS_WARN_AGE – Defines the number of days warning is given before a password expires.&lt;/li&gt;
  &lt;/ul&gt;
  &lt;h4 id=&quot;question-how-does-ctrl-alt-del-key-combination-work-in-linux&quot;&gt;&lt;strong&gt;How does Ctrl+Alt+Del key combination work in LINUX?&lt;/strong&gt;&lt;/h4&gt;
  &lt;p id=&quot;1SJu&quot;&gt;&lt;strong&gt;Answer: &lt;/strong&gt;The Ctrl+Alt+Del key combination works in LINUX, just like it works in Windows. This key combination helps in restarting the system. However, in LINUX, there is no confirmation message displayed earlier to the restart, and the reboot occurs immediately.&lt;/p&gt;
  &lt;p id=&quot;hHjA&quot;&gt;&lt;/p&gt;
  &lt;p id=&quot;Rq1P&quot;&gt;&lt;strong&gt;How does Ctrl+Alt+F1(F2) key combination work in LINUX?&lt;/strong&gt;&lt;/p&gt;
  &lt;p id=&quot;rUJk&quot;&gt;&lt;/p&gt;
  &lt;p id=&quot;IpYS&quot;&gt;&lt;strong&gt;How can you enhance the security of the password file in Linux?&lt;/strong&gt;&lt;/p&gt;
  &lt;p id=&quot;9nal&quot;&gt;Linux keeps user account information in a text file called /etc/passwd. This file also store one way encrypted password. This file is accessed by several tools to get user information, so file need to world-readable. This is a security risk. To minimize the security risk you can use shadow password format. This method save account information in regular file /etc/passwd. However, the password is stored as a single &amp;quot;x&amp;quot; character (not actually stored in this file). A second file, called &amp;quot;/etc/shadow&amp;quot;, contains encrypted password as well as other information such as account or password expiration values, etc. ...&lt;/p&gt;
  &lt;p id=&quot;q4au&quot;&gt;&lt;/p&gt;
  &lt;h2 id=&quot;Ldid&quot;&gt;Which account is created on Linux installation?&lt;/h2&gt;
  &lt;p id=&quot;GWXQ&quot;&gt;- With the installation of Linux, a super user account is created called as ‘root’.&lt;/p&gt;
  &lt;h2 id=&quot;vyfV&quot;&gt;Which daemon tracks events on your system?&lt;/h2&gt;
  &lt;p id=&quot;NAeF&quot;&gt;- The syslogd daemon tracks the system information and saves it to specified log files.&lt;/p&gt;
  &lt;h2 id=&quot;EZxj&quot;&gt;Which command would you use if you want to remove the password assigned to a group?&lt;/h2&gt;
  &lt;p id=&quot;f4gB&quot;&gt;- gpasswd – r removes the password from the group. &lt;br /&gt;- Here, the gpasswd changes the password of the group and when it is accompanied by –r, the password gets removed.&lt;/p&gt;
  &lt;h2 id=&quot;lrcS&quot;&gt;You wish to print a file ‘draft’ with 60 lines to a page. What command would you use?&lt;/h2&gt;
  &lt;p id=&quot;v0AS&quot;&gt;- The command that I would use is: pr -l60 draft&lt;br /&gt;- The default page length when using pr is 66 lines. &lt;br /&gt;- The -l option specifies a different length.&lt;/p&gt;
  &lt;h2 id=&quot;yXro&quot;&gt;Which file would you examine to determine the levels of messages written to system log files?&lt;/h2&gt;
  &lt;p id=&quot;IINt&quot;&gt;- kernel.h&lt;/p&gt;
  &lt;h2 id=&quot;vISj&quot;&gt;You are logged on as a regular user. Without logging off and logging on as root, you are required to create a new user account immediately. How would you do it?&lt;/h2&gt;
  &lt;p id=&quot;6X62&quot;&gt;- This can be achieved by issuing the &lt;strong&gt;su&lt;/strong&gt; command. &lt;br /&gt;- This will prompt you for the password of the root account.&lt;br /&gt;- Providing the password, logs you in as root. Now, you can perform any administrative duties.&lt;/p&gt;
  &lt;h2 id=&quot;z9WT&quot;&gt;You are required to restore the file memo.ben. It was backed up in the tar file MyBackup.tar. Which command would you use to do it?&lt;/h2&gt;
  &lt;p id=&quot;7Tx3&quot;&gt;- The command that we would use is: tar xf MyBackup.tar memo.ben&lt;br /&gt;- It uses the x switch to extract a file.&lt;/p&gt;
  &lt;h2 id=&quot;ImxB&quot;&gt;What is partial backup?&lt;/h2&gt;
  &lt;p id=&quot;2gS3&quot;&gt;- When you select only a portion of your file hierarchy or a single partition to back up, it is called partial backup.&lt;/p&gt;
  &lt;h2 id=&quot;Pq8V&quot;&gt;What is the fastest way to enter a series of commands from the command-line?&lt;/h2&gt;
  &lt;p id=&quot;xRHZ&quot;&gt;- Write the commands, each separated by a semi-colon. Press enter after the last command. &lt;br /&gt;- The semi-colon would inform the shell that multiple commands are being entered at the command line, to be executed serially.&lt;/p&gt;
  &lt;h2 id=&quot;oSsl&quot;&gt;Which command is used to check the number of files and disk space used and the each user’s defined quota?&lt;/h2&gt;
  &lt;p id=&quot;GVvc&quot;&gt;&lt;strong&gt;repquota&lt;/strong&gt; command is used to check the status of the user’s quota along with the disk space and number of files used. &lt;/p&gt;
  &lt;p id=&quot;xEO6&quot;&gt;This command gives a summary of the user’s quota that how much space and files are left for the user. Every user has a defined quota in Linux. This is done mainly for the security, as some users have only limited access to files. This provides a security to the files from unwanted access. The quota can be given to a single user or to a group of users.&lt;/p&gt;
  &lt;h2 id=&quot;owkM&quot;&gt;&lt;/h2&gt;
  &lt;p id=&quot;6WXw&quot;&gt;&lt;/p&gt;
  &lt;h2 id=&quot;7A9e&quot;&gt;How secured is Linux? Explain.&lt;/h2&gt;
  &lt;p id=&quot;2Axp&quot;&gt;Security is the most important aspect of an operating system. Due to its unique authentication module, Linux is considered as more secured than other operating systems. Linux consists of PAM. PAM is Pluggable Authentication Modules. It provides a layer between applications and actual authentication mechanism. It is a library of loadable modules which are called by the application for authentication. It also allows the administrator to control when a user can log in. All PAM applications are configured in the directory &amp;quot;/etc/pam.d&amp;quot; or in a file &amp;quot;/etc/pam.conf&amp;quot;. PAM is controlled using the configuration file or the configuration directory.&lt;/p&gt;
  &lt;h2 id=&quot;Axcp&quot;&gt;Can Linux computer be made a router so that several machines may share a single Internet connection? How?&lt;/h2&gt;
  &lt;p id=&quot;Vbva&quot;&gt;Yes a Linux machine can be made a router. This is called &amp;quot;IP Masquerade.&amp;quot; IP Masquerade is a networking function in Linux similar to the one-to-many (1: Many) NAT (Network Address Translation) servers found in many commercial firewalls and network routers. The IP Masquerade feature allows other &amp;quot;internal&amp;quot; computers connected to this Linux box (via PPP, Ethernet, etc.) to also reach the Internet as well. Linux IP Masquerading allows this functionality even if the internal computers do not have IP addresses.&lt;br /&gt;The IP masquerading can be done by the following steps:&lt;/p&gt;
  &lt;p id=&quot;tO8K&quot;&gt;1. The Linux PC must have an internet connection and a connection to LAN. Typically, the Linux PC has two network interfaces-an Ethernet card for the LAN and a dial-up PPP connection to the Internet (through an ISP).&lt;/p&gt;
  &lt;p id=&quot;W48b&quot;&gt;2. All other systems on your LAN use the Linux PC as the default gateway for TCP/IP networking. Use the same ISP-provided DNS addresses on all systems.&lt;/p&gt;
  &lt;p id=&quot;a76P&quot;&gt;3. Enable IP forwarding in the kernel. By default the IP forwarding is not enabled. To ensure that IP forwarding is enabled when you reboot your system, place this command in the /etc/rc.d/rc.local file.&lt;/p&gt;
  &lt;p id=&quot;tKBq&quot;&gt;4. Run /sbin/iptables-the IP packet filter administration program-to set up the rules that enable the Linux PC to masquerade for your LAN.&lt;/p&gt;
  &lt;h2 id=&quot;5ns3&quot;&gt;What is the minimum number of partitions that you need to install Linux?&lt;/h2&gt;
  &lt;p id=&quot;CDdK&quot;&gt;Minimum 2 partitions are needed for installing Linux. The one is &amp;quot;/ or root&amp;quot; which contains all the files and the other is swap. Linux file system is function specific which means that files and folders are organized according to their functionality. For example, all executables are in one folder, all devices in another, all libraries in another and so on. &amp;quot;/ or root&amp;quot; is the base of this file system. All the other folders are under this one. &amp;quot;/&amp;quot; can be consider as &amp;quot;C:&amp;quot;. Swap is a partition that will be used as virtual memory. If there is no more available RAM a Linux computer will use an area of the hard disk, called swap, to temporarily store data. In other words it is a way of expanding your computers RAM.&lt;/p&gt;
  &lt;h2 id=&quot;6DUQ&quot;&gt;Which command is used to review boot messages?&lt;/h2&gt;
  &lt;p id=&quot;CB9b&quot;&gt;dmesg command is used to review boot messages. This command will display system messages contained in the kernel ring buffer. We can use this command immediately after booting to see boot messages. A ring buffer is a buffer of fixed size for which any new data added to it overwrites the oldest data in it.&lt;/p&gt;
  &lt;p id=&quot;s4dg&quot;&gt;&lt;strong&gt;Its basic syntax is:&lt;/strong&gt;dmesg [options]&lt;/p&gt;
  &lt;p id=&quot;7mqp&quot;&gt;Invoking dmesg without any of its options causes it to write all the kernel messages to standard output. This usually produces far too many lines to fit into the display screen all at once and thus only the final messages are visible. However, the output can be redirected to the less command through the use of a pipe, thereby allowing the startup messages to be viewed on one screen at a time&lt;br /&gt;dmesg | less&lt;/p&gt;
  &lt;h2 id=&quot;uAWX&quot;&gt;Which utility is used to make automate rotation of a log?&lt;/h2&gt;
  &lt;p id=&quot;m6G6&quot;&gt;logrotate command is used to make automate rotation of log.&lt;/p&gt;
  &lt;p id=&quot;p3WI&quot;&gt;&lt;strong&gt;Syntax of the command is:&lt;/strong&gt;logrotate [-dv] [-f|] [-s|] config_file+&lt;/p&gt;
  &lt;p id=&quot;ANuh&quot;&gt;It allows automatic rotation, compression, removal, and mailing of log files. This command is mainly used for rotating and compressing log files. This job is done every day when a log file becomes too large. This command can also be run by giving on command line. We can done force rotation by giving –f option with this command in command line. This command is also used for mailing. We can give –m option for mailing with this command. This option takes two arguments one is subject and other is recipient name.&lt;/p&gt;
  &lt;p id=&quot;t1v1&quot;&gt;&lt;/p&gt;
  &lt;h2 id=&quot;fe2B&quot;&gt;Which commands are used to set a processor-intensive job to use less CPU time?&lt;/h2&gt;
  &lt;p id=&quot;I7eQ&quot;&gt;nice command is used for changing priority of the jobs.&lt;/p&gt;
  &lt;p id=&quot;re1v&quot;&gt;&lt;strong&gt;Syntax:&lt;/strong&gt;nice [OPTION] [COMMAND [ARG]...]&lt;/p&gt;
  &lt;p id=&quot;76Ry&quot;&gt;Range of priority goes from -20 (highest priority) to 19 (lowest). Priority is given to a job so that the most important job is executed first by the kernel and then the other least important jobs. This takes less CPU times as the jobs are scheduled and are given priorities so the CPU executes fast. The priority is given by numbers like -20 describe the highest priority and 19 describe the least priority.&lt;/p&gt;
  &lt;p id=&quot;HD41&quot;&gt;&lt;/p&gt;
  &lt;h2 id=&quot;z9ze&quot;&gt;Which daemon is responsible for tracking events on Linux system?&lt;/h2&gt;
  &lt;p id=&quot;EKPf&quot;&gt;syslogd is responsible for tracking system information and save it to the desired log files. It provides two system utilities which provide system logging and kernel message trapping. Internet and UNIX domain sockets support enable this utility package to support both local and remote logging. Every logged message contains at least a time and a hostname field, normally a program name field, too. So to track these information this daemon is used. &lt;/p&gt;
  &lt;p id=&quot;Us1h&quot;&gt;syslogd mainly reacts to the set of signals given by the user.&lt;/p&gt;
  &lt;p id=&quot;0XOa&quot;&gt;&lt;strong&gt;These are the signals given to syslogd:&lt;/strong&gt;&lt;/p&gt;
  &lt;p id=&quot;uC7X&quot;&gt;- SIGHUP: This lets syslogd perform a re-initialization. All open files are closed, the configuration file (default is /etc/syslog.conf) will be reread and the syslog facility is started again.&lt;/p&gt;
  &lt;p id=&quot;giMt&quot;&gt;- SIGTERM: The syslogd will die.&lt;/p&gt;
  &lt;p id=&quot;8tdB&quot;&gt;- SIGINT, SIGQUIT: If debugging is enabled these are ignored, otherwise syslogd will die.&lt;/p&gt;
  &lt;p id=&quot;wjaT&quot;&gt;- SIGUSR1: Switch debugging on/off. This option can only be used if syslogd is started with the - d debug option.&lt;/p&gt;
  &lt;p id=&quot;XisQ&quot;&gt;- SIGCHLD: Wait for Childs if some were born, because of waiting messages.&lt;/p&gt;
  &lt;p id=&quot;TjQc&quot;&gt;&lt;strong&gt;What is the minimum number of partitions that you need to install Linux?&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;Answer:&lt;/strong&gt;&lt;br /&gt;Minimum 2 partitions are needed for installing Linux&lt;/p&gt;
  &lt;p id=&quot;X2dy&quot;&gt;&lt;strong&gt;3. Is there any relation between modprobe.conf file and network devices?&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;Answer:&lt;/strong&gt;&lt;br /&gt;Yes, this file assigns a kernel module to each network device.&lt;br /&gt;For Example:-&lt;br /&gt;[root@localhost ~]# cat /etc/modprobe.conf&lt;br /&gt;alias eth0 b44&lt;br /&gt;Here, b44 is the kernel module for network device eth0.&lt;br /&gt;We can confirm whether this module “b44” is present or not by the following command&lt;br /&gt;[root@localhost ~]# lsmod |grep b44&lt;br /&gt;b44 29005 0&lt;/p&gt;
  &lt;p id=&quot;qXWK&quot;&gt;&lt;strong&gt;How do you limit memory usage for commands?&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;Answer:&lt;/strong&gt;&lt;br /&gt;ulimit -Sv 1000 # 1000 KBs = 1 MB&lt;br /&gt;ulimit -Sv unlimited # Remove limit&lt;/p&gt;
  &lt;p id=&quot;g0l4&quot;&gt;&lt;strong&gt;What is du -s * | sort -k1,1rn | head command used for?&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;Answer:&lt;/strong&gt;&lt;br /&gt;This command shows top disk users in current dir.&lt;/p&gt;
  &lt;p id=&quot;FOEX&quot;&gt;&lt;strong&gt;41. How to exit from vi editors?&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;Answer:&lt;/strong&gt;&lt;br /&gt;The following commands are used to exit from vi editors.&lt;br /&gt;:wq saves the current work and exits the VI.&lt;br /&gt;:q! exits the VI without saving current work.&lt;/p&gt;
  &lt;p id=&quot;mDyS&quot;&gt;&lt;strong&gt;42. How to delete information from a file in vi?&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;Answer:&lt;/strong&gt;&lt;br /&gt;The following commands are used to delete information from vi editors.&lt;br /&gt;x deletes a current character.&lt;br /&gt;dd deletes the current line.&lt;/p&gt;
  &lt;p id=&quot;OvRL&quot;&gt;&lt;/p&gt;
  &lt;h2 id=&quot;JtTy&quot;&gt;&lt;/h2&gt;
  &lt;p id=&quot;Joq4&quot;&gt;strace&lt;/p&gt;
  &lt;p id=&quot;gh1L&quot;&gt;The &lt;strong&gt;strace&lt;/strong&gt; is the tool that helps in debugging issues by tracing system calls executed by a program.&lt;/p&gt;
  &lt;p id=&quot;uHOk&quot;&gt;Here are the samples of strace command:&lt;/p&gt;
  &lt;pre id=&quot;OrRI&quot;&gt;# Slow the target command and print details for each syscall:
strace command

# Slow the target PID and print details for each syscall:
strace -p PID

# Slow the target PID and any newly created child process, printing syscall details:
strace -fp PID

# Slow the target PID and record syscalls, printing a summary:
strace -cp PID

# Slow the target PID and trace open() syscalls only:
strace -eopen -p PID

# Slow the target PID and trace open() and stat() syscalls only:
strace -eopen,stat -p PID

# Slow the target PID and trace connect() and accept() syscalls only:
strace -econnect,accept -p PID

# Slow the target command and see what other programs it launches (slow them too!):
strace -qfeexecve command

# Slow the target PID and print time-since-epoch with (distorted) microsecond resolution:
strace -ttt -p PID

# Slow the target PID and print syscall durations with (distorted) microsecond resolution:
strace -T -p PID
&lt;/pre&gt;
  &lt;p id=&quot;R1R8&quot;&gt;The &lt;strong&gt;strace&lt;/strong&gt; command allows us to trace the system calls made by a program. This is useful for debugging, or simply to find out what a program is doing. By default, &lt;strong&gt;strace&lt;/strong&gt; writes its output to &lt;strong&gt;stderr&lt;/strong&gt;, but we can change this using the &lt;strong&gt;-o filename&lt;/strong&gt; option - from The Linux Programming Interface.&lt;/p&gt;
  &lt;pre id=&quot;669m&quot;&gt;$ strace date
execve(&amp;quot;/bin/date&amp;quot;, [&amp;quot;date&amp;quot;], [/* 118 vars */]) = 0
brk(0)                                  = 0x18b5000
access(&amp;quot;/etc/ld.so.nohwcap&amp;quot;, F_OK)      = -1 ENOENT (No such file or directory)
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f809a459000
access(&amp;quot;/etc/ld.so.preload&amp;quot;, R_OK)      = -1 ENOENT (No such file or directory)
open(&amp;quot;/etc/ld.so.cache&amp;quot;, O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=154081, ...}) = 0
...
close(1)                                = 0
munmap(0x7f809a458000, 4096)            = 0
close(2)                                = 0
exit_group(0)                           = ?
+++ exited with 0 +++
&lt;/pre&gt;
  &lt;p id=&quot;ljNR&quot;&gt;Each system call is displayed in the form of a function call, with both input and out- put arguments shown in parentheses.&lt;/p&gt;
  &lt;p id=&quot;61xy&quot;&gt;After the closing parenthesis of the traced call, &lt;strong&gt;strace&lt;/strong&gt; prints an equal sign ( = ), fol- lowed by the return value of the system call. If the system call failed, the symbolic &lt;strong&gt;errno&lt;/strong&gt; value is also displayed. Thus, we see ENOENT displayed for the failure of the access() call above.&lt;/p&gt;
  &lt;p id=&quot;mZsE&quot;&gt;Even for a simple program, the output produced by &lt;strong&gt;strace&lt;/strong&gt; is made voluminous by the system calls executed by the C run-time startup code and the loading of shared libraries. For a complex program, the &lt;strong&gt;strace&lt;/strong&gt; output can be extremely long.&lt;/p&gt;
  &lt;p id=&quot;DznH&quot;&gt;For these reasons, it is sometimes useful to selectively filter the output of &lt;strong&gt;strace&lt;/strong&gt;.&lt;/p&gt;
  &lt;pre id=&quot;YUpJ&quot;&gt;$ strace date 2&amp;gt;&amp;amp;1 | grep open
open(&amp;quot;/etc/ld.so.cache&amp;quot;, O_RDONLY|O_CLOEXEC) = 3
open(&amp;quot;/lib/x86_64-linux-gnu/libc.so.6&amp;quot;, O_RDONLY|O_CLOEXEC) = 3
open(&amp;quot;/usr/lib/locale/locale-archive&amp;quot;, O_RDONLY|O_CLOEXEC) = 3
open(&amp;quot;/etc/localtime&amp;quot;, O_RDONLY|O_CLOEXEC) = 3
&lt;/pre&gt;
  &lt;p id=&quot;94Ty&quot;&gt;Another method is to use the &lt;strong&gt;-e&lt;/strong&gt; option to select the events to be traced. For example, we can use the following command to trace &lt;strong&gt;open()&lt;/strong&gt; and &lt;strong&gt;close()&lt;/strong&gt; system calls:&lt;/p&gt;
  &lt;pre id=&quot;qBjq&quot;&gt;$ strace -e trace=open,close date
open(&amp;quot;/etc/ld.so.cache&amp;quot;, O_RDONLY|O_CLOEXEC) = 3
close(3)                                = 0
open(&amp;quot;/lib/x86_64-linux-gnu/libc.so.6&amp;quot;, O_RDONLY|O_CLOEXEC) = 3
close(3)                                = 0
open(&amp;quot;/usr/lib/locale/locale-archive&amp;quot;, O_RDONLY|O_CLOEXEC) = 3
close(3)                                = 0
open(&amp;quot;/etc/localtime&amp;quot;, O_RDONLY|O_CLOEXEC) = 3
close(3)                                = 0
Sun Nov 29 14:40:08 PST 2015
close(1)                                = 0
close(2)                                = 0
+++ exited with 0 +++
&lt;/pre&gt;
  &lt;p id=&quot;PJWX&quot;&gt;&lt;/p&gt;
  &lt;p id=&quot;dyzk&quot;&gt;dmesg&lt;/p&gt;
  &lt;p id=&quot;nMAE&quot;&gt;The &lt;strong&gt;dmesg&lt;/strong&gt; command displays all messages from the kernel ring buffer which is a data structure that records messages related to the operation of the kernel. A ring buffer is a special kind of buffer that is always a constant size, removing the oldest messages when new messages come in.&lt;/p&gt;
  &lt;p id=&quot;tKXT&quot;&gt;We can use &lt;strong&gt;dmesg&lt;/strong&gt; command to check why a process was killed. That happens if the process was consuming too much memory, and the kernel &amp;quot;Out of Memory&amp;quot; (OOM) killer will automatically kill the offending process.&lt;/p&gt;
  &lt;pre id=&quot;HFyY&quot;&gt;$ dmesg | less
[   54.125380] Out of memory: Kill process 8320 (stress-ng-brk) score 324 or sacrifice child
[   54.125382] Killed process 8320 (stress-ng-brk) total-vm:1309660kB, anon-rss:1287796kB, file-rss:76kB
[   54.522906] gmain invoked oom-killer: gfp_mask=0x24201ca, order=0, oom_score_adj=0
[   54.522908] gmain cpuset=accounts-daemon.service mems_allowed=0
...
&lt;/pre&gt;
  &lt;p id=&quot;gktM&quot;&gt;Дебаг&lt;/p&gt;
  &lt;ul id=&quot;OO9z&quot;&gt;
    &lt;li id=&quot;ZdS2&quot;&gt;Инструмент dmesg&lt;/li&gt;
    &lt;li id=&quot;GScn&quot;&gt;Демон syslog&lt;/li&gt;
    &lt;li id=&quot;3hOW&quot;&gt;Инструмент journald&lt;/li&gt;
    &lt;li id=&quot;dpVN&quot;&gt;Утилита strace&lt;/li&gt;
    &lt;li id=&quot;WJLi&quot;&gt;Утилита tcpdump&lt;/li&gt;
  &lt;/ul&gt;
  &lt;p id=&quot;a9vG&quot;&gt;&lt;a href=&quot;https://www.nightwolf.in/nightwolf-cotribution/linux_L3/&quot; target=&quot;_blank&quot;&gt;https://www.nightwolf.in/nightwolf-cotribution/linux_L3/&lt;/a&gt;&lt;/p&gt;
  &lt;p id=&quot;DQ4n&quot;&gt;&lt;a href=&quot;https://www.nightwolf.in/nightwolf-cotribution/linux_L2/&quot; target=&quot;_blank&quot;&gt;https://www.nightwolf.in/nightwolf-cotribution/linux_L2/&lt;/a&gt;&lt;/p&gt;
  &lt;p id=&quot;GIdC&quot;&gt;&lt;a href=&quot;https://www.nightwolf.in/nightwolf-cotribution/linux_L1/&quot; target=&quot;_blank&quot;&gt;https://www.nightwolf.in/nightwolf-cotribution/linux_L1/&lt;/a&gt;&lt;/p&gt;
  &lt;p id=&quot;UT8b&quot;&gt;&lt;a href=&quot;https://opensource.com/article/17/2/linux-boot-and-startup&quot; target=&quot;_blank&quot;&gt;https://opensource.com/article/17/2/linux-boot-and-startup&lt;/a&gt;&lt;/p&gt;
  &lt;p id=&quot;6iSP&quot;&gt;&lt;a href=&quot;https://awstip.com/sre-devops-interview-questions-linux-troubleshooting-1b8ffe82c16&quot; target=&quot;_blank&quot;&gt;https://awstip.com/sre-devops-interview-questions-linux-troubleshooting-1b8ffe82c16&lt;/a&gt;&lt;/p&gt;
  &lt;p id=&quot;xfqF&quot;&gt;&lt;a href=&quot;https://www.golinuxhub.com/2018/06/scenario-based-interview-question-beginner-experience-linux/&quot; target=&quot;_blank&quot;&gt;https://www.golinuxhub.com/2018/06/scenario-based-interview-question-beginner-experience-linux/&lt;/a&gt;&lt;/p&gt;

</content></entry><entry><id>it255ru:0bmvwfataDO</id><link rel="alternate" type="text/html" href="https://teletype.in/@it255ru/0bmvwfataDO?utm_source=teletype&amp;utm_medium=feed_atom&amp;utm_campaign=it255ru"></link><title>Бесплатные ресурсы для изучения PYTHON</title><published>2022-12-29T07:52:48.108Z</published><updated>2022-12-29T09:32:40.554Z</updated><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://img2.teletype.in/files/d2/17/d217b8a1-e134-4732-afef-00e14316bff6.png"></media:thumbnail><summary type="html">&lt;img src=&quot;https://thehackernews.com/images/-0JTZDWCT-o0/XEmuJERb6vI/AAAAAAAAzIg/DOHcqB8IgSIowbHZirX_dm7H0SOn2es1gCLcBGAs/w0/learn-python-programming-language-video-tutorial.png&quot;&gt;Список, что изучать, где тренироваться и как действовать дальше.
Но главное - практика. Сделайте собственную программу, пробуйте на практике полученные знания и если что, гуглите. </summary><content type="html">
  &lt;figure id=&quot;HbBu&quot; class=&quot;m_column&quot;&gt;
    &lt;img src=&quot;https://thehackernews.com/images/-0JTZDWCT-o0/XEmuJERb6vI/AAAAAAAAzIg/DOHcqB8IgSIowbHZirX_dm7H0SOn2es1gCLcBGAs/w0/learn-python-programming-language-video-tutorial.png&quot; width=&quot;728&quot; /&gt;
  &lt;/figure&gt;
  &lt;p id=&quot;r0sr&quot;&gt;Список, что изучать, где тренироваться и как действовать дальше.&lt;br /&gt;Но главное - практика. Сделайте собственную программу, пробуйте на практике полученные знания и если что, гуглите. &lt;/p&gt;
  &lt;h3 id=&quot;pYsV&quot;&gt;Оф. инструкция&lt;/h3&gt;
  &lt;p id=&quot;pa4a&quot;&gt;&lt;br /&gt;- &lt;a href=&quot;https://docs.python.org/3/tutorial/&quot; target=&quot;_blank&quot;&gt;https://docs.python.org/3/tutorial/&lt;/a&gt;&lt;br /&gt;- &lt;a href=&quot;https://proglib.io/p/python-docs&quot; target=&quot;_blank&quot;&gt;https://proglib.io/p/python-docs&lt;/a&gt; # Работа с документацией в Python&lt;/p&gt;
  &lt;h3 id=&quot;328n&quot;&gt;PEP8&lt;/h3&gt;
  &lt;p id=&quot;jq4D&quot;&gt;- &lt;a href=&quot;https://defpython.ru/pep8&quot; target=&quot;_blank&quot;&gt;https://defpython.ru/pep8&lt;/a&gt;&lt;br /&gt;- &lt;a href=&quot;https://pep8.org/&quot; target=&quot;_blank&quot;&gt;https://pep8.org/&lt;/a&gt;&lt;/p&gt;
  &lt;h3 id=&quot;xeTe&quot;&gt;Интерактивные курсы&lt;/h3&gt;
  &lt;p id=&quot;hCo1&quot;&gt;- &lt;a href=&quot;https://pythontutor.ru/&quot; target=&quot;_blank&quot;&gt;https://pythontutor.ru/&lt;/a&gt;&lt;br /&gt;- &lt;a href=&quot;https://ru.hexlet.io/courses/python_101&quot; target=&quot;_blank&quot;&gt;https://ru.hexlet.io/courses/python_101&lt;/a&gt;&lt;br /&gt;- &lt;a href=&quot;https://www.coursera.org/specializations/python#courses&quot; target=&quot;_blank&quot;&gt;https://www.coursera.org/specializations/python#courses&lt;/a&gt;&lt;/p&gt;
  &lt;h3 id=&quot;qRyJ&quot;&gt;Видео лекции&lt;/h3&gt;
  &lt;p id=&quot;z0El&quot;&gt;- &lt;a href=&quot;https://www.lektorium.tv/lecture/13897&quot; target=&quot;_blank&quot;&gt;https://www.lektorium.tv/lecture/13897&lt;/a&gt; [RU]&lt;br /&gt;- &lt;a href=&quot;https://ru.hexlet.io/courses/python_101&quot; target=&quot;_blank&quot;&gt;https://ru.hexlet.io/courses/python_101&lt;/a&gt; [EN]&lt;br /&gt;- &lt;a href=&quot;https://www.youtube.com/watch?v=fgf57Sa5A-A&quot; target=&quot;_blank&quot;&gt;https://www.youtube.com/watch?v=fgf57Sa5A-A&lt;/a&gt; [RU]&lt;/p&gt;
  &lt;h3 id=&quot;JDro&quot;&gt;Видео обсуждение книг&lt;/h3&gt;
  &lt;p id=&quot;Komt&quot;&gt;&lt;a href=&quot;https://www.youtube.com/playlist?list=PLv_mO3iQ2o2fZllHFsEniuy1D-2IXr8eU&quot; target=&quot;_blank&quot;&gt;Изучаем Python с Марком Лутцем&lt;/a&gt;&lt;/p&gt;
  &lt;h3 id=&quot;y7jw&quot;&gt;Видео интервью с разработчиком на Python&lt;/h3&gt;
  &lt;p id=&quot;tzRp&quot;&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=VFBXx7O9BxU&quot; target=&quot;_blank&quot;&gt;https://www.youtube.com/watch?v=VFBXx7O9BxU&lt;/a&gt;&lt;/p&gt;
  &lt;h3 id=&quot;et0e&quot;&gt;Текстовые&lt;/h3&gt;
  &lt;p id=&quot;5S2B&quot;&gt;- &lt;a href=&quot;https://intuit.ru/studies/courses/49/49/info&quot; target=&quot;_blank&quot;&gt;https://intuit.ru/studies/courses/49/49/info&lt;/a&gt;&lt;br /&gt;- &lt;a href=&quot;http://programarcadegames.com/index.php?lang=ru&amp;chapter=python_as_calculator&quot; target=&quot;_blank&quot;&gt;http://programarcadegames.com/index.php?lang=ru&amp;amp;chapter=python_as_calculator&lt;/a&gt;&lt;br /&gt;- &lt;a href=&quot;https://developers.google.com/edu/python&quot; target=&quot;_blank&quot;&gt;https://developers.google.com/edu/python&lt;/a&gt;&lt;br /&gt;- &lt;a href=&quot;https://www.tutorialspoint.com/python/&quot; target=&quot;_blank&quot;&gt;https://www.tutorialspoint.com/python/&lt;/a&gt;&lt;br /&gt;- &lt;a href=&quot;https://github.com/Asabeneh/30-Days-Of-Python&quot; target=&quot;_blank&quot;&gt;https://github.com/Asabeneh/30-Days-Of-Python&lt;/a&gt;&lt;/p&gt;
  &lt;h3 id=&quot;D8zC&quot;&gt;Сайты&lt;/h3&gt;
  &lt;p id=&quot;BDqk&quot;&gt;- &lt;a href=&quot;https://pythonru.com/&quot; target=&quot;_blank&quot;&gt;https://pythonru.com/&lt;/a&gt;&lt;br /&gt;- &lt;a href=&quot;https://pythonworld.ru/samouchitel-python&quot; target=&quot;_blank&quot;&gt;https://pythonworld.ru/samouchitel-python&lt;/a&gt;&lt;br /&gt;- &lt;a href=&quot;https://pythonchik.ru/osnovy/&quot; target=&quot;_blank&quot;&gt;https://pythonchik.ru/osnovy/&lt;/a&gt;&lt;br /&gt;- &lt;a href=&quot;https://younglinux.info/python/&quot; target=&quot;_blank&quot;&gt;https://younglinux.info/python/&lt;/a&gt;&lt;br /&gt;- &lt;a href=&quot;https://www.learnpython.org/&quot; target=&quot;_blank&quot;&gt;https://www.learnpython.org/&lt;/a&gt;&lt;br /&gt;- &lt;a href=&quot;https://ru.hexlet.io/blog/posts/grokaem-algoritmy-gayd-po-algoritmam-dlya-teh-komu-slozhno-reshat-zadachi&quot; target=&quot;_blank&quot;&gt;https://ru.hexlet.io/blog/posts/grokaem-algoritmy-gayd-po-algoritmam-dlya-teh-komu-slozhno-reshat-zadachi&lt;/a&gt;&lt;br /&gt;- &lt;a href=&quot;https://www.w3schools.com/PYTHON/python_exercises.asp&quot; target=&quot;_blank&quot;&gt;https://www.w3schools.com/PYTHON/python_exercises.asp&lt;/a&gt;&lt;br /&gt;- &lt;a href=&quot;https://www.w3resource.com/python-exercises/&quot; target=&quot;_blank&quot;&gt;https://www.w3resource.com/python-exercises/&lt;/a&gt;&lt;br /&gt;- &lt;a href=&quot;https://pynative.com/python-exercises-with-solutions/&quot; target=&quot;_blank&quot;&gt;https://pynative.com/python-exercises-with-solutions/&lt;/a&gt;&lt;br /&gt;- &lt;a href=&quot;https://www.hackerrank.com/domains/python&quot; target=&quot;_blank&quot;&gt;https://www.hackerrank.com/domains/python&lt;/a&gt;&lt;br /&gt;- &lt;a href=&quot;https://www.dataquest.io/blog/python-practice/&quot; target=&quot;_blank&quot;&gt;https://www.dataquest.io/blog/python-practice/&lt;/a&gt;&lt;br /&gt;- &lt;a href=&quot;https://edabit.com/challenges/python3&quot; target=&quot;_blank&quot;&gt;https://edabit.com/challenges/python3&lt;/a&gt;&lt;br /&gt;- &lt;a href=&quot;https://www.geeksforgeeks.org/python-exercises-practice-questions-and-solutions/&quot; target=&quot;_blank&quot;&gt;https://www.geeksforgeeks.org/python-exercises-practice-questions-and-solutions/&lt;/a&gt;&lt;/p&gt;
  &lt;h3 id=&quot;FTb4&quot;&gt;Игры&lt;/h3&gt;
  &lt;p id=&quot;R50p&quot;&gt;- &lt;a href=&quot;https://checkio.org/&quot; target=&quot;_blank&quot;&gt;https://checkio.org/&lt;/a&gt; [EN][RU]&lt;br /&gt;- &lt;a href=&quot;https://codecombat.com/&quot; target=&quot;_blank&quot;&gt;https://codecombat.com/&lt;/a&gt; [EN][RU]&lt;br /&gt;- &lt;a href=&quot;https://www.codingame.com/&quot; target=&quot;_blank&quot;&gt;https://www.codingame.com/ &lt;/a&gt;[EN]&lt;br /&gt;- &lt;a href=&quot;https://www.pythonchecker.com/&quot; target=&quot;_blank&quot;&gt;https://www.pythonchecker.com/&lt;/a&gt; [EN]&lt;/p&gt;
  &lt;h3 id=&quot;rVKH&quot;&gt;Тесты&lt;/h3&gt;
  &lt;p id=&quot;1idj&quot;&gt;- &lt;a href=&quot;https://www.afterhoursprogramming.com/tests/python/&quot; target=&quot;_blank&quot;&gt;https://www.afterhoursprogramming.com/tests/python/&lt;/a&gt; [EN]&lt;br /&gt;- &lt;a href=&quot;https://app.finxter.com/learn/computer/science/&quot; target=&quot;_blank&quot;&gt;https://app.finxter.com/learn/computer/science/&lt;/a&gt; [EN]&lt;/p&gt;
  &lt;h3 id=&quot;I7Ng&quot;&gt;Проекты для изучения кода&lt;/h3&gt;
  &lt;p id=&quot;Ru3W&quot;&gt;- &lt;a href=&quot;https://proglib.io/p/project-list&quot; target=&quot;_blank&quot;&gt;https://proglib.io/p/project-list&lt;/a&gt;&lt;br /&gt;- &lt;a href=&quot;https://github.com/vinta/awesome-python&quot; target=&quot;_blank&quot;&gt;https://github.com/vinta/awesome-python&lt;/a&gt;&lt;br /&gt;- &lt;a href=&quot;https://github.com/Hexlet/ru-test-assignments&quot; target=&quot;_blank&quot;&gt;https://github.com/Hexlet/ru-test-assignments&lt;br /&gt;&lt;/a&gt;- &lt;a href=&quot;https://github.com/jtprogru/interview-task&quot; target=&quot;_blank&quot;&gt;https://github.com/jtprogru/interview-task&lt;/a&gt;&lt;br /&gt;- &lt;a href=&quot;https://github.com/Python-World/python-mini-projects&quot; target=&quot;_blank&quot;&gt;https://github.com/Python-World/python-mini-projects&lt;/a&gt;&lt;/p&gt;
  &lt;h3 id=&quot;3UeP&quot;&gt;Практика&lt;/h3&gt;
  &lt;p id=&quot;VRBf&quot;&gt;- &lt;a href=&quot;https://www.codewars.com/?language=python&quot; target=&quot;_blank&quot;&gt;https://www.codewars.com/?language=python&lt;/a&gt; [EN]&lt;br /&gt;- &lt;a href=&quot;https://leetcode.com/&quot; target=&quot;_blank&quot;&gt;https://leetcode.com/&lt;/a&gt; [EN]&lt;br /&gt;- &lt;a href=&quot;https://projecteuler.net/&quot; target=&quot;_blank&quot;&gt;https://projecteuler.net/&lt;/a&gt; [EN]&lt;/p&gt;
  &lt;h3 id=&quot;4LF6&quot;&gt;Телеграм каналы c книгами&lt;/h3&gt;
  &lt;p id=&quot;mdo7&quot;&gt;@pythonbooks&lt;br /&gt;@pythonknigi&lt;br /&gt;@pythonbooksarchive&lt;br /&gt;@pythonlib&lt;br /&gt;@pythonknigi_backup&lt;br /&gt;@pythonbookarchive&lt;/p&gt;
  &lt;p id=&quot;KipM&quot;&gt;Книги бесплатно&lt;br /&gt;- &lt;a href=&quot;https://fr.be1lib.org/&quot; target=&quot;_blank&quot;&gt;https://fr.be1lib.org/&lt;/a&gt; # нужен VPN&lt;br /&gt;- &lt;a href=&quot;https://automatetheboringstuff.com/&quot; target=&quot;_blank&quot;&gt;https://automatetheboringstuff.com/&lt;/a&gt;&lt;/p&gt;
  &lt;h3 id=&quot;ddhI&quot;&gt;Телеграм каналы с курсами&lt;/h3&gt;
  &lt;p id=&quot;0Zjv&quot;&gt;&lt;a href=&quot;https://t.me/+iTL2SbuBL1M2ZDgy&quot; target=&quot;_blank&quot;&gt;https://t.me/+iTL2SbuBL1M2ZDgy&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;https://t.me/sl1vakerA&quot; target=&quot;_blank&quot;&gt;https://t.me/sl1vakerA&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;https://t.me/+9qArPpoG_5s2MTEy&quot; target=&quot;_blank&quot;&gt;https://t.me/+9qArPpoG_5s2MTEy&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;https://t.me/archive_cmd&quot; target=&quot;_blank&quot;&gt;https://t.me/archive_cmd&lt;/a&gt;&lt;/p&gt;
  &lt;h3 id=&quot;gfZw&quot;&gt;Онлайн IDE python (ТОП компиляторов)&lt;/h3&gt;
  &lt;p id=&quot;8rnb&quot;&gt;- &lt;a href=&quot;https://pythontutor.com/&quot; target=&quot;_blank&quot;&gt;https://pythontutor.com/&lt;/a&gt;&lt;br /&gt;- &lt;a href=&quot;https://replit.com/&quot; target=&quot;_blank&quot;&gt;https://replit.com/&lt;/a&gt;&lt;br /&gt;- &lt;a href=&quot;http://pythonfiddle.com/&quot; target=&quot;_blank&quot;&gt;http://pythonfiddle.com/&lt;/a&gt;&lt;br /&gt;- &lt;a href=&quot;https://www.pythonanywhere.com/&quot; target=&quot;_blank&quot;&gt;https://www.pythonanywhere.com/&lt;/a&gt;&lt;br /&gt;- &lt;a href=&quot;https://www.online-python.com/&quot; target=&quot;_blank&quot;&gt;https://www.online-python.com/&lt;/a&gt;&lt;/p&gt;
  &lt;h3 id=&quot;tSu3&quot;&gt;Шпаргалки (cheatsheet)&lt;/h3&gt;
  &lt;p id=&quot;yuCl&quot;&gt;- &lt;a href=&quot;https://github.com/aspittel/coding-cheat-sheets&quot; target=&quot;_blank&quot;&gt;https://github.com/aspittel/coding-cheat-sheets&lt;/a&gt;&lt;br /&gt;- &lt;a href=&quot;https://zerotomastery.io/cheatsheets/python-cheat-sheet&quot; target=&quot;_blank&quot;&gt;https://zerotomastery.io/cheatsheets/python-cheat-sheet&lt;/a&gt;&lt;br /&gt;- &lt;a href=&quot;https://github.com/wilfredinni/python-cheatsheet&quot; target=&quot;_blank&quot;&gt;https://github.com/wilfredinni/python-cheatsheet&lt;/a&gt;&lt;br /&gt;- &lt;a href=&quot;https://github.com/crazyguitar/pysheeet/blob/master/docs/notes/python-basic.rst&quot; target=&quot;_blank&quot;&gt;https://github.com/crazyguitar/pysheeet/blob/master/docs/notes/python-basic.rst&lt;/a&gt;&lt;/p&gt;
  &lt;h3 id=&quot;FEJp&quot;&gt;Design patterns and idioms&lt;/h3&gt;
  &lt;p id=&quot;TIKO&quot;&gt;&lt;a href=&quot;https://github.com/faif/python-patterns&quot; target=&quot;_blank&quot;&gt;https://github.com/faif/python-patterns&lt;/a&gt;&lt;/p&gt;

</content></entry><entry><id>it255ru:XNfe00GOSwE</id><link rel="alternate" type="text/html" href="https://teletype.in/@it255ru/XNfe00GOSwE?utm_source=teletype&amp;utm_medium=feed_atom&amp;utm_campaign=it255ru"></link><title>Контейнеризация приложений: что это такое и когда стоит использовать</title><published>2022-10-07T11:46:01.927Z</published><updated>2022-12-30T10:08:02.364Z</updated><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://img2.teletype.in/files/54/ac/54ac7bb3-aebf-48df-92a0-d288888e44b2.png"></media:thumbnail><summary type="html">&lt;img src=&quot;https://mcs.mail.ru/wp-content/uploads/2021/01/container-1.jpg&quot;&gt;Контейнеризация «позволяет писать приложения один раз и запускать их где угодно». (IBM)</summary><content type="html">
  &lt;p id=&quot;nlYq&quot;&gt;Контейнеризация «позволяет писать приложения один раз и запускать их где угодно». (IBM)&lt;/p&gt;
  &lt;h2 id=&quot;paragraph-1&quot;&gt;Что такое контейнер и чем эта технология удобна для разработчиков приложений&lt;/h2&gt;
  &lt;p id=&quot;8qNr&quot;&gt;Контейнер приложения — экземпляр исполняемого программного обеспечения (ПО), который объединяет двоичный код приложения вместе со всеми связанными файлами конфигурации, библиотеками, зависимостями и средой выполнения.&lt;/p&gt;
  &lt;p id=&quot;rK9j&quot;&gt;Смысл и главное преимущество технологии в том, что контейнер абстрагирует приложение от операционной системы хоста, то есть остается автономным, благодаря чему становится легко переносимым — способным работать на любой платформе.&lt;/p&gt;
  &lt;blockquote id=&quot;UOlI&quot;&gt;Эта автономность отражена в самом названии: словно груз в таре на контейнеровозе, отделенный от самого судна, но перемещающийся на нем, все необходимое для разработки, доставки и развертывания приложения располагается в контейнере, но обособлено от среды, в которой фактически работает.&lt;/blockquote&gt;
  &lt;p id=&quot;7JDa&quot;&gt;Контейнеры используют не только для изоляции различных программных процессов, но и для контроля ресурсов, за которые эти процессы могут конкурировать. Это, например, объем памяти или ресурсы процессора.&lt;/p&gt;
  &lt;p id=&quot;hFI6&quot;&gt;Уже существующие приложения можно переупаковать в контейнеры, например, посредством технологии Docker, и они будут эффективнее использовать вычислительные ресурсы. Этот процесс называется контейнеризацией. Потребность в ней может возникнуть, когда надо быстро и без повторной сборки приложения переместить его из одной вычислительной среды в другую, где развернуть легко и согласованно.&lt;/p&gt;
  &lt;blockquote id=&quot;SFzG&quot;&gt;В качестве упражнения попробуйте выполнить без контейнеров процесс миграции ПО на с одной ОС на другую:&lt;br /&gt;1. Развернуть на ВМ Centos 8 steam - MongoDB 4.4&lt;br /&gt;2. Создать базу с одной коллекцией и одним документом с любым содержимым&lt;br /&gt;3. Перенести на Ubuntu 22.04 - MongoDB и базу (Спойлер - MongoDB 4.4 не получится установить из-за openssl 3й версии. Требуется первая версия. Которую можно поставить, но процесс очень не простой и точно не рекомендуемый даже для среды разработки.)&lt;/blockquote&gt;
  &lt;p id=&quot;cMma&quot;&gt;Еще одно применение технологии — использовать контейнер, содержащий экземпляр другого дистрибутива ОС, что позволяет запускать одновременно несколько контейнеров с приложениями, требующими разных дистрибутивов. Такие контейнеры называют системными и применяют их для традиционных приложений: все конфигурации, инструменты (различное вспомогательное ПО) и монолитная архитектура приложения находятся в одном контейнере.&lt;/p&gt;
  &lt;blockquote id=&quot;rAFr&quot;&gt;Например, на сервере с Ubuntu Linux запущены контейнеры с приложениями, которым требуется Alpine Linux, а также другие контейнеры с приложениями, которым необходима определенная версия Debian.&lt;/blockquote&gt;
  &lt;p id=&quot;Eu1f&quot;&gt;Чтобы лучше понять, чем хороши контейнеры, стоит сравнить их с виртуальными машинами.&lt;/p&gt;
  &lt;h2 id=&quot;paragraph-2&quot;&gt;В чем разница между контейнерами и виртуальными машинами&lt;/h2&gt;
  &lt;p id=&quot;Utje&quot;&gt;&lt;strong&gt;1. Виртуальные машины — абстракция на уровне физического оборудования, превращает один сервер в несколько &lt;/strong&gt;&lt;/p&gt;
  &lt;p id=&quot;X5Du&quot;&gt;На каждой виртуальной машине (ВМ) отдельная гостевая операционная система работает поверх операционной системы хоста с виртуализированным доступом к базовому оборудованию. Виртуальные машины с разными ОС могут работать на одном физическом сервере: ВМ UNIX может работать вместе с ВМ Linux и так далее. Микроядро и система виртуализации, которые создают и запускают виртуальные машины, называются гипервизорами или мониторами ВМ. Это то, что находится между оборудованием и ВМ и необходимо для виртуализации сервера, а также для изоляции операционных систем друг от друга&lt;/p&gt;
  &lt;p id=&quot;67om&quot;&gt;&lt;strong&gt;2. Контейнеры — абстракция на уровне приложения, объединяет код и зависимости&lt;/strong&gt;&lt;/p&gt;
  &lt;p id=&quot;diZr&quot;&gt;Контейнеры устанавливаются поверх физического сервера и его ОС, например Linux или Windows. Каждый контейнер отделяет свое содержимое от операционной системы. Контейнеры «легкие» — весят всего мегабайты и запускаются за секунды, ведь они берут лишь небольшую часть памяти при совместном использовании ОС.&lt;/p&gt;
  &lt;figure id=&quot;OBn7&quot; class=&quot;m_column&quot;&gt;
    &lt;img src=&quot;https://mcs.mail.ru/wp-content/uploads/2021/01/container-1.jpg&quot; width=&quot;1600&quot; /&gt;
  &lt;/figure&gt;
  &lt;p id=&quot;0KT5&quot;&gt;Виртуальные машины могут запускать любое ядро операционной системы независимо от основной операционной системы, контейнер должен быть совместим с ядром ОС сервера.&lt;/p&gt;
  &lt;p id=&quot;1Y1L&quot;&gt;Как и ВМ, контейнеры позволяют упаковывать приложение вместе с библиотеками и другими зависимостями, обеспечивая изолированные среды для запуска программных сервисов. Они отделяют приложения друг от друга. Это означает, что не придется беспокоиться о конфликтующих зависимостях или конфликте ресурсов, ведь можно установить лимиты ресурсов для каждого контейнера. Важно отметить, что это дополнительный уровень безопасности, поскольку приложения не работают в операционной системе сервера.&lt;/p&gt;
  &lt;h2 id=&quot;paragraph-4&quot;&gt;Безопасность контейнеров&lt;/h2&gt;
  &lt;p id=&quot;eJws&quot;&gt;При запуске контейнеров надо учитывать, что есть некоторый риск запустить их с неполной изоляцией, тогда какой-то вредоносный код из сети может получить доступ к памяти сервера.&lt;/p&gt;
  &lt;p id=&quot;xgbZ&quot;&gt;Здесь нужно использовать решения, повышающие безопасность контейнеров:&lt;/p&gt;
  &lt;ol id=&quot;FQWo&quot;&gt;
    &lt;li id=&quot;Sz2m&quot;&gt;Добиться изолированности процессов с помощью принципа «каждый контейнер — для решения только одной задачи», его еще формулируют как «одно приложение — один контейнер».&lt;/li&gt;
    &lt;li id=&quot;Vo4l&quot;&gt;Не загружать готовые к использованию контейнеры из ненадежных источников, а в особых случаях использовать исключительно собственные непубличные репозитории с контейнерами (Container Registry), которые интегрируются в CI/CD-среды.&lt;/li&gt;
    &lt;li id=&quot;2xzs&quot;&gt;Использовать внутренние функции сервиса контейнеризации по поиску уязвимостей во всем вспомогательном ПО — такое тестирование тоже легко автоматизируется в CI/CD-средах и позволяет исключить развертывание уязвимых контейнеров в продакшене.&lt;/li&gt;
  &lt;/ol&gt;
  &lt;h2 id=&quot;paragraph-6&quot;&gt;Для чего подходит и не подходит контейнеризация&lt;/h2&gt;
  &lt;p id=&quot;lhO2&quot;&gt;&lt;strong&gt;Контейнеризация не подходит&lt;/strong&gt;: если для работы приложения требуется другая ОС, а не та, что установлена на сервере.&lt;/p&gt;
  &lt;p id=&quot;1SMj&quot;&gt;&lt;strong&gt;Контейнеризация подходит:&lt;/strong&gt;&lt;/p&gt;
  &lt;ul id=&quot;cWVK&quot;&gt;
    &lt;li id=&quot;FTHb&quot;&gt;для упрощения процесса развертывания и сопровождения приложений;&lt;/li&gt;
    &lt;li id=&quot;PRvY&quot;&gt;для запуска небезопасного или непроверенного кода с целью тестирования или отладки — для этого контейнеры подходят в 99% случаев;&lt;/li&gt;
    &lt;li id=&quot;jqHf&quot;&gt;для запуска приложений, требующих другого дистрибутива ОС (системные контейнеры);&lt;/li&gt;
    &lt;li id=&quot;qlVi&quot;&gt;для передачи отдельных компонентов приложения между членами команды в ходе цикла «разработка — тестирование — внедрение» и быстрого внесения изменений;&lt;/li&gt;
    &lt;li id=&quot;ai78&quot;&gt;для микросервисов, которые можно разрабатывать и обновлять независимо;&lt;/li&gt;
    &lt;li id=&quot;qXoT&quot;&gt;для горизонтально масштабируемых приложений — когда запускается несколько одинаковых контейнеров на текущих ресурсах без увеличения стоимости этих ресурсов. В отличие от вертикального масштабирования, где увеличение количества ядер CPU, объемов RAM, размера HDD на сервере стоит денег;&lt;/li&gt;
    &lt;li id=&quot;t56m&quot;&gt;для модернизации и миграции существующих приложений в более современные среды.&lt;/li&gt;
  &lt;/ul&gt;

</content></entry><entry><id>it255ru:OuwbmZoHuEu</id><link rel="alternate" type="text/html" href="https://teletype.in/@it255ru/OuwbmZoHuEu?utm_source=teletype&amp;utm_medium=feed_atom&amp;utm_campaign=it255ru"></link><title>Docker - устройство и принципы работы</title><published>2022-10-07T11:17:37.307Z</published><updated>2022-10-07T12:14:55.390Z</updated><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://img3.teletype.in/files/2a/ae/2aae0843-7d10-4d8e-b22f-1895cb34ed1a.png"></media:thumbnail><summary type="html">&lt;img src=&quot;https://mcs.mail.ru/wp-content/uploads/2021/06/%D0%A1%D1%85%D0%B5%D0%BC%D0%B0_02-1024x480.png&quot;&gt;Прежде чем рассказывать про Docker, нужно сказать несколько слов о технологии контейнеризации.</summary><content type="html">
  &lt;p id=&quot;hxTt&quot;&gt;Прежде чем рассказывать про Docker, нужно сказать несколько слов о технологии контейнеризации.&lt;/p&gt;
  &lt;p id=&quot;2RwU&quot;&gt;&lt;strong&gt;Контейнеры&lt;/strong&gt; — это способ стандартизации развертки приложения и отделения его от общей инфраструктуры. Экземпляр приложения запускается в изолированной среде, не влияющей на основную операционную систему.&lt;/p&gt;
  &lt;p id=&quot;GCDH&quot;&gt;Разработчикам не нужно задумываться, в каком окружении будет работать их приложение, будут ли там нужные настройки и зависимости. Они просто создают приложение, упаковывают все зависимости и настройки в некоторый единый образ. Затем этот образ можно запускать на других системах, не беспокоясь, что приложение не запустится.&lt;/p&gt;
  &lt;h2 id=&quot;JijV&quot;&gt;Что такое Docker?&lt;/h2&gt;
  &lt;p id=&quot;oGvg&quot;&gt;Docker — популярная технология контейнеризации, появившаяся в 2013 году. Тогда одноименная компания предложила способ виртуализации ОС, при котором код приложения, среда запуска, библиотеки и зависимости упаковываются в единую «капсулу» — контейнер Docker.&lt;/p&gt;
  &lt;blockquote id=&quot;WBp0&quot;&gt;Одной из реализаций идеи о разделении ресурсов стали Croot jail и операция Chroot, которые появились в 1979 году в UNIX версии 7. С помощью Chroot jail процесс и его дочерние элементы изолировались от основной ОС. Docker фактически можно считать продолжением этой идеи. Но корневой процесс мог выходить из chroot, а механизмов безопасности на тот момент еще не придумали.&lt;/blockquote&gt;
  &lt;blockquote id=&quot;lu5V&quot;&gt;Спустя 20 лет появился FreeBSD Jail — механизм виртуализации, позволяющий внутри одной ОС использовать несколько изолированных систем, которые назвали тюрьмами. Далее технологии контейнеризации развивались стремительно. В 2001 году появился Linux VServer, который использовал chroot-подобную утилиту и применялся для безопасного разделения ресурсов. Каждый раздел назывался «контекстом безопасности», а виртуализированная система внутри него — виртуальным частным сервером.&lt;/blockquote&gt;
  &lt;blockquote id=&quot;YpJc&quot;&gt;В 2005 году представили OpenVZ с виртуализацией на уровне ОС, благодаря которой усовершенствовалась технология изоляции. Но был и серьезный недостаток: у контейнеров и хоста была одна архитектура и версия ядра. Если требовалась другая, возникали проблемы.&lt;/blockquote&gt;
  &lt;blockquote id=&quot;WRCf&quot;&gt;В 2007 году компания Google представила функцию CGroups, ограничивающую использование ресурсов (CPU, ROM, дисковый ввод-вывод, сеть и т. д.) на уровне групп процессов. Спустя год выпустили Linux Containers (LXC), который имел много общего с OpenVZ и Linux-VServer, но использовал механизмы namespaces и CGroups из Linux-ядра вместо сторонних механизмов, внедряемых в ядро с помощью патчей.&lt;/blockquote&gt;
  &lt;blockquote id=&quot;srxx&quot;&gt;В 2013 году компания Cloud Foundry создала Warden. Новая утилитапредназначалась для запуска приложений, которые получают все свои зависимости от частей ПО, называемых &lt;code&gt;buildpacks&lt;/code&gt;. Контейнеры Warden обычно имеют два слоя: слой только для чтения с корневой файловой системой ОС и неперсистентный слой чтения/записи самого приложения и его зависимостей. В 2013 году на рынке появился и Docker.&lt;/blockquote&gt;
  &lt;h2 id=&quot;9TYL&quot;&gt;Для чего вообще нужен docker контейнер? &lt;/h2&gt;
  &lt;p id=&quot;bM8F&quot;&gt;Обычно, во время разработки, для каждого проекта вы настраиваете своё окружение. Но вот произошла такая ситуация: что-то случилось с вашим компьютером и приходится переустанавливать операционную систему(ОС). Соответственно, чтобы запустить ваш проект, необходимо настраивать окружение заново. Бывает ещё гигантское количество ситуаций, которые сводятся к одной проблеме - настройка окружения для разработки. Так вот Docker - коробка, которую достаточно единожды настроить под проект, чтобы в дальнейшем не было проблем с эксплуатацией/расширением сервиса.&lt;/p&gt;
  &lt;blockquote id=&quot;OoTX&quot;&gt;Благодаря контейнеризации и использованию Docker разработчики больше не задумываются о том, в какой среде будет функционировать их приложение и будут ли в этой в среде необходимые для тестирования опции и зависимости. Достаточно упаковать приложение со всеми зависимостями и процессами в контейнер, чтобы запускать в любых системах: Linux, Windows и macOS. Платформа Docker позволила отделить приложения от инфраструктуры. Контейнеры не зависят от базовой инфраструктуры, их можно легко перемещать между облачной и локальной инфраструктурами.&lt;/blockquote&gt;
  &lt;h2 id=&quot;ebY4&quot;&gt;Чем контейнеризация отличается от виртуализации?&lt;/h2&gt;
  &lt;p id=&quot;sqDp&quot;&gt;Виртуализация напоминает отдельный компьютер со своим оборудованием и ОС, внутри которого можно запустить еще одну ОС. А контейнеризация предполагает, что виртуальная среда запускается из ядра ОС, не предусматривает виртуализации оборудования и снижает потребление ресурсов.&lt;/p&gt;
  &lt;p id=&quot;sWRM&quot;&gt;Если цель виртуалки — полностью воспроизвести устройство компьютера, то основная цель Docker — создать среду для одного приложения. Виртуальная среда контейнера запускается внутри операционной системы. Ей не нужно виртуализировать оборудование — она использует его через ОС. Поэтому контейнеры Docker потребляют меньше ресурсов, быстрее развёртываются, проще масштабируются и меньше весят.&lt;/p&gt;
  &lt;p id=&quot;FxHQ&quot;&gt;Оба способа изолируют приложение от основной операционной системы, но если на виртуалку можно поставить любую ОС, то Docker ориентирован на ядро Linux.&lt;/p&gt;
  &lt;blockquote id=&quot;s6XF&quot;&gt;Docker и виртуальные машины не очень хорошо сочетаются друг с другом. Да, иногда в продакшене сервер нарезают на виртуалки и в них запускают контейнеры. Но такая схема, с двойной виртуализацией, приводит к избыточному расходу ресурсов. Её часто критикуют, и, надо признаться, по делу. Если в компании всё же сложилась такая практика, вместо гипервизора можно поставить Kubernetes, который будет устанавливать приложения напрямую на железо.&lt;/blockquote&gt;
  &lt;p id=&quot;uJxh&quot;&gt;Давайте рассмотрим особенности контейнеров.&lt;/p&gt;
  &lt;h3 id=&quot;osobennosti-kontejnerov&quot;&gt;Особенности контейнеров&lt;/h3&gt;
  &lt;ul id=&quot;4IGg&quot;&gt;
    &lt;li id=&quot;4ZhJ&quot;&gt;Важнейшая особенность контейнеров — их сравнительно короткий жизненный цикл. Любой контейнер можно остановить, перезапустить или уничтожить, если это необходимо. Данные, которые содержатся в контейнере, при этом тоже пропадут. Так выработалось правило проектирования приложений: не хранить важные данные в контейнере. Такой подход называют Stateless.&lt;/li&gt;
    &lt;li id=&quot;vKvX&quot;&gt;Объем контейнеров измеряется в мегабайтах, поскольку в них упаковывают лишь те процессы и зависимости ОС, которые необходимы для выполнения кода. Легковесные контейнеры быстро запускаются и экономят место на диске.&lt;/li&gt;
    &lt;li id=&quot;P8ax&quot;&gt;Один контейнер соответствует одному запущенному процессу. Отключение отдельного контейнера для отладки или обновления никак не помешает нормальной работе всего приложения.&lt;/li&gt;
    &lt;li id=&quot;7bFk&quot;&gt;Контейнеризация обеспечивает надежную изоляцию процессов и повышает уровень безопасности систем. Приложения, которые работают внутри контейнера, не имеют доступа к основной ОС и не могут на неё влиять.&lt;/li&gt;
    &lt;li id=&quot;93gm&quot;&gt;Благодаря контейнерам можно автоматизировать развертывание приложений на разных хостах.&lt;/li&gt;
    &lt;li id=&quot;ndic&quot;&gt;Использование контейнеров позволяет перейти с монолита на микросервисную архитектуру. За счет этого ускоряется разработка новой функциональности, поскольку нет опасений, что изменения в одной компоненте затронут всю остальную систему.&lt;/li&gt;
    &lt;li id=&quot;PzDS&quot;&gt;С точки зрения эффективности контейнеры котируются выше виртуальных машин. На одинаковом оборудовании можно запустить большое количество контейнеров, тогда как ВМ будет в разы меньше. Это важно при использовании облачной инфраструктуры — потребуется меньше ресурсов.&lt;/li&gt;
  &lt;/ul&gt;
  &lt;h2 id=&quot;preimushestva-ispolzovaniya-docker&quot;&gt;Преимущества использования Docker&lt;/h2&gt;
  &lt;p id=&quot;hLKL&quot;&gt;Какие преимущества Docker приносит компаниям и разработчикам?&lt;/p&gt;
  &lt;ol id=&quot;kXk2&quot;&gt;
    &lt;li id=&quot;JYsd&quot;&gt;&lt;strong&gt;Гибкость и адаптивность.&lt;/strong&gt; Благодаря Docker можно легко запускать контейнер в облачной инфраструктуре и на любом локальном устройстве. Можно создать базовые шаблоны контейнеров и использовать повторно бесконечное число раз. Бесшовная переносимость и простота развертывания — важные преимущества этой технологии.&lt;/li&gt;
    &lt;li id=&quot;LUXx&quot;&gt;&lt;strong&gt;Меньше ошибок и несовпадений окружений.&lt;/strong&gt; В контейнерах Docker содержится всё, что требуется для запуска приложения, поэтому перенос приложений из одной среды в другую не вызывает затруднений. Исчезает проблема, когда у разработчиков всё функционирует как надо, а на боевом сервере — нет.&lt;/li&gt;
    &lt;li id=&quot;jOs1&quot;&gt;&lt;strong&gt;Скорость развертывания.&lt;/strong&gt; Так как настраивать окружение для разработки, тестирования и боевого режима больше не нужно, время развертывания сокращается в несколько раз.&lt;/li&gt;
    &lt;li id=&quot;CQri&quot;&gt;&lt;strong&gt;Рост универсальности.&lt;/strong&gt; Docker позволяет использовать любые языки программирования и стек технологий на сервере, избавляя от проблемы несовместимости разных библиотек и технологий.&lt;/li&gt;
    &lt;li id=&quot;GeJn&quot;&gt;&lt;strong&gt;Комьюнити и поддержка.&lt;/strong&gt; Существует огромная библиотека контейнеров с открытым исходным кодом. Можно скачать нужный образ для конкретной задачи или обратиться за помощью к большому комьюнити разработчиков, которые используют Docker.&lt;/li&gt;
    &lt;li id=&quot;BfqG&quot;&gt;&lt;strong&gt;Непрерывность работы.&lt;/strong&gt; С учетом инструментов управления трафиком можно построить процесс обновления приложения так, чтобы обновление одних контейнеров не влияло на работоспособность системы и оказание услуг пользователям.&lt;/li&gt;
    &lt;li id=&quot;shTT&quot;&gt;&lt;strong&gt;Упрощение администрирования.&lt;/strong&gt; С помощью Docker легче перенести контейнер с одного хоста на другой, запустить сразу несколько образов, обновить группы контейнеров и откатиться к старой версии.&lt;/li&gt;
    &lt;li id=&quot;7cWJ&quot;&gt;&lt;strong&gt;Повышение уровня безопасности.&lt;/strong&gt; Контейнеры в Docker частично изолированы друг от друга на уровне процессов и ОС, поэтому запуск большого количества контейнеров на одной машине не несет рисков.&lt;/li&gt;
    &lt;li id=&quot;R6RN&quot;&gt;&lt;strong&gt;Экономическая эффективность.&lt;/strong&gt; Контейнеры легковесны и производительны, а благодаря использованию Docker можно эффективнее управлять имеющимися ресурсами и сократить расходы компании.&lt;/li&gt;
    &lt;li id=&quot;GYGZ&quot;&gt;&lt;strong&gt;Современный подход.&lt;/strong&gt; Отказ от монолитной архитектуры в пользу микросервисной позволяет более гибко развивать продукт, добавлять в него новые функции.&lt;/li&gt;
  &lt;/ol&gt;
  &lt;h2 id=&quot;osnovnye-komponenty-docker&quot;&gt;Основные компоненты Docker&lt;/h2&gt;
  &lt;p id=&quot;uY3z&quot;&gt;&lt;strong&gt;Dockerfile.&lt;/strong&gt; Текстовый файл с последовательно расположенными инструкциями для создания образа Docker. Файл создаётся по принципу «одна строка — одна команда».&lt;/p&gt;
  &lt;p id=&quot;l6xT&quot;&gt;&lt;strong&gt;Daemon.&lt;/strong&gt; Фоновая служба на хосте, которая отвечает за создание, запуск и уничтожение контейнеров.&lt;/p&gt;
  &lt;p id=&quot;9oH4&quot;&gt;&lt;strong&gt;Image.&lt;/strong&gt; Неизменяемый файл (образ), из которого можно неограниченное количество раз развернуть контейнер.&lt;/p&gt;
  &lt;p id=&quot;Z6fd&quot;&gt;&lt;strong&gt;Client.&lt;/strong&gt; Утилита командной строки в Docker для управления демоном. Любое взаимодействие с контейнером проходит через Daemon.&lt;/p&gt;
  &lt;p id=&quot;Gp14&quot;&gt;&lt;strong&gt;Container.&lt;/strong&gt; Запущенное приложение, которое развернули из образа.&lt;/p&gt;
  &lt;p id=&quot;tJqB&quot;&gt;&lt;strong&gt;Registry.&lt;/strong&gt; Служба в Docker, выполняющая функции репозитория (хранилища). Позволяет следить за версиями образов, создавать приватные репозитории.&lt;/p&gt;
  &lt;p id=&quot;51AH&quot;&gt;&lt;strong&gt;Docker Hub.&lt;/strong&gt; Популярный публичный репозиторий, используемый по умолчанию в Docker. Обеспечивает интеграцию с GitHub и BitBucket.&lt;/p&gt;
  &lt;p id=&quot;xpKB&quot;&gt;&lt;strong&gt;Docker Desktop.&lt;/strong&gt; Приложение, позволяющее локально собирать, выполнять и тестировать контейнеры. Работает на Windows и macOS.&lt;/p&gt;
  &lt;p id=&quot;DzdJ&quot;&gt;&lt;strong&gt;Docker volumes.&lt;/strong&gt; Тома для постоянного хранения информации. По умолчанию в Docker папки хранилищ создаются на хост-машине, но предусмотрена и возможность подключения удаленных хранилищ. Использование томов позволяет лучшим образом настроить хранение данных.&lt;/p&gt;
  &lt;h2 id=&quot;kak-ustroen-obraz-docker&quot;&gt;Как устроен образ Docker&lt;/h2&gt;
  &lt;p id=&quot;ZrfT&quot;&gt;Базовый образ — главный элемент контейнеризации в Docker. В нем содержатся процессы и зависимости, необходимые для нормальной работы приложения. Разработчики предпочитают скачивать готовые образы из репозиториев, а не создавать их с нуля, так как уже есть огромное количество готовых компонент для самых разных задачи. Например, в Docker Hub уже загружено свыше 100 000 образов.&lt;/p&gt;
  &lt;figure id=&quot;DZ7T&quot; class=&quot;m_column&quot;&gt;
    &lt;img src=&quot;https://mcs.mail.ru/wp-content/uploads/2021/06/%D0%A1%D1%85%D0%B5%D0%BC%D0%B0_02-1024x480.png&quot; width=&quot;1024&quot; /&gt;
  &lt;/figure&gt;
  &lt;p id=&quot;7i23&quot;&gt;Образ — это неизменяемые слои, которые доступны только для чтения. А контейнер — это тот же самый образ, у которого «сверху» есть еще один слой для записи. Контейнер использует его, когда ему нужно сохранить информацию в процессе своей работы: логи, временные файлы и так далее. Если контейнер уничтожится, то этот слой и вся информация на нем тоже пропадут. А когда из этого же образа создастся новый контейнер, слой для записи у него будет новый и пустой.&lt;/p&gt;
  &lt;p id=&quot;Mvta&quot;&gt;На базовый образ в Docker один за другим накладываются доступные только для чтения слои, которые образуются после любых изменений в образе. Каждый новый слой — это актуальная версия образа. Получается, что финальный образ — это объединение всех слоев в один. Каждый слой образа сохраняется, чтобы при необходимости быстро откатываться назад. Такое решение экономит пространство диска и сокращает время сборки контейнера.&lt;/p&gt;
  &lt;p id=&quot;dRUX&quot;&gt;Если образ — это набор доступных только для чтения слоев, то контейнер представляет собой тот же образ, но с еще одним слоем сверху — с возможностью записи. Информация записывается в контейнер, а когда он уничтожается, верхний слой и содержащиеся в нем данные пропадают. В случае необходимости создается новый (чистый) контейнер из старого образа.&lt;/p&gt;
  &lt;figure id=&quot;0Sl1&quot; class=&quot;m_column&quot;&gt;
    &lt;img src=&quot;https://mcs.mail.ru/wp-content/uploads/2021/06/%D0%A1%D1%85%D0%B5%D0%BC%D0%B0_03-1024x480.png&quot; width=&quot;1024&quot; /&gt;
    &lt;figcaption&gt;&lt;em&gt;Когда к Docker-образу добавляется слой для записи, получается Docker-контейнер&lt;/em&gt;&lt;/figcaption&gt;
  &lt;/figure&gt;
  &lt;p id=&quot;wZyT&quot;&gt;В Dockerfile записываются команды и опции создания образа, а также некоторые настройки будущего контейнера, такие как порты, переменные окружения и другие опции.&lt;/p&gt;
  &lt;p id=&quot;iUWX&quot;&gt;Каждая команда записанная в dockerfile создаёт свой слой. Чем больше слоёв, тем дольше будет собираться образ и дольше загружаться контейнер. Финальный Docker-образ — это объединение всех слоев в один. Благодаря такому подходу можно переиспользовать уже готовые образа для создания новых образов.&lt;/p&gt;
  &lt;figure id=&quot;DvYw&quot; class=&quot;m_column&quot;&gt;
    &lt;img src=&quot;https://static.1cloud.ru/img/blog/519.png&quot; width=&quot;1600&quot; /&gt;
  &lt;/figure&gt;
  &lt;p id=&quot;erAa&quot;&gt;В любом образе Docker хранится Docker manifest. Это JSON-файл, содержащий информацию об образе: ссылки на каждый существующий слой, данные об их размере, хеш, а также сведения о платформе, на которой он будет работать.&lt;/p&gt;
  &lt;h2 id=&quot;sozdanie-obraza-docker&quot;&gt;Теория создания образа Docker&lt;/h2&gt;
  &lt;p id=&quot;lkYw&quot;&gt;Развертывать образ можно любое количество раз на любом хосте. Для создания образа используется один из двух способов: интерактивный или через Dockerfile.&lt;br /&gt;Для работы с контейнерами Docker предоставляет всего несколько основных команд: docker run/stop/restart.&lt;/p&gt;
  &lt;p id=&quot;bEeI&quot;&gt;Интерактивный — простой способ, при котором разработчик сам изменяет среду окружения во время запуска контейнера. После запуска Docker в сессии терминала запустите оболочку контейнера (bash) командой &lt;code&gt;docker run image_name: tag_name&lt;/code&gt;. Имя тега можно не указывать, тогда задействуется текущая версия образа.&lt;/p&gt;
  &lt;p id=&quot;Hqgn&quot;&gt;Вариант с Dockerfile сложнее. Вы уже знаете, что каждому образу присваивается свой Dockerfile. После указания нужных команд в Dockerfile, исключите в .dockerignore все файлы, не используемые в сборке. Затем создайте образ командой &lt;code&gt;docker image build&lt;/code&gt;, присвойте ему имя и тег.&lt;/p&gt;
  &lt;p id=&quot;fmcf&quot;&gt;Но как же быть, если мы хотим, скажем, запускать базы данных или иные приложения в контейнере, для которых важна целостность данных? Docker предлагает два решения:&lt;/p&gt;
  &lt;ol id=&quot;3Fde&quot;&gt;
    &lt;li id=&quot;y8wo&quot;&gt;Монтирование папки с хоста к контейнеру. Такое решение отлично подходит для разработки и отладки приложения, когда вносимые изменения на хосте сразу отражаются в контейнере. Конечно, для продакшна такой подход не годится.&lt;/li&gt;
    &lt;li id=&quot;DLzn&quot;&gt;Создание специальных томов для хранения данных — Docker volume. DV — это обычные каталоги хоста, которые могут быть смонтированы как отдельные файловые системы (bind mounting) внутри контейнера.&lt;/li&gt;
  &lt;/ol&gt;
  &lt;p id=&quot;Gl47&quot;&gt;Docker-контейнеры могут не только хранить информацию в специальных томах, но и использовать их совместно с другими контейнерами. Всеми процессами коммуникации между контейнерами управляет демон Docker. Именно он создает и запускает контейнеры.&lt;/p&gt;
  &lt;p id=&quot;U9lR&quot;&gt;По умолчанию демон Docker использует собственный драйвер Docker runc, который тесно связан со следующими механизмами ядра:&lt;/p&gt;
  &lt;ul id=&quot;yaZd&quot;&gt;
    &lt;li id=&quot;9X4C&quot;&gt;Cgroups (контрольные группы) — механизм управления ресурсами, используемыми контейнером (процессор, оперативная память и т.д.). С помощью cgroups Docker также реализует возможность остановки контейнеров — docker pause (freezing и unfreezing).&lt;/li&gt;
    &lt;li id=&quot;ZD21&quot;&gt;Namespaces (пространства имен) — механизм изоляции контейнеров, гарантирующий, что файловая система, имя хоста, пользователи, сетевая среда и процессы любого контейнера полностью отделены от остальной части системы.&lt;/li&gt;
  &lt;/ul&gt;
  &lt;p id=&quot;M2wC&quot;&gt;Ещё одна технология, которую Docker использует для хранения слоев в контейнере — файловая система с каскадно-объединенным монтированием (Union File System – UnionFS). Как видите Docker умело использует уже хорошо работающие технологии, и в этом его сила.&lt;/p&gt;
  &lt;p id=&quot;APDX&quot;&gt;Сами по себе контейнеры не эфемерны, более того Docker их не скрывает и вы можете совершенно спокойно заглянуть в них. Они располагаются здесь: &lt;code&gt;/var/lib/docker/containers&lt;/code&gt;. Обращаться к контейнеру как к набору файлов бывает полезно, когда вам нужно прочитать логи контейнера.&lt;/p&gt;
  &lt;p id=&quot;u7CR&quot;&gt;&lt;strong&gt;Dockerfile&lt;/strong&gt; — это конфигурационный файл с инструкциями по созданию Docker-образов. Почти каждая команда инструкции создаёт новый слой в образе. Это нужно для дальнейшего использования уже готовых слоев.&lt;/p&gt;
  &lt;p id=&quot;X7BF&quot;&gt;Например, мы изменили последнюю инструкцию в Dockerfile и собрали образ заново. Docker не будет заново всё пересобирать. Он возьмет все предшествующие слои и переиспользует их. Вот как образно выглядит соотношение инструкций в Dockerfile со слоями в Docker-образе:&lt;/p&gt;
  &lt;figure id=&quot;AZwy&quot; class=&quot;m_column&quot;&gt;
    &lt;img src=&quot;https://static.1cloud.ru/img/blog/523.png&quot; width=&quot;1600&quot; /&gt;
  &lt;/figure&gt;
  &lt;p id=&quot;ZvJz&quot;&gt;Существуют определенные правила и логика заполнения Dockerfile. Разберем базовые инструкции на примере Dockerfile с иллюстрации выше.&lt;/p&gt;
  &lt;p id=&quot;XviY&quot;&gt;1. &lt;strong&gt;FROM&lt;/strong&gt;&lt;/p&gt;
  &lt;p id=&quot;ekpH&quot;&gt;Любой код или набор инструкций выполняется сверху вниз. Поэтому Dockerfile всегда начинается с открывающей инструкции FROM, которая говорит демону Docker, какой образ для основы нужно взять. Если образа локально нет — он будет скачан с Docker hub.&lt;/p&gt;
  &lt;p id=&quot;w3hH&quot;&gt;&lt;strong&gt;2. RUN&lt;/strong&gt;&lt;/p&gt;
  &lt;p id=&quot;qXU6&quot;&gt;Далее идет инструкция RUN с определенной командой. В нашем случае мы использовали команду mkdir -p для создания папки /app. Инструкций RUN может быть неограниченное количество, но стоит помнить, что каждая инструкция создает свой слой, поэтому хорошей практикой является запись цепочки команд через &amp;amp;&amp;amp;: RUN comand_1 &amp;amp;&amp;amp; comand_2 &amp;amp;&amp;amp; comand_3.&lt;/p&gt;
  &lt;p id=&quot;GhcT&quot;&gt;&lt;strong&gt;3. WORKDIR&lt;/strong&gt;&lt;/p&gt;
  &lt;p id=&quot;QWdR&quot;&gt;Есть инструкции логически связанные между собой. Инструкция WORKDIR устанавливает активный рабочий каталог. Все последующие команды, такие как COPY, RUN, CMD и некоторые другие будут выполнены из рабочего каталога, установленного через WORKDIR.&lt;/p&gt;
  &lt;p id=&quot;kmaK&quot;&gt;&lt;strong&gt;4. COPY&lt;/strong&gt;&lt;/p&gt;
  &lt;p id=&quot;XW7b&quot;&gt;С инструкцией COPY всё просто. Первым аргументом указывается папка для копирования, а вторым аргументом — папка в контейнере куда будут помещены файлы из копируемой директории. В нашем случае, из текущего каталога (“.” — каталог, в котором находится пользователь, “..” — каталог выше относительно “.”.), в котором находится пользователь, был скопирован файл requirements.txt и помещен в папку /app в контейнере.&lt;/p&gt;
  &lt;p id=&quot;lOPD&quot;&gt;&lt;strong&gt;5. RUN&lt;/strong&gt;&lt;/p&gt;
  &lt;p id=&quot;I1RV&quot;&gt;Инструкцию RUN мы рассмотрели ранее. Тут лишь хотим обратить ваше внимание на её поведение в сочетании с инструкцией WORKDIR. Ранее инструкция COPY перенесла файл requirements.txt в контейнер. Кстати, в качестве финального пути мы могли указать “.”, так как инструкция WORKDIR установила в качестве рабочей директории контейнера папку /app. И теперь команда RUN будет выполнена именно из директории /app.&lt;/p&gt;
  &lt;p id=&quot;cHrn&quot;&gt;&lt;strong&gt;6. CMD&lt;/strong&gt;&lt;/p&gt;
  &lt;p id=&quot;rM0Z&quot;&gt;Финальной инструкцией в любом Dockerfile является CMD или ENTRYPOINT. В отличие от других инструкций CMD может быть только одна и она может быть переопределена при старте контейнера командой docker run. Инструкция CMD наследует условия установленные инструкцией WORKDIR.&lt;/p&gt;
  &lt;p id=&quot;OvkE&quot;&gt;Не все инструкции указанные в Dockerfile непосредственно исполняются при сборке образа и запуске контейнера. Например, инструкция EXPOSE лишь говорит демону Docker, что мы намереваемся пробросить указанный нами порт наружу контейнера — EXPOSE 80. В этом примере мы хотим пробросить порт 80 изнутри контейнера наружу.&lt;/p&gt;
  &lt;p id=&quot;cnBL&quot;&gt;Однако после запуска контейнера «постучаться» на 80 порт к нему мы не сможем. Так как для подтверждения инструкции EXPOSE используется ключ -P команды docker run. Если требуется прокинуть порт и переназначить его снаружи — используется следующая команда: docker run -p 80:80 --name test_cont -d.&lt;/p&gt;
  &lt;h2 id=&quot;servisy-dlya-raboty-s-kontejnerami&quot;&gt;Сервисы для работы с контейнерами&lt;/h2&gt;
  &lt;p id=&quot;uBPF&quot;&gt;Использование образов и контейнеров позволяет организовывать сложную архитектуру приложений. Чем сложнее проект, тем труднее им управлять. Есть сервисы, позволяющие упростить и автоматизировать работу с контейнерами.&lt;/p&gt;
  &lt;h3 id=&quot;docker-compose&quot;&gt;Docker Compose&lt;/h3&gt;
  &lt;p id=&quot;zXSr&quot;&gt;В составе Docker есть инструмент, который позволяет централизованно запускать большое количество сервисов: Docker Compose. Документирование и конфигурирование сервисов приложения осуществляется с помощью текстового YAML-файла. Команда &lt;code&gt;docker‑compose up&lt;/code&gt; развертывает сервисы приложений и создает из образа новые контейнеры, а также сети, тома и все конфигурации, указанные в файле Docker Compose.&lt;/p&gt;
  &lt;p id=&quot;qiYC&quot;&gt;На этапе тестирования разработчикам приходится создавать изолированные среды, а потом уничтожать их. Docker Compose позволяет создать и уничтожить среду путем ввода нескольких команд. К участию в проекте можно привлекать и сторонних пользователей.&lt;/p&gt;
  &lt;h3 id=&quot;yandex-container-registry&quot;&gt;Yandex Container Registry&lt;/h3&gt;
  &lt;p id=&quot;eDHF&quot;&gt;Поддерживает управление через интерфейс консоли, командной строки (CLI) и командной строки Docker на основе Docker Registry HTTP API V2, работу через API.&lt;/p&gt;
  &lt;p id=&quot;m1Mo&quot;&gt;Доступны контейнеры с ОС Linux и Windows, которые можно запускать локально или на виртуальных машинах Yandex Compute Cloud.&lt;/p&gt;
  &lt;h2 id=&quot;orkestraciya&quot;&gt;Оркестрация&lt;/h2&gt;
  &lt;p id=&quot;R0PP&quot;&gt;Когда контейнеров становится слишком много, ими трудно управлять. На помощь приходят системы оркестрации.&lt;/p&gt;
  &lt;h3 id=&quot;docker-swarm&quot;&gt;Docker Swarm&lt;/h3&gt;
  &lt;p id=&quot;ATO5&quot;&gt;Стандартная система оркестрации контейнеров, достаточная для решения базовых задач. Позволяет быстро создать из нескольких хостов с контейнерами последовательный кластер Swarm, считая все кластерные хосты единым контейнерным пространством. В Docker-кластере должна быть как минимум одна управляющая нода (manager).&lt;/p&gt;
  &lt;h3 id=&quot;kubernetes&quot;&gt;Kubernetes&lt;/h3&gt;
  &lt;p id=&quot;Rjqq&quot;&gt;Платформа для автоматизации работы с контейнерами на Ubuntu, CentOS и других ОС Linux. Позволяет централизованно группировать контейнеры, балансировать нагрузку, активировать сервисы из сотен приложений одновременно. Kubernetes предоставляет пользователям больше возможностей по сравнению со Swarm, но и настраивать его сложнее.»&lt;/p&gt;
  &lt;h3 id=&quot;etY9&quot;&gt;OpenShift&lt;/h3&gt;
  &lt;p id=&quot;sFWQ&quot;&gt;OpenShift — это открытая и расширяемая платформа приложений-контейнеров, которая позволяет использовать Docker и Kubernetes на предприятии.&lt;/p&gt;
  &lt;p id=&quot;XuNX&quot;&gt;OpenShift включает Kubernetes для оркестрации контейнеров и управления ими. Здесь добавлены инструменты для разработчиков и операций, позволяющие:&lt;/p&gt;
  &lt;ul id=&quot;Jjpu&quot;&gt;
    &lt;li id=&quot;TUwX&quot;&gt;быстро разрабатывать приложения;&lt;/li&gt;
    &lt;li id=&quot;99ZH&quot;&gt;легко развертывать и масштабировать решения;&lt;/li&gt;
    &lt;li id=&quot;SfoZ&quot;&gt;обслуживать жизненный цикл команд и приложений в долгосрочной перспективе.&lt;/li&gt;
  &lt;/ul&gt;
  &lt;p id=&quot;nZxw&quot;&gt;Существует несколько доступных версий OpenShift: платформа контейнеров OpenShift и OKD (прежнее название OpenShift Origin).&lt;/p&gt;
  &lt;h2 id=&quot;fQmt&quot;&gt;&lt;strong&gt;Как Docker помогает на практике?&lt;/strong&gt;&lt;/h2&gt;
  &lt;p id=&quot;kwaG&quot;&gt;Приведу несколько примеров использования Docker, которые хорошо иллюстрируют его преимущества.&lt;/p&gt;
  &lt;h3 id=&quot;zYQ7&quot;&gt;&lt;strong&gt;Разработка приложений с зависимостями&lt;/strong&gt;&lt;/h3&gt;
  &lt;p id=&quot;OfhF&quot;&gt;Обычно, чтобы установить какую-то библиотеку или базу данных, разработчику нужно прочитать инструкцию на сайте. Он её скачивает, устанавливает, настраивает и запускает. А когда нужно перейти на другую зависимость — удаляет. И так приходится возиться с каждой зависимостью.&lt;/p&gt;
  &lt;p id=&quot;YD2x&quot;&gt;Docker предоставляет альтернативный путь. Вендоры библиотек, фреймворков и баз данных практически каждый день публикуют на Docker Hub свой софт в виде Docker image. Образ можно скачать и развернуть через Docker, поработать с ним, запушить, а потом остановить или удалить, и в операционной системе не останется никаких следов.&lt;/p&gt;
  &lt;p id=&quot;016c&quot;&gt;Единый интерфейс управления исключает необходимость индивидуальных команд. Достаточно выучить команды Docker: как скачивать образы, запускать контейнеры, пробрасывать, останавливать и удалять порты. С Docker можно запустить сколько угодно одинаковых баз внутри одной операционки. Благодаря изоляции, если что-то пойдёт не так, ошибки не затронут операционную систему и ничего не сломают.&lt;/p&gt;
  &lt;h3 id=&quot;s4OH&quot;&gt;&lt;strong&gt;Автоматизация тестирования&lt;/strong&gt;&lt;/h3&gt;
  &lt;p id=&quot;M5Wq&quot;&gt;Чтобы запустить автотесты, требуются определённые зависимости, например базы данных, брокеры сообщений и тому подобное. Их необходимо предварительно установить и сконфигурировать на сервере сборки. В этом месте иногда возникают проблемы: если при настройке упустить какую-то деталь, то можно испортить данные или что-то поломать. Гораздо безопаснее автоматически развернуть зависимости в виде контейнера прямо на сервере. Это позволяет быстро прогнать тесты, а после — бесследно удалить контейнеры.&lt;/p&gt;
  &lt;p id=&quot;KCg4&quot;&gt;Даже если тесты «сломают» какие-то данные, они удалятся вместе с контейнером. Кроме того, сам сервер с Docker, на котором запускаются автотесты, станет универсальным. Ведь благодаря контейнеризации на нём можно будет запускать что угодно. А значит, вы сэкономите на железе и настройке системы.&lt;/p&gt;
  &lt;h3 id=&quot;rJRf&quot;&gt;&lt;strong&gt;Публикация приложения&lt;/strong&gt;&lt;/h3&gt;
  &lt;p id=&quot;gf3H&quot;&gt;После тестирования проект упаковывают в образ и публикуют, передают клиентам или инфраструктурным инженерам.&lt;/p&gt;
  &lt;p id=&quot;CbzO&quot;&gt;Docker упрощает дальнейшее развёртывание приложения. SRE не нужно думать, какие зависимости установить, ведь всё уже упаковано в образ. Для них это чёрный ящик, который они обновляют единообразно и автоматически через одни и те же команды.&lt;/p&gt;
  &lt;p id=&quot;MeKa&quot;&gt;Среда для деплоя тоже становится универсальной, потому что всегда имеет дело только с контейнерами. Сегодня в ней развернули один контейнер, завтра — другой. При этом в контейнерах могут быть упакованы совершенно не похожие друг на друга приложения.&lt;/p&gt;
  &lt;h2 id=&quot;5Inc&quot;&gt;&lt;strong&gt;Минусы Docker&lt;/strong&gt;&lt;/h2&gt;
  &lt;p id=&quot;WsiR&quot;&gt;Как известно, за удовольствие приходится платить. И Docker — не исключение.&lt;/p&gt;
  &lt;p id=&quot;rz0F&quot;&gt;&lt;strong&gt;Высокое потребление ресурсов.&lt;/strong&gt; Docker создаёт дополнительную логическую прослойку и потребляет дополнительные ресурсы. Поэтому вы должны определить, что для вас более важно — ресурсы или удобства. Если ресурсов с запасом, можно смело ставить Docker — будете удобно обновлять и версионировать приложения, не боясь испортить операционную систему. Если же ресурсы в дефиците, то лучше использовать классическую схему установки приложений.&lt;/p&gt;
  &lt;p id=&quot;wW84&quot;&gt;&lt;strong&gt;Для больших приложений нужен оркестратор. &lt;/strong&gt;Docker подходит для запуска нескольких контейнеров. В стандартной поставке Docker Compose есть механизм, который позволяет управлять их запуском с помощью конфигурационного файла YAML. Но этот механизм простой, он не потянет приложение, включающее 50–100 сервисов. У Docker не хватит механизмов управления и распределения ресурсов, резервирования и отказоустойчивости, чтобы реализовывать разные схемы обновления контейнеров.&lt;/p&gt;
  &lt;p id=&quot;i5Lc&quot;&gt;В больших приложениях с микросервисной архитектурой используют оркестраторы &lt;a href=&quot;https://kubernetes.io/&quot; target=&quot;_blank&quot;&gt;Kubernetes&lt;/a&gt; или &lt;a href=&quot;https://www.redhat.com/en/technologies/cloud-computing/openshift&quot; target=&quot;_blank&quot;&gt;OpenShift&lt;/a&gt;. Единицей управления в Kubernetes является контейнер Docker, но на голом Docker прод практически никто не держит. Когда-то в России были такие компании — они рассказывали о своём травмирующем опыте на конференциях :)&lt;/p&gt;
  &lt;p id=&quot;deiL&quot;&gt;Kubernetes — это мощный слой абстракции над железом, альтернатива гипервизорам у виртуалок. Он позволяет настраивать политики безопасности, реализует различные схемы обновления и позволяет гибко управлять ресурсами.&lt;/p&gt;
  &lt;p id=&quot;Swfw&quot;&gt;&lt;strong&gt;Проблемы с установкой на Windows и macOS. &lt;/strong&gt;Как я сказал ранее, Docker создавался под Linux. На других операционках он не поддерживает некоторые типы сетей. В большинстве случаев никто этого не заметит, но об этом ограничении нужно помнить. Также на некоторых устройствах возникает &lt;a href=&quot;https://www.reddit.com/r/virtualbox/comments/kfov5h/docker_or_other_applications_conflicting_with/&quot; target=&quot;_blank&quot;&gt;конфликт с Virtual Box&lt;/a&gt; при установке Docker на Windows.&lt;/p&gt;
  &lt;h2 id=&quot;paragraph-4&quot;&gt;Аналоги Docker&lt;/h2&gt;
  &lt;p id=&quot;44RQ&quot;&gt;Docker стал стандартом де-факто в мире контейнеров. Часто, когда говорят про контейнеры, подразумевают именно Docker-контейнеры. Но это не единственная реализация технологии контейнеризации, есть и другие:&lt;/p&gt;
  &lt;ol id=&quot;E5au&quot;&gt;
    &lt;li id=&quot;umwN&quot;&gt;&lt;strong&gt;&lt;a href=&quot;https://podman.io/&quot; target=&quot;_blank&quot;&gt;PodMan&lt;/a&gt;&lt;/strong&gt;Имеет интерфейс командной строки, который очень похож на команды Docker. Основное отличие от докера заключается в том, что у Podman нет отдельного демона, это самостоятельная утилита. Podman используется как инструмент управления контейнерами по умолчанию в дистрибутиве Fedora Linux.&lt;/li&gt;
    &lt;li id=&quot;PqIB&quot;&gt;&lt;strong&gt;&lt;a href=&quot;https://linuxcontainers.org/lxc/&quot; target=&quot;_blank&quot;&gt;LXC&lt;/a&gt;&lt;/strong&gt;Система виртуализации на уровне ОС, а не самостоятельная платформа, как Docker. Она создает отдельное виртуальное окружение с собственным пространством процессов и сетевым стеком, в котором все контейнеры используют один экземпляр ядра ОС. LXC часто рассматривается как среднее между chroot и полноценной виртуальной машиной.&lt;/li&gt;
    &lt;li id=&quot;fwYv&quot;&gt;&lt;strong&gt;&lt;a href=&quot;https://github.com/rkt/rkt&quot; target=&quot;_blank&quot;&gt;rkt&lt;/a&gt;&lt;/strong&gt;Движок, который изначально был ориентирован на современные облачные приложения. В 2019 году разработка прекратилась, и движок переведен в архив. Возможно, еще можно встретить проекты, где он используется. Но в новых разработках rkt уже не стоит выбирать.&lt;/li&gt;
  &lt;/ol&gt;
  &lt;h2 id=&quot;paragraph-5&quot;&gt;Docker подходит для облаков&lt;/h2&gt;
  &lt;p id=&quot;xUxd&quot;&gt;Докер-контейнеры можно запускать не только на своих серверах, но и в облаке. Во-первых, это позволит не заниматься выбором, покупкой и настройкой серверов. Во-вторых, у облачных провайдеров разработано много готовых сервисов, которые позволяют получить дополнительные преимущества.&lt;/p&gt;
  &lt;h2 id=&quot;Dgny&quot;&gt;&lt;strong&gt;Как изучать Docker&lt;/strong&gt;&lt;/h2&gt;
  &lt;p id=&quot;0YXB&quot;&gt;Я рекомендую изучать Docker по книгам, сайтам и закреплять прочитанное на практике.&lt;/p&gt;
  &lt;p id=&quot;rSd4&quot;&gt;&lt;strong&gt;Книги.&lt;/strong&gt; Есть две хорошие книги — Using Docker и Docker in Action. Правда, они немного устарели (опубликованы в 2018–2019 годах), поэтому там может быть неактуальная информация. Надеюсь, скоро будет переиздание.&lt;/p&gt;
  &lt;p id=&quot;FM25&quot;&gt;&lt;strong&gt;Сайт &lt;a href=&quot;https://www.docker.com/&quot; target=&quot;_blank&quot;&gt;docker.com&lt;/a&gt;&lt;/strong&gt; — основной сайт Docker. На нём есть справочники и референсы по Docker, Docker-файлам, образам и Docker Compose. Читаете книгу, проверяете на сайте актуальность команд и изучаете примеры.&lt;/p&gt;
  &lt;p id=&quot;YAeu&quot;&gt;&lt;strong&gt;Упражнения.&lt;/strong&gt; &lt;/p&gt;
  &lt;ul id=&quot;avxp&quot;&gt;
    &lt;li id=&quot;5sAt&quot;&gt;Установите Docker на рабочий компьютер. Возьмите готовый Docker image с Docker Hub с базой данных и запустите на его основе контейнер. Это можно сделать по инструкции, которую производитель image выкладывает на Docker Hub. Затем подключитесь к запущенной БД каким-нибудь клиентом и убедитесь, что всё работает.&lt;/li&gt;
    &lt;li id=&quot;eicr&quot;&gt;Напишите простенький сервис REST API и Docker-файл для упаковки сервиса в образ, подглядывая в референсы или книгу. Ваша задача — разобраться в теории, получить Docker image и проставить теги.&lt;/li&gt;
    &lt;li id=&quot;Whov&quot;&gt;Из полученного ранее образа создайте и запустите контейнер. Вам придётся разобраться с параметрами команды Docker run, настройками портов, передачей переменных окружению, монтированием и основными параметрами. Также стоит научиться подключаться к контейнеру, выполнять bash-команды и смотреть логи приложения.&lt;/li&gt;
    &lt;li id=&quot;5U9w&quot;&gt;Усложните тестовый сервис, научив его работать с базой данных. Затем разверните контейнеры с сервисом и базой данных и соедините их внутренней сетью. Простое и в то же время очень полезное упражнение, на котором очень часто возникают затруднения на собеседованиях.&lt;/li&gt;
    &lt;li id=&quot;uHgC&quot;&gt;Переходим к Docker Compose. Посмотрите, как написать YAML и создать группу контейнеров, как соединять их в сеть и работать с маунтами.&lt;/li&gt;
    &lt;li id=&quot;UsW8&quot;&gt;Опубликуйте свой Docker image в Docker Hub. На одном аккаунте можно бесплатно публиковать только один образ, но есть GitLab, где нет таких ограничений. Правда, он устроен немного сложнее, новичок может запутаться. Ещё в том же GitLab можно создать приватный registry-режим и публиковать проекты без ограничений.&lt;/li&gt;
  &lt;/ul&gt;

</content></entry><entry><id>it255ru:h-ZEkECVmlU</id><link rel="alternate" type="text/html" href="https://teletype.in/@it255ru/h-ZEkECVmlU?utm_source=teletype&amp;utm_medium=feed_atom&amp;utm_campaign=it255ru"></link><title>Docker. Запускаем скрипт Bash внутри контейнера.</title><published>2021-07-27T06:39:18.233Z</published><updated>2022-10-07T12:23:10.750Z</updated><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://img3.teletype.in/files/6d/ad/6dad942a-8e47-4574-af87-99250a61da21.png"></media:thumbnail><summary type="html">&lt;img src=&quot;https://timeweb.com/media/default/0001/01/3e1f6baaf24c122a0c40fb932d2a241fafb21f48.png&quot;&gt;Мы создадим небольшое приложение на bash, обернем его в образ и запустим.</summary><content type="html">
  &lt;figure id=&quot;q2iq&quot; class=&quot;m_column&quot;&gt;
    &lt;img src=&quot;https://timeweb.com/media/default/0001/01/3e1f6baaf24c122a0c40fb932d2a241fafb21f48.png&quot; width=&quot;740&quot; /&gt;
  &lt;/figure&gt;
  &lt;p id=&quot;olsX&quot;&gt;Мы создадим небольшое приложение на bash, обернем его в образ и запустим.&lt;/p&gt;
  &lt;p id=&quot;ebAh&quot;&gt;В первую очередь эта статья будет полезна тем, кто уже знаком с контейнерами или Docker.&lt;/p&gt;
  &lt;h2 id=&quot;R4Uc&quot;&gt;Требования&lt;/h2&gt;
  &lt;p id=&quot;MSTf&quot;&gt;Все что требуется от сервера, чтобы запустить Docker – более-менее современная ОС Linux с ядром не ниже 3.8.&lt;/p&gt;
  &lt;p id=&quot;gxhB&quot;&gt;Для того чтобы выполнить необходимые действия, вам понадобятся:&lt;/p&gt;
  &lt;ul id=&quot;PxIL&quot;&gt;
    &lt;li id=&quot;3vNm&quot;&gt;установленная ОС Centos 7 с пользователем, который может выполнять команды sudo, и фаерволом;&lt;/li&gt;
  &lt;/ul&gt;
  &lt;p id=&quot;oaXa&quot;&gt;По умолчанию для выполнения команды &lt;code&gt;docker&lt;/code&gt; необходимо иметь root-привилегии. Однако команду можно выполнять и без добавления &lt;code&gt;sudo&lt;/code&gt;, если работать от имени пользователя, который находится в группе &amp;quot;docker&amp;quot;.&lt;/p&gt;
  &lt;p id=&quot;AkNV&quot;&gt;В данном руководстве предполагается, что сервер настроен так, чтобы выполнять команду &lt;code&gt;docker&lt;/code&gt; можно без использования &lt;code&gt;sudo&lt;/code&gt;.&lt;/p&gt;
  &lt;p id=&quot;qM0o&quot;&gt;Для такой настройки вам нужно ввести:&lt;/p&gt;
  &lt;pre id=&quot;9ZSw&quot;&gt;$ sudo usermod -aG docker ${USER}&lt;/pre&gt;
  &lt;p id=&quot;v4YG&quot;&gt;Текущий пользователь будет добавлен в группу &amp;quot;docker&amp;quot;. Для того чтобы изменения вступили в силу, выполните команду:&lt;/p&gt;
  &lt;pre id=&quot;RX9Z&quot;&gt;$ su - ${USER}&lt;/pre&gt;
  &lt;p id=&quot;UQfF&quot;&gt;Есть много способов гарантировать, что изменения вступят в силу, однако самый безопасный способ - перезагрузить компьютер. После перезагрузки вы должны теперь иметь возможность использовать докер со своим &amp;quot;обычным&amp;quot; пользователем (обратите внимание, что &lt;code&gt;sudo&lt;/code&gt; не используется):&lt;/p&gt;
  &lt;pre id=&quot;m7kH&quot;&gt;$ docker run hello-world&lt;/pre&gt;
  &lt;p id=&quot;11uB&quot;&gt;&lt;/p&gt;
  &lt;h3 id=&quot;ATY9&quot;&gt;Шаг 1. Установка Docker&lt;/h3&gt;
  &lt;p id=&quot;Zw22&quot;&gt;Для начала необходимо &lt;a href=&quot;https://docs.docker.com/engine/install/&quot; target=&quot;_blank&quot;&gt;установить Docker Engine&lt;/a&gt;&lt;/p&gt;
  &lt;p id=&quot;wMJV&quot;&gt;Следующим этапом &lt;a href=&quot;https://docs.docker.com/compose/install/&quot; target=&quot;_blank&quot;&gt;устанавливаем Docker Compose&lt;/a&gt;&lt;/p&gt;
  &lt;p id=&quot;zS7y&quot;&gt;Для того чтобы посмотреть версию Docker Engine и Tools, введите:&lt;/p&gt;
  &lt;pre id=&quot;Ttlr&quot;&gt;$ docker info &amp;amp;&amp;amp; docker version&lt;/pre&gt;
  &lt;p id=&quot;SVVR&quot;&gt;Если нужно удалить все пакеты Docker, которые, возможно, были установлены ранее:&lt;/p&gt;
  &lt;pre data-lang=&quot;bash&quot; id=&quot;QRIa&quot;&gt;$ apt-get remove docker docker-engine docker.io&lt;/pre&gt;
  &lt;p id=&quot;BezC&quot;&gt;А затем уже перейти к установке самого Docker.&lt;/p&gt;
  &lt;h3 id=&quot;t8B5&quot;&gt;&lt;/h3&gt;
  &lt;p id=&quot;B0d2&quot;&gt;Создадим структуру нашего проекта.&lt;/p&gt;
  &lt;p id=&quot;FyIk&quot;&gt;У меня есть каталог, содержащий только два файла, &lt;code&gt;Dockerfile&lt;/code&gt; и &lt;code&gt;sayhello.sh&lt;/code&gt;:&lt;/p&gt;
  &lt;pre data-lang=&quot;dockerfile&quot; id=&quot;QZxN&quot;&gt;.
├── Dockerfile
└── sayhello.sh&lt;/pre&gt;
  &lt;p id=&quot;OjRt&quot;&gt;&lt;code&gt;sayhello.sh&lt;/code&gt; содержит просто вывод сообщения в терминал.&lt;/p&gt;
  &lt;pre data-lang=&quot;bash&quot; id=&quot;Uiam&quot;&gt;#!/bin/sh
echo &amp;quot;hello from $HOSTNAME&amp;quot;&lt;/pre&gt;
  &lt;blockquote id=&quot;043z&quot;&gt;Если вы используете ОС Alpine то можете сразу запустить контейнер&lt;br /&gt;docker run -it --rm -v $(pwd):/src alpine /project/hello.sh&lt;/blockquote&gt;
  &lt;p id=&quot;H94s&quot;&gt;&lt;code&gt;Dockerfile&lt;/code&gt; содержит организацию рабочего пространства внутри нашего контейнера.&lt;/p&gt;
  &lt;pre data-lang=&quot;dockerfile&quot; id=&quot;z3IU&quot;&gt;# Для начала укажем базовый образ
# centos — это название официального репозитория Docker, 
# предоставляющего базовую версию популярной ОС семейства Linux
FROM centos:7
# Устанавливаем рабочую директорию для проекта в контейнере 
WORKDIR /project
# |ВАЖНЫЙ МОМЕНТ| копируем содержимое папки, где находится Dockerfile,  
# в рабочую директорию контейнера
COPY . /project
# команда для запуска приложения
# Главное предназначение CMD — это сообщить контейнеру какие команды 
# нужно выполнить при старте
CMD [&amp;quot;sayhello.sh&amp;quot;]&lt;/pre&gt;
  &lt;p id=&quot;0aRY&quot;&gt;Теперь можно создать образ. Команда &lt;code&gt;docker build&lt;/code&gt; занимается сложной задачей создания образа на основе &lt;code&gt;Dockerfile&lt;/code&gt;&lt;/p&gt;
  &lt;p id=&quot;jNLG&quot;&gt;&lt;strong&gt;Перед тем, как запустите команду сами (не забудьте точку в конце)&lt;/strong&gt;&lt;/p&gt;
  &lt;p id=&quot;KHO3&quot;&gt;Команда &lt;code&gt;docker build&lt;/code&gt; довольно проста: она принимает опциональный тег с флагом &lt;code&gt;-t&lt;/code&gt; и путь до директории, в которой лежит &lt;code&gt;Dockerfile&lt;/code&gt;.&lt;/p&gt;
  &lt;pre data-lang=&quot;bash&quot; id=&quot;TYmG&quot;&gt;$ docker build \
--build-arg ARTIFACTORY_USERNAME=timothy.mugayi \
--build-arg ARTIFACTORY_SECRET_TOKEN=AP284233QnYX9Ckrdr7pUEY1F \
--build-arg LICENSE_URL=&amp;#x27;https://source.com/license.txt&amp;#x27; \
--no-cache  -t helloworld:latest.&lt;/pre&gt;
  &lt;p id=&quot;34En&quot;&gt;Это создаст образ Docker с опциональными аргументами сборки. Docker будет по умолчанию кэшировать результаты для первой сборки Dockerfile или последующих сборок, основанных на слоях, добавленных к образу через команду &lt;code&gt;run&lt;/code&gt; в Dockerfile, что позволит этим сборкам работать быстрее. Если вам это не нужно, можете добавить аргумент “no-cache”, как это сделано в примере выше.&lt;/p&gt;
  &lt;blockquote id=&quot;YgGz&quot;&gt;&lt;strong&gt;Заметка:&lt;/strong&gt; команды Docker могут быть выполнены по имени или по ID контейнера. &lt;code&gt;&amp;lt;CONTAINER&amp;gt;&lt;/code&gt; допускает подстановку либо ID контейнера, либо его имени.&lt;/blockquote&gt;
  &lt;p id=&quot;Fky1&quot;&gt;&lt;code&gt;Dockerfile&lt;/code&gt; успешно построен:&lt;/p&gt;
  &lt;pre id=&quot;lMgP&quot;&gt;kurtpeek@Sophiemaries-MacBook-Pro ~/d/s/trybash&amp;gt; docker build --tag trybash .
Sending build context to Docker daemon 3.072 kB
Step 1/3 : FROM alpine
 ---&amp;gt; 665ffb03bfae
Step 2/3 : COPY sayhello.sh sayhello.sh
 ---&amp;gt; Using cache
 ---&amp;gt; fe41f2497715
Step 3/3 : CMD sayhello.sh
 ---&amp;gt; Using cache
 ---&amp;gt; dfcc26c78541
Successfully built dfcc26c78541&lt;/pre&gt;
  &lt;p id=&quot;0LC3&quot;&gt;Если все прошло хорошо, то образ готов! Запустите &lt;code&gt;docker images&lt;/code&gt; и увидите свой образ в списке.&lt;/p&gt;
  &lt;p id=&quot;BJcy&quot;&gt;Последний шаг — запустить образ и проверить его работоспособность (замените username на свой):&lt;/p&gt;
  &lt;pre id=&quot;fF2N&quot;&gt;$ docker run&lt;/pre&gt;
  &lt;p id=&quot;VC0M&quot;&gt;Поздравляю! Вы успешно создали свой первый образ Докера!&lt;/p&gt;
  &lt;p id=&quot;izyc&quot;&gt;&lt;/p&gt;
  &lt;p id=&quot;ZTRi&quot;&gt;&lt;a href=&quot;https://devopscube.com/run-scripts-docker-arguments/&quot; target=&quot;_blank&quot;&gt;link: https://devopscube.com/run-scripts-docker-arguments/&lt;/a&gt;&lt;/p&gt;

</content></entry><entry><id>it255ru:83iyLeZe_fQ</id><link rel="alternate" type="text/html" href="https://teletype.in/@it255ru/83iyLeZe_fQ?utm_source=teletype&amp;utm_medium=feed_atom&amp;utm_campaign=it255ru"></link><title>(LFCS) 6. Storage Management - 13%</title><published>2021-06-18T12:55:43.097Z</published><updated>2021-06-18T12:55:43.097Z</updated><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://teletype.in/files/0e/8d/0e8d28b1-6775-4cd8-a62d-eefb41781b73.png"></media:thumbnail><summary type="html">&lt;img src=&quot;https://teletype.in/files/1b/be/1bbe7eab-99d9-4025-b31a-e0ff47ad2722.png&quot;&gt;1. Essential Commands - 25%
2. Operation of Running Systems - 20%
3. User and Group Management - 10%
4. Networking - 12%
5. Service Configuration - 20%
6. Storage Management - 13%

6.1 List, create, delete, and modify physical storage partitions
6.2 Manage and configure LVM storage
6.3 Create and configure encrypted storage
6.4 Configure systems to mount file systems at or during boot
6.5 Configure and manage swap space
6.6 Create and manage RAID devices
6.7 Configure systems to mount file systems on demand
6.8 Create, manage and diagnose advanced file system permissions
6.9 Setup user and group disk quotas for filesystems
6.10 Create and configure file systems</summary><content type="html">
  &lt;figure class=&quot;m_original&quot;&gt;
    &lt;img src=&quot;https://teletype.in/files/1b/be/1bbe7eab-99d9-4025-b31a-e0ff47ad2722.png&quot; width=&quot;640&quot; /&gt;
    &lt;figcaption&gt;Linux Foundation Certified System Administrator (LFCS)&lt;/figcaption&gt;
  &lt;/figure&gt;
  &lt;p&gt;&lt;a href=&quot;/@it255ru/b_QRrhjE9rq&quot;&gt;&lt;strong&gt;1.&lt;/strong&gt; &lt;strong&gt;Essential Commands - 25%&lt;br /&gt;&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;2. Operation of Running Systems - 20%&lt;br /&gt;3. User and Group Management - 10%&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;4. Networking - 12%&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;5. Service Configuration - 20%&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;6. Storage Management - 13%&lt;br /&gt;&lt;br /&gt;&lt;/strong&gt;6.1 List, create, delete, and modify physical storage partitions&lt;br /&gt;6.2 Manage and configure LVM storage&lt;br /&gt;6.3 Create and configure encrypted storage&lt;br /&gt;6.4 Configure systems to mount file systems at or during boot&lt;br /&gt;6.5 Configure and manage swap space&lt;br /&gt;6.6 Create and manage RAID devices&lt;br /&gt;6.7 Configure systems to mount file systems on demand&lt;br /&gt;6.8 Create, manage and diagnose advanced file system permissions&lt;br /&gt;6.9 Setup user and group disk quotas for filesystems&lt;br /&gt;6.10 Create and configure file systems&lt;/p&gt;
  &lt;p&gt;&lt;/p&gt;
  &lt;p&gt;&lt;/p&gt;
  &lt;h2&gt;6.1 List, create, delete, and modify physical storage partitions&lt;/h2&gt;
  &lt;p&gt;&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;&lt;code&gt;lsblk&lt;/code&gt; lists all available disk devices plus available partitions&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;fdisk&lt;/code&gt; it is used to manage disk partition in MBR modality&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;E.g. &lt;code&gt;fdisk /dev/sda&lt;/code&gt;This will open an interactive menu that will permit to show current status of partitions or create a delete new partitions&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;&lt;code&gt;gdisk&lt;/code&gt; it is used to manage disk partition in GPT modality&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;E.g. &lt;code&gt;gdisk /dev/sda&lt;/code&gt;&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;Destroy all MBR partition on a disk&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;code&gt;gdisk /dev/sda&lt;/code&gt; -&amp;gt; &lt;code&gt;x&lt;/code&gt; (expert) -&amp;gt; &lt;code&gt;z&lt;/code&gt; (zap)&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;Convert MBT to GPT&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;code&gt;gdisk /dev/sda&lt;/code&gt; -&amp;gt; &lt;code&gt;W&lt;/code&gt; -&amp;gt; &lt;code&gt;Y&lt;/code&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/ul&gt;
  &lt;h2&gt;6.2 Manage and configure LVM storage&lt;/h2&gt;
  &lt;p&gt;&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;Before create a Logical Volume must be created in sequence a physical volume and after a volume group&lt;/li&gt;
    &lt;li&gt;A physical volume is a partition that can be part of volume group. Inside a volume group can be created logical volume&lt;/li&gt;
    &lt;li&gt;The advance of logical volume is that their dimension can be managed easly&lt;/li&gt;
    &lt;li&gt;If more space is need a volume group can be extended as well&lt;/li&gt;
  &lt;/ul&gt;
  &lt;p&gt;Physical Volume&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;&lt;code&gt;pvcreate /dev/sdb1&lt;/code&gt;To create a physical volume with partition sbd1&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;pvs&lt;/code&gt; lists available physical volumes&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;pvdisplay /dev/sdb1&lt;/code&gt; shows info of a physical volume&lt;/li&gt;
  &lt;/ul&gt;
  &lt;p&gt;Volume Group&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;&lt;code&gt;vgcreate vgname /dev/sdb1&lt;/code&gt;To create a volume group called &lt;em&gt;vgname&lt;/em&gt; and add the sdb1 physical volume to it&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;vgs&lt;/code&gt; lists available volume groups&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;vgdisplay vgname&lt;/code&gt; shows info of a volume group&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;vgextend vgname /dev/sdc3&lt;/code&gt; extends a volume group adding a new physical volume &lt;code&gt;/dev/sdc3&lt;/code&gt;&lt;/li&gt;
  &lt;/ul&gt;
  &lt;p&gt;Logical volume&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;&lt;code&gt;lvcreate -n volumename -L 10G vgname&lt;/code&gt;To create a logical volume called &lt;em&gt;volumename&lt;/em&gt; of size 10GB on volume group &lt;em&gt;vgname&lt;/em&gt;&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;lvcreate -n volumename -l 100%FREE vgname&lt;/code&gt;To create a logical volume called &lt;em&gt;volumename&lt;/em&gt; with all available space on volume group &lt;em&gt;vgname&lt;/em&gt;&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;lvs&lt;/code&gt; list available logical volumes&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;lvdisplay&lt;/code&gt; shows info of all logical volumes&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;lvdisplay vgname/volumename&lt;/code&gt; shows info of a logical volume &lt;em&gt;volumename&lt;/em&gt; contained in &lt;em&gt;vgname&lt;/em&gt; volume group&lt;/li&gt;
    &lt;li&gt;Before use a logical volume, a file system must be created on it&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;blkid /dev/vgname/volumename &lt;/code&gt;shows the UUID of a formatted volume group&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;lvextend -L +1G -r vgname/volumename &lt;/code&gt;extends the logical volume &lt;em&gt;volumename&lt;/em&gt; of one giga&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;code&gt;-r&lt;/code&gt; is used to resize file system&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;&lt;code&gt;lvreduce -L -1G -r vgname/volumename &lt;/code&gt;reduce the logical volume &lt;em&gt;volumename&lt;/em&gt; of one giga&lt;/li&gt;
  &lt;/ul&gt;
  &lt;h2&gt;6.3 Create and configure encrypted storage&lt;/h2&gt;
  &lt;p&gt;&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;To use encrypted storage a kernel module must be loaded&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;code&gt;sudo modprobe dm_crypt&lt;/code&gt; Loads kernel module dm_crypt&lt;/li&gt;
      &lt;li&gt;&lt;code&gt;echo dm_crypt &amp;gt;&amp;gt; /etc/modules-load.d/dm_crypt.conf&lt;/code&gt; to load dm_crypt module automatically when system will be restarted&lt;/li&gt;
      &lt;li&gt;&lt;code&gt;lsmod&lt;/code&gt; lists all loaded kernel modules&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;&lt;code&gt;yum -y install cryptsetup&lt;/code&gt; install software used to manage encrypted storage&lt;/li&gt;
  &lt;/ul&gt;
  &lt;p&gt;Encrypt&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;&lt;code&gt;cryptsetup luksFormat /dev/vgname/volumename&lt;/code&gt; encrypts a logical volume &lt;em&gt;volumename&lt;/em&gt; contained in &lt;em&gt;vgname&lt;/em&gt; volume group&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;A password must be provided&lt;/li&gt;
      &lt;li&gt;When confirmation will be required insert a capital YES&lt;/li&gt;
      &lt;li&gt;&lt;strong&gt;NOTE&lt;/strong&gt;: this command can be used with physical volume as well&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;&lt;code&gt;cryptsetup open --type luks /dev/vgname/volumename namenewdevice&lt;/code&gt;It open encrypted volume and associate it to a new device called &lt;em&gt;namenewdevice&lt;/em&gt;&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;Password must be provided&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;&lt;code&gt;mkfs.ext4 /dev/mapper/namenewdevice&lt;/code&gt;It creates a file system in &lt;em&gt;namenewdevice&lt;/em&gt;Now new the new device can be mounted&lt;/li&gt;
  &lt;/ul&gt;
  &lt;p&gt;Close device&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;Unmount device&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;cryptsetup close namenewdevice&lt;/code&gt;close &lt;em&gt;namenewdevice&lt;/em&gt;&lt;/li&gt;
  &lt;/ul&gt;
  &lt;p&gt;Automount&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;&lt;code&gt;echo &amp;quot;passwd&amp;quot; &amp;gt;&amp;gt; /root/key&lt;/code&gt; Insert a string that will be used that will be used as authentication key to open device&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;chmod 400 /root/key&lt;/code&gt; reduces permission on key file&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;cryptsetup luksAddKey /dev/mapper/namenewdevice /root/key&lt;/code&gt; add key to encrypted device called &lt;em&gt;namenewdevice&lt;/em&gt;&lt;/li&gt;
    &lt;li&gt;Edit &lt;code&gt;/etc/crypttab&lt;/code&gt; and add below row:&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;code&gt;namenewdevice /dev/vgname/volumename /root/key&lt;/code&gt;&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;Add below row to &lt;code&gt;/etc/fstab&lt;/code&gt;&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;code&gt;/dev/mapper/namenewdevice /mnt/mountpoint ext4 defaults 0 0&lt;/code&gt;&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;Reboot system or reload system manager&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;code&gt;systemctl daemon-reload&lt;/code&gt;&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;The new encrypted volume will be mounted on &lt;code&gt;/mnt/mountpoint&lt;/code&gt;&lt;/li&gt;
  &lt;/ul&gt;
  &lt;h2&gt;6.4 Configure systems to mount file systems at or during boot&lt;/h2&gt;
  &lt;p&gt;&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;Edit &lt;code&gt;/etc/fstab&lt;/code&gt; adding a row similar to:&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;/dev/sdb1 /mnt/mountpoint ext4 defaults 0 0&lt;/li&gt;
      &lt;ul&gt;
        &lt;li&gt;Mount device sdb1 to mountpoint.&lt;/li&gt;
        &lt;li&gt;Device is formatted using ext4 filesystem.&lt;/li&gt;
        &lt;li&gt;Default mount options are used&lt;/li&gt;
        &lt;li&gt;0 0 -&amp;gt; Dump (bkp) and fsck.&lt;/li&gt;
        &lt;ul&gt;
          &lt;li&gt;First 0 means no backup required&lt;/li&gt;
          &lt;li&gt;Second 0 means no fsck required in case of not correct umount. To enable fsck insert 2 because number indicate the check order, and 1 is given to operating system disk and two do data disks&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/ul&gt;
    &lt;/ul&gt;
    &lt;li&gt;&lt;code&gt;mount&lt;/code&gt; shows mounted volumes&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;mount -a&lt;/code&gt; reloads /etc/fstab&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;mount -t type -o options device dir&lt;/code&gt;&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;It mounts a &lt;em&gt;device&lt;/em&gt; formatted with file system &lt;em&gt;type&lt;/em&gt; on directory &lt;em&gt;dir&lt;/em&gt; using a list of options&lt;/li&gt;
      &lt;li&gt;options can be:&lt;/li&gt;
      &lt;ul&gt;
        &lt;li&gt;async -&amp;gt; I/O asincrono&lt;/li&gt;
        &lt;li&gt;auto -&amp;gt; Can be mounted using mount -a&lt;/li&gt;
        &lt;li&gt;default -&amp;gt;Equal to this list of options: async,auto,dev,exec,nouser,rw,suid&lt;/li&gt;
        &lt;li&gt;loop -&amp;gt; To mount an ISO image&lt;/li&gt;
        &lt;li&gt;noexec -&amp;gt; no exec&lt;/li&gt;
        &lt;li&gt;nouser -&amp;gt; A user cannot mount this volume&lt;/li&gt;
        &lt;li&gt;remount -&amp;gt; Mount volume also if it is already mounted&lt;/li&gt;
        &lt;li&gt;ro -&amp;gt; Read only&lt;/li&gt;
        &lt;li&gt;rw -&amp;gt; Read an write&lt;/li&gt;
        &lt;li&gt;relatime -&amp;gt; Modify file access time (atime) if file is changed or one time a day. Alternative, to reduce disk traffic, noatime can be used. This is useful with SSD to avoid not useful write.&lt;/li&gt;
      &lt;/ul&gt;
    &lt;/ul&gt;
  &lt;/ul&gt;
  &lt;p&gt;SMB protocol&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;&lt;code&gt;yum -y install samba-client cifs-utils&lt;/code&gt; it installs software need to manage CIFS/SMB protocol&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;smbclient -L targetIP&lt;/code&gt;It lists all SMB shared directory available on a target IP&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;root password must be provided&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;&lt;code&gt;mount -t cifs -o username=smbuser,password=1234pwd //192.168.0.10/share /media/samba&lt;/code&gt;It mounts a directory &lt;em&gt;share&lt;/em&gt;, shared by server 192.168.0.10 on samba directory. User and password to authentication are provided&lt;/li&gt;
    &lt;li&gt;Permanent configuration&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;code&gt;echo &amp;quot;username=smbuser&amp;quot; &amp;gt;&amp;gt; /media/smb/.smbconf&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;&lt;code&gt;echo &amp;quot;password=1234pwd&amp;quot; &amp;gt;&amp;gt; /media/smb/.smbconf&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;&lt;code&gt;chmod 600 /media/smb/.smbconf&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;In &lt;code&gt;/etc/fstab&lt;/code&gt; insert:&lt;/li&gt;
      &lt;ul&gt;
        &lt;li&gt;&lt;code&gt;//192.168.0.10/share /media/samba cifs credentials=/media/samba/.smbcredentials,defaults 0 0&lt;/code&gt;&lt;/li&gt;
      &lt;/ul&gt;
    &lt;/ul&gt;
  &lt;/ul&gt;
  &lt;p&gt;NFS protocol&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;&lt;code&gt;yum -y install nfs-utils&lt;/code&gt; it install software to manage NFS protocol&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;showmount -e targetIP&lt;/code&gt;It lists all NFS shared directory available on a target IP&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;mount -t nfs -o defaults 192.168.0.10:/srv/nfs /media/nfs&lt;/code&gt;It mounts a directory &lt;em&gt;nfs&lt;/em&gt;, shared by server 192.168.0.10 on nfs directory&lt;/li&gt;
    &lt;li&gt;Permanent configuration&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;In &lt;code&gt;/etc/fstab&lt;/code&gt; insert:&lt;/li&gt;
      &lt;ul&gt;
        &lt;li&gt;&lt;code&gt;192.168.0.10:/srv/nfs /media/nfs nfs defaults 0 0&lt;/code&gt;&lt;/li&gt;
      &lt;/ul&gt;
      &lt;li&gt;To user NFSv3 insert:&lt;/li&gt;
      &lt;ul&gt;
        &lt;li&gt;&lt;code&gt;192.168.0.10:/srv/nfs /media/nfs nfs defaults,vers=3 0 0&lt;/code&gt;&lt;/li&gt;
      &lt;/ul&gt;
    &lt;/ul&gt;
  &lt;/ul&gt;
  &lt;h2&gt;6.5 Configure and manage swap space&lt;/h2&gt;
  &lt;p&gt;&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;To use a device as swap space:&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;code&gt;mkswap /dev/sdb3&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;&lt;code&gt;swapon -v /deb/sdb3&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;In &lt;code&gt;/etc/fstab&lt;/code&gt; insert:&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/ul&gt;
  &lt;ul&gt;
    &lt;ul&gt;
      &lt;ul&gt;
        &lt;li&gt;&lt;code&gt;/dev/sdb3 swap swap defaults 0 0&lt;/code&gt;&lt;/li&gt;
      &lt;/ul&gt;
    &lt;/ul&gt;
  &lt;/ul&gt;
  &lt;h2&gt;6.6 Create and manage RAID devices&lt;/h2&gt;
  &lt;p&gt;&lt;/p&gt;
  &lt;p&gt;Concepts:&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;Parity disk. It is used to provide fault tolerance.&lt;/li&gt;
    &lt;li&gt;The spare device. It not take part of RAID and it is used only in case of a disk fault. In this case spare enter in the RAID and the content of lost disk is reconstructed and saved on it.&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;yum -y install mdadm&lt;/code&gt; installs software to manage RAID devices&lt;/li&gt;
    &lt;li&gt;RAID 0 - Striped - No spare&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;code&gt;mdadm --create --verbose /dev/md0 --level=stripe --raid-devices=2 /dev/sdb1 /dev/sdc1&lt;/code&gt;&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;RAID 1 - Mirror&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;code&gt;mdadm --create --verbose /dev/md0 --level=1 --raid-devices=2 /dev/sdb1 /dev/sdc1&lt;/code&gt;&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;RAID 5 - (1 parity + 1 spare)&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;code&gt;mdadm --create --verbose /dev/md0 --level=5 --raid-devices=3 /dev/sdb1 /dev/sdc1&lt;/code&gt; &lt;code&gt;/dev/sdd1 --spare-devices=1 /dev/sde1&lt;/code&gt;&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;RAID 6 - (2 parity + 1 spare)&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;code&gt;mdadm --create --verbose /dev/md0 --level=6 --raid-devices=4 /dev/sdb1 /dev/sdc1&lt;/code&gt; &lt;code&gt;/dev/sdd1 /dev/sde --spare-devices=1 /dev/sdf1&lt;/code&gt;&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;RAID 10 - (Stripe + Mirror + 1 spare)&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;code&gt;mdadm --create --verbose /dev/md0 --level=10 --raid-devices=4 /dev/sd[b-e]1 --spare-devices=1 /dev/sdf1&lt;/code&gt;&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;&lt;code&gt;mdadm --detail /dev/md0&lt;/code&gt; shows status of RAID device&lt;/li&gt;
    &lt;li&gt;To use device md0, format it and use as a classical device&lt;/li&gt;
  &lt;/ul&gt;
  &lt;p&gt;Monitoring RAID devices&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;&lt;code&gt;mdadm --assemble --scan&lt;/code&gt;&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;mdadm --detail --scan &amp;gt;&amp;gt; /etc/mdadm.conf&lt;/code&gt;&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;echo &amp;quot;MAILADDR root&amp;quot; &amp;gt;&amp;gt; /etc/mdadm.conf&lt;/code&gt;&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;systemctl start mdmonitor&lt;/code&gt;&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;systemctl enable mdmonitor&lt;/code&gt;&lt;/li&gt;
  &lt;/ul&gt;
  &lt;p&gt;Add disk&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;&lt;code&gt;mdadm /dev/md0 --add /dev/sbc2&lt;/code&gt;&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;mdadm --grow --raid-devices=4 /dev/md0&lt;/code&gt;It adds a spare disk and after it grows array&lt;/li&gt;
  &lt;/ul&gt;
  &lt;p&gt;Remove disk&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;&lt;code&gt;mdadm /dev/md0 --fail /dev/sdc1 --remove /dev/sdc1mdadm --grow /dev/md0 --raid-devices=2&lt;/code&gt;It mark disk as failed and remove it. After the size of array must be adjusted&lt;/li&gt;
  &lt;/ul&gt;
  &lt;p&gt;Delete RAID&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;Unmount device&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;mdadm --stop /dev/md0&lt;/code&gt;&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;mdadm --zero-superblock /dev/sbc2&lt;/code&gt; It clean partition that, after, can be reused&lt;/li&gt;
  &lt;/ul&gt;
  &lt;p&gt;References:&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;&lt;a href=&quot;https://raid.wiki.kernel.org/index.php/A_guide_to_mdadm&quot; target=&quot;_blank&quot;&gt;https://raid.wiki.kernel.org/index.php/A_guide_to_mdadm&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;
  &lt;h2&gt;6.7 Configure systems to mount file systems on demand&lt;/h2&gt;
  &lt;p&gt;&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;&lt;code&gt;yum -y install autofs&lt;/code&gt; installs software need to manage automount&lt;/li&gt;
  &lt;/ul&gt;
  &lt;p&gt;Automount NFS directory&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;Edit &lt;code&gt;/etc/auto.master&lt;/code&gt; and insert:&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;code&gt;/media /etc/nfs.misc --timeout=60&lt;/code&gt;&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;Edit &lt;code&gt;/etc/nfs.misc&lt;/code&gt; and insert:&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;code&gt;nfs -fstype=nfs 192.168.0.10:/srv/nfs&lt;/code&gt;&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;&lt;code&gt;systemctl start autofs&lt;/code&gt;&lt;/li&gt;
  &lt;/ul&gt;
  &lt;h2&gt;6.8 Create, manage and diagnose advanced file system permissions&lt;/h2&gt;
  &lt;p&gt;&lt;/p&gt;
  &lt;p&gt;&lt;strong&gt;ACL Access control list&lt;/strong&gt;&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;They must be supported by filesystem&lt;/li&gt;
    &lt;li&gt;With some old filesystem a mount option (e.g. &lt;em&gt;acl&lt;/em&gt;) must be provided to enable ACL&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;getfacl file&lt;/code&gt; shows ACL applied to a file&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;setfacl -R -m g:sales:rx file&lt;/code&gt; set ACL on file&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;code&gt;-R&lt;/code&gt; recursive, if file is a directory, ACL will be applied to all file inside it&lt;/li&gt;
      &lt;li&gt;&lt;code&gt;-m&lt;/code&gt; modify&lt;/li&gt;
      &lt;li&gt;&lt;code&gt;g:sales:rx&lt;/code&gt; group sales can read and execute&lt;/li&gt;
      &lt;ul&gt;
        &lt;li&gt;&lt;code&gt;g&lt;/code&gt; group&lt;/li&gt;
        &lt;li&gt;&lt;code&gt;u&lt;/code&gt; user&lt;/li&gt;
        &lt;li&gt;&lt;code&gt;o&lt;/code&gt; other&lt;/li&gt;
      &lt;/ul&gt;
    &lt;/ul&gt;
    &lt;li&gt;&lt;code&gt;setfacl -m u:dummy:- file&lt;/code&gt; remove all permissions of user dummy.&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;setfacl -m d:g:sales:rx directory&lt;/code&gt; set a default ACL to a directory. In this way all files created inside it will have same ACL as defaultThe default ACL is a specific type of permission assigned to a directory, that doesn’t change the permissions of the directory itself, but makes so that specified ACLs are set by default on all the files created inside of it&lt;/li&gt;
    &lt;li&gt;If an ACL is applied, when &lt;code&gt;ls -la&lt;/code&gt; is executed an + is inserted after other permissions&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;setfacl -x u:test:w test&lt;/code&gt; remove ACL&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;setfacl -b file&lt;/code&gt; removes all ACL&lt;/li&gt;
  &lt;/ul&gt;
  &lt;p&gt;&lt;strong&gt;Extended attributes&lt;/strong&gt;&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;They are file properties&lt;/li&gt;
    &lt;li&gt;With some old filesystem a mount option (e.g. &lt;em&gt;user_xattr&lt;/em&gt;) must be provided to enable extended attributes&lt;/li&gt;
    &lt;li&gt;Only root user can remove an attribute&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;chattr +i file&lt;/code&gt; add &lt;em&gt;immutable&lt;/em&gt; attribute to a file. It cannot be deleted or removed&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;chattr -i file&lt;/code&gt; remove &lt;em&gt;immutable&lt;/em&gt; attribute from a file.&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;lsattr file&lt;/code&gt; shows file&amp;#x27;s extended attributes&lt;/li&gt;
  &lt;/ul&gt;
  &lt;h2&gt;6.9 Setup user and group disk quotas for filesystems&lt;/h2&gt;
  &lt;p&gt;&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;&lt;strong&gt;Quota&lt;/strong&gt;: space that can be used by an user on one specific filesystem&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;NOTE: To limit space in a directory it is better create a specific mount point with a specific partition&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;&lt;code&gt;yum -y install quota&lt;/code&gt; installs software need to manage quota&lt;/li&gt;
    &lt;li&gt;&lt;em&gt;usrquota,grpquota&lt;/em&gt; mount options must be inserted for filesystem to which enable quota (e.g. editing &lt;code&gt;/etc/fstab&lt;/code&gt;)&lt;/li&gt;
    &lt;li&gt;After that options are inserted, remount partition to enable them&lt;/li&gt;
    &lt;li&gt;After remount execute &lt;code&gt;quotacheck -mavug&lt;/code&gt; that check used blocks and inserted them in a tracking file&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;Two files will be created:&lt;/li&gt;
      &lt;ul&gt;
        &lt;li&gt;aquota.group&lt;/li&gt;
        &lt;li&gt;aquota.user&lt;/li&gt;
      &lt;/ul&gt;
    &lt;/ul&gt;
    &lt;li&gt;&lt;code&gt;quotaon -a&lt;/code&gt; start quota system&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;Alternative:&lt;/li&gt;
      &lt;li&gt;&lt;code&gt;quotaon -vu /mnt/mountpoint&lt;/code&gt; it starts only quota user for specific mountpoint&lt;/li&gt;
      &lt;li&gt;&lt;code&gt;quotaon -vg /mnt/mountpoint&lt;/code&gt; it starts only quota group for specific mountpoint&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;&lt;code&gt;quota -vu user&lt;/code&gt; shows user&amp;#x27;s quota&lt;/li&gt;
    &lt;li&gt;The quota is specified in blocks of 1K size and in number of inode that is the number of files that can be created&lt;/li&gt;
    &lt;li&gt;Hard limit: maxim value allowed&lt;/li&gt;
    &lt;li&gt;Soft limit: a limit that can be exceeded for a &lt;em&gt;grace period&lt;/em&gt;. Default &lt;em&gt;grace period&lt;/em&gt; is a week&lt;/li&gt;
    &lt;li&gt;When grace period is reached, soft limit become and hard limit&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;edquota -t&lt;/code&gt; Edit the grace period. Is an unique value for all system&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;edquota -u user&lt;/code&gt; edit user&amp;#x27;s quota&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;In each column can be insert a value for soft and hard limit for blocks and inode&lt;/li&gt;
      &lt;li&gt;&lt;strong&gt;NOTE&lt;/strong&gt;: Normally soft and hard limits are configured equal to avoid confusion&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;&lt;code&gt;repquota -aug&lt;/code&gt; It shows an overview of current quota for each users&lt;/li&gt;
  &lt;/ul&gt;
  &lt;h2&gt;6.10 Create and configure file systems&lt;/h2&gt;
  &lt;p&gt;&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;&lt;code&gt;mkfs.ext4 /dev/sdb1&lt;/code&gt; creates an filesystem ext4 on sdb1 partition&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;fsck.ext4 /dev/sdb1&lt;/code&gt; checks the integrity of sdb1 filesystem&lt;/li&gt;
  &lt;/ul&gt;

</content></entry><entry><id>it255ru:0gP3kOJAuh3</id><link rel="alternate" type="text/html" href="https://teletype.in/@it255ru/0gP3kOJAuh3?utm_source=teletype&amp;utm_medium=feed_atom&amp;utm_campaign=it255ru"></link><title>(LFCS) 5. Service Configuration - 20%</title><published>2021-06-18T12:46:51.467Z</published><updated>2021-06-18T12:46:51.467Z</updated><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://teletype.in/files/0e/8d/0e8d28b1-6775-4cd8-a62d-eefb41781b73.png"></media:thumbnail><summary type="html">&lt;img src=&quot;https://teletype.in/files/1b/be/1bbe7eab-99d9-4025-b31a-e0ff47ad2722.png&quot;&gt;1. Essential Commands - 25%
2. Operation of Running Systems - 20%
3. User and Group Management - 10%
4. Networking - 12%
5. Service Configuration - 20%</summary><content type="html">
  &lt;figure class=&quot;m_original&quot;&gt;
    &lt;img src=&quot;https://teletype.in/files/1b/be/1bbe7eab-99d9-4025-b31a-e0ff47ad2722.png&quot; /&gt;
    &lt;figcaption&gt;Linux Foundation Certified System Administrator (LFCS)&lt;/figcaption&gt;
  &lt;/figure&gt;
  &lt;p&gt;&lt;a href=&quot;/@it255ru/b_QRrhjE9rq&quot;&gt;&lt;strong&gt;1.&lt;/strong&gt; &lt;strong&gt;Essential Commands - 25%&lt;br /&gt;&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;2. Operation of Running Systems - 20%&lt;br /&gt;3. User and Group Management - 10%&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;4. Networking - 12%&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;5. Service Configuration - 20%&lt;/strong&gt;&lt;/p&gt;
  &lt;p&gt;5.1 Configure a caching DNS server&lt;br /&gt;5.2 Maintain a DNS zone&lt;br /&gt;5.3 Configure email aliases&lt;br /&gt;5.4 Configure SSH servers and clients&lt;br /&gt;5.5 Restrict access to the HTTP proxy server&lt;br /&gt;5.6 Configure an IMAP and IMAPS service&lt;br /&gt;5.7 Query and modify the behavior of system services at various operating modes&lt;br /&gt;5.8 Configure an HTTP server&lt;br /&gt;5.9 Configure HTTP server log files&lt;br /&gt;5.10 Configure a database server&lt;br /&gt;5.11 Restrict access to a web page&lt;br /&gt;5.12 Manage and configure containers&lt;br /&gt;5.13 Manage and configure Virtual Machines&lt;br /&gt;&lt;strong&gt;&lt;br /&gt;6. Storage Management - 13%&lt;/strong&gt;&lt;/p&gt;
  &lt;p&gt;&lt;/p&gt;
  &lt;h2&gt;5.1 Configure a caching DNS server&lt;/h2&gt;
  &lt;p&gt;&lt;/p&gt;
  &lt;figure class=&quot;m_original&quot;&gt;
    &lt;img src=&quot;https://teletype.in/files/60/fe/60fec1b4-d402-4238-ba39-b77f88b379d9.png&quot; width=&quot;503&quot; /&gt;
  &lt;/figure&gt;
  &lt;ul&gt;
    &lt;li&gt;Linux DNS server is &lt;em&gt;bind&lt;/em&gt;&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;code&gt;yum -y install bind bind-utils&lt;/code&gt;&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;Main configuration file &lt;code&gt;/etc/named.conf&lt;/code&gt;&lt;/li&gt;
    &lt;li&gt;Most important configurations:&lt;/li&gt;
  &lt;/ul&gt;
  &lt;pre&gt;options {
        listen-on port 53 { 127.0.0.1; 192.168.0.0/24; };
		...
        allow-query        { localhost; 192.168.0.0/24; };
        allow-query-cache  { localhost; 192.168.0.0/24; };
		...
        recursion yes;
        forwarders {
                8.8.8.8;
                8.8.4.4;
        };
		...
};

zone &amp;quot;test.com.&amp;quot; IN {
        type master;
        file &amp;quot;/var/named/test.com.zone&amp;quot;;
};

zone &amp;quot;0.168.192.in-addr.arpa&amp;quot; IN {
        type master;
        file &amp;quot;/var/named/rev.test.com.zone&amp;quot;;
};&lt;/pre&gt;
  &lt;ul&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;code&gt;listen-on port 53&lt;/code&gt; tell on which network interfaces and port to accept client queries.&lt;/li&gt;
      &lt;li&gt;&lt;code&gt;allow-query&lt;/code&gt; defines the networks from which clients can post DNS requests.&lt;/li&gt;
      &lt;li&gt;&lt;code&gt;allow-query-cache&lt;/code&gt; defines the addresses/networks from which clients are allowed to issue queries that access the local cache.&lt;/li&gt;
      &lt;li&gt;&lt;code&gt;forwarders&lt;/code&gt; specifies the name servers to which DNS requests should be forwarded if they cannot be resolved directly.&lt;/li&gt;
      &lt;li&gt;&lt;code&gt;zone&lt;/code&gt; contains domain configuration. After &lt;code&gt;zone&lt;/code&gt;, specify the name of the domain to administer.&lt;/li&gt;
      &lt;ul&gt;
        &lt;li&gt;&lt;code&gt;file&lt;/code&gt; specifies the file where zone data for the domain is located.&lt;/li&gt;
      &lt;/ul&gt;
      &lt;li&gt;&lt;code&gt;zone &amp;quot;0.168.192.in-addr.arpa&amp;quot;&lt;/code&gt; is the configuration for reverse zone or reverse lookup. A reverse zone allows DNS to convert from an address to a name.&lt;/li&gt;
      &lt;ul&gt;
        &lt;li&gt;&lt;code&gt;0.168.192&lt;/code&gt; must be substituted with the first three octets of whatever network addresses range are managed&lt;/li&gt;
      &lt;/ul&gt;
    &lt;/ul&gt;
    &lt;li&gt;&lt;code&gt;systemctl start named&lt;/code&gt; start bind server&lt;/li&gt;
  &lt;/ul&gt;
  &lt;p&gt;References:&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;&lt;a href=&quot;http://web.deu.edu.tr/doc/oreily/networking/dnsbind/ch02_06.htm&quot; target=&quot;_blank&quot;&gt;http://web.deu.edu.tr/doc/oreily/networking/dnsbind/ch02_06.htm&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;https://www.pks.mpg.de/~mueller/docs/suse10.1/suselinux-manual_en/manual/sec.dns.named.html&quot; target=&quot;_blank&quot;&gt;https://www.pks.mpg.de/~mueller/docs/suse10.1/suselinux-manual_en/manual/sec.dns.named.html&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;
  &lt;h2&gt;5.2 Maintain a DNS zone&lt;/h2&gt;
  &lt;ul&gt;
    &lt;li&gt;&lt;code&gt;/var/named/test.com.zone&lt;/code&gt; &lt;/li&gt;
  &lt;/ul&gt;
  &lt;pre&gt;$TTL 3H
@       IN SOA  dns root.test.com. (
                                        0       ; serial
                                        1D      ; refresh
                                        1H      ; retry
                                        1W      ; expire
                                        3H )    ; minimum
        IN NS   dns
        IN MX   10 email

dns     IN A    192.168.0.29
email   IN A    192.168.0.29
web     IN A    192.168.0.29
www.web IN CNAME web&lt;/pre&gt;
  &lt;ul&gt;
    &lt;ul&gt;
      &lt;li&gt;Line 2: This is where the SOA (start of authority) control record begins.&lt;/li&gt;
      &lt;ul&gt;
        &lt;li&gt;&lt;code&gt;@&lt;/code&gt; means that zone name will be extracted from the corresponding entry in &lt;code&gt;/etc/named.conf&lt;/code&gt; (in this example test.com.)&lt;/li&gt;
        &lt;li&gt;&lt;code&gt;dns&lt;/code&gt; is the name of authoritative server for the zone&lt;/li&gt;
        &lt;li&gt;&lt;code&gt;root.test.com.&lt;/code&gt; an e-mail address of the person in charge of this name server. Because the &lt;code&gt;@&lt;/code&gt; sign already has a special meaning, &lt;code&gt;.&lt;/code&gt; is entered here instead. For &lt;code&gt;root@test.com&lt;/code&gt; the entry must read&lt;code&gt;root.test.com.&lt;/code&gt;&lt;/li&gt;
      &lt;/ul&gt;
      &lt;li&gt;Line 8: The &lt;code&gt;IN NS&lt;/code&gt; specifies the name server responsible for this domain (authoritative server)&lt;/li&gt;
      &lt;li&gt;Line 9: The &lt;code&gt;MX&lt;/code&gt; record specifies the mail server that accepts, processes, and forwards e-mails for this domain&lt;/li&gt;
      &lt;li&gt;Last lines: These are the actual address records where one or more IP addresses are assigned to hostnames.&lt;/li&gt;
      &lt;ul&gt;
        &lt;li&gt;CNAMES maps a name on another name&lt;/li&gt;
      &lt;/ul&gt;
    &lt;/ul&gt;
    &lt;li&gt;&lt;code&gt;/var/named/rev.test.com.zone&lt;/code&gt; contents:&lt;/li&gt;
  &lt;/ul&gt;
  &lt;pre&gt;$TTL 3H
@       IN SOA  dns.test.com. root.test.com. (
                                        0       ; serial
                                        1D      ; refresh
                                        1H      ; retry
                                        1W      ; expire
                                        3H )    ; minimum
        IN NS   dns.test.com.

29      IN PTR  dns.test.com.&lt;/pre&gt;
  &lt;ul&gt;
    &lt;ul&gt;
      &lt;li&gt;Line 2: The configuration file should activate reverse lookup for the network &lt;code&gt;192.168.1.0&lt;/code&gt;. Given that the zone is called &lt;code&gt;1.168.192.in-addr.arpa&lt;/code&gt;, should not be added to the hostnames. Therefore, all hostnames are entered in their complete form—with their domain and with a &lt;code&gt;.&lt;/code&gt; at the end. The remaining entries correspond to those described for the &lt;code&gt;test.com.&lt;/code&gt; zone&lt;/li&gt;
      &lt;li&gt;Line 8: This line specifies the name server responsible for this zone. This time, however, the name is entered in its complete form with the domain and a &lt;code&gt;.&lt;/code&gt; at the end.&lt;/li&gt;
      &lt;li&gt;Line 10: This is the pointer record hinting at the IP addresses on the respective hosts. Only the last part of the IP address is entered at the beginning of the line, without the &lt;code&gt;.&lt;/code&gt; at the end.&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;&lt;strong&gt;NOTE&lt;/strong&gt;: Examples of configuration files are contained in &lt;code&gt;/usr/share/doc/bind-9.9.4/sample&lt;/code&gt;&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;code&gt;bind&lt;/code&gt; directory name depends by installed version&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;To check name resolution is possible to use &lt;code&gt;host&lt;/code&gt;&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;code&gt;host name_to_resolve dns_server_ip&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;E.g. &lt;code&gt;host dns localhost&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;E.g of reverse zone &lt;code&gt;host 192.168.0.29 localhost&lt;/code&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/ul&gt;
  &lt;p&gt;References:&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;&lt;a href=&quot;https://www.pks.mpg.de/~mueller/docs/suse10.1/suselinux-manual_en/manual/sec.dns.zonefile.html&quot; target=&quot;_blank&quot;&gt;https://www.pks.mpg.de/~mueller/docs/suse10.1/suselinux-manual_en/manual/sec.dns.zonefile.html&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;
  &lt;h2&gt;5.3 Configure email aliases&lt;/h2&gt;
  &lt;p&gt;&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;To manage mail spool&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;code&gt;yum -y install mailx&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;&lt;code&gt;mailx&lt;/code&gt; reads the user&amp;#x27;s mail spool&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;Send an email to spool&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;code&gt;echo &amp;quot;Test&amp;quot; | mail -s &amp;quot;Oggetto&amp;quot; root&lt;/code&gt;&lt;em&gt;root&lt;/em&gt; is target user&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;To create an alias edit file &lt;code&gt;/etc/aliases&lt;/code&gt;&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;Add line like &lt;code&gt;root: user,root&lt;/code&gt;This create an alias for &lt;code&gt;root&lt;/code&gt; and this means that email for root will be sent to &lt;code&gt;user&lt;/code&gt; and &lt;code&gt;root&lt;/code&gt; mail spool&lt;/li&gt;
      &lt;li&gt;&lt;code&gt;root: user@test.com&lt;/code&gt;Whit this syntax will be added a classical email address&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;At the end of changes to &lt;code&gt;/etc/aliases&lt;/code&gt; execute &lt;code&gt;newaliases&lt;/code&gt; to apply changes&lt;/li&gt;
  &lt;/ul&gt;
  &lt;h2&gt;5.4 Configure SSH servers and clients&lt;/h2&gt;
  &lt;p&gt;&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;&lt;code&gt;/etc/ssh/sshd_config&lt;/code&gt; ssh server configuration file&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;code&gt;PermitRootLogin no&lt;/code&gt; Disable &lt;code&gt;root&lt;/code&gt; login with ssh client&lt;/li&gt;
      &lt;li&gt;&lt;code&gt;PasswordAuthenticaion no&lt;/code&gt; Disable login with password. This means that only login with public and private keys is allowed&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;&lt;code&gt;/etc/ssh/ssh_config&lt;/code&gt; ssh client configuration file&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;code&gt;ForwardX11 yes&lt;/code&gt; allows use of X11 Server with ssh&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/ul&gt;
  &lt;p&gt;Server management&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;&lt;code&gt;systemctl status sshd&lt;/code&gt; to control ssh server status&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;systemctl stop sshd&lt;/code&gt; stop ssh server&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;systemct start sshd&lt;/code&gt; start ssh server&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;systemctl restart sshd&lt;/code&gt; restart ssh server&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;It must be executed each time configuration file will be changed&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;&lt;code&gt;systemctl disable sshd&lt;/code&gt; disable the ssh server start at boot&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;systemctl enable sshd&lt;/code&gt; enable the ssh server start at boot&lt;/li&gt;
  &lt;/ul&gt;
  &lt;p&gt;Client commands&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;&lt;code&gt;ssh 129.123.123.123 &lt;/code&gt;it try to connect current user to an ssh server located on 192.123.123.123&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;ssh root@129.123.123.123 &lt;/code&gt;it try to connect root user to an ssh server located on 192.123.123.123&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;ssh -X root@129.123.123.123&lt;/code&gt;&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;code&gt;-X&lt;/code&gt; enable X11 forwarding. This means that graphical application can be started&lt;/li&gt;
      &lt;li&gt;NOTE: It must be allowed on client configuration file as well.&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;First time that an ssh connection is established with a server, the server will send a public key that it is used to verify its identity.&lt;/li&gt;
    &lt;li&gt;The server public key is stored in the user&amp;#x27;s home inside file&lt;code&gt;.ssh/know_hosts&lt;/code&gt;&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;E.g. &lt;code&gt;/home/user/.ssh/know_hosts&lt;/code&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/ul&gt;
  &lt;p&gt;Authentication with public/private keys&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;On the ssh client machine a couple of ssh public/private keys can be generated using &lt;code&gt;ssh-keygen&lt;/code&gt;&lt;/li&gt;
    &lt;li&gt;The keys will be stored in the user&amp;#x27;s home inside directory &lt;code&gt;.ssh&lt;/code&gt;&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;code&gt;id_rsa&lt;/code&gt; private key&lt;/li&gt;
      &lt;li&gt;&lt;code&gt;id_rsa.pub&lt;/code&gt; public key&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;&lt;code&gt;ssh-copy-id 123.123.123.123&lt;/code&gt; it is used to copy current user public key to home directory of same user on ssh server. The key will be stored in the user&amp;#x27;s home inside file &lt;code&gt;.ssh/authorized_keys&lt;/code&gt;&lt;/li&gt;
    &lt;li&gt;After that public key is copied on the server, user can use ssh client to login into the server without providing password&lt;/li&gt;
  &lt;/ul&gt;
  &lt;p&gt;scp&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;Secure copy. It use ssh to copy file on a server&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;scp /test/source 123.123.123.123:/dest&lt;/code&gt; It will copy local file /test/source in /dest directory on the server 123.123.123.123&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;scp 123.123.123.123:/source /dest&lt;/code&gt; It will copy source file from server to local directory dest&lt;/li&gt;
  &lt;/ul&gt;
  &lt;h2&gt;5.5 Restrict access to the HTTP proxy server&lt;/h2&gt;
  &lt;p&gt;&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;To enable the use of a proxy server environment variable &lt;code&gt;http_proxy&lt;/code&gt; must be configured&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;code&gt;export http_proxy=http://127.0.0.1:3128/&lt;/code&gt; use a local proxy listening on port 3128&lt;/li&gt;
      &lt;li&gt;&lt;code&gt;export http_proxy=http://username:password@192.168.0.1:8080/&lt;/code&gt; use a remote proxy on server 192.168.0.1, listening on port 8080 that require user and password&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;&lt;code&gt;unset http_proxy&lt;/code&gt; Disable use of proxy&lt;/li&gt;
    &lt;li&gt;The keep configuration permanent for all user insert variable configuration in &lt;code&gt;/etc/environment&lt;/code&gt;&lt;/li&gt;
  &lt;/ul&gt;
  &lt;h2&gt;5.6 Configure an IMAP and IMAPS service&lt;/h2&gt;
  &lt;p&gt;&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;Server used to manage IMAP protocol is dovecot&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;code&gt;yum -y install dovecot&lt;/code&gt;&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;Basic configuration&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;code&gt;/etc/dovecot/dovecot.conf&lt;/code&gt;&lt;/li&gt;
      &lt;ul&gt;
        &lt;li&gt;&lt;code&gt;protocols = imap pop3&lt;/code&gt;This will enable imap and pop3 protocol&lt;/li&gt;
      &lt;/ul&gt;
      &lt;li&gt;&lt;code&gt;/etc/dovecot/conf.d/10-mail.conf&lt;/code&gt;&lt;/li&gt;
      &lt;ul&gt;
        &lt;li&gt;&lt;code&gt;mail_location = maildir:~/Maildir&lt;/code&gt;This indicate to server where is located mail file&lt;/li&gt;
      &lt;/ul&gt;
      &lt;li&gt;&lt;code&gt;/etc/dovecot/conf.d/10-ssl.conf&lt;/code&gt;&lt;/li&gt;
      &lt;ul&gt;
        &lt;li&gt;Nothing to change, default configuration will enable ssl version of protocols that are enable in &lt;code&gt;dovecot.conf&lt;/code&gt;&lt;/li&gt;
      &lt;/ul&gt;
    &lt;/ul&gt;
  &lt;/ul&gt;
  &lt;h2&gt;5.7 Query and modify the behavior of system services at various operating modes&lt;/h2&gt;
  &lt;p&gt;&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;&lt;code&gt;/usr/lib/systemd/system&lt;/code&gt; contain unit file &lt;em&gt;.service&lt;/em&gt; used by systemctl to start various service&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;/etc/systemd/system&lt;/code&gt; can contain unit file that &amp;quot;override&amp;quot; the files contained in /usr/lib/systemd/system. If a unit file for a service is present in this directory, it will be used in substitution of file present in /usr.&lt;/li&gt;
    &lt;li&gt;The correct way to permanently alter a start property of a service is to copy original file from &lt;code&gt;/usr/lib/systemd/system&lt;/code&gt; to &lt;code&gt;/etc/systemd/system&lt;/code&gt; and modify copy&lt;/li&gt;
    &lt;li&gt;From the output of &lt;code&gt;system status service&lt;/code&gt; it is possible to find from which file service was start&lt;code&gt;ed&lt;/code&gt;&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;code&gt;Loaded&lt;/code&gt; show the name of .service file used&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;Under &lt;code&gt;[install]&lt;/code&gt; session, voice &lt;code&gt;WantedBy&lt;/code&gt; indicates for which target service is required&lt;/li&gt;
    &lt;li&gt;When a service is enabled, a symbolic link to file &lt;code&gt;.service&lt;/code&gt; of service will be created in &lt;code&gt;/etc/systemd/system/targetname.target.wants&lt;/code&gt; where &lt;em&gt;targetname&lt;/em&gt; is the name of target for which service is required&lt;/li&gt;
    &lt;li&gt;Some service properties can be changed at runtime&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;code&gt;systemctl set-property httpd.service MemoryLimit=500M&lt;/code&gt;Command will change property and will create a file in &lt;code&gt;/etc/systemd/system&lt;/code&gt; for future boot&lt;/li&gt;
      &lt;li&gt;&lt;code&gt;system status service&lt;/code&gt; will show&lt;/li&gt;
      &lt;ul&gt;
        &lt;li&gt;&lt;code&gt;Loaded&lt;/code&gt; will show the name of .service file used&lt;/li&gt;
        &lt;li&gt;&lt;code&gt;Drop-in&lt;/code&gt; will show the change in &lt;code&gt;/etc/systemd&lt;/code&gt;&lt;/li&gt;
      &lt;/ul&gt;
    &lt;/ul&gt;
    &lt;li&gt;&lt;code&gt;systemctl list-dependencies service&lt;/code&gt; It will show service dependencies&lt;/li&gt;
  &lt;/ul&gt;
  &lt;h2&gt;5.8 Configure an HTTP server&lt;/h2&gt;
  &lt;p&gt;&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;Used server: Apache HTTP Server&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;yum -y install httpd&lt;/code&gt; will install server&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;systemctl start httpd&lt;/code&gt; will start server&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;/etc/httpd/conf/httpd.conf&lt;/code&gt; is the principal configuration file&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;code&gt;ServerName localhost&lt;/code&gt; contains the local server name.&lt;/li&gt;
      &lt;ul&gt;
        &lt;li&gt;&lt;strong&gt;NOTE&lt;/strong&gt;: it must correspond to an IP. Simple solution is to modify /etc/hosts to insert a name-IP mapping&lt;/li&gt;
      &lt;/ul&gt;
    &lt;/ul&gt;
    &lt;li&gt;Virtual host can be created inserting a file &lt;em&gt;.conf&lt;/em&gt; in &lt;code&gt;/etc/httpd/conf.d/&lt;/code&gt;&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;E.g. &lt;code&gt;/etc/httpd/conf.d/file.conf&lt;/code&gt;&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;The file structure can be copied from &lt;code&gt;/usr/share/doc/httpd-2.4.6/httpd-vhosts.conf&lt;/code&gt;&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;strong&gt;NOTE&lt;/strong&gt;: The version depends by server version installed&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;Normally as &lt;em&gt;DocumentRoot&lt;/em&gt;, directory that will contain site&amp;#x27;s files, it will be used a directory in &lt;code&gt;/var/www&lt;/code&gt;&lt;/li&gt;
  &lt;/ul&gt;
  &lt;h2&gt;5.9 Configure HTTP server log files&lt;/h2&gt;
  &lt;p&gt;&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;E.g.&lt;/li&gt;
  &lt;/ul&gt;
  &lt;pre&gt;ErrorLog /var/log/httpd/example.com_error_log
LogFormat %s %v combined
CustomLog /var/log/httpd/example.com_access_log combined&lt;/pre&gt;
  &lt;ul&gt;
    &lt;ul&gt;
      &lt;li&gt;This will generate store Error log in /var/log/httpd/example.com_error_log&lt;/li&gt;
      &lt;li&gt;Plus will generate a log with a custom format in /var/log/httpd/example.com_access_log&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;Normally log are stored in /var/log/httpd&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;yum -y install httpd-manual&lt;/code&gt; will install httpd manuals&lt;/li&gt;
    &lt;li&gt;Manuals are in http format&lt;/li&gt;
    &lt;li&gt;In &lt;code&gt;/usr/share/httpd/manual/vhosts&lt;/code&gt; are stored manual for vhost&lt;/li&gt;
  &lt;/ul&gt;
  &lt;h2&gt;5.10 Configure a database server&lt;/h2&gt;
  &lt;p&gt;&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;Used database: MariaDB&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;yum -y install mariadb mariadb-server&lt;/code&gt; will install database&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;systemctl start mariadb&lt;/code&gt; will start database&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;mysql -u root -p&lt;/code&gt; will connect to database as root database user&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;Default password is blank&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;&lt;code&gt;mysql_secure_installation&lt;/code&gt; improves MariaDB security&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;It will permit to configure root password&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/ul&gt;
  &lt;h2&gt;5.11 Restrict access to a web page&lt;/h2&gt;
  &lt;p&gt;&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;Edit &lt;code&gt;/etc/httpd/conf/httpd.conf&lt;/code&gt; and change&lt;/li&gt;
  &lt;/ul&gt;
  &lt;pre&gt;&amp;lt;Directory &amp;quot;/var/www&amp;quot;&amp;gt;
	AllowOverride All&lt;/pre&gt;
  &lt;ul&gt;
    &lt;li&gt;In subdirectory of &lt;code&gt;/var/www&lt;/code&gt; where site pages are contained create a file &lt;code&gt;.htaccess&lt;/code&gt; whit follow content:&lt;/li&gt;
  &lt;/ul&gt;
  &lt;pre&gt;Order Deny, Allow
Deny from 192.168.3.1&lt;/pre&gt;
  &lt;p&gt;This will deny accesso to pages from IP 192.168.3.1 and allow access from all other IPs&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;Alternatively:&lt;/li&gt;
  &lt;/ul&gt;
  &lt;pre&gt;Order Allow, Deny
Allow from 192.168.3.1&lt;/pre&gt;
  &lt;p&gt;This will allow access to pages from IP 192.168.3.1 and deny access from all other IPs&lt;/p&gt;
  &lt;h2&gt;5.12 Manage and configure containers&lt;/h2&gt;
  &lt;p&gt;&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;Concepts:&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;em&gt;Images&lt;/em&gt;: Read only template used to create container.&lt;/li&gt;
      &lt;li&gt;&lt;em&gt;Container&lt;/em&gt;: Isolated application platform, it contains all the need to execute application&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;&lt;code&gt;yum install docker&lt;/code&gt; It will install docker&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;systemctl start docker&lt;/code&gt;It start docker&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;docker version&lt;/code&gt; to test if docker is working properly&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;usermod -aG dockerroot user&lt;/code&gt;&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;This will enable &lt;em&gt;user&lt;/em&gt; to use docker&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;&lt;code&gt;docker search java&lt;/code&gt;&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;Search java image in docker hub&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;&lt;code&gt;docker images&lt;/code&gt;&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;List local images&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;Run container, examples:&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;code&gt;docker run busybox ls&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;&lt;code&gt;docker run busybox echo &amp;quot;hello&amp;quot;&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;&lt;code&gt;docker run centos:7 ping 127.0.0.1&lt;/code&gt;&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;&lt;code&gt;docker run -i -t centos:7 bash&lt;/code&gt;&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;Run container with terminal&lt;/li&gt;
      &lt;li&gt;&lt;code&gt;-i&lt;/code&gt; connects standard input to container&lt;/li&gt;
      &lt;li&gt;&lt;code&gt;-t&lt;/code&gt; get pseudo terminal&lt;/li&gt;
      &lt;li&gt;&lt;strong&gt;NOTA&lt;/strong&gt;: &lt;code&gt;ctrl+p+q&lt;/code&gt; exit form terminal without terminate container execution&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;&lt;code&gt;docker run -d centos:7 ping 127.0.0.1&lt;/code&gt;&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;Container will be executed in detached mode. This means that is in execution in background and not attached to Bash shell&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;&lt;code&gt;docker ps -a&lt;/code&gt;&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;List all container&lt;/li&gt;
      &lt;li&gt;&lt;code&gt;-a&lt;/code&gt; show container stopped as well&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;&lt;code&gt;docker attach containername&lt;/code&gt;&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;Attach to container in detached mode&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;&lt;code&gt;docker logs containername&lt;/code&gt;&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;Show logs of a container&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;&lt;code&gt;docker run -d -P nginx&lt;/code&gt;&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;Map container ports to host ports&lt;/li&gt;
      &lt;li&gt;&lt;strong&gt;NOTE&lt;/strong&gt;: &lt;em&gt;firewalld&lt;/em&gt; must be enable and running&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;&lt;code&gt;docker run -d -P --restart always nginx&lt;/code&gt;&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;This container will be restarted at bootstrap if the guest host will be restarted&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;&lt;code&gt;docker update --restart=no containername&lt;/code&gt;&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;Disable auto restart at bootstrap&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;Stop container:&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;code&gt;docker stop containername&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;&lt;code&gt;docker kill containername&lt;/code&gt; forced stop&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;&lt;code&gt;docker start name&lt;/code&gt;&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;Restart a stopped container&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;&lt;code&gt;docker rm containername&lt;/code&gt;&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;Remove a container&lt;/li&gt;
      &lt;li&gt;&lt;strong&gt;NOTE&lt;/strong&gt;: It must be stopped&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;&lt;code&gt;docker rmi imageid&lt;/code&gt;&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;Remove local image&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;&lt;code&gt;docker diff containername&lt;/code&gt;&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;List differences between container and original images. E.g. Some software can be installed in running container&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;&lt;code&gt;docker commit containername&lt;/code&gt;&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;Create a new image using based on the content of current running container. E.g It will contain software that was installed in container&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/ul&gt;
  &lt;h2&gt;5.13 Manage and configure Virtual Machines&lt;/h2&gt;
  &lt;p&gt;&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;&lt;code&gt;yum install qemu-kvm qemu-img libvirt virt-install libvirt-client&lt;/code&gt; this will install all tools need to manage and configure virtual machines&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;systemctl start libvirtd&lt;/code&gt; this will start daemon need to manage virtual enviroments&lt;/li&gt;
  &lt;/ul&gt;
  &lt;p&gt;Manage storage volume&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;Concepts:&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;Storage Pool -&amp;gt; Container of storage volumes (e.g. directory, partitions)&lt;/li&gt;
      &lt;li&gt;Storage Volume -&amp;gt; virtual disk&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;Create a Storage Pool:&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;code&gt;virsh pool-define-as spool dir - - - - &amp;quot;/media/vdisk/&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;&lt;code&gt;virsh pool-build&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;&lt;code&gt;virsh pool-start&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;&lt;code&gt;virsh pool-autostart&lt;/code&gt;&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;In files &lt;code&gt;/etc/libvirt/storage/*.xml&lt;/code&gt; you can find info about storage pool&lt;/li&gt;
    &lt;li&gt;Create a virtual disk&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;code&gt;qemu-img create -f raw /media/vdisk/disk.img 1G&lt;/code&gt; size will be 1G&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/ul&gt;
  &lt;p&gt;Manage Virtual Machines&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;If you what that &lt;em&gt;root&lt;/em&gt; will be able to execute virtual machines, in &lt;code&gt;/etc/libvirt/qemu.conf&lt;/code&gt; uncomment &lt;code&gt;user=root&lt;/code&gt; and &lt;code&gt;group=root&lt;/code&gt; and after restart &lt;em&gt;libvirtd&lt;/em&gt; daemon with &lt;code&gt;systemctl&lt;/code&gt; &lt;code&gt;restart libvirtd&lt;/code&gt;&lt;/li&gt;
    &lt;li&gt;Create a Virtual Machine&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;code&gt;virt-install --name=rhel7 --disk path=/mnt/personal-data/SPool1/SVol1.img,size=2 --vcpu=1 --ram=1024 --location=/run/media/dos/9e6f605a-f502-4e98-826e-e6376caea288/rhel-server-7.0-x86_64-dvd.iso --network bridge=virbr0 --graphics none --extra-args console=ttyS0&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;This will prepare a new virtual machine named &lt;em&gt;rhel7&lt;/em&gt; with 1 virtual cpu, 1G of RAM, and a virtual disk of 2G.&lt;/li&gt;
      &lt;li&gt;After creation, virtual machine will be booted for the first time ad a provided ISO image will be executed. Normally ISO will be an operating system installation disk&lt;/li&gt;
      &lt;li&gt;Virtual Machine is configured to not use graphical environment and plus a configuration to allow a connection from the local machine is set&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;Virtual Machine management&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;code&gt;virsh list --all&lt;/code&gt;List all available virtual machines in any state&lt;/li&gt;
      &lt;li&gt;&lt;code&gt;virsh start rhel7&lt;/code&gt;Start a virtual machine called rhel7&lt;/li&gt;
      &lt;li&gt;&lt;code&gt;virsh shutdown rhel7&lt;/code&gt;Shutdown virtual machine called rhel7&lt;/li&gt;
      &lt;li&gt;&lt;code&gt;virsh destroy rhel7&lt;/code&gt;Forced shutdown of a virtual machine called rhel7&lt;/li&gt;
      &lt;li&gt;&lt;code&gt;virsh undefine rhel7&lt;/code&gt;Delete a virtual machine called rhel7&lt;/li&gt;
      &lt;li&gt;&lt;code&gt;virsh console rhel7&lt;/code&gt;Establish a connection toward virtual machine called rhel7&lt;strong&gt;NOTE&lt;/strong&gt;: console must be configured in virtual machine&lt;code&gt;ctrl+5&lt;/code&gt; to exit&lt;/li&gt;
      &lt;li&gt;&lt;code&gt;virsh autostart rhel7&lt;/code&gt;Set the virtual machine to re-start if hosting machine will be rebooted&lt;/li&gt;
      &lt;li&gt;&lt;code&gt;virsh autostart --disable rhel7&lt;/code&gt;Disable autostart&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;Edit virtual machine&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;code&gt;virsh dominfo rhel7&lt;/code&gt;It shows virtual machine information&lt;/li&gt;
      &lt;li&gt;&lt;code&gt;virsh edit rhel7&lt;/code&gt;Edit configuration file of virtual machine called rhel7&lt;/li&gt;
      &lt;li&gt;&lt;code&gt;virsh vcpucount rhel7&lt;/code&gt;It shows the number of virtual cpu&lt;/li&gt;
      &lt;ul&gt;
        &lt;li&gt;&lt;strong&gt;maximum config&lt;/strong&gt;: Specifies the maximum number of virtual CPUs that can be made available for the virtual server after the next restart.&lt;/li&gt;
        &lt;li&gt;&lt;strong&gt;maximum live&lt;/strong&gt;: Specifies the maximum number of virtual CPUs that can be made available for the running or paused virtual server. If you change maximum this can be different until virtual machine is rebooted&lt;/li&gt;
        &lt;li&gt;&lt;strong&gt;current config&lt;/strong&gt;: Specifies the actual number of virtual CPUs which will be available for the virtual server with the next restart.&lt;/li&gt;
        &lt;li&gt;&lt;strong&gt;current live&lt;/strong&gt;: Specifies the actual number of virtual CPUs which are available for the running or paused virtual server&lt;/li&gt;
      &lt;/ul&gt;
      &lt;li&gt;&lt;code&gt;virsh setvcpus --count 2 rhel7 --maximum --config&lt;/code&gt;It sets the maximum number of virtual cpu in configuration file to 2.It require virtual machine reboot to be applied. After reboot maximum live will be aligned&lt;/li&gt;
      &lt;li&gt;&lt;code&gt;virsh setvcpus --count 2 rhel7 --config&lt;/code&gt;It sets the configure for virtual machine. This value its the value with which virtual machine will be booted&lt;/li&gt;
      &lt;li&gt;&lt;code&gt;virsh setvcpu --count 2 rhel7&lt;/code&gt;Set the number of virtual cpu (current live).Number must be less or equal to maximum live.You cannot remove virtual CPUs from a running virtual server&lt;/li&gt;
      &lt;li&gt;&lt;code&gt;virsh setmaxmem --size 2G rhel7&lt;/code&gt;It sets the maximum amount of virtual machine memoryVirtual machine must be off&lt;/li&gt;
      &lt;li&gt;&lt;code&gt;virsh setmem --size 2G rhel7&lt;/code&gt;It sets the amount of virtual machine memoryVirtual machine must be running&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/ul&gt;
  &lt;p&gt;References:&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;&lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/en/linuxonibm/com.ibm.linux.z.ldva/ldva_t_modifyingCPUNumber.html&quot; target=&quot;_blank&quot;&gt;https://www.ibm.com/support/knowledgecenter/en/linuxonibm/com.ibm.linux.z.ldva/ldva_t_modifyingCPUNumber.html&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;

</content></entry><entry><id>it255ru:hxOtBxZyFgH</id><link rel="alternate" type="text/html" href="https://teletype.in/@it255ru/hxOtBxZyFgH?utm_source=teletype&amp;utm_medium=feed_atom&amp;utm_campaign=it255ru"></link><title>(LFCS) 4. Networking - 12%</title><published>2021-06-18T10:42:06.448Z</published><updated>2021-06-18T10:42:06.448Z</updated><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://teletype.in/files/0e/8d/0e8d28b1-6775-4cd8-a62d-eefb41781b73.png"></media:thumbnail><summary type="html">&lt;img src=&quot;https://teletype.in/files/1b/be/1bbe7eab-99d9-4025-b31a-e0ff47ad2722.png&quot;&gt;1. Essential Commands - 25%
2. Operation of Running Systems - 20%
3. User and Group Management - 10%
4. Networking - 12%</summary><content type="html">
  &lt;figure class=&quot;m_original&quot;&gt;
    &lt;img src=&quot;https://teletype.in/files/1b/be/1bbe7eab-99d9-4025-b31a-e0ff47ad2722.png&quot; /&gt;
    &lt;figcaption&gt;&lt;strong&gt;Linux Foundation Certified System Administrator (LFCS)&lt;/strong&gt;&lt;/figcaption&gt;
  &lt;/figure&gt;
  &lt;p&gt;&lt;a href=&quot;/@it255ru/b_QRrhjE9rq&quot;&gt;&lt;strong&gt;1.&lt;/strong&gt; &lt;strong&gt;Essential Commands - 25%&lt;br /&gt;&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;2. Operation of Running Systems - 20%&lt;br /&gt;3. User and Group Management - 10%&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;4. Networking - 12%&lt;/strong&gt;&lt;/p&gt;
  &lt;p&gt;4.1 Configure networking and hostname resolution statically or dynamically&lt;br /&gt;4.2 Configure network services to start automatically at boot&lt;br /&gt;4.3 Implement packet filtering&lt;br /&gt;4.4 Start, stop, and check the status of network services&lt;br /&gt;4.5 Statically route IP traffic&lt;br /&gt;4.6 Synchronize time using other network peers&lt;br /&gt;&lt;strong&gt;&lt;br /&gt;5. Service Configuration - 20%&lt;br /&gt;6. Storage Management - 13%&lt;/strong&gt;&lt;/p&gt;
  &lt;p&gt;&lt;/p&gt;
  &lt;h2&gt;4.1 Configure networking and hostname resolution statically or dynamically&lt;/h2&gt;
  &lt;p&gt;&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;&lt;code&gt;ip addr show&lt;/code&gt;Show IP addresses configuration&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;code&gt;ip a s&lt;/code&gt;Short syntax&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;&lt;code&gt;nmtui&lt;/code&gt;&lt;em&gt;Network Manager Text User Interface&lt;/em&gt; - Graphical interface to manage network connections configuration&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;Manual means that IP will be configured manually&lt;/li&gt;
      &lt;li&gt;Automatic means that will be used DHCP protocol&lt;/li&gt;
      &lt;li&gt;&lt;strong&gt;NOTE&lt;/strong&gt;: IP must be inserted with syntax IP/NETMASK (e.t. 192.168.0.2/24)&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;All network configuration will be stored in &lt;code&gt;/etc/sysconfig/network-scripts&lt;/code&gt;&lt;/li&gt;
    &lt;li&gt;If there is need to change IP configuration of an interface without using &lt;code&gt;nmtui&lt;/code&gt; remember to shutdown interface, change IP, restart interface&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;code&gt;ip link set eth0 down&lt;/code&gt; Shutdown interface eth0&lt;/li&gt;
      &lt;li&gt;&lt;code&gt;ip addr add 192.168.0.2/24 dev eth0&lt;/code&gt; Assign IP 192.168.0.2/24 to interface eth0&lt;/li&gt;
      &lt;li&gt;&lt;code&gt;ip link set eth0 up&lt;/code&gt; Restart interface eth0&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;The hostname can be changed editing &lt;code&gt;/etc/hostname&lt;/code&gt;&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;code&gt;hostname&lt;/code&gt; show current hostname&lt;/li&gt;
      &lt;li&gt;Alternative: &lt;code&gt;hostnamectl set-hostname your-new-hostname&lt;/code&gt; set hostname equal to your-new-hostname&lt;/li&gt;
      &lt;li&gt;Reboot is required to see new hostname applied&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;In &lt;code&gt;/etc/hosts&lt;/code&gt; is configured a name resolution that take precedence of DNS&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;It contains static DNS entry&lt;/li&gt;
      &lt;li&gt;It is possible add hostname to row for 127.0.0.1 resolution, or insert a static IP configured on principal interface equal to hostname&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;In &lt;code&gt;/etc/resolv.conf&lt;/code&gt; there are configured DNS servers entry&lt;/li&gt;
    &lt;li&gt;It is possible to insert more than one &lt;em&gt;nameserver&lt;/em&gt; as backup (primary and secondary)&lt;/li&gt;
  &lt;/ul&gt;
  &lt;h2&gt;4.2 Configure network services to start automatically at boot&lt;/h2&gt;
  &lt;p&gt;&lt;/p&gt;
  &lt;p&gt;Network Manager&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;Its purpose is to automatically detect, configure, and connect to a network whether wired or wireless such as VPN, DNS, static routes, addresses, etc which is why you&amp;#x27;ll see #Configured by NetworkManager in /etc/resolv.conf, for example. Although it will prefer wired connections, it will pick the best known wireless connection and whichever it deems to be the most reliable. It will also switch over to wired automatically if it&amp;#x27;s there. It&amp;#x27;s not necessary and many (including me) disable it as most would rather manage their own network settings and don&amp;#x27;t need it done for them.&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;systemctl stop NetworkManager.service&lt;/code&gt;&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;systemctl disable NetworkManager.service&lt;/code&gt;&lt;/li&gt;
  &lt;/ul&gt;
  &lt;p&gt;Network&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;&lt;code&gt;systemctl status network&lt;/code&gt; to check network configuration status&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;systemctl restart network&lt;/code&gt; to reload network configuration&lt;/li&gt;
  &lt;/ul&gt;
  &lt;p&gt;References:&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;&lt;a href=&quot;https://unix.stackexchange.com/questions/449186/what-is-the-usage-of-networkmanager-in-centos-rhel7&quot; target=&quot;_blank&quot;&gt;https://unix.stackexchange.com/questions/449186/what-is-the-usage-of-networkmanager-in-centos-rhel7&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;
  &lt;h2&gt;4.3 Implement packet filtering&lt;/h2&gt;
  &lt;p&gt;&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;The firewall is managed by Kernel&lt;/li&gt;
    &lt;li&gt;The kernel firewall functionality is Netfilter&lt;/li&gt;
    &lt;li&gt;Netfilter will process information that will enter and will exit from system&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;For this it has two tables of rules called chains:&lt;/li&gt;
      &lt;ul&gt;
        &lt;li&gt;&lt;em&gt;INPUT&lt;/em&gt; that contains rules applied to packets that enter in the system&lt;/li&gt;
        &lt;li&gt;&lt;em&gt;OUTPUT&lt;/em&gt; that contains rules applied to packets that leave the system&lt;/li&gt;
      &lt;/ul&gt;
    &lt;/ul&gt;
    &lt;li&gt;Another chain can be used if system is configured as router: &lt;em&gt;FORWARD&lt;/em&gt;&lt;/li&gt;
    &lt;li&gt;Finally there are other two chains: PREROUTING, POSTROUTING&lt;/li&gt;
  &lt;/ul&gt;
  &lt;figure class=&quot;m_original&quot;&gt;
    &lt;img src=&quot;https://teletype.in/files/16/3c/163cf432-15ad-4962-a40e-b9058020b983.png&quot; width=&quot;1024&quot; /&gt;
  &lt;/figure&gt;
  &lt;ul&gt;
    &lt;li&gt;Picture show the order with which the various chains are valued. The arrows indicate the route of the packages:&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;Incoming packets are generated from the outside&lt;/li&gt;
      &lt;li&gt;Outgoing packets are either generated by an application or are packets in transit&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;The rules inside chains are evaluated in an orderly way.&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;When a rule match the other rules are skipped&lt;/li&gt;
      &lt;li&gt;If no rules match, default policy will be applied&lt;/li&gt;
      &lt;ul&gt;
        &lt;li&gt;Default policy:&lt;/li&gt;
        &lt;ul&gt;
          &lt;li&gt;ACCEPT: the packet will be accepted and it will continue its path through the chains&lt;/li&gt;
          &lt;li&gt;DROP: the packet will be rejected&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/ul&gt;
    &lt;/ul&gt;
    &lt;li&gt;The utility to manage firewall is &lt;code&gt;iptables&lt;/code&gt;&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;iptables&lt;/code&gt; will create rules for chains that will be processed in an orderly way&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;firewalld&lt;/code&gt; is a service that use iptables to manage firewalls rules&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;firewall-cmd&lt;/code&gt; is the command to manage firewalld&lt;/li&gt;
  &lt;/ul&gt;
  &lt;p&gt;Firewalld&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;firewalld is enabled by default in CentOS&lt;/li&gt;
    &lt;li&gt;It works with zone, &lt;em&gt;public&lt;/em&gt; is default zone&lt;/li&gt;
    &lt;li&gt;The &lt;em&gt;zone&lt;/em&gt; is applied to an interface&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;The idea is that we can have safe zone, e.g. bound to an internal interface, and unsafe zone, e.g. bound to external interfaces internet facing&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;&lt;code&gt;firewall-cmd --list-all&lt;/code&gt; show current configuration&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;services -&amp;gt; service that are allowed to use interface&lt;/li&gt;
      &lt;li&gt;ports -&amp;gt; ports that are allowed to use interface&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;&lt;code&gt;firewall-cmd --get-services&lt;/code&gt; shows the list of default services&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;The services are configured in &lt;code&gt;/urs/lib/firewalld/services&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;&lt;code&gt;/urs/lib/firewalld/services&lt;/code&gt; contains xml file with service configuration&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;&lt;code&gt;firewall-cmd --add-service service&lt;/code&gt; add service to current configuration&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;strong&gt;NOTE&lt;/strong&gt;: it isn&amp;#x27;t a permanent configuration&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;&lt;code&gt;firewall-cmd --reload&lt;/code&gt; reload firewalld configuration&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;strong&gt;NOTE&lt;/strong&gt;: If a service was added with previous command now it is disappeared&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;&lt;code&gt;firewall-cmd --add-service service --permanent&lt;/code&gt; add service to configuration as permanent&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;strong&gt;NOTE&lt;/strong&gt;: Now if firewalld configuration is reloaded service it is still present&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;&lt;code&gt;firewall-cmd --add-port 4000-4005/tcp&lt;/code&gt; Open TCP ports from 4000 to 4005&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;firewall-cmd --permanent --direct --add-rule ipv4 filter OUTPUT 1 -p tcp -m tcp --dport 80 -j ACCEPT&lt;/code&gt;&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;Add a firewall rule using iptables syntax&lt;/li&gt;
      &lt;li&gt;This add permanently a rule as first in OUTPUT chain to allow connections to TCP destination port 80&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/ul&gt;
  &lt;p&gt;iptables&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;The &lt;code&gt;firewalld&lt;/code&gt; daemon can be substitute with &lt;code&gt;iptables&lt;/code&gt; daemon (the configuration that was in place until recently)&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;code&gt;systemctl stop firewalld&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;&lt;code&gt;iptables -L&lt;/code&gt;&lt;/li&gt;
      &lt;ul&gt;
        &lt;li&gt;More verbose output &lt;code&gt;iptables -L -v&lt;/code&gt;&lt;/li&gt;
        &lt;li&gt;Show configuration of iptables chains&lt;/li&gt;
        &lt;li&gt;Note that policies is set equal to ACCEPT for every chain. This means that no package will be rejected. This is equal to have a shut downed firewall&lt;/li&gt;
      &lt;/ul&gt;
      &lt;li&gt;&lt;code&gt;systemctl disable firewalld&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;&lt;code&gt;yum -y install iptables-services&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;&lt;code&gt;systemctl enable iptables&lt;/code&gt;&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;With this configuration rules must be inserted&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;iptables -P INPUT DROP&lt;/code&gt;&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;Set default policy to DROP for INPUT chain&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;iptables rules syntax:&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;code&gt;iptables {-A|I} chain [-i/o interface][-s/d ipaddres] [-p tcp|upd|icmp [--dport|--sport nn…]] -j [LOG|ACCEPT|DROP|REJECTED]&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;&lt;code&gt;{-A|I} chain&lt;/code&gt;&lt;/li&gt;
      &lt;ul&gt;
        &lt;li&gt;&lt;code&gt;-A&lt;/code&gt; append as last rule&lt;/li&gt;
        &lt;li&gt;&lt;code&gt;-I&lt;/code&gt; insert. This require a number after chain that indicate rule position&lt;/li&gt;
      &lt;/ul&gt;
      &lt;li&gt;&lt;code&gt;[-i/o interface]&lt;/code&gt;&lt;/li&gt;
      &lt;ul&gt;
        &lt;li&gt;E.g. &lt;code&gt;-i eth0&lt;/code&gt; - the package is received (input) on the interface eth0&lt;/li&gt;
      &lt;/ul&gt;
      &lt;li&gt;&lt;code&gt;[-s/d ipaddres]&lt;/code&gt;&lt;/li&gt;
      &lt;ul&gt;
        &lt;li&gt;&lt;code&gt;-s&lt;/code&gt; Source address. ipaddres can be an address or a subnet&lt;/li&gt;
        &lt;li&gt;&lt;code&gt;-d&lt;/code&gt; Destination address. ipaddres can be an address or a subnet&lt;/li&gt;
      &lt;/ul&gt;
      &lt;li&gt;[-p tcp|upd|icmp [--dport|--sport nn…]]&lt;/li&gt;
      &lt;ul&gt;
        &lt;li&gt;&lt;code&gt;-p&lt;/code&gt; protocol&lt;/li&gt;
        &lt;li&gt;&lt;code&gt;--dport&lt;/code&gt; Destination port&lt;/li&gt;
        &lt;li&gt;&lt;code&gt;--sport&lt;/code&gt; Source port&lt;/li&gt;
      &lt;/ul&gt;
      &lt;li&gt;&lt;code&gt;-j [LOG|ACCEPT|DROP|REJECTED]&lt;/code&gt;&lt;/li&gt;
      &lt;ul&gt;
        &lt;li&gt;&lt;code&gt;ACCEPT&lt;/code&gt; accept packet&lt;/li&gt;
        &lt;li&gt;&lt;code&gt;DROP&lt;/code&gt; silently rejected&lt;/li&gt;
        &lt;li&gt;&lt;code&gt;REJECTED&lt;/code&gt; reject the packet with an ICMP error packet&lt;/li&gt;
        &lt;li&gt;&lt;code&gt;LOG&lt;/code&gt; log packet. Evaluation of rules isn&amp;#x27;t blocked.&lt;/li&gt;
      &lt;/ul&gt;
    &lt;/ul&gt;
    &lt;li&gt;E.g.&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;iptables -A INPUT -i lo -j ACCEPT&lt;/code&gt;&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;Accept all inbound loopback traffic&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;&lt;code&gt;iptables -A OUTPUT -o lo -j ACCEPT&lt;/code&gt;&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;Accept all outbound loopback traffic&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;&lt;code&gt;iptable -A INPUT -p tcp --dport 22 -j ACCEPT&lt;/code&gt;&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;Accept all inbound traffic for tcp port 22&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;&lt;code&gt;iptable -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT&lt;/code&gt;&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;This is a rule that is used to ACCEPT all traffic generated as a response of an inbound connection that was accepted. E.g. if incoming traffic for web server on port 80 was accepted, this rule permits to response traffic to exit from system without inserting specific rules in OUTPUT chain&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;&lt;strong&gt;NOTE&lt;/strong&gt; file &lt;code&gt;/etc/services&lt;/code&gt; contains a list of well know ports with services name&lt;/li&gt;
  &lt;/ul&gt;
  &lt;p&gt;References:&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;&lt;a href=&quot;https://debian-handbook.info/browse/da-DK/stable/sect.firewall-packet-filtering.html&quot; target=&quot;_blank&quot;&gt;https://debian-handbook.info/browse/da-DK/stable/sect.firewall-packet-filtering.html&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;
  &lt;h2&gt;4.4 Start, stop, and check the status of network services&lt;/h2&gt;
  &lt;p&gt;&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;Network services are controlled as other daemon with &lt;code&gt;systemctl&lt;/code&gt; command&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;code&gt;systemctl status servicename&lt;/code&gt;&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;With &lt;code&gt;netstat&lt;/code&gt; is it possible list internet port opened by a process&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;code&gt;yum -y install net-tools&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;&lt;code&gt;netstat -tln&lt;/code&gt;&lt;/li&gt;
      &lt;ul&gt;
        &lt;li&gt;Show TCP port opened by processes&lt;/li&gt;
      &lt;/ul&gt;
    &lt;/ul&gt;
  &lt;/ul&gt;
  &lt;h2&gt;4.5 Statically route IP traffic&lt;/h2&gt;
  &lt;p&gt;&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;&lt;code&gt;ip route show&lt;/code&gt;&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;Print route&lt;/li&gt;
      &lt;li&gt;Alternative command &lt;code&gt;route -n&lt;/code&gt;&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;&lt;code&gt;ip route add 192.0.2.1 via 10.0.0.1 [dev interface]&lt;/code&gt;&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;Add route to 192.0.2.1 through 10.0.0.1. Optionally interface can be specified&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;To make route persistent, create a &lt;em&gt;route-ifname&lt;/em&gt; file for the interface through which the subnet is accessed, e.g eth0:&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;code&gt;vi /etc/sysconfig/network-scripts/route-eth0&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;Add line &lt;code&gt;192.0.2.1 via 10.0.0.101 dev eth0&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;&lt;code&gt;service network restart&lt;/code&gt; to reload file&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;&lt;code&gt;ip route add 192.0.2.0/24 via 10.0.0.1 [dev ifname]&lt;/code&gt;&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;Add a route to subnet 192.0.2.0/24&lt;/li&gt;
    &lt;/ul&gt;
    &lt;li&gt;To configure system as route forward must be enabled&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;code&gt;echo 1 &amp;gt; /proc/sys/net/ipv4/ip_forward&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;To make configuration persistent&lt;/li&gt;
      &lt;ul&gt;
        &lt;li&gt;&lt;code&gt;echo net.ipv4.ip_forward = 1 &amp;gt; /etc/sysctl.d/ipv4.conf&lt;/code&gt;&lt;/li&gt;
      &lt;/ul&gt;
    &lt;/ul&gt;
  &lt;/ul&gt;
  &lt;p&gt;References:&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;&lt;a href=&quot;https://my.esecuredata.com/index.php?/knowledgebase/article/2/add-a-static-route-on-centos&quot; target=&quot;_blank&quot;&gt;https://my.esecuredata.com/index.php?/knowledgebase/article/2/add-a-static-route-on-centos&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;
  &lt;h2&gt;4.6 Synchronize time using other network peers&lt;/h2&gt;
  &lt;p&gt;&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;In time synchronization the concept of Stratum define the accuracy of server time.&lt;/li&gt;
    &lt;li&gt;A server with Stratum 0 it is the most reliable&lt;/li&gt;
    &lt;li&gt;A server synchronized with a Stratum 0 become Stratum 1&lt;/li&gt;
    &lt;li&gt;Stratum 10 is reserved for local clock. This means that it is not utilizable&lt;/li&gt;
    &lt;li&gt;The upper limit for Stratum is 15&lt;/li&gt;
    &lt;li&gt;Stratum 16 is used to indicate that a device is unsynchronized&lt;/li&gt;
    &lt;li&gt;Remember that time synchronization between servers is a slowly process&lt;/li&gt;
  &lt;/ul&gt;
  &lt;p&gt;CHRONYD&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;Default mechanism to synchronize time in CentOS&lt;/li&gt;
    &lt;li&gt;Configuration file &lt;code&gt;/etc/chrony.conf&lt;/code&gt;&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;server&lt;/code&gt; parameters are servers that are used as source of synchronization&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;chronyc sources&lt;/code&gt; contact server and show them status&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;chronyc tracking&lt;/code&gt; show current status of system clock&lt;/li&gt;
    &lt;li&gt;&lt;strong&gt;NOTE&lt;/strong&gt;: if some of the commands below doesn&amp;#x27;t work please refer to this bug &lt;a href=&quot;https://bugzilla.redhat.com/show_bug.cgi?id=1574418&quot; target=&quot;_blank&quot;&gt;https://bugzilla.redhat.com/show_bug.cgi?id=1574418&lt;/a&gt;&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;Simple solution: &lt;code&gt;setenforce 0&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;Package &lt;code&gt;selinux-policy-3.13.1-229&lt;/code&gt; should resolve problem&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/ul&gt;
  &lt;p&gt;NTP&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;The old method of synchronization. To enable it Chronyd must be disabled&lt;/li&gt;
    &lt;li&gt;Configuration file &lt;code&gt;/etc/ntp.conf&lt;/code&gt;&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;server&lt;/code&gt; parameters are servers that are used as source of synchronization&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;ntpq -p&lt;/code&gt; check current status of synchronization&lt;/li&gt;
  &lt;/ul&gt;

</content></entry></feed>