SlideShare a Scribd company logo
Lab 1: Hello, Linux!
Advanced Operating Systems

Zubair Nabi
zubair.nabi@itu.edu.pk

January 23, 2013
Unix

• Multi-task, multi-user OS out of Bell Labs in 19691
• Initially in Assembly but later in C (1973)2
• Code recycling!
• Ken Thompson, Dennis Ritchie, Brian Kernighan, Douglas
McIlroy, Michael Lesk and Joe Ossanna
• Branched into BSD (FreeBSD, NetBSD, etc.)

1
2

http://www.youtube.com/watch?v=tc4ROCJYbm0

Dennis M. Ritchie and Ken Thompson. 1974. The UNIX time-sharing system.
Commun. ACM 17, 7 (July 1974), 365-375. DOI=10.1145/361011.361061
Linux
• Linux (circa 1991) is a Unix-clone under FOSS
• Comes in many flavours/distributions (distros): Linux kernel3 +
GUI (optional) + application/software suite
• bash (shell) + GCC + GDB + coreutils
• 600+ distros
• Popular ones: Ubuntu, Fedora, Debian, Gentoo, SUSE, etc.

• Now being used atop desktops, servers, and mobile/embedded
systems

Linus Torvalds: comp.os.minix mailing list (1991-08-25)
I’m doing a (free) operating system (just a hobby, won’t be big and
professional like gnu) for 386(486) AT clones.
3

http://www.kernel.org/
Ubuntu

• Built on top of Debian and developed/distributed by Canonical
Ltd.
• Most popular desktop/laptop distribution
• Applications: LibreOffice, Firefox (web browser), Thunderbird
(email/chat/news), Empathy (IM/VoIP), etc.
• Variants: Ubuntu Deskop, Ubuntu Server, Ubuntu for Phones, etc.
Linux guide(s)

• Introduction to Linux: A Hands on Guide; Achtelt Garrels;
CreateSpace Independent Publishing Platform
Available online:

http://www.tldp.org/LDP/intro-linux/html/
Common commands

Command

ls
cd
file
cat
pwd
man
logout/exit

Description
List the contents of a directory
Change directory (jump across the filesystem tree)
Display file type
Send file contents to standard output
Display current working directory
Display manual page
Close the current session
Files
Everything is a file
On a UNIX system, everything is a file; if something is not a file, it is a
process.
Type
Regular (-)
Directory (d)
Special (c)
Links (l)
Domain sockets (s)
Named pipes (p)
Block device files (b)

Description
Ordinary files
To list other files
Used for input/output
Pointers to other files
IPC through TCP/IP-like sockets
IPC enablers
To represent block devices
Partitioning

• Divides the disk device into multiple logical storage units
• Data partitions contain regular user data
• Swap partitions house the swap space
• Attached to the file system at mount points
• df displays free disk space in active partitions
Filesystem layout
Type

/bin
/boot
/dev
/etc
/home
/lib
/lost+found
/media
/mnt
/opt
/proc

Description
Programs shared by users, administrators,
and the system itself
Start-up files
Hardware devices
Configuration files
Home directories of users
Library files for programs and the system
Files saved in case of failure
Mount point for removable media
Mount point for external filesystems
Third-party software
Information about system resources (userspace window into kernel data structures)
Filesystem layout (2)

/sbin
/tmp
/usr
/var

Programs shared by administrators and the
system
Temporary space
User processes and libraries
Files which change size regularly, e.g. log
files, etc.
Paths, environment variables, and home directories

• Two types of paths:
1

Relative: Relative to the current working directory
• ∼: Relative to home directory

2

Absolute: Starting from the root directory

• Environment variables: Contain dynamic values that change the
behaviour of running programs, e.g. PATH, HOME, etc.
• Each user has a home directory
Manipulating files/directories

• Create directory: mkdir
• Move file/directory: mv
• Copy file/directory: cp
• Remove file/directory: rm
• Find file/directory: find <path> -name <filename>
Manipulating files and their contents

• Filter results: grep
• Invert: -v
• Display values from the top: head
• Display values from the bottom: tail
• Display unique values: uniq
• Change file permissions: chmod
• Permissions: -, r, w, x (bit masks)
• Permission categories: owner, group, everyone else

• Count number of lines (-l), words (-w), and bytes(-c): wc
Pipes and input/output redirection

• Pipe (|): Redirect standard output to standard input
• Input/output redirection (<>): Redirect standard input or output
to a file
• Appending redirection: << or >>
• Replacing a string in place:

