Chapter 2: Text Manipulation
Continuing with Linux Basics for Hackers, I learned how to deal with text files and manipulate text with a few commands.
head: used to view first 10 lines of a file
tail: used to view last 10 lines of a file
If there are more or less than 10 lines that need to be seen, I could do: head -20 home/newdirectory/file.txt or tail -20 home/newdirectory/.file.txt
nl: displays a file with line numbers
sed: searches for occurrences of a word or text pattern and then performs some action on it
more: displays a page of a file at at time and lets you move down the page using the “Enter/Return” key.
less: similar to the “more” command except it does not load the entire file at once and you’re able to search for text within the file.
Below are the exercises I did!
Exercises
Navigate to /usr/share/metasploit-framework/data/wordlists.
Use the cat command to view the contents of the password.lst file. There are over 88,000 passwords in this file so obviously I couldn’t show them all.
Use more command to display password.lst file.
Use the less command to view contents of the password.lst file.
Use the nl command to place line numbers on the passwords in password.lst.
Use tail command to see the last 20 passwords in password.lst.
Use cat command to display password.lst and pipe it to find all passwords containing “123”.
This chapter was pretty short! What I found interesting is that there are “head” and “tail” commands in Linux. When I was learning R and Pandas (a Python library for data manipulation and analysis), I came across “head” and “tail” functions. These functions seem to perform the same across languages.
Looking forward to Chapter 3!