Updated: 2015-10-12 11:32 EDT
awk
vi/vim, nano
head, tail
find
using “wildcard” (GLOB) patterns - same as shell GLOB.bashrc
fileCheck the due date for each assignment and put a reminder in your agenda, calendar, and digital assistant.
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 teach you how commands work. Worksheets are not for hand-in; they are not worth marks.
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.
PS1, cd, find, less, ls, man, mkdir, passwd, pwd, rmdir
cat, clear, cp, find, grep, history, less, man, mv, rm, sleep, touch
alias, sum, unalias
date, head, nl, tail, tr, wc
vim
vimtutor
program on the CLS.Read the Test Instructions (all the words) before your midterm tests.
Tests take place in class in your one-hour lecture hour, not in your lab period.
;
to separate multiple commands on the same line, to save space and paper, e.g. three separate commands can be written on one line like this: date ; echo "hi" ; ls
This quiz is one of several quizzes in this course. See last week for the details.
Take notes in class! Your in-class notes would go here.
The stupid nano
text editor. (Learn vim
instead!)
Students who did not change their passwords (see Assignment #02) will have had their CLS accounts disabled.
There is information on Automatic Backups on the CLS that explains how to get back a file you’ve deleted or changed.
The VI Text Editor creates hidden recovery files as you edit that can get included in recursive path listings: .*.swp
Take notes in class! A student writes:
But for the note taking, I personally find that without my laptop in front of me I am more focused on the teacher. Also with taking the notes by hand I find that the information that is presented to me in the lectures is remembered much easier.
But I do have my ipad in front of my with the class notes. This also helps me follow along with the examples that you present in class.
Also sometimes I read over the class notes after the class and fix my notes with anything that was missed.
Students who save an hour by not attending a lecture usually end up spending three hours trying to answer assignment questions that I gave the answers to in the lecture. Work smarter.
READ THIS: This is a repeat of what I told you back in Week 3:
Your time as a student is valuable. If you come up against a tough problem and make no progress in fifteen minutes despite your best efforts:
This happens to all of us, and we need to watch out for it when it happens.
Be especially careful if you find yourself trying to solve a problem with online searches, since those searches will return answers irrelevant to the assignment. Read and search the course notes; don’t waste time searching the entire Internet.
I watch students trying to solve assignment problems using online searches for answers. They may end up using commands we haven’t even covered yet:
Sorry, I dont know what
sudo
does; was getting help online to find files.
If you look at the List of Commands You Should Know that is given in the weekly readings every week, you will see that we never use the sudo
command, so you should not be using it. Don’t use commands that you haven’t learned yet.
Also, you must never use any command that you don’t understand, even if you get it from the course notes or a worksheet. You risk deleting all your files if you use commands you don’t understand.
If you use online help, you will find thousands of complex wrong ways to do things. If you read the course notes, not Google, you will find a simple, right way.
You only need to use the commands we’ve learned so far in the course notes and the worksheets. That is all.
Growing up under Mac/Windows, you are accustomed to having to “go to” a folder to make any changes to files in that folder. This leads to some inefficient behaviour under Unix/Linux, because Unix/Linux can operate on any file in any folder without having to “go” there:
The “Windows/Mac” way to create a file under a/b/c/d/date.txt
:
$ mkdir a
$ cd a
$ mkdir b
$ cd b
$ mkdir c
$ cd c
$ mkdir d
$ cd d
$ date >date.txt
$ cd
The Unix/Linux way:
$ mkdir -p a/b/c/d
$ date >a/b/c/d/date.txt
The “Windows/Mac” way to rename a file under a/b/c/d/date.txt
to be old.txt
:
$ cd a
$ cd b
$ cd c
$ cd d
$ mv date.txt old.txt
$ cd
The Unix/Linux way:
$ mv a/b/c/d/date.txt a/b/c/d/old.txt
The “Windows/Mac” way to delete a/b/c/d/old.txt
:
$ cd a
$ cd b
$ cd c
$ cd d
$ rm old.txt
$ cd
The Unix/Linux way:
$ rm a/b/c/d/old.txt
Using Unix/Linux pathnames, you can work faster, and all your commands are saved in your history for modification and re-use.
awk
IndexThe oddly-named awk
command can extract a field, by field number, from one or more input lines. See using awk
to select fields.
The shell built-in command pushd
works like cd
to change the current directory, but it saves the previous directory on a stack and lets you type popd
to return to the previous directory. You may find this saves you some typing. See the shell man page or use the help
built-in.
fgrep -c "refused connect" /var/log/auth.log
fgrep "refused connect" /var/log/auth.log | wc
fgrep 'refused connect' /var/log/auth.log | tail
less /etc/hosts.evil
Don’t do this:
Sep 30 12:33:50 Invalid user Patrick from 99.240.239.9
Sep 30 12:33:58 Failed password for invalid user Patrick from 99.240.239.9
Sep 30 12:34:35 Failed password for invalid user Patrick from 99.240.239.9
Sep 30 12:35:11 Failed password for invalid user Patrick from 99.240.239.9
Sep 30 12:35:14 Failed password for invalid user Patrick from 99.240.239.9
Sep 30 12:44:13 refused connect from cpec8be198f774b-cmbc140127c8b0.cpe.net.cable.rogers.com (99.240.239.9)
Or this:
Oct 4 21:11:01 Failed password for pate0377 from 99.224.164.198
Oct 4 21:11:10 Failed password for pate0377 from 99.224.164.198
Oct 4 21:11:27 Failed password for pate0377 from 99.224.164.198
Oct 4 21:11:48 Invalid user pate0037 from 99.224.164.198
Oct 4 21:12:10 Failed password for invalid user pate0037 from 99.224.164.198
Oct 4 21:12:37 refused connect from cpe00fc8d22a843-cm00fc8d22a840.cpe.net.cable.rogers.com (99.224.164.198)
Or this:
Oct 4 23:34:43 Invalid user martr0991 from 99.245.238.68
Oct 4 23:35:00 Failed password for invalid user martr0991 from 99.245.238.68
Oct 4 23:35:12 Failed password for invalid user martr0991 from 99.245.238.68
Oct 4 23:35:24 Failed password for invalid user martr0991 from 99.245.238.68
Oct 4 23:35:39 Failed password for invalid user martr0991 from 99.245.238.68
Oct 4 23:36:46 Invalid user mart091 from 99.245.238.68
Oct 4 23:36:57 Failed password for invalid user mart091 from 99.245.238.68
Oct 4 23:37:07 Failed password for invalid user mart091 from 99.245.238.68
Or this:
Oct 4 20:27:51 Invalid user lavi2078 from 70.26.160.194
Oct 4 20:28:18 Failed password for invalid user lavi2078 from 70.26.160.194
Oct 4 20:28:29 Failed password for invalid user lavi2078 from 70.26.160.194
Oct 4 20:28:47 Failed password for invalid user lavi2078 from 70.26.160.194
Oct 4 23:43:39 Invalid user lavi2078 from 70.26.160.194
Oct 4 23:43:55 Failed password for invalid user lavi2078 from 70.26.160.194
Oct 4 23:45:09 refused connect from bas1-jockvale05-1176150210.dsl.bell.ca (70.26.160.194)
Or this:
Oct 5 01:36:50 Invalid user from 70.55.30.201
Oct 5 01:37:03 Failed password for invalid user from 70.55.30.201
Oct 5 01:37:06 Failed password for invalid user from 70.55.30.201
Oct 5 01:37:30 Failed password for invalid user from 70.55.30.201
Oct 5 01:37:32 Failed password for invalid user from 70.55.30.201
Oct 5 01:38:17 refused connect from bas2-kanata16-1178017481.dsl.bell.ca (70.55.30.201)
A student writes me the night before the assignment is due:
I locked myself out of the CLS. I cant hand in my assignment because of this.
You can. As it says in the Course Linux Server notes, you can submit your assignment from any other IP address. If you’re locked out of home, go somewhere else to submit. You can always submit from school.
Working from home is a privilege. If you abuse the privilege and lock yourself out, go to school.