Practical activity

Duration1h15

Presentation & objectives

The aim of this activity is to help you discover how your computer works, and what are the main physical elements inside it.

Also, you will learn to manipulate the terminal to navigate in your file system, and run commands.

Activity contents

You may already know the insides of your own computer, nevertheless you might not know how to get them from a Command Line Interface (CLI). In this activity, we will try to map all your system components using only the terminal. We will then verify all the information using the Graphical User Interface.

If you want you can edit a text file on your computer to write down the command lines’ output or use a good old-fashioned pen&paper.

1 — What is your operating system?

The first thing you need to know in order to continue this activity is what is your operating system. For this first question we will not get into the detail, we only need to know the OS family: Linux, Windows or MacOS.

2 — Using the command line

The second step is launching the Terminal application of your operating system. This application may differ from one OS to another (hence the first easy question):

Modern Windows versions have two Terminal applications that you can use: the old cmd.exe or the more advanced PowerShell. The first one, cmd.exe, is more ancient and simpler but can be seen as less practical. PowerShell on the other hand is more modern and quite flexible, but it’s object-oriented syntax can be hard to understand. It is however more similar to the Linux and MacOS one as most of the Unix-like commands are aliases for the native PowerShell ones.

To launch either of them click on the start icon and type-in: Command Prompt (or PowerShell) to run either of them. Feel free to use both at the same time.

Command Prompt and PowerShell terminals.

Explore the menus and look for an application called “Terminal”, “Shell” or similar. It is probably an icon figuring a rectangular black&white screen displaying the text $. Just in case, some indications for Linux Ubuntu.

Gnome-terminal.

Bring Finder into focus, then in the menu bar, click “Go” and select “Utilities”. A folder will open, scroll through until you find an application called “Terminal”. It is probably an icon figuring a rectangular black&white screen displaying the text %. Just in case, some indications for MacOS.

MacOS Terminal.

3 — Discover your own computer

Now that you have opened the Terminal application of you specific OS we are going to learn a little bit about your computer.

3.1 — Hardware components

In this exercise we are going to try to get the list of the most important hardware components of your computer. In particular, we are going to learn about the components of the von Neumann architecture that we have introduced during the lecture.

3.1.1 — CPU

First, let’s determine your CPU:

wmic cpu get name
Get-CimInstance -ClassName Win32_Processor
lscpu
system_profiler SPHardwareDataType
Information

On Windows, when using cmd.exe, the wmic command is currently deprecated, and Microsoft is pushing for the adoption of the PowerShell approach.

Also, you can use the simple systeminfo command that displays operating system configuration information. However, it is really verbose and here we just want the CPU characteristics.

Answer the following questions:

  • What is your CPU vendor?

  • What is the frequency of your CPU?

  • Optional – Did you get the number of cores available (you may have to search for an additional parameters)?

3.1.2 — Memory

Let’s have a look at the RAM:

wmic memorychip get devicelocator, manufacturer, partnumber, serialnumber, capacity, speed, memorytype, formfactor
Get-CimInstance -ClassName Win32_PhysicalMemory

# You can also only select the information you want to display using an anonymous pipe `|`
Get-CimInstance -ClassName Win32_PhysicalMemory | Select-Object devicelocator, manufacturer, partnumber, serialnumber, capacity, speed, memorytype, formfactor
lshw -short -C memory

# Note that if you use the `lshw` command without parameters you will also get the CPU info that we retrieved before
system_profiler SPMemoryDataType

Answer the following questions:

  • How much physical memory do you have on your computer?

  • What is the frequency of the chip(s)?

3.1.3 — Storage

Let’s check your storage devices:

wmic diskdrive get model,serialNumber,size,mediaType
Get-CimInstance -ClassName Win32_DiskDrive

# You can also only select the information you want to display to get the same ones as the `cmd.exe` output using an anonymous pipe `|`
Get-CimInstance -ClassName Win32_DiskDrive | Select-Object model,serialNumber,size,mediaType
lsblk
hdparm -I /dev/sda

# `/dev/sd[a-z]` stands for the hard drive
# During installation, Linux takes the first hard disk found and assigns it the value `sda`
# It does the naming in alphabetical order depending on the number of disks found
system_profiler SPStorageDataType

Answer the following questions:

  • How many storage drives are installed in your computer?

  • What is the total size of your drive(s)?

  • Do you have Hard Disk Drive(s) or Solid State Drive(s)?

  • Optional – How many partitions are present, and what is a partition?

3.1.4 — Peripherals

What are the peripherals plugged to your computer? Let’s check:

