Unless noted otherwise, you should perform the instructions below using your own
virtual instance of Kali.
Visit https://ryanstutorials.net/linuxtutorial/ and work through these
sections: Basic Navigation, More About Files, Manual Pages, File Manipulation,
Wildcards, Permissions, Filters, Grep and Regular Expressions, Piping and
Redirection, Process Management, and Cheat Sheet. Be sure to do the Activities
section in each tutorial.
Based on our discussion of text editors in the online video, decide which text editor you
would like to use: vim or nano. Then follow the instructions for the
editor of your choice below:
- vim
- Make sure you have the cheat sheet(s) handy as a reference.
See: https://josephus.sergeantservices.com/classes/all/docs/vi-ref.pdf and https://josephus.sergeantservices.com/classes/all/docs/vi-back.pdf.
At the command-line enter the command: vimtutor and read and
follow the instructions for lessons 1 and 2 (each lesson has quite
a few parts so this will take about an hour).
- nano
- Read and follow the tutorial found at:
https://www.howtogeek.com/42980/the-beginners-guide-to-nano-the-linux-command-line-text-editor/
You'll need to jot down some things in a text editor as you go. In the instructions
that follow there will be several times the instructions say “(Save)” which is
your cue to record what you learned in a text file (named stats.txt) along
with a description. Some of the commands may be new to you. Feel free to use
the man command to get a quick description if you are not sure how to
proceed.
Using the command-line complete these tasks:
- You will get a copy of all files (including subdirectories) from the
josephus.sergeantservices.com server. The files are currently combined and compressed
into a single document with a .tgz extension ... which is to say
the documents have been “tarred and zipped”. The file is located here:
https://josephus.sergeantservices.com/classes/cy/source/data.tgz
The easiest way to get it to your Kali VM is to use wget:
wget https://josephus.sergeantservices.com/classes/cy/source/data.tgz
- In your Kali instance, untar/zip the data.tgz file you just downloaded:
tar xvzf data.tgz
- Change into your newly created directory called data and do the
remainder of the steps from there.
- Delete the gotthought directory and everything in it.
- Make a copy of alice.txt called greenalice.txt.
- Use a text editor to open greenalice.txt and find the line number of
the first mention of “Cheshire”. (Save the line number to your text file)
- In the same file replace all occurrences of “Cheshire” with “Green”.
Save and exit the file.
- Use the diff command to compare alice.txt with greenalice.txt.
How many lines differ between the two files? (Save)
- Take moment to play around with the wc command (which counts lines, words,
and characters in a file).
- Use ls, wc and the pipe to count how many .txt files
are in the current directory. (Save)
- Use find, wc and the pipe to count how many .txt files
are in the current directory and all of its subdirectories. (Save)
- Create a subdirectory called fun and copy zip1999.zip into it
and then make it your working directory.
- Use unzip to unzip zip1999.zip.
Take note of the size of zip1999.zip and of the files that were
extracted from it (zipnov99.DBF and zipcodes.doc).
(Save sizes) Then use a calculator to determine the space savings as a percentage. (Save calculated percentage).
- Remove all the files from the fun directory (but remain inside
it). Then copy the file named p1source.tgz from the parent directory
to fun.
- Use the tar command to extract the files from p1source.tgz
inside fun. You may need to look up how to use this command. How many
files were extracted from p1source.tgz? (Save)
- Without leaving the fun directory, copy the file pc.txt
from the games directory to it.
- Return to the parent directory and delete fun and all the files in it.
- Use an editor to modify Indent.java so that it is properly indented.
Instead of indenting each line one at a time look up how to indent a block of
lines using your chosen text editor and indent accordingly. Save your changes.
- Don't delete this working directory yet ... we'll be using it in future
steps.
Start the Firefox web browser in Kali (Kali Icon -> Web Browser).
Use the interactive lessons at https://regexone.com to learn/practice writing
regular expressions. When you reach the screen with the graduation cap you can stop.
Make a screen capture of the final screen and save it under the name cap.jpg.
NOTE: This site has a section of additional exercises that you do not need to
work through unless you just want extra practice.
The program sed is a stream editor that will apply editing commands to
whatever is fed into it. This can be done by piping output from another command
to it or it can be applied to an existing file in place. Often you will want
to use a regular expression to match a pattern and then insert new text after
the pattern, delete the pattern, or replace the pattern. There are a number of
decent sed tutorials online but not a single one that to me seemed the
go-to tutorial. Take some time to play around with various sed commands
and then proceed to the instructions below when you are ready to use it.
- Return to the data directory you created using the steps
above.
- Use the wget utility to download this document into data:
https://josephus.sergeantservices.com/classes/ds/source/melville.txt. The
following exercises should be applied to melville.txt in place so that
the file is modified. (If you accidently destroy the file you can
download a fresh copy.
- Use sed to remove the leading spaces on each line.
Once you have a command that works save the command to stats.txt
along with a description.
- Use sed to replace all lines that begin with a hypen with a blank
line. (Save)
Use the tar command to create a .tgz file that contains these files:
- stats.txt
- Contains notes you took of various values and command along
with descriptions of the the meaning of those values and commands.
- greenalice.txt
- Contains text of Alice in Wonderland with
all instances of “Cheshire” replaced with “Green”.
- Ident.java
- Contains properly indented Java program.
- cap.jpg
- Is the screen capture of your completed regex tutorial.
Transfer your newly-created .tgz file from Kali to your host operating
system by clicking Machine->File Manager in the VirtualBox menu of the
window containing the running Kali machine. Initially you'll see a message that
says: “No Guest Session found!”. To create a guest session enter your
Kali username and password in the boxes to the left and then click the
“Create Session” button. Once a connection has been made you can transfer
a file from Kali to your local computer by simply dragging from the left panel
to the right panel. Once you have transfered the file to your local computer
you are ready to upload the .tgz file in Canvas. Once you have turned in
your work you can/should remove the data directory in Kali in which you've
been working.
Be sure to perform a proper shutdown of you Kali instance (File->Close) and save
the results of the current session for future logins. NOTE: This may take a few
minutes because of the many changes we made to the Kali file system.