Practical activity
Duration1h15Presentation & 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.
Rafiner l’idée c’est de cartographier leur machine (CPU, archi, ram, partition, nom de l’os, leur compte utilisateur, où sont les fichiers) d’abord peut être en ligne de commande puis vérifier en clic bouton
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. Fell free to use both at the same time.
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 “>_” (the historical Unix prompt). Just in case, some indications for Linux Ubuntu
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.
Hardware components
In this exercise we are going to try to retrieve 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.
There are a multiple way to get the information about your CPU inside a Windows terminal, one of them is use the simple systeminfo
command that displays operating system configuration information. However, it is really verbose and here we just want the CPU characteristics.
- With cmd.exe :
wmic cpu get name
- With powershell:
Get-CimInstance -ClassName Win32_Processor
The wmic
command is currently deprecated and Microsoft is pushing for the adoption of the powershell
approach.
lscpu
TODO check that with a macOS user and refine
system_profiler SPHardwareDataType
- 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)
- With cmd.exe :
wmic memorychip get devicelocator, manufacturer, partnumber, serialnumber, capacity, speed, memorytype, formfactor
- With powershell:
Get-CimInstance -ClassName Win32_PhysicalMemory
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_PhysicalMemory | Select-Object devicelocator, manufacturer, partnumber, serialnumber, capacity, speed, memorytype, formfactor
The wmic
command is currently deprecated and Microsoft is pushing for the adoption of the powershell
approach.
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
- How much physical memory do you have on your computer ?
- What is the frequency of the Chip(s) ?
- With cmd.exe :
wmic diskdrive get model,serialNumber,size,mediaType
- With powershell:
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
The wmic
command is currently deprecated and Microsoft is pushing for the adoption of the powershell
approach.
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
- 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 ?
- With cmd.exe :
wmic Path Win32_PNPEntity get Description,DeviceId
- With powershell:
Get-PnpDevice -PresentOnly | Where-Object { $_.InstanceId -match '^USB' }
The wmic
command is currently deprecated and Microsoft is pushing for the adoption of the powershell
approach.
To get all the USB devices
lsusb
To get the PCI devices (for example your graphic card).
lspci
Note: you may need to update the PCI ID database using a command such as sudo update-pciids
first in order to display full information.
system_profiler SPUSBDataType
You can also install the Linux lsusb
command to help you.
brew install usbutils
- What are the current USB devices connected to your computer if any ?
- Can you get your graphic card information ?
Operating System
In this exercise we are going to learn about the features of your Operating System that we have introduced during the lecture.
- With cmd.exe :
ver
- With powershell:
Get-ComputerInfo OsName,OsVersion,OsBuildNumber,OsHardwareAbstractionLayer,WindowsVersion
uname -a
uname -a
- What is the specific version of your operating system ?
- Did you manage to get the kernel version ?
- With cmd.exe :
tasklist
- With powershell:
Get-Process
ps
ps
- Is there a way to make the output more readable ? (think of the
more
command) - Are all the processes listed ?
- With cmd.exe & Powershell:
whoami
whoami
whoami
Available memory
- With cmd.exe:
wmic os get TotalVisibleMemorySize,FreePhysicalMemory
- With powershell:
Get-CimInstance -Class Win32_OperatingSystem | Select-Object FreePhysicalMemory
Available disk space
- with cmd.exe there is no simple command to get the available disk space, with the administrator privileges you can use:
chkdsk
- with Powershell
Get-CimInstance -Class Win32_LogicalDisk |
Select-Object -Property DeviceID, Name, @{
label='FreeSpace'
expression={($_.FreeSpace/1GB).ToString('F2')}
}
Available memory
free
- available disk space
df
Available memory
vm_stat
Available disk space
df
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 OSes 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.
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 …
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).
TODO
- 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, …
Software components
TODO
- 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)
TODO
5 — 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 practice you should follow in order to keep your computer relatively safe (unfortunately it can never be 100% secured).
- 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
The content of this section is optional. It contains additional material for you to consolidate your understanding of the current topic.
TODO add simple scripts
To go beyond
The content of this section is very optional. We suggest you directions to explore if you wish to go deeper in the current topic.
TODO WSL
- name.
Short description.