% CST8207 Week 13 Notes – Boot process, GRUB, Run Levels % Ian! D. Allen – – [www.idallen.com] % Fall 2014 - September to December 2014 - Updated Sat Dec 6 06:01:17 EST 2014 C O U R S E    E V A L U A T I O N ================================== ____ _ ____ ____ | _ \| | ___ __ _ ___ ___ | _ \ ___ / ___|___ _ _ _ __ ___ ___ | |_) | |/ _ \/ _` / __|/ _ \ | | | |/ _ \ | | / _ \| | | | '__/ __|/ _ \ | __/| | __/ (_| \__ \ __/ | |_| | (_) | | |__| (_) | |_| | | \__ \ __/ |_| |_|\___|\__,_|___/\___| |____/ \___/ \____\___/ \__,_|_| |___/\___| _____ _ _ _ | ____|_ ____ _| |_ _ __ _| |_(_) ___ _ __ | _| \ \ / / _` | | | | |/ _` | __| |/ _ \| '_ \ | |___ \ V / (_| | | |_| | (_| | |_| | (_) | | | | |_____| \_/ \__,_|_|\__,_|\__,_|\__|_|\___/|_| |_| - - Dogbert on [satisfaction surveys] - When you are done your evaluation do `touch .courseval_done` in your `Assignments` directory on the CLS and the nag messages will go away. Readings, Assignments, Labs, and ToDo ===================================== - Read (at least) these things (All The Words): - [Week 13 Notes HTML] – this file – **Read All The Words** - [Unix/Linux Boot Process, GRUB, Run Levels, services, telinit, chkconfig] - [Data Mining] - [Running commands on remote servers] - [List of Commands You Should Know] - [Video Tutorials on Lynda.com] - Using your [lynda.com] account, watch [Unix for Mac OS X Users] - **4. Ownership and Permissions 34m 58s** - The root user 1m 57s - sudo and sudoers 5m 20s Assignments, Quizzes, and Lab work this week -------------------------------------------- - **Reminder:** There are now three quizzes that you need to complete on Blackboard as part of your term Quiz mark. - 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 #07 HTML] – [Permissions], mode, [Umask] and [Worksheet #08 HTML] - minimum permissions needed for basic file operations - [Assignment #09 HTML] – tar, processes, syslog, crontab, at, mail - [Package Management], [System Logs], [Processes], [Cron and At] - [Assignment #10 HTML] – CentOS 6.6 Installation and Configuration - You need to get this working before you can do the final assignments in this course. See your instructor for help. - [Assignment #11 HTML] – [Users and Groups] - User and Group management: Simpsons, StarWars, the Megadeth Project - [Assignment #12 HTML] – [Partitions and File Systems] - Partitions, File Systems, Single-User - 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] online viewing: [Worksheet #02 HTML] – Using standard Linux commands I - `PS1, cd, find, less, ls, man, mkdir, passwd, pwd, rmdir` - [Worksheet #03 ODT] online viewing: [Worksheet #03 HTML] – Using standard Linux commands II - `cat, clear, cp, find, grep, history, less, man, mv, rm, sleep, touch` - [Worksheet #04 ODT] online viewing: [Worksheet #04 HTML] – GLOB Patterns and Aliases - bash GLOB patterns (wildcards), `alias, sum` - [Worksheet #05 ODT] online viewing: [Worksheet #05 HTML] – I/O Redirection and Pipes - bash I/O redirection (including pipes), `date, head, nl, tail, tr, wc` - [Worksheet #08 ODT] online viewing: [Worksheet #08 HTML] – minimal permissions, mode, umask, octal - `chmod, ls -lid, umask` ### Optional Bonus Assignments – extra marks - [Assignment #03 HTML] – *Optional* BONUS VIM Text Editor Practice - this is an *optional* worksheet for a BONUS assignment using `vim` - Optional Reading: [The VI (VIM) Text Editor] - [Worksheet #06 HTML] – *Optional* 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. - [Assignment #05 HTML] – *Optional* BONUS Midterm Assignment - This is an *optional* BONUS assignment reviewing your midterm test. - There is an Assignment #5 checking script available to verify the format of your file before you submit it for marking, but only people who **Read All The Words** here will know about it. - **New Due Date** due to Blackboard failure last week. - [Assignment #08 HTML] – *Optional* BONUS Midterm Assignment - This is an *optional* BONUS assignment reviewing your midterm test. - There is an Assignment #8 checking script available to verify the format of your file before you submit it for marking, but only people who **Read All The Words** here will know about it. From the Class Notes link on the Course Home Page ================================================= - Review last week. Did you do everything assigned last week? From the Classroom Whiteboard/Chalkboard ======================================== - **Take notes in class!** Your in-class notes would go here. - `last` - last logins - `md5sum` - checksum (like `sum` but better) Windows/VMware Bugs ------------------- See [CentOS Install VMware Bugs] Monospace Fixed-Width (Courier) Fonts on Tests ============================================== When you are asked to count arguments that are separated by spaces, the command lines are always printed using a monospace, fixed-width, Courier-style font where every character, including a space, has the same width. If you couldn’t fit a capital `M` into the gap, there is no space there: MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM 'def' ' ghi ' it's 'mno ' ' pqr' 's' '' ' ' MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM Real Sysadmin Work ================== Linux II Student overloads CLS ------------------------------ 1. On the afternoon of November 25 a Linux II student ran a `bash` script that ran itself. This caused an “infinite loop” of processes to be created. At 15:43 the system ran out of memory and called the `oom-killer` (out-of-memory killer) to terminate some tasks, but the script just created more to replace them. Students working in my lab alerted me to the CLS problem around 15:50. I wasn’t able to get any of my `root` shells to respond, so I didn’t know what was wrong. I had to go back to my office and reboot the system around 16:15. 2. I ran a check of `lastcomm` and discovered repeated executions of `bash` by a student. 3. I went to the student’s home directory and looked for recent files: # find . -mtime -1 . ./.viminfo ./.bash_history ./CST8177-14F/Assignments/practice ./CST8177-14F/Assignments/practice/myscript.sh ./CST8177-14F/Assignments/practice/foo ./CST8177-14F/Assignments/practice/test1 ./CST8177-14F/Assignments/practice/bar 4. I read each of the script files in the list and discovered that the file `bar` contained this line that called itself: ./bar a "b c" 'a ' **BINGO!** I disabled that file and sent email to the student. 5. I turned on process limits in the system-wide `/etc/bash.bashrc` so that no student can run more than 50 processes at the same time. Using Linux skills on the job ----------------------------- Student sends me email talking about using Linux skills in Ottawa: > Currently, I am doing part-time work (volunteering) at the National Capital > FreeNet. They use Ubuntu Desktops and Linux servers. Skills you taught me > are coming yet again, very useful. Especially, those you tested me on. > Linux rules at the NCF. I think you were one of their first Sys Admins. I was NCF employee #2. I worked there from 1993 to 1996, in the era of dial-up modems. The password file had over 50,000 accounts in it, with over 300 people connected to the system at the same time. If only 1% of your users have problems, what does that mean when there are over 50,000 users? Using Linux to disinfect Windows -------------------------------- A student in Linux I this term uses Linux to fix Windows: October 23: > Hi Ian, > > Just thought you might find this interesting since it’s relevant to what > we’re learning in CST8207. My aunt and uncle are hosting some friends from > Cuba, and they have been (among other things) having fun using the internet > on my uncle’s laptop. Naturally, since it’s a Windows laptop, the system > has gotten bogged down in crap to the point that you can’t do much on it > anymore. > > My approach to this? Create a Ubuntu 14.04 live USB stick. I configured it > to reserve 2GB on the stick to carry data between reboots, and installed > ClamAV on the USB install. I then successfully mounted the Windows > partition in Linux as /home/ubuntu/ntfs, and am watching ClamAV scan things > on the Windows partition as I write this e-mail - in fact, it just detected > a trojan in the Program Files directory somewhere (I’m sure it’s probably > not the only thing wrong with the system, though). Additionally, I’ve been > looking around the file system in a few of the “usual suspect” locations > for adware, and then using the find command to locate all instances of > anything that shouldn’t be there and delete them. October 28: > So, to conclude this tale, it turns out this approach worked - ClamAV found > and deleted enough viruses that, combined with a bit of poking at the NTFS > filesystem in Ubuntu (to delete any obvious malware), I was able to get the > Windows OS at least to a point where it mostly worked again. From there, > Windows-based anti-malware and anti-virus programs were enough to finish > the job, and the laptop now boots up and runs cleanly. > > Effectively, I rescued an inoperable Windows install using a Ubuntu live > USB stick, with minimal risk of cross-contamination to another system. If I > had plugged the laptop’s hard drive into another Windows machine (a > potentially viable approach), it may have become infected with the viruses > on the laptop. > > As a side note, I also discovered in the process that the NTFS file system > itself had some (mild) issues with corruption. GPartEd could read the FAT32 > boot loader partition and the small NTFS recovery partition, but was not > able to retrieve any information about the primary Windows partition. I was > still able to mount the Windows partition and access it, so I scheduled a > bootup checkdisk operation in Windows, which found and corrected a few > problems in the file system. > > Derek Awesome License Plate --------------------- ![`fsck` – File System Check] ![Take Notes in Class] -- | 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/ [satisfaction surveys]: http://dilbert.com/strips/comic/2005-04-07/ [Unix/Linux Boot Process, GRUB, Run Levels, services, telinit, chkconfig]: 750_booting_and_grub.html [Data Mining]: 805_data_mining.html [Running commands on remote servers]: 445_quotes_for_remote.html [List of Commands You Should Know]: 900_unix_command_list.html [Video Tutorials on Lynda.com]: 910_lynda_index.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 [Permissions]: 500_permissions.html [Umask]: 510_umask.html [Package Management]: 520_package_management.html [System Logs]: 580_system_log_files.html [Processes]: 600_processes_and_jobs.html [Cron and At]: 630_crontab_at_job_scheduler.html [Users and Groups]: 700_users_and_groups.html [Partitions and File Systems]: 720_partitions_and_file_systems.html [download Libre Office here]: 050_course_introduction.html#install-libreoffice-or-openoffice-into-windows [The VI (VIM) Text Editor]: 300_vi_text_editor.html [CentOS Install VMware Bugs]: 000_centos_install.html#appendix-iv-vmware-bugs [`fsck` – File System Check]: data/fsck.jpg "`fsck` -- File System Check" [Take Notes in Class]: data/remember.jpg "Take Notes in Class" [Plain Text]: week13notes.txt [Pandoc Markdown]: http://johnmacfarlane.net/pandoc/