sed -i s/<original_string>/<new_string>/
<file>
• Replacing a string and copying into a new file:

sed s/<original_string>/<new_string>/
<input_file> > <output_file>
Shell scripts

• Shell commands can be put into a file and executed as a script
• A file can be made executable through chmod
Today’s Task
• Write a bash script that:
1
2

3

4

5

Creates two folders in your home directory: 1) temp, and 2)
results,
Copies both dictionaries into temp and renames them to
american-english-dictionary and
british-english-dictionary,
Counts the total number of lines in both dictionaries and stores
them in count-british-english-dictionary and
count-american-english-dictionary in the
results folder,
Stores unique American English words (not present in the British
English dictionary) in unique-american-english and
unique British English words (not present in the American English
dictionary) in unique-british-english in the results
folder,
Stores common words (present in both dictionaries) in
common-english in the results folder.

More Related Content

PDF
AOS Lab 2: Hello, xv6!
PDF
Part 03 File System Implementation in Linux
PDF
Intro to Python programming and iPython
PPT
Basic 50 linus command
PPTX
Linux commands
PDF
Quick Guide with Linux Command Line
ODP
4. linux file systems
PPT
Namespace
AOS Lab 2: Hello, xv6!
Part 03 File System Implementation in Linux
Intro to Python programming and iPython
Basic 50 linus command
Linux commands
Quick Guide with Linux Command Line
4. linux file systems
Namespace

What's hot (20)

DOC
Some basic unix commands
PDF
UNIX Basics and Cluster Computing
ODP
Linux Knowledge Transfer
RTF
Useful linux-commands
PDF
An Introduction to User Space Filesystem Development
PDF
Basic commands
PPTX
Introduction to-linux
PDF
Basic unix commands
PPTX
Linux powerpoint
PDF
Linux Network commands
PDF
AOS Lab 10: File system -- Inodes and beyond
PDF
Useful Linux and Unix commands handbook
PDF
Fun with FUSE
PDF
Linux Basic Commands
PDF
AOS Lab 7: Page tables
PPTX
The TCP/IP Stack in the Linux Kernel
PPTX
Linux command for beginners
PDF
AOS Lab 1: Hello, Linux!
PDF
Module 02 Using Linux Command Shell
Some basic unix commands
UNIX Basics and Cluster Computing
Linux Knowledge Transfer
Useful linux-commands
An Introduction to User Space Filesystem Development
Basic commands
Introduction to-linux
Basic unix commands
Linux powerpoint
Linux Network commands
AOS Lab 10: File system -- Inodes and beyond
Useful Linux and Unix commands handbook
Fun with FUSE
Linux Basic Commands
AOS Lab 7: Page tables
The TCP/IP Stack in the Linux Kernel
Linux command for beginners
AOS Lab 1: Hello, Linux!
Module 02 Using Linux Command Shell
Ad

Viewers also liked (15)

PDF
AOS Lab 11: Virtualization
PDF
AOS Lab 8: Interrupts and Device Drivers
PDF
Topic 13: Cloud Stacks
PDF
Raabta: Low-cost Video Conferencing for the Developing World
PDF
MapReduce and DBMS Hybrids
PDF
MapReduce Application Scripting
PDF
AOS Lab 4: If you liked it, then you should have put a “lock” on it
PDF
The Anatomy of Web Censorship in Pakistan
PDF
AOS Lab 5: System calls
PDF
AOS Lab 6: Scheduling
PDF
AOS Lab 9: File system -- Of buffers, logs, and blocks
PDF
Topic 14: Operating Systems and Virtualization
PPTX
The Big Data Stack
PDF
AOS Lab 12: Network Communication
PDF
Topic 15: Datacenter Design and Networking
AOS Lab 11: Virtualization
AOS Lab 8: Interrupts and Device Drivers
Topic 13: Cloud Stacks
Raabta: Low-cost Video Conferencing for the Developing World
MapReduce and DBMS Hybrids
MapReduce Application Scripting
AOS Lab 4: If you liked it, then you should have put a “lock” on it
The Anatomy of Web Censorship in Pakistan
AOS Lab 5: System calls
AOS Lab 6: Scheduling
AOS Lab 9: File system -- Of buffers, logs, and blocks
Topic 14: Operating Systems and Virtualization
The Big Data Stack
AOS Lab 12: Network Communication
Topic 15: Datacenter Design and Networking
Ad

Similar to AOS Lab 1: Hello, Linux! (20)

