0% found this document useful (0 votes)
10 views14 pages

OS2 - Week 3 - Week4

This document outlines a lab exercise for students at the College of Telecommunications & Electronics in Jeddah, focusing on the Linux filesystem and commands. It includes tasks related to absolute and relative paths, file and directory manipulation, and system hardware information retrieval using commands like 'lscpu', 'free', and 'lspci'. The lab is designed to enhance students' understanding of operating systems and their functionalities.

Uploaded by

salshehri9522
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views14 pages

OS2 - Week 3 - Week4

This document outlines a lab exercise for students at the College of Telecommunications & Electronics in Jeddah, focusing on the Linux filesystem and commands. It includes tasks related to absolute and relative paths, file and directory manipulation, and system hardware information retrieval using commands like 'lscpu', 'free', and 'lspci'. The lab is designed to enhance students' understanding of operating systems and their functionalities.

Uploaded by

salshehri9522
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

‫المملكـــــــة العربيــــة السعوديـــــة‬

KINGDOM OF SAUDI ARABIA


‫المؤسسة العامة للتدريب التقني والمهني‬
Technical and Vocational Training Corporation
College of Telecommunications & Electronics – Jeddah
‫كلية االتصاالت واإللكترونيات بجدة‬
Department of Computer Technology
‫قسم تقنية الحاسب‬

Operating System – 2 Labs

Week 2 – Lab 1
Part 1: The Linux Filesystem
Task 1: Refer to the figure answer the following questions

Budget.doc

1. Write either absolute path or relative path for the following paths:

/etc/
/usr/bin/
usr/share/
Pictures/Hawaii/
family/mom.jpg cdcd
/home/fred/Docs/
/boot/
../Docs/
../../home/
./Music/
/proc/
/
downtown
./img02.jpg
/dev/

Designed by Aiman Alobadi 1 / 14


‫المملكـــــــة العربيــــة السعوديـــــة‬
KINGDOM OF SAUDI ARABIA
‫المؤسسة العامة للتدريب التقني والمهني‬
Technical and Vocational Training Corporation
College of Telecommunications & Electronics – Jeddah
‫كلية االتصاالت واإللكترونيات بجدة‬
Department of Computer Technology
‫قسم تقنية الحاسب‬

Operating System – 2 Labs

2. Write the absolute path for the following files and directories:
 include directory: …………………………………………………………………………
 fred home directory: ………………………………………………………………………
 fido.jpg file: ……………………………………………………………………………….
 sue Desktop directory: ……………………………………………………………………
 img03.jpg file: …………………………………………………………………………….
 .mozilla directory: …………………………………………………………………………
 Docs directory: ……………………………………………………………………………
 Budget.doc file: …………………………………………………………………………..
 proc directory: ……………………………………………………………………………
 dev directory: ……………………………………………………………………………..
 sue home directory: ………………………………………………………………………
 bin directory: ……………………………………………………………………………..
 downtown directory: ………………………………………………………………………
 timmy.jpg file: …………………………………………………………………………….
 lib directory: ………………………………………………………………………………

3. Write the relative path for the following files and directories:
 from usr directory to include directory: ………………………………………………….
 from home directory to fred home directory: …………………………………………….
 from sue directory to fido.jpg file: ………………………………………………………..
 from sue home directory to sue Desktop directory: ………………………………………
 from Pictures directory to sue directory: …………………………………………………
 from Pictures directory to Img01.jpg file:………………………………………………..
 form sue directory to mom.jpg file: ………………………………………………………
 from fred directory to Budget.doc file: …………………………………………………..
 from family directory to downtouwn directory: ………………………………………….
 from fred home directory to proc directory: ……………………………………………...
 from hawaii directory to Music directory: ……………………………………………….
 from bin directory to sue home directory: ………………………………………………..
 from pet directory to fluffy.jpg file: ……………………………………………………...
 from downtown directory to share directory: …………………………………………….
 from family directory to fred Desktop directory: …………………………………………

Designed by Aiman Alobadi 2 / 14


‫المملكـــــــة العربيــــة السعوديـــــة‬
KINGDOM OF SAUDI ARABIA
‫المؤسسة العامة للتدريب التقني والمهني‬
Technical and Vocational Training Corporation
College of Telecommunications & Electronics – Jeddah
‫كلية االتصاالت واإللكترونيات بجدة‬
Department of Computer Technology
‫قسم تقنية الحاسب‬

