JB

CSC1030 Systems and Data Management Flashcards

CSC1030 Systems and Data Management Fundamentals - Module 1 (Systems) Practical Exercises (Weeks 1 and 2)

1.1 Explore the Course VM-1 hosted on the Azure Labs platform

  • Register for the Azure Labs Course VM-1 (see URL provided in StudyDesk Announcement).
  • Start and connect to the AzLabs Course VM-1 using the Remote Desktop app on your computer.
  • Open the Windows Terminal (PowerShell) within the VM.
    • To exit PowerShell, type exit.
  • Run the Ubuntu (WSL) app.
    • To exit Ubuntu, type exit.
  • Start Hyper-V and run the headless Debian that is already installed.
  • Log in to the VM:
    • First as usqstudent (password: initial1stPw)
    • Then as root (password: initial1stPw)
  • Exit and shut down the VM from the Hyper-V window.
  • Important Reminders:
    • Always stop the VM in the Azure Labs portal when finished.
    • Virtual resources are subject to the university's Acceptable Use policy.
    • VMs are not being backed up.

1.2 Linux Distributions

  • The course uses various Linux distributions.
  • neofetch is a tool to display information about a distro.
    • It may or may not be pre-installed.
    • Usage: Use neofetch in the Ubuntu (WSL) app.
    • Try to use neofetch in the headless Debian on Hyper-V.

1.3 The Shell in Linux and in Windows

  • Focus is on Command Line Interface (CLI) using a "Shell".
  • Ubuntu (WSL) and headless Debian in Hyper-V automatically provide a terminal for shell commands.
  • Try these simple commands in either Linux machine:
    • $ date
    • $ df
    • $ cal
    • $ free
  • On Windows, PowerShell can be used; some commands work on both Linux and Windows.
  • In the Windows Terminal, try:
    • whoami
    • hostname
    • pwd
    • ls
    • dir
  • These commands can be tried in Linux for comparison.
  • Focus is primarily on Linux shell commands for automation, but PowerShell uses different commands ('cmdlets').

1.4 Use of man pages

  • The man command is very useful.
    • Example: $ man ls
  • Man pages provide detailed help for shell commands.
  • Navigation:
    • Space bar: step through the man page.
    • b: go back.
    • q: quit and return to the command line.
  • Find options to modify the output within the man page for ls (e.g., change how a file size is reported).

1.5 Commands to navigate the filesystem

  • Focus on file manipulation will increase in Module 2.
  • Understanding the current directory is essential; commands act on objects (files) within this directory by default.
  • Check the man pages for pwd and cd:
    • $ man pwd
    • $ man cd
  • Try the following commands in the Ubuntu WSL app:
    • $ pwd
    • $ ls
    • $ ls /usr/bin
    • $ cd /usr/bin
    • $ pwd
    • $ ls
    • $ cd
  • Navigate to /etc and list all files in the "long listing" format (using the -l option).

1.6 Upgrading, and Installing Software

  • Linux often requires manual upgrades for the OS and programs, although automation is possible.
  • Debian-based distros use the apt package manager.
  • Update the system using:
    • $ sudo apt update
    • $ sudo apt upgrade
  • Check if a package is installed using which:
    • $ which neofetch
  • Install new programs after updating the system using apt install:
    • $ sudo apt install neofetch
    • $ sudo apt install tree
    • $ sudo apt install wget
    • $ sudo apt install batcat
  • CLI commands are emphasized for enabling automation, despite the availability of GUI tools.
  • Man pages are available for newly installed programs.
    • Example: $ man wget
  • Install neofetch on the headless Debian VM running in Hyper-V, logging in as root (since usqstudent lacks sudo privileges).

1.7 Processes

  • Try the following commands:
    • $ ps -u usqstudent
    • $ top
  • Processes can run in the foreground and background.
  • Commands typed in the shell run in the foreground by default.
  • Services ('daemons') run in the background and start when the system boots, listening for connections from clients.

1.8 Environment Variables

  • Create environment variables in the shell:
    • $ MYNEWVAR=thevalue
  • Example: Create a variable called COURSECODE and set its value to CSC1030.
  • Check the current value of a variable using echo:
    • $ echo $PATH
  • The $ symbol is needed to get the value but not to set it.
  • The variable PS1 controls the prompt's appearance and can be changed and printed like any other variable.

1.9 Looking at text files (pagers)

  • In the Ubuntu (WSL) app:
    • $ cd ~
    • $ pwd
    • $ wget https://www.gnu.org/licenses/gpl-3.0.txt
    • $ ls
  • View the content using:
    • $ more gpl-3.0.txt
    • $ less gpl-3.0.txt
    • $ cat gpl-3.0.txt
    • $ head gpl-3.0.txt
    • $ tail gpl-3.0.txt
  • Use space bar to advance pages in more or less, and q to exit.
  • Understand the differences between these commands.
  • Question: How can I see more or fewer lines when using head or tail? (Check the man pages.)

1.10 Edit an existing text file (vi, nano)

  • nano and vi are the CLI text editors of choice.
  • Learn the basics of both for working in headless machines.
  • Also, learn to use a sophisticated GUI text/code editor like VSCode.
  • Use of 'vim':
    • Open the downloaded file: $ vi gpl-3.0.txt
    • Initially in 'Command Mode'. Use arrow keys to move.
    • Press i to enter 'Insert Mode'.
    • Type characters. Use Enter and Delete.
    • Press Esc to exit 'Insert Mode' and return to 'Command Mode'.
    • Enter 'Last Line Mode' by typing : (in command mode).
    • Type wq and press Enter to save and quit (w = write/save, q = quit).
  • Use of 'nano':
    • Achieve the same outcomes as with vi but using nano.
    • nano provides help at the bottom of the screen and does not use separate modes, making it easier to learn.

1.11 Hypervisor

  • Return to Hyper-V.
  • Explore the program to understand how to create new VMs, remove existing ones, and modify settings.
  • Other software hypervisors for your own computer include VirtualBox and VMWare Workstation.
  • Hypervisors allow running different virtual machines side-by-side (e.g., on macOS).
  • The VM-1's Hyper-V has a pre-installed headless Debian VM (no Desktop Environment).
  • Do not delete this VM as it will be used in assessment items.
  • The Debian headless is a guest, and Hyper-V is the hypervisor running on the host machine.
  • Windows 11 host is itself a guest, running as a VM on the Azure Labs platform (nested virtualization).
  • Experiment with creating a new VM in Hyper-V. (Time-consuming, so not done in the Prac Session.)
  • Use the StudyDesk Forum for questions.
  • To create a new VM, point Hyper-V to an ISO file (several are in the Windows host's Downloads folder).
  • Refer to the provided external website walkthrough for help.

1.12 WSL

  • A Linux app (Ubuntu) is pre-installed in the Windows Subsystem for Linux (WSL) on the Course VM-1 Windows 11 machine.
  • A WSL app is similar to a full virtual machine but faster and simpler to use (though with some drawbacks).
  • Use the Microsoft Store to download and install a second Linux app that is different from Ubuntu and Debian (e.g., Kali Linux).
  • Kali Linux is a popular distro for learning ethical hacking; more information available from the Kali project page.
  • (Note that several Linux distributions, such as Ubuntu, Kali, Mint, Pop!_OS, are derived from Debian, which is known for its stability.
  • Other distributions, such as Red Hat and Arch, are not derived from Debian.)
  • After downloading and opening the app, a minimal installation process will occur.
  • Use usqstudent as the new account with password initial1stPw (for ease of access, despite not being a general security best practice).
  • Security is managed by the Azure Labs portal, keeping VM-1 private to you and the course team.