If you can see this check that

Main Page

Essential Basic Centos


Basic File Analysis

User:
Password:

Objectives

In this session you will be covering the basics of file content searching and manipulation, including basic editing and regular expressions.

Question 1: Create demo account

To follow along with the examples shown here using the virtual machines is it safer to use an account other than the administration account (root). By pressing the button below a new account is created called "demo", password is also "demo". Log in using this account and you cannot do any damage. If you mess the account up and want to start again, just press the button again.

Once created, you can log into this account using telnet or ssh, logging into the hostname linuxzoo.net. Remember the username is demo and the password is demo. And remember, you cannot break anything using this account! The account begins with an empty directory, so dont be shocked that "ls" shows nothing...

MAKE SURE YOU USE THE USER demo. If you do this with "root" or another account, you will be marked wrong. If you start with the wrong user, make sure you delete any files you created wrongly before changing to demo.

Tests - not attempted
Create an account called demo, password demo UNTESTED

Question 2: Signatures

This question covers basic file manipulation. To begin this question use the first button to set up a small file and directory tree in /home/demo. The resulting tree looks like:

/
+--- home
     |
     +--- demo
          |
          +--- theanalysis
          |    +--- file1
          |    +--- file2
          |    +--- file3
          |    +--- file4
          |    +--- file5
          |
          +--- tree (plus directories and subdirectories)
          |
          +--- suspect
               +--- data1

You only have to press the button to create this tree. You do not create this structure yourself. It is completely automatic. If you lose this structure or accidentally delete it then you can press the button again to restore the struture.

Tests - not attempted
Created Structure UNTESTED

Using the "file" command, evaluate the file signature of theanalysis/file1.
What is file1?

Tests - not attempted
file1 type identified UNTESTED

User the "file" command, evaluate the file signature of theanalysis/file4.
What is file4?

Tests - not attempted
file1 type identified UNTESTED

Use the md5sum command to calculate the md5 hash of file3.
What is the md5 hash of file3?

Tests - not attempted
md5sum of file3 UNTESTED

If another file has the same md5 hash, what does this mean?
Meaning of two files with same hash?

Tests - not attempted
Identical Hash understanding UNTESTED

Use the md5sum command to calculate the md5 hash of file4.
What is the md5 hash of file4?

Tests - not attempted
Hash of file4 UNTESTED

Use the cmp command to verify that file3 and file4 are identical.
Output of cmp command

Tests - not attempted
cmp output UNTESTED

Check file3 and file4 using a 512 bit sha hash.
512 bit hash of file3
512 bit hash of file4
So this means?

Tests - not attempted
512 bit SHA of file3 UNTESTED
512 bit SHA of file4 UNTESTED
And this means UNTESTED

Question 3: FIND command

Use the find command to locate all files which start with an "a" and end in a ".conf" which exist somewhere in /usr/share. Save this list to a file '/home/demo/alist'. Make sure that the first parameter of find is "/usr/share". Run the command as user "demo" and do not worry about any permission error messages.

Tests - not attempted
/home/demo/alist exists UNTESTED
Files found UNTESTED

Use the find command to locate all FILES in /usr/share which have the permissions "rwxr-xr-x". Save this list to /home/demo/blist. Make sure that the first parameter of find is "/usr/share". Run the command as user "demo" and ignore any permission error messages.

Tests - not attempted
/home/demo/blist exists UNTESTED
Files found UNTESTED

Use the find command to locate all directories in /usr/share which have the permissions "rwxr-xr-x". Pipe this list to wc and count the number of directories.
Number of directories:

Tests - not attempted
Correct number of directories UNTESTED

Again using the find command find out how many FILES in /etc are in group lp.
Number of files:

Tests - not attempted
Correct number of files UNTESTED

Question 4: GREP and regexp

Using a combination of grep, regular expressions, and wc via a pipe count how many words in the /usr/share/dict/words dictionary starts with "anti" and ends with an "n".
Number of words:

Tests - not attempted
Word count UNTESTED

Using grep and regular expressions, create a file /home/demo/aword which contains all the words which start with "tele" from /usr/share/dict/words, and which are exactly 7 characters long.

Tests - not attempted
/home/demo/aword exists UNTESTED
Words correct UNTESTED

How many words have the string "ra" in them twice in /usr/share/dict/words?
Number of words:

Tests - not attempted
Word count UNTESTED

How many words are in /usr/share/dict/words which contains "ice" then immediately following that either an "s" or a "d" (i.e. ices or iced). Use square brackets to form a set in your regular expression.
Number of words:

Tests - not attempted
Word count UNTESTED

Use grep on words to find a word that contains each of the vowels in alphabetical (i.e first an A, then an E, etc) order in /usr/share/dict/words. How many such words are there? (you may include words with extra vowels such as adventitious. A vowel is one of A,E,I,O,U.
Number of words:

Tests - not attempted
all vowels in order UNTESTED

The word interlinking includes the same two characters (e.g. "in") which appear three times. The word "priestessess" also contains the same two characters repeated three time (e.g. "es").

How many words can you find which contain any two characters repeated three times, like the examples "interlinking" and "priestessess". Use /usr/share/dict/words as your list of possible words and grep to find the answer.
Number of words:

Note. Do a case sensitive match, so do not use "-i".

Tests - not attempted
Two character string appears 3 times (takes a few seconds) UNTESTED

Challenge Question: This is a tricky question. Just give it 10 minutes before moving onto the next question!

How many words are 5 character palindromes? A palindrome is a word spelled the same way forward and backwards, such as "sagas". Use /usr/share/dict/words. Hint: Use multiple groups and backreferences.
Number of words:

Tests - not attempted
Number of 5 character palindromes UNTESTED


Centos 7 intro: Paths | BasicShell | Search
Linux tutorials: intro1 intro2 wildcard permission pipe vi essential admin net SELinux1 SELinux2 fwall DNS diag Apache1 Apache2 log Mail
Caine 9.0: Essentials | Basic | Search | SysIntro | 5a | 5b | 5c | 6 | 7a | 7b | 8a | 8b | Browser
CPD: Cygwin | Paths | Files and head/tail | Find and regex | Sort | Log Analysis
Kali: 1a | 1b | 1c | 2 | 3 | 4a | 4b | 5 | 6 | 7a | 8a | 8b | 9 | 10 |
Useful: Quiz | Forums | Privacy Policy | Terms and Conditions
Site Links:XMLZoo ActiveSQL ProgZoo SQLZoo

Linuxzoo created by Gordon Russell.
@ Copyright 2004-2018 Edinburgh Napier University