Search
Question 2: Signatures
Using the "file" command, evaluate the file signature of theanalysis/file1.
file file1
file1: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=3d705971a4c4544545cb78fd890d27bf792af6d4, stripped
User the "file" command, evaluate the file signature of theanalysis/file4.
file file4
file4: data
What is the md5 hash of file3?
md5sum file3
79054025255fb1a26e4bc422aef54eb4 file3
Meaning of two files with same hash?
File content are probably identical
What is the md5 hash of file4?
md5sum file4
79054025255fb1a26e4bc422aef54eb4 file4
Use the cmp command to verify that file3 and file4 are identical.
cmp file3 file4
file3 file4 differ: byte 20, line 1
Check file3 and file4 using a 512 bit sha hash.
sha512sum file3 file4
9272889ad0f7372047229d19ca58b93c539002f21f6e3da1697514406fe9b3cb20fcf546b9005ebadc16691a71658af848e35abad58422d5ae4650c21d7ad749 file3
77e921be6902b03a34e6e56aa80f611bb5aec86850f83a5260959ff33012dfc6bb554141fe8641c09ffdd44955ea0af232e9883b91eae6db26a87782640e0a95 file4
File Content are definitely different
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.
find /usr/share -type f -name a*.conf > /home/demo/alist
cat /home/demo/alist
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.
find /usr/share -type f -perm 755 > /home/demo/blist
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.
find /usr/share -type d -perm 755 | wc -l
6405
Again using the find command find out how many FILES in /etc are in group lp.
find /etc -type f -group lp | wc -l
9
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".
grep -E '^anti.*n$' /usr/share/dict/words | wc -l
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.
# tele is 4 character, we will add +3
grep -E '^tele.{3}$' /usr/share/dict/words > /home/demo/aword
How many words have the string "ra" in them twice in /usr/share/dict/words?
# !!!
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.
grep ice /usr/share/dict/words | grep ice*d | wc -l
198
[root@host-1-129 ~]# grep ice /usr/share/dict/words | grep ice*s | wc -l
213
411
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.
grep 'a.*e.*i.*o.*u' /usr/share/dict/words | wc -l
247
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.
# !!!
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.
# !!!
Last updated
Was this helpful?