% CST8207 Week 02 Notes -- the shell, arguments and options, man pages, pathnames absolute and relative % Ian! D. Allen -- -- [www.idallen.com] % Winter 2017 - January to April 2017 - Updated 2017-03-13 09:11 EDT - [Course Home Page] - [Course Outline] - [All Weeks] - [Plain Text] Readings, Assignments, Labs, Tests, and ToDo ============================================ Read (at least) these things (All The Words) -------------------------------------------- 1. [Week 02 Notes HTML] -- this file -- **Read All The Words** 2. [The Unix/Linux Shell] -- using the shell command line in Linux 3. [Command Arguments and Options] 4. [Finding Help in Manual Pages -- RTFM] 5. [File System and Pathnames] -- ROOT, absolute, relative, dot, dot dot 6. [List of Commands You Should Know] 7. [Linux and Sysadmin News in the World] - Create your [lynda.com] account and watch these sections of [Unix for Mac OS X Users] - these videos are for *all* Unix/Linux students, not just Mac OSX users - **1. Intro to Unix** - Command structure 5m 22s - command names, options, and arguments - Kernels and shells 5m 25s - the O/S core vs. the shell programs that read your command line - Unix manual pages 4m 6s - `man` - how to get help on every Unix/Linux command name - some say this is "the most valuable movie", "your best friend" - **2. Filesystem Basics** - The working directory 2m 49s - `pwd` - Listing files and directories 3m 59s - `pwd`, `ls`, hidden files - Moving around the filesystem 4m 58s - `cd`, TAB filename completion, absolute/relative paths - Filesystem organization 4m 12s - ROOT, standard Unix folders - **3. Working with Files and Directories** - Naming files 5m 41s - Unix is case-sensitive, OSX is case-insensitive! - avoid special characters or blanks in Unix pathnames Assignments this week --------------------- Check the due date for each assignment and put a reminder in your agenda, calendar, and digital assistant. Just like in the Real World, not all due dates are on the same days or at the same times. - Review last week. Did you do everything assigned last week? - Read All The Words, Do, and then Submit via Blackboard: - [Assignment #01 HTML] -- Multi-tasking and Schoolwork - [Assignment #02 HTML] -- Course Linux Server simple commands - Really do **Read All The Words**. You don't get a second chance to get it right. Lab work this week ------------------ - Last week, your instructor showed you how to log in to the [Course Linux Server] and use some simple commands to create a file and then transfer the file to your laptop and upload it to Blackboard. - [Assignment #02 HTML] will have you log in to the CLS, do some simple commands with output redirection, and change your CLS password. - After you finish the above assignments, read [File System and Pathnames]. - If you understand pathnames, start work on the first two worksheets. - You need to understand the worksheets for your next assignments. ### Worksheets Worksheets are preparation for your assignments. You can't do the assignments without having done the worksheets first, and you can't do the worksheets without having first read the Course Notes: 1. Read. 2. Worksheet. 3. Assignment. Form a small study group to do the worksheets. Each person tries the example given, and you make sure you all get the same answers. Worksheets are not for hand-in; they are not worth marks; the assignments test your knowledge of the lectures and worksheets. > The worksheets are available in four formats: Open Office (ODT), PDF, HTML, > and Text. Only the Open Office format allows you "fill in the blanks" in > the worksheet. The PDF format looks good but doesn't allow you to type into > the blanks in the worksheet. The HTML format is crude but useful for quick > for viewing online. Do **NOT** open the Worksheet ODT files using any Microsoft products; they will mangle the format and mis-number the questions. Use the free Libre Office or Open Office programs to open these ODT documents. On campus, you can [download Libre Office here]. These first two worksheets require you to have read [File System and Pathnames]: - [Worksheet #02 ODT] -- Using standard Linux commands I - [Worksheet #02 PDF] - [Worksheet #02 HTML] - `PS1, cd, find, less, ls, man, mkdir, passwd, pwd, rmdir` - [Worksheet #03 ODT] -- Using standard Linux commands II - [Worksheet #03 PDF] - [Worksheet #03 HTML] - `cat, clear, cp, find, grep, history, less, man, mv, rm, sleep, touch` Worksheets prepare you for the upcoming assignments. Upcoming tests ============== For full marks, read the [Test Instructions] (all the words) before your midterm tests. 1. First Midterm test: 45 minutes; in lecture class 10am on Friday in Week 5 (Feb 10) 2. Second Midterm test: 45 minutes; in lecture class 10am on Friday in Week 9 (Mar 17) Tests take place at 10am in your lecture class, not in your lab period. ### Midterm Test #1 -- February 10 - Midterm #1 takes place at 10am on Friday, February 10 (Week 5) in your scheduled lecture class (not in your lab period). - For full marks, you must read the [Test Instructions] before the test for important directions on how to enter your name, student number, answers, your lab (not lecture) section number, and the test version code on the question sheet and the mark-sense forms. - There may be more questions on the test than you can answer in the time allowed; answer the ones you know, first. - I will post a set of practice questions and quizzes for the test soon. Notes from the Classroom ======================== - **Take notes in class!** Keep a pad open on your desk. - This week in lecture we learn about the terminal, the shell, and using pathnames, especially relative pathnames. - Keep a notebook with a [List of Commands][List of Commands You Should Know] in it. - You need to write down yourself what each command *does*. Fifteen minute rule: don't waste your time ------------------------------------------ See the [Course Introduction: fifteen minute rule] Assignment #1: Read All The Words --------------------------------- - As of 5am Monday, 55 of 99 students submitted the first assignment. - One person submitted two files instead of just the one required. - One person submitted comments in the comment box (ignored). - One person didn't upload any file but pasted into the "Write Submission" box (zero). - One person submitted a single long line of text instead of three paragraphs. - Three students used the wrong file name: Bad file name: assignment01.txt.txt Bad file name: assignment01.txt.txt Bad file name: assinment 01.txt - Six students did not use the exact numbering specified in the assignment. - Ten people used a word processor instead of Notepad, resulting in non-ASCII characters such as Microsoft "Smart Quotes" and Unicode instead of Plain Text. - Activity 2 in the Week 1 notes told you to [Turn off Smart Quotes] Please Read All The Words. Course Linux Server under attack -------------------------------- The Course Linux Server \[CLS\] is on the open Internet, not hidden behind a firewall, and is subject to attacks on its SSH port by people looking to take over the machine. Our job as System Administrators is to prevent that from happening. Last term (September through December 2016) the CLS received over 131,705 attacks on the SSH port, mostly from China. Here are the counts, IP addresses, and country codes of the machines that attacked the CLS more than 500 times last term: $ ./attack_whois.sh 82482 116.31.116.28 CN 18572 116.31.116.24 CN 13497 116.31.116.23 CN 1547 116.31.116.26 CN 966 68.55.78.69 US 545 221.194.47.229 CN 542 121.18.238.104 CN 532 221.194.47.249 CN 529 221.194.47.208 CN 526 221.194.47.224 CN 518 121.18.238.114 CN (The above output is generated by a shell script that you will be able to write when you successfully complete CST8207.) Here are excerpts from a sample attack from the CLS authorization log file `/var/log/auth.log` on the evening of January 14 this week: Jan 14 21:22:49 Invalid user cisco from 181.25.160.99 Jan 14 21:22:50 Invalid user test from 181.25.160.99 Jan 14 21:22:54 Invalid user admin from 181.25.160.99 [...] Jan 14 21:23:24 PAM 8 more authentication failures; logname= uid=0 euid=0 tty=ssh ruser= rhost=181.25.160.99 A `whois` lookup of IP address `181.25.160.99` shows that it is part of a network hosted in Buenos Aires, Argentina. Your careful work in CST8207 is critical to preventing these types of attacks from compromising the machines you control. Locked out of the Course Linux Server ------------------------------------- This student did not type his own userid correctly and got his home IP address locked out of the server on Tuesday afternoon: Jan 16 14:30:05 Invalid user XXXXXXXX from 70.29.53.248 Jan 16 14:30:23 Failed password for invalid user XXXXXXXX from 70.29.53.248 Jan 16 14:30:32 Failed password for invalid user XXXXXXXX from 70.29.53.248 Jan 16 14:30:49 Failed password for invalid user XXXXXXXX from 70.29.53.248 Jan 16 14:31:23 Invalid user XXXXXXXX from 70.29.53.248 Jan 16 14:31:36 Failed password for invalid user XXXXXXXX from 70.29.53.248 Jan 16 14:31:49 Failed password for invalid user XXXXXXXX from 70.29.53.248 Jan 16 14:31:57 Failed password for invalid user XXXXXXXX from 70.29.53.248 Jan 16 14:35:33 refused connect from otwaon1140w-lp130-03-70-29-53-248.dsl.bell.ca (70.29.53.248) When you are locked out, [follow the directions] in the notes to get your IP address re-enabled. Trying to use privileged commands on the CLS -------------------------------------------- No, you are not allowed to use privileged commands such as `sudo` on my Course Linux Server. Use your own Linux virtual machine if you want to play with those commands. Bruce Schneier on cyber attacks ------------------------------- *"For decades, hackers have used techniques such as jump hosts, VPNs, Tor and open relays to obscure their origin, and in many cases they work. I'm sure that many national intelligence agencies route their attacks through China, simply because everyone knows lots of attacks come from China."* ![Take Notes in Class] -- | Ian! D. Allen, BA, MMath - idallen@idallen.ca - Ottawa, Ontario, Canada | Home Page: http://idallen.com/ Contact Improv: http://contactimprov.ca/ | College professor (Free/Libre GNU+Linux) at: http://teaching.idallen.com/ | Defend digital freedom: http://eff.org/ and have fun: http://fools.ca/ [Plain Text] - plain text version of this page in [Pandoc Markdown] format [www.idallen.com]: http://www.idallen.com/ [Course Home Page]: .. [Course Outline]: course_outline.pdf [All Weeks]: indexcgi.cgi [Plain Text]: week02notes.txt [Week 02 Notes HTML]: week02notes.html [The Unix/Linux Shell]: 120_shell_basics.html [Command Arguments and Options]: 150_arguments_and_options.html [Finding Help in Manual Pages -- RTFM]: 140_man_page_RTFM.html [File System and Pathnames]: 160_pathnames.html [List of Commands You Should Know]: 900_unix_command_list.html [Linux and Sysadmin News in the World]: 950_linux_world.html [lynda.com]: http://algonquincollege.com/onlineresources/mobileStudent/lynda.htm [Unix for Mac OS X Users]: http://www.lynda.com/Mac-OS-X-10-6-tutorials/Unix-for-Mac-OS-X-Users/78546-2.html [Assignment #01 HTML]: assignment01.html [Assignment #02 HTML]: assignment02.html [Course Linux Server]: 070_course_linux_server.html [download Libre Office here]: 050_course_introduction.html#install-libreoffice-or-openoffice-into-windows [Worksheet #02 ODT]: worksheet02.odt [Worksheet #02 PDF]: worksheet02.pdf [Worksheet #02 HTML]: worksheet02.html [Worksheet #03 ODT]: worksheet03.odt [Worksheet #03 PDF]: worksheet03.pdf [Worksheet #03 HTML]: worksheet03.html [Test Instructions]: 000_test_instructions.html [Course Introduction: fifteen minute rule]: 050_course_introduction.html#fifteen-minute-rule-dont-waste-your-time [Turn off Smart Quotes]: 050_course_introduction.html#turn-off-smart-quotes-for-linux-work [follow the directions]: 070_course_linux_server.html#getting-locked-out-of-the-server [Take Notes in Class]: data/remember.jpg "Take Notes in Class" [Pandoc Markdown]: http://johnmacfarlane.net/pandoc/