Operating System – 2 Labs

pwpec1cPart 2: Files and Directories


In this task you will explore the concepts of files and directories.

On a Linux OS, data is stored in files and files are stored in directories. You may be used to the
term folders to describe directories.

Directories are actually files, too; the data that they hold are the names of the files that have been
entered into the them, along with the inode number (a unique identifier number assigned to each
file) for where the data for that file exists on the disk. As a Linux user, you will want to know how
to manipulate these files and directories.

Warning: File and directory names in Linux are case sensitive. This means that a file
named "ABC" is not the same as a file named "abc".

Now open the terminal application and complete the following tasks

1) Type the following command to print the working directory:

pwd

The working directory is the directory that your terminal window is currently "in". This is also
called the current directory. This will be important for when you are running future commands
as they will behave differently based on the directory you are currently in.

The output of the pwd command (/home/sysadmin in the example above) is called the path.
The first slash represents the root directory, the top level of the directory structure.

In the output above, home is a directory under the root directory and sysadmin is a directory
under the home directory.

Designed by Aiman Alobadi 3 / 14


‫المملكـــــــة العربيــــة السعوديـــــة‬
KINGDOM OF SAUDI ARABIA
‫المؤسسة العامة للتدريب التقني والمهني‬
Technical and Vocational Training Corporation
College of Telecommunications & Electronics – Jeddah
‫كلية االتصاالت واإللكترونيات بجدة‬
Department of Computer Technology
‫قسم تقنية الحاسب‬

Operating System – 2 Labs


When you first open a terminal window, you will be placed in your home directory. This is a
directory where you have full access and other users normally have no access by default. To see
the path to your home directory, you can execute the following command to view the value of
the HOME variable:

echo $HOME

Write your home directory :………………………………………………………………………

2) You can use the cd command with a path to a directory to change your current directory. Type
the following command to make the root directory your current working directory and verify w
cd ith the pwd command:

/
pwd

cdecuted without a path. Change back to your home directory and verify by typing the following
commands:

cd
pwd

Notice the change in the prompt. The tilde (~) character represents your home directory. This
part of the prompt will tell you what directory you are currently in.

3) When you provide the cd command a path to a directory, the path is called an argument to the
cd command. Execute the cd command with the /home directory as an argument by typing the
following:

cd /home
pwd

Designed by Aiman Alobadi 4 / 14


‫المملكـــــــة العربيــــة السعوديـــــة‬
KINGDOM OF SAUDI ARABIA
‫المؤسسة العامة للتدريب التقني والمهني‬
Technical and Vocational Training Corporation
College of Telecommunications & Electronics – Jeddah
‫كلية االتصاالت واإللكترونيات بجدة‬
Department of Computer Technology
‫قسم تقنية الحاسب‬

Operating System – 2 Labs

When the path that is provided as an argument to the cd command starts with the forward slash
(/), that path is referred to as an “absolute path”. Absolute paths are always complete paths from
the root directory to a sub-directory or file.

4) Change back to your home directory, using the cd command with the tilde (~)as an argument:

cd ~
pwd

When the path that is provided as an argument to cd command starts with a tilde (~) character,
the terminal will expand the character to the home directory of a user with an account on the
system.

If either no other characters or a forward slash follows the tilde, then it will expand to the home
directory of the user currently active in the shell.

If a user name immediately follows the tilde character, then the shell will expand the tilde and
user name to the home directory of that user name. For example, ~bob would be expanded to
/home/bob.

Paths that start with a tilde are considered absolute paths because after the shell expands the
tilde path, an absolute path is formed.

5) Use the echo command below to display some other examples of using the tilde as part of path:

echo ~ ~sysadmin ~root ~mail ~nobody

Designed by Aiman Alobadi 5 / 14


‫المملكـــــــة العربيــــة السعوديـــــة‬
KINGDOM OF SAUDI ARABIA
‫المؤسسة العامة للتدريب التقني والمهني‬
Technical and Vocational Training Corporation
College of Telecommunications & Electronics – Jeddah
‫كلية االتصاالت واإللكترونيات بجدة‬
Department of Computer Technology
‫قسم تقنية الحاسب‬

