% CST8207 Week 02 Notes -- the shell, arguments and options, man pages, file system % Ian! D. Allen -- -- [www.idallen.com] % Fall 2018 - September to December 2018 - Updated 2018-09-27 10:51 EDT - [Course Home Page] - [Course Outline] - [All Weeks] - [Plain Text] Student Feedback -- How to Succeed in Linux =========================================== _ _ _____ ____ _ _ _ _ | | | | _____ __ |_ _|__ / ___| _ _ ___ ___ ___ ___ __| | (_)_ __ | | (_)_ __ _ ___ __ | |_| |/ _ \ \ /\ / / | |/ _ \ \___ \| | | |/ __/ __/ _ \/ _ \/ _` | | | '_ \ | | | | '_ \| | | \ \/ / | _ | (_) \ V V / | | (_) | ___) | |_| | (_| (_| __/ __/ (_| | | | | | | | |___| | | | | |_| |> < |_| |_|\___/ \_/\_/ |_|\___/ |____/ \__,_|\___\___\___|\___|\__,_| |_|_| |_| |_____|_|_| |_|\__,_/_/\_\ [Some advice from CST student Joshua McNeely] *"learn how to use the website early, because it is an incredibly useful resource (it's the only resource needed)."* A note to you from another former student: From: Christopher Glover To: "Ian! D. Allen" Subject: Fond Linux 1 memories Hello Ian! I wanted to thank you for all the hard work you put into teaching the Linux I course last semester, especially with the extra difficulties created by the work stoppage. I was enrolled in a computer science program many years ago at Algonquin, and I didn't manage to connect with the Linux professor's teaching style. As a result, I withdrew from the class, and ended up off-track for my program, eventually leading to withdrawing from the entire program. I have seen several students make this same mistake in my new program, and I was hoping you would share this email with your level 1 students. No matter how challenging they find Linux 1, they really need to keep it on their schedule. Personally, I found your teaching style to be exactly what I needed to transform the subject from something difficult, to a class that I truly enjoyed. For anyone that finds Ian! D. Allen an "acquired taste" - take it from me, you are in the very best of hands. Read all the words, do all the worksheets and assignments, get help with them if needed, and you will do well. Sincerely, Christopher Glover a.k.a "A Linux Person" I encourage you to read the course notes. Don't take my word for it: Note from a student in 17W: From: Damien Houle - CST8207-17W Subject: Wonderful Website I wanted to make sure you're aware of how much the students and myself from last semester appreciate your awesome website. Many of us have used it on multiple occasions throughout our level 2 course for our current assignments because it has everything we need, as long as we READ ALL THE WORDS! I really miss your labs and lectures and realize now how spoiled I was to have you as my teacher and Linux mentor. Hope the semester offers you as much fun as our class was although i doubt it. Best regards Damien Houle (aka Linux people) Note from a student in 17W: Dear Professor Allen, I was working with the mid-term practice last weekend, and it doesn't goes very well. And then I go back to watch the class notes(I know! I should do that in the first place) because I realize that I missed lots of the information. Then I found that the pages of course notes are super helpful. It helps me a lot! I thought the pages are too much links and too complex when I just taking a quick look in the first time, but I was wrong. It's so impressive that the contents are strong logical, everything is explained in detail but not complicated, easy to understand. Most of the things does not take me a long time to understand. I really should read the pages earlier!!! It does takes me many time to adapt the new learning style as a foreign student, but I am feeling better right now. Hopefully, it is not too late for the test. Anyway, just want to tell you that the course pages are very helpful. And thank you, This is a great work for us! Mail about the web site from the USA: From: King, Alexander J To: Ian Allen Subject: Lecture cap inquiry Date: Sat, 8 Apr 2017 05:22:52 -0400 Professor Allen, My name is Alexander King and I'm a computer science engineering student at The University of Toledo, Ohio. I came across a video of you rapping the other day. I must say it was entertaining. After that I went on to find your website . I'm writing to inquire if any of your lectures have been recorded and if you're able and willing to share them with me? Your is amazing as it is but I figured I would ask if actual lectures were out there somewhere. All the best, Alexander J King 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. [File Transfer] -- File transfer to/from Unix/Linux machines. - You need to know this to upload your assignments for marking. 3. [The Unix/Linux Shell] -- using the shell command line in Linux 4. [Command Arguments and Options] 5. [Finding Help in Manual Pages -- RTFM] 6. [File System and Pathnames] -- ROOT, basename, absolute, relative, dot, dot dot - Read this *before* you start any of the Worksheets. 7. [List of Commands] -- Command names you should know, listed by week 8. [Linux and Sysadmin News in the World] - Follow last week's instructions to create your lynda.com account, then watch these sections of [Unix for Mac OS X Users] - these videos are for *all* Unix/Linux students, not just Mac OSX users - **Introduction** - Introduction 1m 10s - **Ch.1. Introduction to Unix** - What is Unix 7m 27s - Logging in and using the command prompt 5m 19s - Ignore the Mac-specific menus, user information, and shortcuts - 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 - Creating files 2m 19s - `touch` - Unix text editors 6m 39s - `vi/vim, nano` - `head, tail` - Reading files 5m 35s - `cat, more, less` - Reading portions of files 3m 27s - `head, tail` - Creating directories 2m 40s - `mkdir` - Moving and renaming files and directories 8m 32s - `mv` (including using `..`) - Copying files and directories 3m 7s - `cp` - Deleting files and directories 3m 38s - `rm, rmdir` - Searching for files and directories 6m 32s - `find` using "wildcard" (GLOB) patterns - same as shell GLOB - **5. Commands and Programs** - Command basics 4m 4s - commands are usually small programs; ways to exit from programs - Using the command history 8m 16s - shell command history is saved your `.bash_history` file 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 Brightspace: - [Assignment #01 HTML] -- Head Shot, 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. This week, you will create a file and then transfer the file to your laptop and upload it to Brightspace. - [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. Worksheets. 3. Assignment. Make notes from the worksheets on *how each command works*. What do the options used in the worksheets mean, for each command? (See the weekly [List of Commands].) 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 get a copy here: [Course Introduction: Install Libre Office]. Worksheets #02 and #03 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` - remember to set your `PS1` prompt every time you log in to the CLS - [Worksheet #03 ODT] -- Using standard Linux commands II - [Worksheet #03 PDF] - [Worksheet #03 HTML] - `cat, clear, cp, find, fgrep, history, less, man, mv, rm, sleep, touch` Worksheets prepare you for the upcoming assignments. Upcoming tests -------------- Follow this link to see all your upcoming [Quizzes and Tests]. The dates are also posted on the [Course Home Page] and on [Brightspace CST8207]. For full marks, read the [Test Instructions] (all the words) before your midterm tests. 1. First Midterm test: 45 minutes; in your one-hour lecture class in Week 6. 2. Second Midterm test: 45 minutes; in your one-hour lecture class in Week 10. Tests take place in your one-hour lecture class, not in your lab period. You must write the test in the lecture class in which you are registered. 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, simple output redirection, and using pathnames, especially relative pathnames in the current directory. - Keep a notebook with a [List of Commands] in it. - You need to write down yourself what each command *does*. - Navigating Brightspace and the Course Notes: - Always open links in new tabs as you were shown in class; do not click through links or you'll get lost. - Turn on "show file extensions" in your Windows machines, or else you may upload files with incorrect names such as `assginment01.txt.txt`! - Never use the sample userid *abcd0001* to log in. These are example userids used in the notes that are meant to be replaced with *your own login userid*. If you try repeatedly to log in to the [Course Linux Server] from home using a non-existent userid or password, your home IP address will be locked out; see the [Course Linux Server] notes for help on how to fix this. - Make sure you read [Course Introduction: Basic EMail Etiquette] before you send email to your professor. - Make the **Subject:** match the message. - Don't quote irrelevant crap in replies; remove the junk. - [Don't top-post] unless forwarding. - Used in class and lab this week via [Remote Login] to the [Course Linux Server] -- all the commands from [Assignment #02][Assignment #02 HTML]: - `exit`, `date`, `users`, `who`, `cal`, `fortune`, `sl`, `cmatrix -s`, `echo hello`, `figlet hello`, `toilet hello`, `history` - To delete (remove) a file named `foo.txt`, use the command: `rm foo.txt` - Unix/Linux has no *Recycle Bin*. The file is deleted. - Terminal special characters: `^U ^L ^W ^C UpArrow DownArrow` Fifteen minute rule: don't waste your time ------------------------------------------ See the [Course Introduction: Fifteen Minute Rule] Course Linux Server (CLS) account no login ------------------------------------------ As of 10am Monday September 10, 161 out of 240 students still have not logged in to the [Course Linux Server]. You will need to know how to log in to work on [Assignment #02 HTML] this week. See your lab instructor for help reading all the words. Locked out of the Course Linux Server ------------------------------------- As I said last week, if you typed your CLS userid or password incorrectly more than about three times, you got your IP address locked out. When you are locked out, follow the directions in [Course Linux Server: Geting Locked Out] for finding out your real IP address and getting it unblocked. Assignment #1: Read All The Words --------------------------------- Some students have submitted the two files as two assignment uploads instead of submitting the two files in the same, one assignment upload. Some students submitted two files, then submitted another more recent assignment with only one file in it. I only mark the most recent. Both files for this assignment must be submitted in the same assignment. See this [image of incorrect assignment]. I only mark the most recent assignment. If it only has one file in it, you lose half your marks. Make sure your most recent assignment upload has two files in it. Trying to use privileged commands `sudo` and `su` on the CLS ------------------------------------------------------------ No, you are *not allowed* to use privileged commands such as `sudo` or `su` on my Course Linux Server. Use your own Linux virtual machine if you want to play with those commands. Don't use the place-holder userid `abcd0001` -------------------------------------------- - Never use the sample userid *abcd0001* to log in. These are example userids used in the notes that are meant to be replaced with *your own login userid*. If you try repeatedly to log in to the [Course Linux Server] from home using a non-existent userid or password, your home IP address will be locked out; see the [Course Linux Server] notes for help on how to fix this. Getting a job reference from your professor =========================================== Note from another former student: I just wanted to thank you again for the reference that you me when applying for a government position last year. I ended up getting the job and I am part of a great team. Thanks again, If you want a good reference from me, get great marks and keep your lab class attendance up-to-date. This is documented in the [Course Introduction]. Copying from other students -- plagiarism ========================================= Over 15% of the class were caught plagiarizing their assignments last term. **There is no group work in this course. Do your own assignments.** Review the Course Introduction notes on [Plagiarism]. If you copy the work of other students or if you let your work be copied by other students, you both could fail the course. Attacks on the CLS ================== The CLS is on the open Internet and subject to attack. On bad days, attacks happen every few seconds. Below are some commands you can use on the CLS to investigate the attacks by looking in some system log files. 1. Count the current number of lines, words, and characters in the system file `/etc/hosts.evil` that has a list of locked out IP addresses: $ wc /etc/hosts.evil 2. Show the ten most recent attacking IP addresses: $ tail /etc/hosts.evil 3. Count the number attempts to use those locked-out IP addresses, as logged in the system file `/var/log/auth.log`: $ fgrep -c 'refused connect' /var/log/auth.log 4. Show the ten most recent attacks: $ fgrep 'refused connect' /var/log/auth.log | tail 5. Count the unique locked-out addresses and then show the top twenty: $ fgrep 'refused connect' /var/log/auth.log | awk '{print $NF}' | sort -u | wc $ fgrep 'refused connect' /var/log/auth.log | awk '{print $NF}' | sort | uniq -c | sort -nr | head -n 20 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 [Some advice from CST student Joshua McNeely]: notes/data/joshua_testimony.txt [Week 02 Notes HTML]: week02notes.html [File Transfer]: 015_file_transfer.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]: 900_unix_command_list.html [Linux and Sysadmin News in the World]: 950_linux_world.html [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 [Course Introduction: Install Libre Office]: 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 [Quizzes and Tests]: 000_quizzes_and_tests.html [Brightspace CST8207]: https://brightspace.algonquincollege.com/d2l/home/117776 [Test Instructions]: 000_test_instructions.html [Course Introduction: Basic EMail Etiquette]: 050_course_introduction.html#basic-email-etiquette [Don't top-post]: http://idallen.com/topposting.html [Remote Login]: 110_remote_login.html [Course Introduction: Fifteen Minute Rule]: 050_course_introduction.html#fifteen-minute-rule-dont-waste-your-time [Course Linux Server: Geting Locked Out]: 070_course_linux_server.html#getting-locked-out-of-the-server [image of incorrect assignment]: data/incorrect_assignment.png [Course Introduction]: 050_course_introduction.html [Plagiarism]: 050_course_introduction.html#plagiarism-and-working-together [Take Notes in Class]: data/remember.jpg "Take Notes in Class" [Pandoc Markdown]: http://johnmacfarlane.net/pandoc/