PPTX
UNIX.pptx
PPT
Karkha unix shell scritping
PPSX
Unix environment [autosaved]
PPTX
Unix Shell Script - 2 Days Session.pptx
PPT
Chapter 1 Overview of system administration.ppt
PPTX
Unix_Introduction_BCA.pptx the very basi
PPT
Online Training in Unix Linux Shell Scripting in Hyderabad
PPT
Linux Administration
PPT
Linux Administration
PPT
User administration concepts and mechanisms
PPT
Shell_Scripting.ppt
PPTX
Presentation for RHCE in linux
PPTX
Unix/Linux
PPTX
Rishav Mishra final presentation on UNIX Final.pptx
PDF
Unix _linux_fundamentals_for_hpc-_b
PPTX
Unix environment [autosaved]
PDF
DOC
58518522 study-aix
PPTX
Introduction to Unix
PDF
Linux Notes-1.pdf
UNIX.pptx
Karkha unix shell scritping
Unix environment [autosaved]
Unix Shell Script - 2 Days Session.pptx
Chapter 1 Overview of system administration.ppt
Unix_Introduction_BCA.pptx the very basi
Online Training in Unix Linux Shell Scripting in Hyderabad
Linux Administration
Linux Administration
User administration concepts and mechanisms
Shell_Scripting.ppt
Presentation for RHCE in linux
Unix/Linux
Rishav Mishra final presentation on UNIX Final.pptx
Unix _linux_fundamentals_for_hpc-_b
Unix environment [autosaved]
58518522 study-aix
Introduction to Unix
Linux Notes-1.pdf

More from Zubair Nabi (11)

PDF
Lab 5: Interconnecting a Datacenter using Mininet
PDF
Topic 12: NoSQL in Action
PDF
Lab 4: Interfacing with Cassandra
PDF
Topic 10: Taxonomy of Data and Storage
PDF
Topic 11: Google Filesystem
PDF
Lab 3: Writing a Naiad Application
PDF
Topic 9: MR+
PDF
Topic 8: Enhancements and Alternative Architectures
PDF
Topic 7: Shortcomings in the MapReduce Paradigm
PDF
Lab 1: Introduction to Amazon EC2 and MPI
PDF
Topic 6: MapReduce Applications
Lab 5: Interconnecting a Datacenter using Mininet
Topic 12: NoSQL in Action
Lab 4: Interfacing with Cassandra
Topic 10: Taxonomy of Data and Storage
Topic 11: Google Filesystem
Lab 3: Writing a Naiad Application
Topic 9: MR+
Topic 8: Enhancements and Alternative Architectures
Topic 7: Shortcomings in the MapReduce Paradigm
Lab 1: Introduction to Amazon EC2 and MPI
Topic 6: MapReduce Applications

Recently uploaded (20)

PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Machine learning based COVID-19 study performance prediction
PPTX
Big Data Technologies - Introduction.pptx
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Approach and Philosophy of On baking technology
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Electronic commerce courselecture one. Pdf
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
Spectroscopy.pptx food analysis technology
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Building Integrated photovoltaic BIPV_UPV.pdf
MIND Revenue Release Quarter 2 2025 Press Release
Machine learning based COVID-19 study performance prediction
Big Data Technologies - Introduction.pptx
Encapsulation_ Review paper, used for researhc scholars
Digital-Transformation-Roadmap-for-Companies.pptx
sap open course for s4hana steps from ECC to s4
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Spectral efficient network and resource selection model in 5G networks
Approach and Philosophy of On baking technology
Unlocking AI with Model Context Protocol (MCP)
NewMind AI Weekly Chronicles - August'25 Week I
Per capita expenditure prediction using model stacking based on satellite ima...
20250228 LYD VKU AI Blended-Learning.pptx
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Electronic commerce courselecture one. Pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
Network Security Unit 5.pdf for BCA BBA.
Spectroscopy.pptx food analysis technology