wmic Path Win32_PNPEntity get Description,DeviceId
Get-PnpDevice -PresentOnly | Where-Object { $_.InstanceId -match '^USB' }
# To get all USB devices
lsusb

# To get all PCI devices (for example your graphic card)
# You may need to update the PCI ID database using a command such as `sudo update-pciids` first in order to display full information
lspci
system_profiler SPUSBDataType

# You can also install the Linux `lsusb` command to help you (you need Homebrew installed)
brew install usbutils
lsusb

Answer the following questions:

  • What are the current USB devices connected to your computer if any?

  • Can you get your graphic card information?

3.2 — Operating system

In this exercise we are going to learn about the features of your Operating System that we have introduced during the lecture.

3.2.1 — OS version

Let’s first get its version:

ver
Get-ComputerInfo OsName,OsVersion,OsBuildNumber,OsHardwareAbstractionLayer,WindowsVersion
uname -a
uname -a

Answer the following questions:

  • What is the specific version of your operating system?

  • Did you manage to get the kernel version?

3.2.2 — Processes and daemons

Let’s have a look at what is running on the computer:

tasklist
Get-Process
ps
ps

Answer the following questions:

  • Is there a way to make the output more readable (think of the more command)?

  • Are all the processes listed?

3.2.3 — Users

Let’s check who you are on the computer:

whoami
whoami
whoami
whoami
3.2.4 — Available resources

What is available on your computer? Let’s check the available memory first:

wmic os get TotalVisibleMemorySize,FreePhysicalMemory
Get-CimInstance -Class Win32_OperatingSystem | Select-Object FreePhysicalMemory
free
vm_stat

Then, let’s check available disk space:

chkdsk
Get-CimInstance -Class Win32_LogicalDisk |
  Select-Object -Property DeviceID, Name, @{
    label='FreeSpace'
    expression={($_.FreeSpace/1GB).ToString('F2')}
  }
df
df

3.3 — Remarks on the terminal

The command line allows you to do many more tasks that we will not cover here. However, you may have noticed that some terminal commands are simpler than the others depending on the operating system, especially the Linux ones. That can be explained by the need to interact with these OSs with a command line more often (to administer a server for example). That is why, even if you are not currently running a Linux machine, we greatly encourage you to learn and practice with Linux commands for the IMT Atlantique computer science curriculum.

4 — Using the graphical interface for validation

Now that we have obtained much of the hardware and operating system information using the CLI we are going to verify all of them using the GUI.

4.1 — The hardware components

Most of the modern OS have a single point of entry to get all the hardware components of your PC, including its CPU, drives, peripherals, etc.

Under Windows you can access what is called the Device Manager (or Gestionnaire de Périphériques) either by searching it in the start menu or with a nice shortcut by right-clicking on the start menu icon. As a matter of facts nearly all the administrative tools of Windows can be accessed that way (it can also save you one click to shut down your computer).

Windows Device Manager.

Unlike Windows and MacOS, Linux distributions do not always come witha pre-installed GUI to display the hardware information as it is often faster to use the CLI (it is the case for Ubuntu for example). Fortunately, you can always install such an application yourself.

On Ubuntu, this application is called hardinfo and you can install it using the App center or even better using the command line.

sudo apt install hardinfo

Let’s decrypt this comand line:

  • sudo – executes a command as another user in order to make the installation possible (usually root). It is why you are prompted for your password, sudo checks that you are allowed to execute the following command.
  • apt – is an application that provides a high-level commandline interface for the package management system.
  • install – performs the installation of one or more packages specified after.
  • hardinfo – is the specified package that contains the application.

If the commands return an error, you may have entered the wrong password, or the package list of the package management system is outdated. In that second case, type in:

sudo apt update
sudo apt install hardinfo

Here is how it looks:

Linux hardinfo application.

On MacOS, the graphical application is called System information (or Informations système) you can find it in the application menu or by pressing and hold the Option key, then choose Apple menu > System Information.

MacOS System information.

If you only want to display the disk information, you can also access Disk Utility (or utilitaire de disque).

Answer the following questions:

  • Verify that all the previous information you gathered about your computer are the same as the one presented in the GUI.

  • Optional – Feel free to explore and discover other information about your hardware: your network adapters, graphic card, etc.

4.2 — The software components

Let’s check OS details using a GUI now:

Under Windows you can access the About (or À propos) either by searching it in the start menu or by right-clicking on the start menu icon and look for system.

System panel under Windows.

