# Lab5 Solution Amirlan Sharipov (BS21-CS-01)

## Table of Contents

- 1. Question 1
- 2. Question 2
- 3. Question 3

## 1. Question 1

    echo "Username: $(whoami)"
    echo "Home Directory: $HOME"
    echo "Shell: $SHELL"
    echo "Hostname: $(hostname)"
    ipaddress="$(ip addr | grep -A5 "enp2s0f1:" | grep "inet .*" | awk '{print $2}')"
    echo "IP address: $ipaddress"

    Username: rinri
    Home Directory: /home/rinri
    Shell: /bin/zsh
    Hostname: akemi
    IP address: 10.244.1.78/24

## 2. Question 2

    HOME=lab5-solution.org # THIS IS DONE TO NOT MAKE HOME BACKUP WHEN EXPORTING
    sudo mkdir -p /var/backups
    FNAME="$(date '+/var/backups/home_backup_%b_%d_%Y_%H_%M_%S.tar.gz')"
    sudo tar caf $FNAME $HOME

## 3. Question 3

    uname -svm

    w

    CUR_USERS="$(who | awk '{print $1}' | sort | uniq)"

    if [ -d "/sys/firmware/efi" ]; then
        echo "EFI"
    else
        echo "No EFI"
    fi

    lsblk -o "+PTTYPE" | sed 's/^\([A-Za-z]*\) \(.*\)gpt/\1*\2gpt/'

    efibootmgr | grep "Boot$(efibootmgr | grep "BootOrder" | awk '{print substr($2, 0, 4);}')"

    Linux #1 SMP PREEMPT_DYNAMIC Tue, 14 Feb 2023 22:08:08 +0000 x86_64
     23:55:56 up  9:44,  2 users,  load average: 1.35, 1.71, 1.34
    USER     TTY        LOGIN@   IDLE   JCPU   PCPU WHAT
    rinri    tty1      14:11    9:44m  8:14   0.00s xinit /home/rinri/.xinitrc -- /etc/X11/xinit/xserverrc :0 vt1 -keeptty -auth /tmp/serverauth.unEBAJdBrv
    root     tty2      14:46    9:09m  0.00s  0.00s -bash
    EFI
    NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS PTTYPE
    sda*     8:0    0 931.5G  0 disk             gpt
    ├─sda1   8:1    0   499M  0 part             gpt
    ├─sda2   8:2    0   100M  0 part             gpt
    ├─sda3   8:3    0    16M  0 part             gpt
    ├─sda4   8:4    0  42.4G  0 part             gpt
    ├─sda5   8:5    0  38.8G  0 part             gpt
    ├─sda6   8:6    0   100M  0 part             gpt
    ├─sda7   8:7    0   3.1G  0 part             gpt
    ├─sda8   8:8    0   315G  0 part /mnt/rec    gpt
    └─sda9   8:9    0 531.5G  0 part /mnt/data   gpt
    sdb*     8:16   0 465.8G  0 disk             gpt
    ├─sdb1   8:17   0    16M  0 part             gpt
    ├─sdb2   8:18   0   250G  0 part             gpt
    ├─sdb3   8:19   0  64.7G  0 part /           gpt
    ├─sdb4   8:20   0  97.2G  0 part /home       gpt
    ├─sdb5   8:21   0     8G  0 part [SWAP]      gpt
    ├─sdb6   8:22   0   781M  0 part /boot       gpt
    ├─sdb7   8:23   0    44G  0 part             gpt
    └─sdb8   8:24   0     1G  0 part             gpt
    Boot0003* Arch BTW	HD(7,GPT,1d75b784-ef17-3c4d-9e74-0b058e17bf83,0x3a1ff800,0x18680f)/File(\vmlinuz-linux)

Author: Amirlan Sharipov (BS21-CS-01)

Created: 2023-03-02 Thu 23:55