linux_course_doc/certificates/essentials/lpi_essentials_lesson_04.md

9.3 KiB
Raw Permalink Blame History

Lesson 4.1

Guided Exercises

  1. Which project makes up the common component of all Linux distributions?
    • CentOS
    • Red Hat
    • Ubuntu
    • Linux Kernel
    • CoreOS
  2. Which operating system is reported in use for macOS from Apple?
    • OS X
    • OSX
    • Darwin
    • MacOS
  3. How does a Linux distribution differ from the Linux kernel?
    • The kernel is part of a distribution, the distribution as applications to surround the kernel to make it useful
    • The kernel is the Linux distribution
    • All distributions that use the same kernel are the same
  4. Which operating system other than Linux also includes the Bash shell as default?
    • macOS
    • Windows 10
    • OS2 Warp
    • DOS
  5. Which of the following is a desktop environment in Linux?
    • Mint
    • Elementary
    • Zorin
    • Wayland
  6. Which component of an operating system allows access to hardware?
    • Drivers
    • Shells
    • Service
    • Application

Explorational Exercises

  1. Retrieve the current Kernel version of your Linux system if you have access to the command line
  2. Using your preferred search engine locate and identify public cloud providers available to you. These could include AWS, Google Cloud, Rackspace and many more. Choose one and see which operating systems are available to deploy.

Lesson 4.2

Guided Exercises

  1. Describe these terms:
    • Processor
    • CPU
    • GPU
  2. If you are primarily running video editing applications (a computationally intensive activity) which components and characteristics would you expect to have the most impact on system usability:
    • CPU cores
    • CPU speed
    • Available system memory
    • Storage system
    • GPU
    • Video display
    • None of the above
  3. What would you expect the name of the device file in /dev to be for partition 3 of the third SATA drive in a system:
    • sd3p3
    • sdcp3
    • sdc3
    • None of the above

Explorational Exercises

  1. Run the lsblk command on your system. Identify the parameters below. If a system is not immediately available, consider the lsblk -f listing for the Raspberry Pi system mentioned in the “Storage” section above:

    $ lsblk -f
    NAME        FSTYPE LABEL  UUID                                 MOUNTPOINT
    mmcblk0
    +-mmcblk0p1 vfat   boot   9304-D9FD                            /boot
    +-mmcblk0p2 ext4   rootfs 29075e46-f0d4-44e2-a9e7-55ac02d6e6cc /
    
    • The type of devices and how many
    • The partition structure of each device
    • The type of file system and mount for each partition

Lesson 4.3.1

Guided Exercises

  1. Use the which command to find out the location of the following programs and if they require root permissions:
    • swapon
    • kill
    • cut
    • usermod
    • cron
    • ps
  2. Where are the following files to be found? In the user home or in /etc?
    • .bashrc
    • bash.bashrc
    • passwd
    • .profile
    • resolv.conf
    • sysctl.conf
  3. Explain the meaning of the number elements for kernel file vmlinuz-4.15.0-50-generic found in /boot:
    • 4
    • 15
    • 0
    • 50
  4. What command would you use to list all hard drives and partitions in /dev?

Explorational Exercises

  1. Device files for hard drives are represented based on the controllers they use\—we saw /dev/sd* for drives using SCSI (Small Computer System Interface) and SATA (Serial Advanced Technology Attachment), but
    • How were old IDE (Integrated Drive Electronics) drives represented?
    • And modern NVMe (Non-Volatile Memory Express) drives?
  2. Take a look at the file /proc/meminfo. Compare the contents of this file to the output of the command free and identify which key from /proc/meminfo correspond to the following fields in the output of free:
    • total
    • free
    • shared
    • buff/cache
    • available

Lesson 4.3.2