AOS Lab 1: Hello, Linux!

  • 1. Lab 1: Hello, Linux! Advanced Operating Systems Zubair Nabi zubair.nabi@itu.edu.pk January 23, 2013
  • 2. Unix • Multi-task, multi-user OS out of Bell Labs in 19691 • Initially in Assembly but later in C (1973)2 • Code recycling! • Ken Thompson, Dennis Ritchie, Brian Kernighan, Douglas McIlroy, Michael Lesk and Joe Ossanna • Branched into BSD (FreeBSD, NetBSD, etc.) 1 2 http://www.youtube.com/watch?v=tc4ROCJYbm0 Dennis M. Ritchie and Ken Thompson. 1974. The UNIX time-sharing system. Commun. ACM 17, 7 (July 1974), 365-375. DOI=10.1145/361011.361061
  • 3. Linux • Linux (circa 1991) is a Unix-clone under FOSS • Comes in many flavours/distributions (distros): Linux kernel3 + GUI (optional) + application/software suite • bash (shell) + GCC + GDB + coreutils • 600+ distros • Popular ones: Ubuntu, Fedora, Debian, Gentoo, SUSE, etc. • Now being used atop desktops, servers, and mobile/embedded systems Linus Torvalds: comp.os.minix mailing list (1991-08-25) I’m doing a (free) operating system (just a hobby, won’t be big and professional like gnu) for 386(486) AT clones. 3 http://www.kernel.org/
  • 4. Ubuntu • Built on top of Debian and developed/distributed by Canonical Ltd. • Most popular desktop/laptop distribution • Applications: LibreOffice, Firefox (web browser), Thunderbird (email/chat/news), Empathy (IM/VoIP), etc. • Variants: Ubuntu Deskop, Ubuntu Server, Ubuntu for Phones, etc.
  • 5. Linux guide(s) • Introduction to Linux: A Hands on Guide; Achtelt Garrels; CreateSpace Independent Publishing Platform Available online: http://www.tldp.org/LDP/intro-linux/html/
  • 6. Common commands Command ls cd file cat pwd man logout/exit Description List the contents of a directory Change directory (jump across the filesystem tree) Display file type Send file contents to standard output Display current working directory Display manual page Close the current session
  • 7. Files Everything is a file On a UNIX system, everything is a file; if something is not a file, it is a process. Type Regular (-) Directory (d) Special (c) Links (l) Domain sockets (s) Named pipes (p) Block device files (b) Description Ordinary files To list other files Used for input/output Pointers to other files IPC through TCP/IP-like sockets IPC enablers To represent block devices
  • 8. Partitioning • Divides the disk device into multiple logical storage units • Data partitions contain regular user data • Swap partitions house the swap space • Attached to the file system at mount points • df displays free disk space in active partitions
  • 9. Filesystem layout Type /bin /boot /dev /etc /home /lib /lost+found /media /mnt /opt /proc Description Programs shared by users, administrators, and the system itself Start-up files Hardware devices Configuration files Home directories of users Library files for programs and the system Files saved in case of failure Mount point for removable media Mount point for external filesystems Third-party software Information about system resources (userspace window into kernel data structures)
  • 10. Filesystem layout (2) /sbin /tmp /usr /var Programs shared by administrators and the system Temporary space User processes and libraries Files which change size regularly, e.g. log files, etc.
  • 11. Paths, environment variables, and home directories • Two types of paths: 1 Relative: Relative to the current working directory • ∼: Relative to home directory 2 Absolute: Starting from the root directory • Environment variables: Contain dynamic values that change the behaviour of running programs, e.g. PATH, HOME, etc. • Each user has a home directory
  • 12. Manipulating files/directories • Create directory: mkdir • Move file/directory: mv • Copy file/directory: cp • Remove file/directory: rm • Find file/directory: find <path> -name <filename>
  • 13. Manipulating files and their contents • Filter results: grep • Invert: -v • Display values from the top: head • Display values from the bottom: tail • Display unique values: uniq • Change file permissions: chmod • Permissions: -, r, w, x (bit masks) • Permission categories: owner, group, everyone else • Count number of lines (-l), words (-w), and bytes(-c): wc
  • 14. Pipes and input/output redirection • Pipe (|): Redirect standard output to standard input • Input/output redirection (<>): Redirect standard input or output to a file • Appending redirection: << or >> • Replacing a string in place: sed -i s/<original_string>/<new_string>/ <file> • Replacing a string and copying into a new file: sed s/<original_string>/<new_string>/ <input_file> > <output_file>
  • 15. Shell scripts • Shell commands can be put into a file and executed as a script • A file can be made executable through chmod
  • 16. Today’s Task • Write a bash script that: 1 2 3 4 5 Creates two folders in your home directory: 1) temp, and 2) results, Copies both dictionaries into temp and renames them to american-english-dictionary and british-english-dictionary, Counts the total number of lines in both dictionaries and stores them in count-british-english-dictionary and count-american-english-dictionary in the results folder, Stores unique American English words (not present in the British English dictionary) in unique-american-english and unique British English words (not present in the American English dictionary) in unique-british-english in the results folder, Stores common words (present in both dictionaries) in common-english in the results folder.