CS 6560 Operating System Design Lecture 3:Tour of GNU/Linux.

17
CS 6560 Operating System Design Lecture 3:Tour of GNU/Linux

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.

CS 6560 Operating System Design

Lecture 3:Tour of GNU/Linux

Page 2: CS 6560 Operating System Design Lecture 3:Tour of GNU/Linux.

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.

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.

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.

Getting Help

• man

• info

• Documents directory of the source

• google

Page 6: CS 6560 Operating System Design Lecture 3:Tour of GNU/Linux.

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.

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.

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.

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.

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.

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.

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.

Editors

• vi (now vim)

• emacs

• pico

Page 14: CS 6560 Operating System Design Lecture 3:Tour of GNU/Linux.

Getting Organized

• Use permissions for privacy

• Organize your work in directories

Page 15: CS 6560 Operating System Design Lecture 3:Tour of GNU/Linux.

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.

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.

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