Guided Exercises

  1. Have a look at the following listing of top and answer the following questions:

    carol@debian:~$ top
    
    top - 13:39:16 up 31 min,  1 user,  load average: 0.12, 0.15, 0.10
    Tasks:  73 total,   2 running,  71 sleeping,   0 stopped,   0 zombie
    %Cpu(s):  1.1 us,  0.4 sy,  0.0 ni, 98.6 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
    KiB Mem :  1020332 total,   698700 free,   170664 used,   150968 buff/cache
    KiB Swap:  1046524 total,  1046524 free,        0 used.   710956 avail Mem
    
      PID USER      PR  NI    VIRT    RES    SHR S %CPU %MEM     TIME+ COMMAND
      605 nobody    20   0 1137620 132424  34256 S  6.3 13.0   1:47.24 ntopng
      444 www-data  20   0  364780   4132   2572 S  0.3  0.4   0:00.44 apache2
      734 root      20   0   95212   7004   6036 S  0.3  0.7   0:00.36 sshd
      887 carol     20   0   46608   3680   3104 R  0.3  0.4   0:00.03 top
        1 root      20   0   56988   6688   5240 S  0.0  0.7   0:00.42 systemd
        2 root      20   0       0      0      0 S  0.0  0.0   0:00.00 kthreadd
        3 root      20   0       0      0      0 S  0.0  0.0   0:00.09 ksoftirqd/0
        4 root      20   0       0      0      0 S  0.0  0.0   0:00.87 kworker/0:0
    (...)
    
    
    • Which processes have been started by the user carol?
    • What virtual directory of /proc should you visit to search for data regarding the top command?
    • What process was run first? How can you tell?
    • Complete the table specifying in what area (Summary or Task) of top output the following information is found:
      • Memory
      • Swap
      • PID
      • CPU time
      • Commands
  2. What command is used to read the following binary logs?

    • /var/log/wtmp
    • /var/log/btmp
    • /run/log/journal/2a7d9730cd3142f4b15e20d6be631836/system.journal
  3. In combination with grep, what commands would you use to find out the following information about your Linux system?

    • When the system was last rebooted (wtmp)
    • Which hard disks are installed (kern.log)
    • When the last login occurred (auth.log)
  4. What two commands would you use to have the kernel ring buffer displayed?

  5. Indicate where the following log messages belong:

    • Jul 10 13:37:39 debian dbus[303]: [system] Successfully activated service 'org.freedesktop.nm_dispatcher'
      • /var/log/auth.log
      • /var/log/kern.log
      • /var/log/syslog
      • /var/log/messages
    • Jul 10 11:23:58 debian kernel: [ 1.923349] usbhid: USB HID core driver
      • /var/log/auth.log
      • /var/log/kern.log
      • /var/log/syslog
      • /var/log/messages
    • Jul 10 14:02:53 debian sudo: pam_unix(sudo:session): session opened for user root by carol(uid=0)
      • /var/log/auth.log
      • /var/log/kern.log
      • /var/log/syslog
      • /var/log/messages
    • Jul 10 11:23:58 debian NetworkManager[322]: [1562750638.8672] NetworkManager (version 1.6.2) is starting...
      • /var/log/auth.log
      • /var/log/kern.log
      • /var/log/syslog
      • /var/log/messages
  6. Have journalctl query information about the following units?

    • ssh
    • networking
    • rsyslog
    • cron

Explorational Exercises

  1. Reconsider the top output from the guided exercises and answer the following questions:
    • What two steps would you follow to kill the apache web server?
    • In the summary area, how could you display the information about physical memory and swap using progress bars?
    • Now, sort the processes by memory usage:
    • Now that you have memory information displayed in progress bars and processes sorted by memory usage, save these configurations so that you get them as default next time you use top:
    • What file stores tops configuration settings? Where does it live? How can you check for its existence?
  2. Learn about the command exec in Bash. Try to demonstrate its functionality by starting a Bash session, finding the Bash process with ps, then run exec /bin/sh and search for the process with the same PID again.
  3. Follow these steps to explore kernel events and udevs dynamic management of devices:
    • Hotplug a USB drive into your computer. Run dmesg and pay attention to the last lines. What is the most recent line?
    • Bearing in mind the output from the previous command, run ls /dev/sd* and make sure your USB drive appears in the listing. What is the output?
    • Now remove the USB drive and run dmesg again. How does the most recent line read?
    • Run ls /dev/sd* again and make sure your device disappeared from the listing. What is the output?

Lesson 4.4

Guided Exercise

  1. A network engineer is asked to assign two IP addresses to the ens33 interface of a host, one IPv4 address (192.168.10.10/24) and one IPv6 address (2001:0:0🔡0:8a2e:0370:7334/64). What commands must they enter to achieve this?
  2. Which addresses from the list below are private?
    • 192.168.10.1
    • 120.56.78.35
    • 172.16.57.47
    • 10.100.49.162
    • 200.120.42.6
  3. What entry would you add into the hosts file to assign 192.168.0.15 to example.com?
  4. What effect would the following command have?
    • sudo ip -6 route add default via 2001:db8:0:abcd::1

Explorational Exercises

  1. Name the DNS record type used to serve the following requests:

    • Textual data
    • Reverse IP address lookup
    • A domain that has no address of its own and relies on another domain for this information
    • Mail Server
  2. Linux has a feature called bridging, what does it do and how is it useful?

  3. What option needs to be supplied to the ss command in order to view all established UDP sockets?

  4. Which command shows a summary of all sockets running on a Linux device?

  5. The following output is generated by the command from the previous exercise. How many TCP and UDP sockets are active?

    Total: 978 (kernel 0)
    TCP:   4 (estab 0, closed 0, orphaned 0, synrecv 0, timewait 0/0), ports 0
    
    Transport Total     IP        IPv6
    *	  0         -         -
    RAW	  1         0         1
    UDP	  7         5         2
    TCP	  4         3         1
    INET	  12        8         4
    FRAG	  0         0         0