------------------------- Week 02 Notes for NET2003 ------------------------- -Ian! D. Allen - idallen@idallen.ca Remember - knowing how to find out an answer is more important than memorizing the answer. Learn to fish! RTFM! (Read The Fine Manual) Midterm test dates are posted on the Course Home Page. Comments on lab work - read the whole question before starting to answer it - the hints that make life easier are at the end of the question Review: - you can log in to the course linux server - you have a basic knowledge of the VIM editor - you have finished Lab 1 - you have at least one copy of a Knoppix 5.1 CD in a good CD case - note the bug fix ---> Knoppix 5.5.1 is available On Learning VIM: http://ian.idallen.ca/pictures/misc/curves.html Knoppix 5.1 ----------- - based on the Debian Linux distribution Knoppix Bug with 5.1.0 (fixed in 5.1.1): - if you switch desktops, you lose the bar on the bottom of the screen - left click on the desktop and select "Configure Desktop" - select "Multiple Desktops" - drag the slider down to one single desktop - click "Apply" - Knoppix 5.1.1 available: http://knopper.net/knoppix/index-en.html - bug fix version also available on Course Linux Server: http://10.50.254.148/distributions/Knoppix/KNOPPIX_V5.1.1CD-2007-01-04-EN/ Knoppix Networking: - print *on paper* the section on reconfiguring Knoppix networking so that you don't have to reboot the machine if your network drops Knoppix GUI tour: - basic X cut-and-paste with mouse: - left button drags and selects into clipboard (no need for "copy") - double click to drag-select words; triple click for lines - right button extends clipboard selection - middle button (often under the scroll wheel) pastes clipboard - DO NOT PASTE TEXT INTO VIM IN COMMAND MODE - the pasted text will be executed as vim commands, silly - don't use Knoppix Konqueror browser; use FireFox/IceWeasel instead - FireFox opens text pages directly, which is nicer than using KWrite - both FireFox and Konqueror have tabbed browsing: - middle button click on a link opens a link in a new tab - Konqueror opens the tab in the foreground (new tab has focus) - FireFox opens the link in the backgound (current window keeps focus) - middle button will paste a URL to open in a tab, from the clipboard - the Konsole terminal has tabs (on the bottom) for multiple shells - SHIFT+RightArrow moves between sessions without using the mouse (a full list of shortcuts is under Settings | Configure Shortcuts) Q: how do you copy text under the X11 window system? Q: how do you paste text under the X11 window system? Q: why should you avoid the Konqueror browser in favour of IceWeasel/FireFox? The Internet - who owns it? who controls it? ------------ - the Internet is not just the WWW (HTTP) - but Algonquin College blocks most non-HTTP traffic - in particular, the SMTP port (25) is blocked to external sites - blocks are "drop packet", not "refuse packet" types; they time out - Internet not developed as a proprietary system - standards-based vs. product-based - nobody pays license fees to use TCP/IP, SMTP, HTTP, etc. - Tim Berners-Lee doesn't get royalties for your web site - why do companies still write web pages that only work in one browser? - e.g. Algonquin Blackboard - http://www.anybrowser.org/campaign/ - Like the downtown streets at rush hour, the Internet doesn't (yet) pass traffic based on how much money you have. You can't get higher priority by paying more; though, this may change (on the Internet) in the next year or two if the backbone carries have their way. - http://www.digital-copyright.ca/node/2894 "Net Neutrality: A Public Discussion on the Future of the Internet in Canada" Feb 6 2007 (free) - The Internet is dumb. Some say you could implement it using two cans and a string. (Or carrier pigeons.) The intelligence is "at the edges". - pigeons: http://tools.ietf.org/html/1149 - pigeons: http://www.blug.linux.no/rfc1149/ Q: T/F the Internet is patented; companies pay royalties to use the WWW and IP protocols Q: T/F you can pay more to have your data packets given priority on the global Internet - WWW slashes are "forward" slashes because the WWW grew up on Unix machines. DOS/Windows came much later. - text-based Internet protocols pre-date XML (everything is text in Unix) - Unix was full of tools to deal with text - an "ethereal" dump of most Internet protocols is often very readable - Internet Engineering Task Force (IETF) - Motto: "Rough consensus and running code." "When I was studying Physics the quickest way to end an argument was to show the explanation in mathematics (albeit a lot of handwaving mathematics!). Most software developers on the otherhand do not grok math, however they surely do grok code. Therefore if you could explain your arguments through code then you would have improved your odds of getting your message through." http://www.manageability.org/blog/stuff/rest-explained-in-code/view "Be liberal in what you accept, and conservative in what you send" (Jon Postel, TCP/IP developer) "If we were all conservative in what we do, then we wouldn't do much that is new, or different. This would seem to retard progress. Of course, the same would be true in protocols so perhaps we need a "where possible" qualifier." http://www.aaronsw.com/weblog/000776 Q: What does "Be liberal in what you accept, and conservative in what you send" mean? - FLOSS (Free/Libre Open Source Software) - open-source discussions occur with source code samples - Internet standards: ARPAnet Request for Comment - RFC http://tools.ietf.org/html/ IP: http://tools.ietf.org/html/791 (45 pages) SMTP: http://tools.ietf.org/html/2821 (79 pages) Q: What does the acronym "FLOSS" mean? Q: What do the initials RFC mean with regard to Internet standards documents? * Who controls handing out the IP numbers and port numbers? - the Internet Corporation for Assigned Names and Numbers (ICANN) through its operating unit the Internet Assigned Numbers Authority (IANA) "Dedicated to preserving the central coordinating functions of the global Internet for the public good." ICANN: http://www.icann.org/ IANA: http://www.iana.org/ - IANA delegates to a few Regional Internet Registries (RIRs) to distribute the large blocks of IP addresses http://www.iana.org/ipaddress/ip-addresses.htm http://www.iana.org/assignments/ipv4-address-space - e.g. ARIN IP address list http://www.arin.net/ - special IP addresses (historical and current) are documented in RFC3330 http://tools.ietf.org/html/3330 - note the important RFC1918 private address space: 10.0.0.0 - 10.255.255.255 (10/8 prefix) 172.16.0.0 - 172.31.255.255 (172.16/12 prefix) 192.168.0.0 - 192.168.255.255 (192.168/16 prefix) "the Internet does not inherently protect against abuse of these addresses; if you expect (for instance) that all packets from the 10.0.0.0/8 block originate within your subnet, all border routers should filter such packets that originate from elsewhere. Attacks have been mounted that depend on the unexpected use of some of these addresses." - IANA TCP/UDP port list (see RFC4340 for the three big divisions) http://www.iana.org/assignments/port-numbers - Well Known Ports are those from 0 through 1023 - Registered Ports are those from 1024 through 49151 - Dynamic and/or Private Ports are those from 49152 through 65535 - a shorter Unix/Linux specific copy of this file is kept in /etc/services Q: What organization is the ultimate authority on IP addresses and ports? Q: What organization is delegated to manage IP addresses in North America? Q: Give the three RFC1918 private address space blocks and their masks Q: What is the last IP address in the RFC1918 block 172.16.0.0/12 ? Q: T/F the Internet will not route RFC1918 private addresses Q: T/F Special address block 0.0.0.0 is reserved for hosts on your local network. [see RFC3330] Q: T/F IP address 0.0.0.0 is not a valid address. [see RFC3330] Q: What Unix/Linux file is used to turn "smtp" into "25" when you do $ telnet localhost smtp $ nc -v localhost smtp Linux basics & Linux command line interface (CLI) tour: ------------ Pagination commands - several comands, e.g. more, less, pg - one set of commands does all the pagination - pagination is not built in to each command, as in DOS - searching can be done using / in MORE and LESS (and VIM) - space bar goes down by pages; return goes down by lines - in more or less, type h or ? at the prompt to get a help screen Q: T/F like DOS, each Unix program has its own pagination option Q: how do you reach the help screen in the "less" pagination program? Q: how do you search for a word when using "less" or "vim"? Using the Unix Shell - up-arrow repeats previous commands in shell command history - TAB will complete command names and pathnames (but not arguments) - "exit" will cause the shell to exit, possibly logging you out if there are no other shells running on that connection Q: In most Unix shells, how do you "get back" or repeat the last command? Q: How can you ask the shell to auto-complete a file name? Q: What built-in shell command causes the shell to terminate? Manual pages - using the man command, man -k, and apropos (man_page_RTFM.txt) - man pages are displayed using LESS on Linux - as with less, you can use / to search the pages for words Q: T/F Linux manual pages are displayed using the "less" pagination program Q: How would you search forward for the word "TCP" when looking at a man page? Entering console or command-line command text - the terminal driver - your terminal is two devices, keyboard and screen, loosely coupled - many programs can write on your screen at the same time - control chars (unprintables) syntax: ^X means CTRL-X for the 32 ASCII characters from @ to A to Z to [ to ^ - see "man ascii" and "man latin1" ^? by convention means the DEL character (does not mean CTRL-?) - use the backspace key to erase one char - but Unix has to know what character the backspace key sends! - do not use the back-arrow key to erase! use the backspace key - VIM and some shell programs use back-arrow to move, not erase - terminal driver line edit characters: ^H ^? ^W ^U - ^H or ^? - erase previous character (backspace) - ^W - erase most recent word on the line (same as vim) - ^U - erase entire line (same as vim) - other control characters: - ^R - redraw line (in case overwritten by background program output) - ^C - interrupt the current (foreground) process - ^D - send EOF (end of input) to program from keyboard - ^L - often clear/redraw screen (in bash shell, less, more, and vim) - ^Z - suspend/stop (not kill) current process temporarily; use the built-in shell command fg to restart the process If your backspace key isn't recognized by Unix/Linux, you can fix it: - see Notes file terminal.txt $ stty erase '^?' $ stty erase '^H' - the quote characters protect the argument to stty from interpretation by the shell Q: when talking to the terminal driver in Unix/Linux: - how do you erase a character? a word? a line? - how do you redraw the current line of input? - how do you interrupt the current process? - how do you send EOF from the keyboard? - how do you clear/redraw the screen? Q: T/F the Unix/Linux keyboard is connected to your terminal screen so that characters from the keyboard go directly to the screen and then off to Unix/Linux Q: how do I fix my backspace character if it is echoing ^? characters? Q: how do I fix my backspace character if it is echoing ^H characters? Important: Most Unix commands that take file names as arguments will read standard input (usually your keyboard) if no file names are given. Unlike the shell, the commands will *not* prompt when reading your keyboard. Q: for most commands that take file names, what happens if you don't give the command any file names? Q; T/F all commands that read your keyboard issue a prompt for input first New command names: - "sort" sorts all its argument files (together) to standard output - the files themselves are not changed - "cat" catenates all its argument files (one after the other) to stdout - the files themselves are not changed - "stty erase X" sets your backspace (erase) character to X Q: what does this command do: sort file1 file2 file3 Q: what does this command do: cat file1 file2 file3 Q: how would I set my backspace character to be ^E (CTRL-E)? Differentiate between EOF (^D) and Interrupting Processes (^C) - ^D and ^C are not the same - ^C kills the process and it doesn't finish what it was doing - many programs read your keyboard if you don't give them any files $ sort - note difference between ^C and ^D $ wc - note difference between ^C and ^D $ cat - less difference, since cat doesn't buffer to a terminal Q: what is the difference between ^C and ^D ? For most programs that talk to your screen to work (e.g. VIM, LESS), Unix needs to know what kind of terminal emulation your screen is using (e.g. vt100, xterm, ansi, etc.). Sometimes you have to set this explicitly: see Notes file terminal.txt Q: What shell variable contains the current terminal type? Unix file system notes - see Notes file pathnames.txt - Unix pathnames use slashes / not backslashes \ - slashes *separate* pathname components - the first directory to the left of the leftmost slash is the ROOT directory that has no name (often incorrectly called "/" because calling it "" is awkward) - "absolute" pathnames start with a slash (preceded by the empty ROOT) - "relative" pathnames do not start with a slash - but note that a leading tilde "~" contains a hidden slash, e.g. ~idallen ! - but note that shell variables such as $HOME may also contain slashes, e.g. $HOME/foo --> /home/idallen/foo --> absolute pathname - there are no "drive letters" in Unix - hardware can be mounted anywhere in the file system tree Q: what is the name of the top (root) of the Unix/Linux directory tree? Q: what is an absolute path? a relative path? Q: T/F an absolute path is dependent on the current directory Q: T/F a relative path always refers to the same file Unix is an O/S designed by programmers for programmers - command-line driven (programmers didn't use the GUI) - things work silently (no confirmation) - messages appear only when things fail - most command names are cryptic abbreviations! - like vim, the commands are hard to learn but easy to use Q: T/F most Unix/Linux commands ask for confirmation of serious actions