Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Ā
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 ļ¬avours/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: LibreOfļ¬ce, 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/
7. Files
Everything is a ļ¬le
On a UNIX system, everything is a ļ¬le; if something is not a ļ¬le, it is a
process.
Type
Regular (-)
Directory (d)
Special (c)
Links (l)
Domain sockets (s)
Named pipes (p)
Block device ļ¬les (b)
Description
Ordinary ļ¬les
To list other ļ¬les
Used for input/output
Pointers to other ļ¬les
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 ļ¬le 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 ļ¬les
Hardware devices
Conļ¬guration ļ¬les
Home directories of users
Library ļ¬les for programs and the system
Files saved in case of failure
Mount point for removable media
Mount point for external ļ¬lesystems
Third-party software
Information about system resources (userspace window into kernel data structures)
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
13. Manipulating ļ¬les 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 ļ¬le 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 ļ¬le
ā¢ Appending redirection: << or >>
ā¢ Replacing a string in place:
sed -i s/<original_string>/<new_string>/
<file>
ā¢ Replacing a string and copying into a new ļ¬le:
sed s/<original_string>/<new_string>/
<input_file> > <output_file>
15. Shell scripts
ā¢ Shell commands can be put into a ļ¬le and executed as a script
ā¢ A ļ¬le 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.