CS 6560 Operating System Design Lecture 3:Tour of GNU/Linux.
-
Upload
bryce-hodges -
Category
Documents
-
view
213 -
download
0
Transcript of CS 6560 Operating System Design Lecture 3:Tour of GNU/Linux.
![Page 1: CS 6560 Operating System Design Lecture 3:Tour of GNU/Linux.](https://reader036.fdocuments.us/reader036/viewer/2022082818/56649eb75503460f94bc10a5/html5/thumbnails/1.jpg)
CS 6560 Operating System Design
Lecture 3:Tour of GNU/Linux
![Page 2: CS 6560 Operating System Design Lecture 3:Tour of GNU/Linux.](https://reader036.fdocuments.us/reader036/viewer/2022082818/56649eb75503460f94bc10a5/html5/thumbnails/2.jpg)
More on Kernel Compiling
• Configuration: – make defconfig– make menuconf– Looking at .conf
• Making the initrd– Documentation on initrd and mkinitrd– Dealing with incompatibilities
![Page 3: CS 6560 Operating System Design Lecture 3:Tour of GNU/Linux.](https://reader036.fdocuments.us/reader036/viewer/2022082818/56649eb75503460f94bc10a5/html5/thumbnails/3.jpg)
Some references
• An introduction to Linux:– http://tldp.org/LDP/intro-linux/html/
• An introduction to the Bash shell– http://tldp.org/LDP/Bash-Beginners-Guide/html
/index.html
![Page 4: CS 6560 Operating System Design Lecture 3:Tour of GNU/Linux.](https://reader036.fdocuments.us/reader036/viewer/2022082818/56649eb75503460f94bc10a5/html5/thumbnails/4.jpg)
Tour of Linux
• Accounts• Logging in and out• Getting help• Shells: bash• Common commands• Editors• Compiler: gcc• Make• Services
![Page 5: CS 6560 Operating System Design Lecture 3:Tour of GNU/Linux.](https://reader036.fdocuments.us/reader036/viewer/2022082818/56649eb75503460f94bc10a5/html5/thumbnails/5.jpg)
Getting Help
• man
• info
• Documents directory of the source
![Page 6: CS 6560 Operating System Design Lecture 3:Tour of GNU/Linux.](https://reader036.fdocuments.us/reader036/viewer/2022082818/56649eb75503460f94bc10a5/html5/thumbnails/6.jpg)
Shells• Why have shells?
– Giving commands (requests) to the system
• What is a shell? – Command interpreter– Basic commands: internal and external
• Internal: – Control structures (if, while, for, break, continue, exit)– Job control (fg, jobs)– Current status (cd, pwd, )– I/O (read, echo, printf)
• External – loaded into new process
• What shells are available?– sh, csh, tcsh, zsh, bash, rc, etc.
![Page 7: CS 6560 Operating System Design Lecture 3:Tour of GNU/Linux.](https://reader036.fdocuments.us/reader036/viewer/2022082818/56649eb75503460f94bc10a5/html5/thumbnails/7.jpg)
Bash Shell Syntax• See “info bash”• Everything is broken into words first• Shell variables
– variables are stored as strings– variables can be assigned values– use of $ to get value– export: shell -> environmental variable
• Parameters– $1, $2, $*– set, unset, shift
• Quoting and expanding– Several types of expansions:
• Brace Expansion: Expansion of expressions within braces.• Tilde Expansion: Expansion of the ~ character.• Shell Parameter Expansion: Expansion of variables to their values.• Command Substitution: Using the output of a command as an argument.• Arithmetic Expansion: Using arithmetic in shell expansions.• Filename Expansion: wild cards and square brackets
– single and double quotes, escaping with backslash
• Pipes, filters, redirection to form pipelines– | > < >>
• Control structures: while, for, until
![Page 8: CS 6560 Operating System Design Lecture 3:Tour of GNU/Linux.](https://reader036.fdocuments.us/reader036/viewer/2022082818/56649eb75503460f94bc10a5/html5/thumbnails/8.jpg)
The Shell as a programming environment
• Creating a script• #! notation
• Executing the script – sourcing with . or source– invoking by name (must set the permissions)
![Page 9: CS 6560 Operating System Design Lecture 3:Tour of GNU/Linux.](https://reader036.fdocuments.us/reader036/viewer/2022082818/56649eb75503460f94bc10a5/html5/thumbnails/9.jpg)
External Commands
• File and directory manipulation– cp, rm, chmod, mkdir, rmdir, ls
• Filters– grep, sort, cat, head, tail, cut, paste, od, tr, pr, wc
• Program development– Gcc, make
• Text processing• System administration
![Page 10: CS 6560 Operating System Design Lecture 3:Tour of GNU/Linux.](https://reader036.fdocuments.us/reader036/viewer/2022082818/56649eb75503460f94bc10a5/html5/thumbnails/10.jpg)
Some Common External Commands:file and directory manipulation
ls List directory entries
cd Change directory
pwd Print path of current directory
chmod Change permissions
mkdir Create a new directory
rmdir Remove a directory
mv Move a directory entry
rm Remove a directory entry
![Page 11: CS 6560 Operating System Design Lecture 3:Tour of GNU/Linux.](https://reader036.fdocuments.us/reader036/viewer/2022082818/56649eb75503460f94bc10a5/html5/thumbnails/11.jpg)
Some Common External Commands: text manipulation (filters)
cat Concatenate multiple files to standard output
more Paged output to standard output
less Fancier version of more
head Show the first few lines of a file
tail Show the last few lines of a file
grep Search files for a pattern
cut Cut columns of text from a file
od Octal dump a file (also: hex,char,binary)
sort Sort a file
tr Translate a file character by character
pr Format a file for printing
wc Count words, lines, characters
![Page 12: CS 6560 Operating System Design Lecture 3:Tour of GNU/Linux.](https://reader036.fdocuments.us/reader036/viewer/2022082818/56649eb75503460f94bc10a5/html5/thumbnails/12.jpg)
Unix Permissions• Each file and directory has an owner and a group
membership
• Permissions are organized by user (owner), group, and others– u = user, g = group, o = others
• Permissions consists of read, write, and execute for each type of user– r = read, w = write, x = execute
• Permissions can be viewed with the ls command and changed with the chmod command.
• Permissions meanings are different for regular files than for directories (see man page for ls and chmod).
• Examples in class
![Page 13: CS 6560 Operating System Design Lecture 3:Tour of GNU/Linux.](https://reader036.fdocuments.us/reader036/viewer/2022082818/56649eb75503460f94bc10a5/html5/thumbnails/13.jpg)
Editors
• vi (now vim)
• emacs
• pico
![Page 14: CS 6560 Operating System Design Lecture 3:Tour of GNU/Linux.](https://reader036.fdocuments.us/reader036/viewer/2022082818/56649eb75503460f94bc10a5/html5/thumbnails/14.jpg)
Getting Organized
• Use permissions for privacy
• Organize your work in directories
![Page 15: CS 6560 Operating System Design Lecture 3:Tour of GNU/Linux.](https://reader036.fdocuments.us/reader036/viewer/2022082818/56649eb75503460f94bc10a5/html5/thumbnails/15.jpg)
Program Development
• Shells
• Perl
• C: gcc
• Use of make (see info make)
![Page 16: CS 6560 Operating System Design Lecture 3:Tour of GNU/Linux.](https://reader036.fdocuments.us/reader036/viewer/2022082818/56649eb75503460f94bc10a5/html5/thumbnails/16.jpg)
The proc file system
• Shows a view of the kernel in terms of files
• For details see– man proc
– /usr/src/linux/Documentation/filesystems/proc.txt
• Assignment #2 - using proc to get information about a machine
![Page 17: CS 6560 Operating System Design Lecture 3:Tour of GNU/Linux.](https://reader036.fdocuments.us/reader036/viewer/2022082818/56649eb75503460f94bc10a5/html5/thumbnails/17.jpg)
Services
• Many processes run in the background taking care of things such as printing and logging people in.
• Vmware-tools is an example service.• Centos has a GUI interface to its service through
the system configuration menu.• Services can be controlled directly from command
lines and scripts located in /etc/init.d and referenced from /etc/rc.d according to runtime level. - see the scripts for vmware-tools