---
# System prepended metadata

title: 'Отчет по заданиям к практической работе №2. Администрирование Linux:'
tags: [Linux]

---

###### tags: `Linux`
# Отчет по заданиям к практической работе №2. Администрирование Linux:

## Практическая работа №2.1.

| 1. Команда `df` в `Linux`.|
|-|
|`$ df`|
|![](https://i.imgur.com/G5syFDq.png)|
|`$ df -h`|
|![](https://i.imgur.com/YXNohet.png)|
|`$ df -a`|
|![](https://i.imgur.com/grsnbK9.png)|
|`$ df -x tmpfs`|
|![](https://i.imgur.com/dPfINo0.png)|
|`$ df -x devtmpfs -x tmpfs`|
|![](https://i.imgur.com/8kcP4QD.png)|
|`$ df -t ext4`|
|![](https://i.imgur.com/iwvGdeO.png)|
|`$ df -h /dev/vda1`|
|![](https://i.imgur.com/n5KbUAs.png)|
|`$ df -hi /dev/vda1`|
|![](https://i.imgur.com/IZe7xKs.png)|
|`$ df -h /home`|
|![](https://i.imgur.com/NhxtWtS.png)|

| 2. Команда `du` в `Linux`.|
|-|
|`$ du ~/Документы`|
|![](https://i.imgur.com/GLBVvSZ.png)|
|`$ du ~/Документы ~/Загрузки ~/.zshrc`|
|![](https://i.imgur.com/DLGg5cQ.png)|
|`$ du -a ~/Документы`|
|![](https://i.imgur.com/l8Ac0bw.png)|
|`$ du -h /var`|
|![](https://i.imgur.com/cECGnk9.png)|
|`$ sudo du -sh /var`|
|![](https://i.imgur.com/wvCL1Kx.png)|
|`$ sudo du -csh /var/log /var/lib`|
|![](https://i.imgur.com/JskQkUz.png)|
|`$ sudo du -h --max-depth=1 /var/lib`|
|![](https://i.imgur.com/7oSgPsz.png)|
|`$ sudo du -sh --apparent-size /var/lib`|
|![](https://i.imgur.com/Xha0VW6.png)|
|`$ sudo du -csh ~/До*`|
|![](https://i.imgur.com/JoaayNS.png)|
|`$ sudo du -h /var/ | sort -rh | head -5`|
|![](https://i.imgur.com/uBM0nVv.png)|

| 3. Команда `free` в `Linux`.|
|-|
|`$ free`|
|![](https://i.imgur.com/lWj6gVv.png)|
|`$ free -w`|
|![](https://i.imgur.com/mZ0GJt4.png)|
|`$ free -h`|
|![](https://i.imgur.com/5TTSISh.png)|
|`$ free --mega && free -m`|
|![](https://i.imgur.com/BW2lVYG.png)|
|`$ free -h -t`|
|![](https://i.imgur.com/Bxl9Nsx.png)|
|`$ free -s 5`|
|![](https://i.imgur.com/yc3b5Fc.png)|
|`$ free -h --si -s 5 -c 5`|
|![](https://i.imgur.com/FIrlPdM.png)|
|`$ watch free -h`|
|![](https://i.imgur.com/rbUgOqN.png)|

| 4. Команда `iostat` в `Linux`.|
|-|
|`$ sudo apt-get install sysstat`|
|![](https://i.imgur.com/cHvytTv.png)|
|`$ iostat`|
|![](https://i.imgur.com/SNnv937.png)|
|`$ iostat -h`|
|![](https://i.imgur.com/E1V1EHV.png)|
|`$ iostat /dev/vda`|
|![](https://i.imgur.com/c14ZEJ6.png)|
|`$ iostat -p /dev/vda`|
|![](https://i.imgur.com/i8tHM8X.png)|
|`$ iostat -p /dev/vda 1`|
|![](https://i.imgur.com/WmWifzU.png)|
|`$ iostat -y -p /dev/vda 1`|
|![](https://i.imgur.com/KbiFGzG.png)|
|`$ iostat -xk -t 10 | awk '// {print strftime("%Y-%m-%d %H:%M:%S"),$0}' >> iostat.log &`|
|![](https://i.imgur.com/7arcCQ7.png)|
|![](https://i.imgur.com/adY2N39.png)|

| 5. Команда `mpstat` в `Linux`.|
|-|
|`$ mpstat -A`|
|![](https://i.imgur.com/PMybtPy.png)|
|`$ mpstat -P 0`|
|![](https://i.imgur.com/HX7hzwN.png)|
|`$ mpstat -V`|
|![](https://i.imgur.com/kCQcxHK.png)|
|`$ mpstat --help`|
|![](https://i.imgur.com/LyF3d7R.png)|

| 6. Команда `vmstat` в `Linux`.|
|-|
|`$ vmstat`|
|![](https://i.imgur.com/9pf6CRV.png)|
|`$ vmstat -a`|
|![](https://i.imgur.com/e18Ht9D.png)|
|`$ vmstat -f`|
|![](https://i.imgur.com/OC3EETa.png)|
|`$ vmstat -d`|
|![](https://i.imgur.com/AWeldqu.png)|
|`$ vmstat -D`|
|![](https://i.imgur.com/H8hojt0.png)|
|`$ vmstat --help`|
|![](https://i.imgur.com/TTXa1ym.png)|
|`$ vmstat 2`|
|![](https://i.imgur.com/ltywQVy.png)|

| 7. Команда `w` в `Linux`.|
|-|
|`$ w`|
|![](https://i.imgur.com/MlutIUe.png)|
|`$ w -h`|
|![](https://i.imgur.com/bIaYRUX.png)|
|`$ w -u`|
|![](https://i.imgur.com/LvRlsIp.png)|
|`$ w -s`|
|![](https://i.imgur.com/MCMs8eb.png)|
|`$ w -f`|
|![](https://i.imgur.com/RBUUofb.png)|
|`$ w -i`|
|![](https://i.imgur.com/Ymy1I5q.png)|
|`$ w -o`|
|![](https://i.imgur.com/ykvnW4v.png)|
|`$ w -V`|
|![](https://i.imgur.com/L8ZoInb.png)|

| 8. Команда `htop` в `Linux`.|
|-|
|`$ htop`|
|![](https://i.imgur.com/UTAno34.png)|
|`$ htop -d 1`|
|![](https://i.imgur.com/EHgatld.png)|
|![](https://i.imgur.com/TF2oULB.png)|
|`$ htop -t`|
|![](https://i.imgur.com/pGkgFqS.png)|

## Практическая работа №2.2.

|1. Установка пакетов SSH.|
|-|
|`sudo apt-get install ssh`|
|![](https://i.imgur.com/IHWX2Dz.png)|
|`systemctl status ssh`|
|![](https://i.imgur.com/Ca4kChc.png)|

|2. Настройка SSH.|
|-|
|`nano /etc/ssh/sshd_config`|
|![](https://i.imgur.com/A5RnoaH.png)|
|Меняем конфигурационный файл.|

|3.Подключаемся к серверу `Linux` c хостовой операционной системы через `Putty`. |
|-|
|![](https://i.imgur.com/V5ILmGh.png)|

## Практическая работа №2.3.


|1. Сгенерируем на локальном компьютере пару ключей `SSH`.|
|-|
|`ssh-keygen`|
|![](https://i.imgur.com/BmYkPCB.png)|

|2. Cкопируeм открытый ключ на ваш сервер.|
|-|
|`ssh-copy-id server@100.65.105.167`|
|![](https://i.imgur.com/Q8TYr7g.png)|

|3. Аутентификация на сервере с использованием ключей SSH|
|-|
|![](https://i.imgur.com/xfWDDuu.png)|

|4. Отключение аутентификации с помощью пароля на сервере.|
|-|
|`sudo nano /etc/ssh/sshd_config`|
|![](https://i.imgur.com/nqR9HvM.png)|
|`sudo service ssh restart`|


## Практическая работа №2.4.

|1. Базовый сбор информации.|
|-|
|`cat /etc/*-release`|
|![](https://i.imgur.com/zFCkCsj.png)|
|`uname -a`|
|![](https://i.imgur.com/mH8GyfV.png)|
|`whoami`|
|![](https://i.imgur.com/2pDza2g.png)|
|`uptime`|
|![](https://i.imgur.com/5lUirwO.png)|
|`ls -la /home`|
|![](https://i.imgur.com/VA5rT9q.png)|
|`sudo chmod o-rx /home/ptvadim`|
|![](https://i.imgur.com/rURDrxl.png)|
|`ip neigh`|
|![](https://i.imgur.com/lWX32Fz.png)|
|`sudo ss -tlnp`|
|![](https://i.imgur.com/9eT4eve.png)|
|`sudo -l`|
|![](https://i.imgur.com/9FGr25C.png)|

|2. SUIDные файлы.|
|-|
|`sudo find / -user root -perm -4000 -exec ls -ldb {} \; 2> /dev/null`|
|![](https://i.imgur.com/zZcfGja.png)|
|`wget https://downloads.cisofy.com/lynis/lynis-3.0.6.tar.gz`|
|![](https://i.imgur.com/5Z36b2v.png)|
|`tar xfv lynis-3.0.6.tar.gz`|
|![](https://i.imgur.com/oeqFdHS.png)|
|`sha256sum lynis-3.0.6.tar.gz`|
|![](https://i.imgur.com/CpqTjqI.png)|
|![](https://i.imgur.com/F4mlUTH.png)|
|`cd lynis && ls`|
|![](https://i.imgur.com/0Aw9dFq.png)|
|`sudo ./lynis audit system`|
|![](https://i.imgur.com/sSzKYsP.png)|
|![](https://i.imgur.com/C02sTAW.png)|
|![](https://i.imgur.com/HfWmUm6.png)|
|`./lynis show options`|
|![](https://i.imgur.com/8aJ6CIM.png)|
|`sudo nano /var/log/lynis-report.dat`|
|![](https://i.imgur.com/TwP9wQY.png)|



|3. Проверка целостности пакетов.|
|-|
|Просмотр пакетов в системе.|
|`dpkg -l`|
|![](https://i.imgur.com/yFmHLKP.png)|
|Просмотр установленных утилит.|
|`dpkg -L coreutils`|
|![](https://i.imgur.com/DIqNSbx.png)|
|`/bin/dir --help`|
|![](https://i.imgur.com/UAF2hSP.png)|
|Cделаем `backup` `/bin/dir`|
|`sudo mv /bin/dir /bin/dir.bak`|
|![](https://i.imgur.com/spWYrnv.png)|
|`cp /bin/false /bin/dir`|
|![](https://i.imgur.com/lFVKgp9.png)|
|`Dir` перестал работать.|
|![](https://i.imgur.com/ljoUbRa.png)|
|Проверим данный пакет.|
|`debsums`|
|![](https://i.imgur.com/S2wg97y.png)|
|`debsums -ac coreutils`|
|`debsums -cs coreutils`|
|![](https://i.imgur.com/cUV9VYW.png)|
|`dpkg --verify coreutils`|
|![](https://i.imgur.com/4Gc6vbJ.png)|
|`sudo find / -printf "%T@;%Tc;%p\\n`|
|![](https://i.imgur.com/3J2tJF1.png)|
|`sudo find /home/ptvadim/ -printf "%T@;%Tc;%p\\n" > timeline.csv`|
|![](https://i.imgur.com/N0kknkb.png)|
|`sort -rn timeline.csv | less`|
|![](https://i.imgur.com/lOyyzJv.png)|
|![](https://i.imgur.com/2pc96yM.png)|
|![](https://i.imgur.com/Ekljvlf.png)|


## Практическая работа №2.5.

|1. Просмотр списка системных переменных окружения.|
|-|
|`sudo apt-get install coreutils`|
|![](https://i.imgur.com/VC5dO0B.png)|
|`printenv`|
|![](https://i.imgur.com/Rk2NbZT.png)|

|2. Запуск команд с указанием нового значения переменной окружения.|
|-|
|`env HOME=/home/server`|
|![](https://i.imgur.com/n1wl0cZ.png)|
|Создадим свою переменную.|
|`TESTKALI=/home/server`|
|`echo $TESTKALI`|
|![](https://i.imgur.com/AQYhnaq.png)|
|`unser TESTKALI`|
|![](https://i.imgur.com/v3XXi9H.png)|




|3. Добавление и удаление пользовательских переменных.|
|-|
|`sudo nano .bashrc`|
|![](https://i.imgur.com/QMSbv4m.png)|
|![](https://i.imgur.com/akMP8TZ.png)|
|`source .bashrc`|
|![](https://i.imgur.com/1qZod5m.png)|
|![](https://i.imgur.com/1Zc9dHk.png)|



|4. Создание и удаление системных переменных окружения.|
|-|
|`sudo nano /etc/profile`|
|![](https://i.imgur.com/qvj84lS.png)|
|![](https://i.imgur.com/aAVtZk9.png)|
|`source /etc/profile`|
|`echo $TESTKALI2`|
|![](https://i.imgur.com/YVI4Qvj.png)|