From the top right-hand menu on Ubuntu you can find a parameters panel, and at the bottom of this panel you will find the about tab as shown below.

System panel in Ubuntu.

From the Apple menu in the top left-hand corner of the screen, choose About this Mac.

About this Mac.

You can also check the running processes:

Under Windows you can access the Task Manager (or Gestionnaire des tâches) either by searching it in the start menu, by right-clicking on the start menu icon or with the keyboard shortcut ctrl + shift + esc.

Winwows task Manager.

Under Ubuntu the graphical application to get the running process is often called System Monitor.

Ubuntu system monitor for processes.

On MacOS, the graphical application is called Activity Monitor (or Moniteur d'activité) you can find it in the application menu.

MacOS activity monitor.

Answer the following questions:

  • Are the running processes the same that you found with the CLI?

  • Launch a simple application (such as a text editor), can you see it in the list of processes?

  • Optional – Try to kill this process (be careful to select the previous process and not another one).

Now, let’s find available resources:

In the Task Manager (or Gestionnaire des tâches) there is tab called Performances where you can find CPU usage, Memory usage, Disk usage and many more.

Winwows task Manager Performance tab.

In the System Monitor, under the Resources tab you can find CPU usage, Memory usage, Disk usage and many more.

Ubuntu system monitor for available resources.

On MacOS, the Activity Monitor (or Moniteur d'activité) can also display CPU usage, Memory usage and Disk usage.

MacOS activity monitor, Memory tab.

5 — Always keep your system and applications up to date

As we have seen, your computer is running a lot of different processes either applications that you are using or services that perform various tasks in the background. There is a specific type of applications that we have not covered for the moment which are malicious software.

Malicious software, or malware, are designed to harm, exploit, or otherwise compromise a computer system or network. The primary purposes of malware include stealing sensitive information (e.g., passwords, financial data), disrupting operations (e.g., causing system crashes, deleting files), gaining unauthorized access to systems, and using compromised devices for illegal activities (e.g., sending spam, launching attacks on other systems).

They can come from various sources: applications downloaded from an untrusted sources (think of pirated games), a fraudulent link, or a macro inside a Word document received by mail for example. Here we give a list of some security best practices you should follow in order to keep your computer relatively safe (unfortunately it can never be 100% secured).

Important

Here are a few important concluding remarks:

  • You should always keep your system up-to-date and especially install all security patches automatically. Nowadays, with the democratization of SSDs a system can install its updates and reboot in a matter of minutes if not seconds.

  • Always download applications from trusted sources (the official website or the package manager of your favorite OS).

  • Always update these applications or at least install their security patches.

  • Always be careful before clicking a link or opening a document. Disable macro/javascript execution by default in word processor or pdf viewers.

  • Monitor your system (use the Command Line or GUI to look for unknown processes and review log files).

  • Back up your work (on a USB stick or in the cloud). You will lose your files, either by deleting them by mistake, falling victim to ransomware, or simply because your hard drive or other parts of your computer fail. The question is not if, but when!

To go further

Important

The content of this section is optional. It contains additional material for you to consolidate your understanding of the current topic.

6 — Using Linux with Windows

As mentioned above, you will probably need to use Linux at some point during your curriculum at IMT Atlantique so it can be a good thing to learn the basics commands as soon as possible. For a long time, that meant having to fully install a Linux distribution on your computer replacing Windows or installed side by side. You then had to reboot your computer to chose between the two OSes which meant that you could not run both at the same time.

However, since 2016, it is possible to run a Linux environment on windows using Windows Subsystem for Linux (WSL). While it was limited at first, it now uses a real Linux Kernel, and it can even execute Linux GUI applications in the newer versions.

We therefore strongly encourage you to install it and play with it. You can find the whole installation procedure on the official Microsoft Website.

Information

Here are a few things that can happen to you during installation:

  • You may get an error Please enable the Virtual Machine Platform Windows feature and ensure virtualization is enabled in the BIOS. If so, check this video for a solution!

  • When installing Linux, you will be asked to create a user. This will be your identity when interacting with the Linux system. On Linux, user names have to be full lowercase, without spaces or special characters.

When WSL and the Linux OS are installed, you will have access to a prompt starting with #. This corresponds to a root (administrator) prompt.

At this point, you can already use your Linux system by typing commands. However, you may want a graphical user interface, which is more friendly than a terminal. To do so, you can follow this tutorial.

To go beyond

Important

The content of this section is very optional. We suggest you directions to explore if you wish to go deeper in the current topic.

If you want to improve your command line skills and impress your fellow students by never touching a mouse again you can follow the links below.