% CST8207 Week 03 Notes – absolute and relative paths, ROOT and HOME, finding files, VIM % Ian! D. Allen – – [www.idallen.com] % Winter 2015 - January to Apil 2015 - Updated Thu Jan 29 02:36:55 EST 2015 Readings, Assignments, Labs, Tests, and ToDo ============================================ - Read (at least) these things (All The Words): 1. [Week 03 Notes HTML] – this file – **Read All The Words** 2. [Unix/Linux File System and Pathnames (ROOT, absolute, relative, dot, dot dot] 3. [Directories: ROOT, /root, HOME, /home, and current] 4. [Searching for and finding files by name, size, use, modify time, etc.] 5. [The VI (VIM) Text Editor] 6. [Shell GLOB patterns (wildcard pathname matching)] 7. [List of Commands You Should Know] - Create your [lynda.com] account and watch [Unix for Mac OS X Users] - **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` - 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. - Read All The Words, Do, and then Submit via Blackboard: - [Assignment #02 HTML] – Course Linux Server simple commands - [Assignment #03 HTML] – working with files: PS1, find, mkdir, mv - Bonus (optional) [Assignment #04 HTML] – the VIM text editor - Really do **Read All The Words**. You don’t get a second chance to get it right. ### 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 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]. - [Worksheet #02 ODT] – Using standard Linux commands - [Worksheet #02 PDF] – Using standard Linux commands - [Worksheet #02 HTML] – Using standard Linux commands - `PS1, cd, find, less, ls, man, mkdir, passwd, pwd, rmdir` - [Worksheet #03 ODT] – Using standard Linux commands - [Worksheet #03 PDF] – Using standard Linux commands - [Worksheet #03 HTML] – Using standard Linux commands - `cat, clear, cp, find, grep, history, less, man, mv, rm, sleep, touch` - [Worksheet #06 HTML] – *Optional* Bonus VIM Text Editor Practice - This is an *optional* worksheet for a BONUS assignment using `vim` - Optional command-line VIM tutorial: the `vimtutor` program on the CLS. - Optional Reading: [The VI (VIM) Text Editor] - Bonus (optional) [Assignment #04 HTML] – the VIM text editor Lab work this week ------------------ - [Assignment #02 HTML] will have you change your CLS password. - [Assignment #03 HTML] is ready - Bonus (optional) [Assignment #04 HTML] is ready - Finish the above assignments, which involve work on the first two worksheets. - The worksheets will be easier once we cover [File System and Pathnames][Unix/Linux File System and Pathnames (ROOT, absolute, relative, dot, dot dot]. Upcoming tests -------------- Read the [Test Instructions] (all the words) before your first midterm test. 1. First Midterm test: 45 minutes; in class 8am Thursday in Week 6 (February 12) 2. Second Midterm test: 45 minutes; in class 8am Thursday in Week 9 (March 12) Tests take place in your 8am lecture hour, not in your lab period. ### Midterm Test #1 - Midterm #1 takes place 8am Thursday February 12 (Week 6) in your scheduled lecture hour (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 answers, your lab (not lecture) section number, and the test version number 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. From the Class Notes link on the Course Home Page ================================================= - Review last week. Did you do everything assigned last week? - I put the link to the GNU Coreutils web site in the web page [Finding Help in Manual Pages – RTFM] From the Classroom Whiteboard/Chalkboard ======================================== - **Take notes in class!** Your in-class notes would go here. - This week, we learn about using pathnames, especially relative pathnames. - This week, we learn about finding files. - Count the attacks:   `fgrep -c "refused connect" /var/log/auth.log` - See the current list of *evil* host IPs:   `less /etc/hosts.evil` - - Another [Multitasking Fail Article]: > Each time we dispatch an email in one way or another, we feel a sense of > accomplishment, and our brain gets a dollop of reward hormones telling us > we accomplished something. Each time we check a Twitter feed or Facebook > update, we encounter something novel and feel more connected socially (in a > kind of weird, impersonal cyber way) and get another dollop of reward > hormones. But remember, it is the dumb, novelty-seeking portion of the > brain driving the limbic system that induces this feeling of pleasure, not > the planning, scheduling, higher-level thought centres in the prefrontal > cortex. Make no mistake: email-, Facebook- and Twitter-checking constitute > a neural addiction. Disabled SFTP writing on CLS ---------------------------- To improve CLS security, I’ve disabled the writing or changing of files on the CLS by the SFTP service, as used by file transfer programs such as **WinSCP** and **FileZilla**. You can copy files out of the CLS (e.g. your assignments) using **WinSCP** and friends, but you can’t copy files into the CLS unless you use the secure `scp` program. Fifteen minute rule ------------------- Your time as a student is valuable. If you come up against a tough problem and make no progress in fifteen minutes despite best efforts: 1. get help from a professor or lab instructor 2. get help from classmates 3. take a break 4. put it on hold and work on something else This happens to all of us, and we need to watch out for it when it happens. *But what about when it’s midnight before the assignment is due?* Remember the “Don’t Leave Things to the Last Minute” rule! Locked out of CLS ----------------- When you use a file transfer program, remember that the program must use your userid to log in and not a blank userid. Someone got their IP address locked out of the CLS yesterday for using a blank userid: Jan 21 20:36:31 Accepted password for XXXXXXXX from 99.246.105.31 Jan 22 01:42:38 Invalid user from 99.246.105.31 Jan 22 01:43:05 Failed password for invalid user from 99.246.105.31 Jan 22 01:43:15 Failed password for invalid user from 99.246.105.31 Jan 22 01:44:07 Invalid user from 99.246.105.31 Jan 22 01:44:37 Failed password for invalid user from 99.246.105.31 Jan 22 01:44:52 Failed password for invalid user from 99.246.105.31 Jan 22 01:46:40 refused connect from cpe0c473dc25fe1-cm0c473dc25fe0.cpe.net.cable.rogers.com (99.246.105.31) Remember your password, and use the correct userid: Jan 10 15:46:52 Failed password for XXXXXXXX from 99.224.126.41 Jan 17 21:31:54 Invalid user steam from 99.224.126.41 Jan 17 21:54:21 Invalid user desktop from 99.224.126.41 Jan 17 22:14:39 refused connect from cpe001ec92c1d15-cm84948c4813b0.cpe.net.cable.rogers.com (99.224.126.41) Commands -------- Commands are usually VERB and OBJECT: $ wc /etc/passwd $ cat /etc/passwd $ less /etc/passwd Commands in worksheets 2 and 3: - `PS1, cd, find, less, ls, man, mkdir, passwd, pwd, rmdir` - `cat, clear, cp, find, grep, history, less, man, mv, rm, sleep, touch` Read All The Words: From: a CST8207 student Hey, was just playing around with "mv" command as per weekly notes "9 Relative Pathname Exercise" kept getting error "-bash: $: command not found" after trying to rename a .txt file. example: -bash-4.2$ $ mv caltest.txt catltest2.txt bash: $: command not found Just wondering if I'm doing something wrong and if so where would the information pertaining to this be? In the Week 2 Notes, under heading “2-1 Readings, Assignments, Labs, Tests, and ToDo”, (the list of things you needed to read last week) is this web page: “3. The Unix/Linux Shell – using the shell command line in Linux” and in that web page is the heading “2 Typing Command Lines”, which is the information you need to Read All The Words, especially the sentence that starts with “You do not”. Real Sysadmin Work ================== Using parent directory chains to attack my server ------------------------------------------------- Using chains of parent directories such as `../..`, people attack web servers, trying to get access to sensitive files. Someone in Kitchener tries to find a list of VMware hosts on my home machine: $ zfgrep ../.. /var/log/apache2/*gz /var/log/apache2/access.log.8.gz:2014-11-27_03:52:57 162.244.31.150 162.244.31.150 - 192.168.2.250 idallen-oak.home.idallen.ca 69-165-154-175.dsl.teksavvy.com "GET /sdk/../../../../../..//etc/vmware/hostd/vmInventory.xml HTTP/1.1" 404 327 "-" "Mozilla/5.0 (compatible; Nmap Scripting Engine; http://nmap.org/book/nse.html)" 223 530 "/var/www/html/etc" 0 3672 FMT=idallen2 /var/log/apache2/other_vhosts_access.log.8.gz:idallen-oak.home.idallen.ca:80 162.244.31.150 - - [27/Nov/2014:03:52:57 -0500] "GET /sdk/../../../../../..//etc/vmware/hostd/vmInventory.xml HTTP/1.1" 404 530 "-" "Mozilla/5.0 (compatible; Nmap Scripting Engine; http://nmap.org/book/nse.html)" See [hundreds of attacks on the CLS web server in March 2014] * * * * * ![Read All The Words 2012] ![Take Notes in Class] - [Remember this for later] -- | Ian! D. Allen - 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/ [Unix/Linux File System and Pathnames (ROOT, absolute, relative, dot, dot dot]: 160_pathnames.html [Directories: ROOT, /root, HOME, /home, and current]: 170_home_and_HOME.html [Searching for and finding files by name, size, use, modify time, etc.]: 180_finding_files.html [The VI (VIM) Text Editor]: 300_vi_text_editor.html [Shell GLOB patterns (wildcard pathname matching)]: 190_glob_patterns.html [List of Commands You Should Know]: 900_unix_command_list.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 [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 [Finding Help in Manual Pages – RTFM]: 140_man_page_RTFM.html [Multitasking Fail Article]: http://www.theguardian.com/science/2015/jan/18/modern-world-bad-for-brain-daniel-j-levitin-organized-mind-information-overload [hundreds of attacks on the CLS web server in March 2014]: notes/data/attacks1.txt [Read All The Words 2012]: data/lesen_sie.jpg "Read All The Words 2012" [Take Notes in Class]: data/remember.jpg "Take Notes in Class" [Remember this for later]: http://somethingofthatilk.com/index.php?id=293 [Plain Text]: week03notes.txt [Pandoc Markdown]: http://johnmacfarlane.net/pandoc/