Intro to Unix-2-2014 - Indiana University...
Transcript of Intro to Unix-2-2014 - Indiana University...
![Page 1: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/1.jpg)
Part 2Unix Introduction
![Page 2: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/2.jpg)
More Unix Commandswc
touch
![Page 3: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/3.jpg)
cp - ‘copy review’Let's copy a directory tree with recursion. Remember that in order to use the -r option when copying directory hierarchies.
Make sure your current directory is Unix_class:
$ cp -r dir2 dir3
![Page 4: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/4.jpg)
wc - ‘count’
This command will let you count the number of characters, words, and lines in a file.
To display the number of lines in a file:
$ wc -l filename
![Page 5: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/5.jpg)
wc - ‘count’
To display the number of words in a file:
$ wc -w filename
This command will let you count the number of characters, words, and lines in a file.
![Page 6: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/6.jpg)
wc - ‘count’
To display the number of characters in a file:
$ wc -m filename
This command will let you count the number of characters, words, and lines in a file.
![Page 7: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/7.jpg)
wc PracticeHow many lines are in the shrodinger poem? (in dir1)
$ wc -l shrodinger
$ wc -w final.paper
57 shrodinger
118 final.paper
How many words are in final.paper? (in dir2)
![Page 8: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/8.jpg)
touch
Use touch to create an empty file.
$ touch newfilename
Using the touch command on an existing file will update the last modify time.
![Page 9: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/9.jpg)
touch Practice
Create a new file in dir3 called my.stuff
$ cd ../dir3 $ touch my.stuff
![Page 10: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/10.jpg)
date
Typing date will give you the current day, date, time, and year and timezone.
$ date
Using the -u option will give you Greenwich Mean Time (universal time).
![Page 11: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/11.jpg)
who
This command will display information about who is currently logged onto the system.
$ who
![Page 12: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/12.jpg)
find
In the very simplest form we can use this command to find the location of a file.This command has four parts to it.
The Swiss Army Knife of Unix Utilities
![Page 13: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/13.jpg)
find
$ find
Start with the command_name find
![Page 14: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/14.jpg)
find
• Specify the directory in which to start your search (such as /home/userid). The find command will start there and go down recursively.
• If you want to start your search in the current directory, simply type a period (.) here. More on this later.
• Don’t start with the root directory (/)-You would not be able to search through some Unix directories.
$ find [directory]
![Page 15: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/15.jpg)
find$ find [directory] -name
-name specifies that you are looking for a filename.
• The find command can search for files by criteria other than the file name, such as modify time, size, or the file access permissions and many more attributes. I devote much more time to this command in S603 Unix Intermediate.
![Page 16: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/16.jpg)
find
$ find [directory] -name [filename]
• Now you type the name of the file you are looking for.
![Page 17: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/17.jpg)
$ find . -name grp.txt (or…)
$ find ~/Unix_class -name grp.txt
• Make Unix_class your current directory • You are looking for your file called grp.txt,
starting in the current directory (Unix_class) and searching in all of its subdirectories.
• What subdirectory is grp.txt in?
dir1
find Practice
![Page 18: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/18.jpg)
find PracticeWhat directory is catalyst in?
$ find . -name catalyst
$ find . -name address.list
./dir2/cats/catalyst (and)
./dir3/cats/catalyst
./dir1/address.list
(remember the . means the current working directory so it is assumed that your current working directory is Unix_class)
What directory is address.list in?
![Page 19: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/19.jpg)
find
$ find /home/jsmith -name rec*
You can also use wildcards with find, (you can’t remember if the name is records, recordings, or just recs).
(It is best to surround the wildcard phrase with single or double quotes.)
![Page 20: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/20.jpg)
find practiceFind all the files that begin with sh in Unix_class.
$ find . -name "sh*"./dir1/shrodinger ./Wildcards/shell.script.113 ./Wildcards/shell.script.276
![Page 21: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/21.jpg)
find
If the program has already found the file you wanted, but is still searching for more, then press Ctrl+C to stop the search.
![Page 22: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/22.jpg)
Review Even More Commands
wc – count the characters, words, or lines in a file touch – create an empty file, modify the file's time date – tells you the current day, date, time, timezone, and year who – see who is logged onto the system find – find the location of a file
![Page 23: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/23.jpg)
Even More Commands
Remember to check the man pages for each of the new
commands you've learned so far.
![Page 24: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/24.jpg)
Command Options
![Page 25: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/25.jpg)
Options/Flags• ls
• cp
• mv
• rm
![Page 26: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/26.jpg)
Review
• Unix Commands generally have three parts:
command_name [options] [operands]
![Page 27: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/27.jpg)
Command Options
So far we have discussed commands and operands.
Now we'll see some options that are available for our commands.
All commands come with default behavior and command options will allow us to modify this default behavior.
![Page 28: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/28.jpg)
Examples
$ ls temp
$ cp test1 test2
$ mv pict /home/jsmith/family_pics
![Page 29: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/29.jpg)
Examples$ ls -l temp
$ cp -r test1 test2
$ mv -i pict /home/jsmith/family_pics
![Page 30: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/30.jpg)
ls
-a
-l
-p
-t
![Page 31: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/31.jpg)
ls -a
“all” • ls -a will list all files
• Just typing ls will not list entries whose names begin with a period (.) “hidden files”
![Page 32: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/32.jpg)
ls -a
Example:
$ ls dir2
address_list final.paper picts cats history.txt
![Page 33: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/33.jpg)
ls -a
Example:
$ ls -a dir2
. .DS_Store cats history.txt
.. address_list final.paper picts
The . stands for the directory itself, and the .. stands for the parent directory. These files are created with the mkdir command.
![Page 34: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/34.jpg)
ls -l
“long format”
ls -l will list files in long format
This will give information about each file, such as who has permission to read it, when it was made, how large it is, etc. (we will cover more of this later in class).
![Page 35: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/35.jpg)
Example:
$ ls -l dir2
-rw-r--r-- 1 name name 455 Jun 30 22:33 address_list
drwxrwxr-x 5 name name 512 Jun 30 22:33 cats
-rw-r--r-- 1 name name 716 Jun 30 22:33 final.paper
-rw-r--r-- 1 name name 7091 Jun 30 22:33 history.txt
drwxrwxr-x 2 name name 512 Jun 30 22:33 picts
ls -l
![Page 36: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/36.jpg)
ls -p puts a slash (/) after each filename if the type of file is a directory.
Remember that in Unix, everything is a file. Some are regular files and some are directory files. There are several other types of files in Unix (i.e. devices, links, etc.) but all you need to know is how to differentiate between regular files and directories.
ls -p
![Page 37: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/37.jpg)
Example:
$ ls -p dir2
address_list final.paper picts/
cats/ history.txt
ls -p
![Page 38: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/38.jpg)
ls -t
“time”
• ls -t will list the files and directories, sorted by time modified (most recently modified first).
![Page 39: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/39.jpg)
Combining OptionsOptions can easily be combined.
If you want to list all files in long format:
$ ls -al
This would also give you information about the current directory and the parent directory, because the . and .. are listed with the -a.
![Page 40: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/40.jpg)
How many files and directories are in dir2, including hidden files?
$ ls -a . .DS_Store cats history.txt .. address_list final.paper picts
(8 files and directories)
ls Practice
![Page 41: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/41.jpg)
List dir2 in long format. Two entries begin with a ‘d’ - why
do you think this is?
$ ls -l (they are directories)
ls Practice
![Page 42: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/42.jpg)
cp
-i
-r
![Page 43: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/43.jpg)
cp -i
“interactive”
When you are copying a file or directory, when using cp -i, the system will ask you before you overwrite a copied file over an existing file.
![Page 44: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/44.jpg)
cp -r
“recursive”
cp -r specifies that when you copy a directory, you also copy all the subdirectories and files within that directory.
![Page 45: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/45.jpg)
m v
-i
![Page 46: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/46.jpg)
mv -i
“interactive”
When you are moving a file or directory, when using mv -i, the system will ask you before you overwrite a moved file over an existing file.
![Page 47: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/47.jpg)
r m
-i
-r
![Page 48: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/48.jpg)
rm -i
“interactive”
When you are removing a file or directory, when using rm -i (or rmdir -i), the system will ask you before you delete any file.
The -i option in cp, mv and rm are safety features for you.
![Page 49: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/49.jpg)
rm -r
Using rm -r will remove a directory and all of the files and directories under it!
Like fire, it can be very useful or catastrophic so be careful when using this command option.
![Page 50: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/50.jpg)
$ pwd (verify you are in Unix_class)
$ rm -r dir3
$ ls
Delete the directory dir3 - deleting all the nested files and
subdirectories at the same time.
rm Practice
![Page 51: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/51.jpg)
More Flags & Options
Check man for a list of available options for each command.
These options will differ slightly with different versions of Unix.
![Page 52: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/52.jpg)
grepGlobal Regular
Expression and Print
![Page 53: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/53.jpg)
grep
Looks inside files and searches for a series of characters (a phrase, a group of numbers, etc.). This is also referred to as contextual searching.
![Page 54: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/54.jpg)
grep
What if ?
...you want to look in all the files in the current directory (but not in its subdirectories) for a string of characters (also referred to as a “pattern list”)
?
![Page 55: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/55.jpg)
grep
What if ? You want to search for the phrase “tiny
fish” in one of your files in the current directory.
?
![Page 56: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/56.jpg)
grep in-class practice
Make dir1 your current working directory.
$ cd Unix_class/dir1
![Page 57: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/57.jpg)
grep 'tiny fish' *|
command
Type the following:
| space
| phrase you are
looking for
‘search string’
|
space | asterisk
* - means grep will look in all the files in the current directory
grep in-class practice
![Page 58: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/58.jpg)
grep
The program will then list the name of the file and the entire line in which the search string was found.
![Page 59: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/59.jpg)
grep
If you know what file to look in, you can substitute the filename for the asterisk (*).
![Page 60: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/60.jpg)
grep PracticeExample:
You want to find Sally’s information in address.list
Type: $ grep 'Sally Smith' address.list
Sally Smith 128 Hickory Lane 555-2974
![Page 61: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/61.jpg)
grep
You will always need single quotes (not any other kind of quote mark) around your search string if it has any spaces:
'class notes' or 'new ideas'
If your search string is only one word, you can still use the single quotes, but you don’t need them:
'notes' or 'ideas'
notes or ideas
![Page 62: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/62.jpg)
grep Practice
While you are in the dir1 subdirectory, search for:
Ash
How many results did you find?
What files were they in?
Remember - Unix is case sensitive
$ grep Ash *
![Page 63: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/63.jpg)
grep PracticeWhile you are in the dir1 subdirectory, search
for:
Ash
$ grep Ash *
address.list:Hon Chin 211 Ash Blvd. 555-5922
address.list:Ashley McNara 608 Redbud Ave. 555-8058
grp.txt:grep will also find parts of words, like bAshful.
![Page 64: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/64.jpg)
grep optionsWhile we are learning about grep it might be
useful to know some useful options: $ man grep
-i Ignores upper/lower case distinction during comparisons.
-l Prints only the names of files with matching lines, separated by NEWLINE characters. Does not repeat the names of files when the pattern is found more than once.
-v Prints all lines except those that contain the pattern.
![Page 65: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/65.jpg)
Using “regular expressions” with grep gives you more flexibility. These special metacharacters mean something specific to the program:
. * [ ] ^ $
grep - Regular Expressions
Regular expressions are sets of symbols and syntactic elements used to match patterns of text.
![Page 66: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/66.jpg)
Using “regular expressions” with grep gives you more flexibility. These special metacharacters mean something specific to the program:
. * [ ] ^ $
grep - Regular Expressions
When you use regular expressions, enclose your search string in quotes.
![Page 67: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/67.jpg)
grep - Regular Expressions
.(period)
Matches any single character
Example: $ grep 't.ck' filename This finds all examples of “tack,” “tick,”
“tock,” or “tuck” in the file, but not “thick”
![Page 68: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/68.jpg)
grep - Regular Expressions
*(asterisk)
Matches multiples of the preceding character
Example: $ grep 'ex3*7' filename This would find “ex37,” “ex337,” “ex333337,”
but not “ex347”
![Page 69: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/69.jpg)
grep - Regular Expressions
^(caret)
Matches only instances of the search string at the beginning of a line
Example: $ grep '^Once upon' filename This would find all lines beginning with the
phrase “Once upon”
![Page 70: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/70.jpg)
grep - Regular Expressions
$(dollar sign)
Matches only instances of the search string at the end of a line
Example: $ grep 'ever after$' filename This would find all lines ending with the phrase
“ever after”
![Page 71: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/71.jpg)
grep - Regular Expressions
[](brackets)
Matches any member of the set; use the brackets to enclose a set of options
Example: $ grep '[12,24,48] apples' filename
This would find “12 apples,” “24 apples,” or “48 apples” in the file
![Page 72: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/72.jpg)
How many lines begin with “No” in the shrodinger file (in dir1)?
grep - Practice
$ grep '^No' shrodinger
$ grep '8$' address.list
4 lines
5 numbers
• How many phone numbers in address.list end with an 8 (in dir1)?
![Page 73: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/73.jpg)
In dir1, type:
$ grep 'r...ing' *
What are the matches in each line?
grep - Practice
Breeding
fairy ring
rhyming
resting
![Page 74: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/74.jpg)
But what if you wanted to search for a phrase which contains a regular expression?
Example: you are looking for “$250” in the directory.
grep - Regular Expressions
If you typed:
$ grep $250 *
Because $ is a regular expression, you would not get the results you were looking for.
![Page 75: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/75.jpg)
To do this you need to use a backslash (\)
This negates the special properties of the following character.
This is often referred to as an 'escape' character. It is used to 'escape' the special meaning of a symbol.
Example: To look for $250, you would type:
$ grep '\$250' *
grep - Regular Expressions
![Page 76: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/76.jpg)
Who has a phone number where the last four digits begin with a 9 and end with a 9?
grep - Practice
$ grep '9..9' address.list
$ grep '\$3.50' *What costs $3.50 in dir1?
A bag of gerbil food (the $3750 appears because the . can stand for any character)
Jordon Davis
![Page 77: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/77.jpg)
In the Shakespeare directory, type:
$ grep 'ade.$' *
What results do you find? Why is the period necessary?
grep - Practice
They live unwoo'd and unrespected fade, Of their sweet deaths are sweetest odours made:
Without the period, the comma or colon would tell the system that 'ade' does not come at the end of the line (the $). So be careful of punctuation.
![Page 78: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/78.jpg)
Wildcards and Regular Expressions
? *
![Page 79: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/79.jpg)
WildcardsThere are two metacharacters which can act as a substitution for unknown letters or numbers in a filename or directory name.
These characters are not the same as they are in regular expressions using grep.
![Page 80: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/80.jpg)
Wildcard Uses
You can use wildcards with commands other than ls.
Wildcards apply to all commands including grep and are used in place of or in combination with operands. Regular Expressions only apply to grep and a few other Unix commands.
![Page 81: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/81.jpg)
Regular Expressions
Wildcards are different from the regular expressions used in grep (although they may look similar at times).
![Page 82: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/82.jpg)
Regular Expressions
The regular expressions used in grep should always be enclosed in the single quotes:
$ grep 'model vx9*0' *|
Here the asterisk is a
regular expression
| Here the
asterisk is a wildcard
![Page 83: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/83.jpg)
Regular Expressions
When you further your study with Unix you will appreciate what you have learned about regular expressions using grep.
Other Unix utilities such as sed, awk, and perl, python, php, and text editors such as vi and emacs will also use similar types of regular expressions.
![Page 84: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/84.jpg)
Regular Expressions
With regular expressions one can easily search through a text file (or a hundred text files) searching for words that have a certain suffix (but only if the word begins with a capital letter and occurs at the beginning of the line), replacing the suffix with another suffix, and then change all the lower case characters to upper case. With the right tools, a series of regular expressions would do just that.
However, this is well beyond the scope of this class.
![Page 85: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/85.jpg)
Unix and the Internet
![Page 86: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/86.jpg)
Unix and the Internet
The internet and the world wide web were built with Unix servers.
A server is just a computer that stores files and “serves” them whenever requested.
![Page 87: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/87.jpg)
Unix and the Internet
A web server is a computer that stores many html files and various programs and then waits for other computers to request certain files usually via the browser. When a request is received it finds the file and serves it to the requesting computer.
![Page 88: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/88.jpg)
Unix and the InternetAn IP number (internet protocol) is the numeric address for a computer on the internet. This address identifies your computer much like your street address identifies your home.
Similarly, your login name (userid) is also translated to a unique number that identifies you to the system.
![Page 89: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/89.jpg)
Unix and the InternetA name can simply be the name of the server (computer/host), i.e. ella. This is referred to as a “relative” hostname. This is just a name we give the computer when Unix is installed. It may be all we need for a local network but there could be a lot of computers named “ella” out there. We need a way to further identify this computer in order to make it more unique.
![Page 90: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/90.jpg)
Unix and the InternetTo create a more unique computer (host) name we use a “fully qualified” hostname. This is similar to identifying your home address further by adding your city, state, and zipcode. The fully qualified hostname of the student Unix web server at SLIS is “ella.ils.indiana.edu”.
The domain, ils.indiana.edu further identifies our server from the “ella” server on the ucs network (ucs.indiana.edu).
![Page 91: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/91.jpg)
Unix and the InternetWhen you visit a site, you are visiting a computer. You may type in a name such as:
www.ils.indiana.edu
This is called a Domain Name.
This name gets translated into a number, the I.P. number. In this case:
129.79.36.75
![Page 92: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/92.jpg)
Unix and the Internet
Most people can remember names better than a string of numbers so a system was setup to make life easier for Internet users. This system is called DNS (Domain Name System).
DNS does the work of translating the name, i.e. www.ils.indiana.edu, to a number the system can use to correctly identify which server you want to connect to.
![Page 93: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/93.jpg)
Unix and the Internet
Domain names are organized in a hierarchical way, similar to the file system in Unix. This hierarchy includes your company or server name, and a country code (for example, .uk or .ca) or a top-level domain (for example, .com or .edu).
A Web site on the server is created with one IP address, one host name and one domain name that together establish the identity of that Web site on the Internet.
![Page 94: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/94.jpg)
Unix and the Internet
When you attempt to access a server via http (normal web browser access) you may have encountered an error from time to time relating to DNS. It may give you an error saying that you had a “DNS lookup failure”.
All this means is that the DNS server (most often running on Unix servers) cannot match the domain name you provided to an IP number.
![Page 95: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/95.jpg)
Unix and the Internet
If you were so inclined, you could look the IP number up yourself using the command, nslookup, or the dig command.
nslookup manually converts a domain name to the matching IP number.
$ nslookup [fullyqualifiedhostname]
![Page 96: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/96.jpg)
Internet Practice
$ nslookup www.ils.indiana.edu
Server: 10.79.1.1 Address: 10.70.1.1#53 www.ils.indiana.edu canonical name = ils.indiana.edu. Name: ils.indiana.edu Address: 129.79.247.195
![Page 97: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/97.jpg)
Names
Canonical names refer to the real hostname of a computer or network server.
A CNAME record in the DNS database allow a server to be known by more than one hostname.
![Page 98: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/98.jpg)
Protection with FirewallsMost companies use ‘firewalls’ as a means to protect their internal (private) network resources. A firewall is usually a set of related programs running on servers that sit at the gateway to a private network. Their function is to protect a private network from the outside world by limiting access to the network.
A firewall also includes or works with a proxy server that makes network requests on behalf of computer users. Basically, a firewall, working closely with a router program, filters
![Page 99: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/99.jpg)
Protection with Firewalls
Firewalls
Firewalls are frequently used to prevent unauthorized Internet users from accessing private networks connected to the Internet, especially intranets. All messages entering or leaving the intranet pass through the firewall, which examines each message and blocks those that do not meet the specified security criteria.
![Page 100: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/100.jpg)
100
Text Editing
![Page 101: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/101.jpg)
What is a text editor?A text editor is not a word processor like Microsoft Word.
It will not do boldface, headers, footers, italics, changing fonts, or other things associated with a word processor.
![Page 102: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/102.jpg)
What is a text editor?
A text editor does let you create a file of text, edit that text, and save the file.
![Page 103: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/103.jpg)
What is a text editor?
The two most common text editors that were mostly there from the beginning in the Unix world are:
vi
emacs
![Page 104: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/104.jpg)
Vi/Vim
I will cover vi/vim in depth in the Unix Intermediate class. For some there can be a steep learning curve and it would be helpful to have a working understanding of regex to make full use of this editor.
Some people fell in love with and are “wired” for emacs… but I am not one of them.
![Page 105: Intro to Unix-2-2014 - Indiana University Bloomingtoninfo.ils.indiana.edu/~stevecox/unix/unix_intro/intro_unix-2.pdf · not be able to search through some Unix directories. $ find](https://reader036.fdocuments.in/reader036/viewer/2022070823/5f320d9f97739c61c6322d86/html5/thumbnails/105.jpg)
Ready for more?