Operating System – 2 Labs


Note: While you can change to your account's home directory path with the cd
command, the home directories of other users are not normally accessible.

6) Attempt to change to the home directory of the root user by typing the following command:

cd ~root

Notice the error message; it indicates that the shell attempted to execute cd with /root as an
argument and it failed due to permission being denied. You will learn more about file and
directory permissions in a later lab.

7) Using an absolute path, change to the /usr/bin directory and display the working directory by
using the following commands:

cd /usr/bin
pwd

8) Use an absolute path to change the /usr directory and display the working directory by issuing
the following commands:

cd /usr
pwd

Designed by Aiman Alobadi 6 / 14


‫المملكـــــــة العربيــــة السعوديـــــة‬
KINGDOM OF SAUDI ARABIA
‫المؤسسة العامة للتدريب التقني والمهني‬
Technical and Vocational Training Corporation
College of Telecommunications & Electronics – Jeddah
‫كلية االتصاالت واإللكترونيات بجدة‬
Department of Computer Technology
‫قسم تقنية الحاسب‬

Operating System – 2 Labs


9) Use an absolute path the change to the /usr/share/doc directory and display the working
directory by issuing the following commands:

cd /usr/share/doc
pwd

Absolute vs. Relative pathnames

Suppose you are in the /usr/share/doc directory and you want to go to the
/usr/share/doc/bash directory. Typing the command cd /usr/share/doc/bash results in a
fair amount of typing. In cases like this, you want to use relative pathnames.

With relative pathnames you provide "directions" of where you want to go from the current
directory. The following examples will illustrate using relative pathnames.

10) Using a relative path, change to the /usr/share/doc/bash directory and display the working
directory by issuing the following commands:

cd bash
pwd

Note: if there wasn't a bash directory under the current directory, the previous
command would fail.

11) Use a relative path to change to the directory above the current directory:

p cd wd
..

Designed by Aiman Alobadi 7 / 14


‫المملكـــــــة العربيــــة السعوديـــــة‬
KINGDOM OF SAUDI ARABIA
‫المؤسسة العامة للتدريب التقني والمهني‬
Technical and Vocational Training Corporation
College of Telecommunications & Electronics – Jeddah
‫كلية االتصاالت واإللكترونيات بجدة‬
Department of Computer Technology
‫قسم تقنية الحاسب‬

Operating System – 2 Labs

The .. represents one level above your current directory location.

12) Use a relative path to change up one level from the current directory and then down into the
dict directory:

cd ../dict
pwd

Designed by Aiman Alobadi 8 / 14


‫المملكـــــــة العربيــــة السعوديـــــة‬
KINGDOM OF SAUDI ARABIA
‫المؤسسة العامة للتدريب التقني والمهني‬
Technical and Vocational Training Corporation
College of Telecommunications & Electronics – Jeddah
‫كلية االتصاالت واإللكترونيات بجدة‬
Department of Computer Technology
‫قسم تقنية الحاسب‬

Operating System – 2 Labs

Week 2 – Lab 2
Listing Computer Hardware
Now open the terminal application and complete the following tasks

1) In order to determine the type of CPU execute the lscpu command:

lscpu

Your output will be similar to the following:


Architecture
CPU op-mode(s)
Byte Order
CPU(s)
On-line CPU(s) lists
Thread(s) per core
Core(s) per socket
Socket(s)
NUMA node(s)
Vendor ID
CPU family
Model
Stepping
CPU MHz
BogoMIPS
Virtualization type
L1d cache
L1i cache
L2 cache
L3 cache
NUMA node0 CPU(s)

Being able to display CPU information can be important when trying to determine if more
advanced Linux features can be used on your system. For even more details about your CPU(s),
you can examine the /proc/cpuinfo file, especially, the "flags" that are listed that determine
whether or not your CPU has certain features.

Designed by Aiman Alobadi 9 / 14


‫المملكـــــــة العربيــــة السعوديـــــة‬
KINGDOM OF SAUDI ARABIA
‫المؤسسة العامة للتدريب التقني والمهني‬
Technical and Vocational Training Corporation
College of Telecommunications & Electronics – Jeddah
‫كلية االتصاالت واإللكترونيات بجدة‬
Department of Computer Technology
‫قسم تقنية الحاسب‬

Operating System – 2 Labs


2) View the /proc/cpuinfo file:

cat /proc/cpuinfo

processor
vendor_id
cpu family
model
model name
stepping
microcode

Designed by Aiman Alobadi 10 / 14


‫المملكـــــــة العربيــــة السعوديـــــة‬
KINGDOM OF SAUDI ARABIA
‫المؤسسة العامة للتدريب التقني والمهني‬
Technical and Vocational Training Corporation
College of Telecommunications & Electronics – Jeddah
‫كلية االتصاالت واإللكترونيات بجدة‬
Department of Computer Technology
‫قسم تقنية الحاسب‬

Operating System – 2 Labs


cpu MHz
cache size
physical id
siblings
core id
cpu cores
apicid
initial apicid
fpu
fpu_exception
cpuid level
wp
flags

3) To discover how much RAM and swap space is being used, use the free command:

free -m
free -g

The output shows the amount of memory in megabytes when the -m option is used and in
gigabytes when the -g option is used:

In the output above, you can see that the system has 16049 megabytes (roughly 15 gigabytes) of
physical memory (RAM). Of that only 1066 megabytes are being used, a good sign that you
have enough memory for your system's needs.

In the event that you run out of memory, Swap is used. Swap is hard drive space that is used to
temporarily store data that is supposed to be stored in RAM.

total used free shared buffers cached


Mem:
-/+ buffers/cache:
Swap:

Designed by Aiman Alobadi 11 / 14


‫المملكـــــــة العربيــــة السعوديـــــة‬
KINGDOM OF SAUDI ARABIA
‫المؤسسة العامة للتدريب التقني والمهني‬
Technical and Vocational Training Corporation
College of Telecommunications & Electronics – Jeddah
‫كلية االتصاالت واإللكترونيات بجدة‬
Department of Computer Technology
‫قسم تقنية الحاسب‬

Operating System – 2 Labs

4) To see what devices are connected to the PCI bus, use the lspci command:

lspci

Notice from the partial output below, that many of the devices connected to the system board
are displayed:

The output of the lspci command can be very important to identify devices that are not
supported by the Linux kernel. Some devices like video cards may only provide basic
functionality without installing proprietary driver software.

Write down the information about following hardware in your system:

VGA
Ethernet
Audio

5) Attempt to list the USB connected devices:

lsusb

Normally, if USB devices are present, it would have shown something like this:

Write the result on your screen:

Designed by Aiman Alobadi 12 / 14


‫المملكـــــــة العربيــــة السعوديـــــة‬
KINGDOM OF SAUDI ARABIA
‫المؤسسة العامة للتدريب التقني والمهني‬
Technical and Vocational Training Corporation
College of Telecommunications & Electronics – Jeddah
‫كلية االتصاالت واإللكترونيات بجدة‬
Department of Computer Technology
‫قسم تقنية الحاسب‬

Operating System – 2 Labs

6) Execute the fdisk command to list the disk devices non-interactively, in sectors, and without
DOS compatibility warnings:

fdisk -cul

The partial output of this command below shows the first disk, /dev/sda and its partitions:

Now write down your system results:

Disk Size

Device Boot Start End Blocks Id System

The fdisk command can be used in two ways: interactively and non-interactively.

When the -l option is used with fdisk, then the command will non-interactively list block
devices, which includes disks (hard drives) and logical volumes.

Without the -l option the fdisk command enters an interactive mode that is typically used to
modify partitions on a disk device.

Designed by Aiman Alobadi 13 / 14


‫المملكـــــــة العربيــــة السعوديـــــة‬
KINGDOM OF SAUDI ARABIA
‫المؤسسة العامة للتدريب التقني والمهني‬
Technical and Vocational Training Corporation
College of Telecommunications & Electronics – Jeddah
‫كلية االتصاالت واإللكترونيات بجدة‬
Department of Computer Technology
‫قسم تقنية الحاسب‬

Operating System – 2 Labs


The -u option causes the fdisk command to display units in sectors instead of cylinders. The
-c option prevents the fdisk command from printing warnings that affect DOS compatibility.

Designed by Aiman Alobadi 14 / 14

You might also like