In this post, You will learn some of the important Linux commands. Hope you have seen the other parts.
If you have any doubts watch the video ????????
Let’s start ????
If you have any doubts you can watch the video above or you can ask questions in discord I have given my twitter profile link so you can ask there. ????????
In previous part we have see how to open a file using cat command and you can also open a file from different directory.
For example take a look at the below example.
Taking the head
The head command helps to display the top contents inside a file. Instead of viewing the full file by default the head command shows the top 10 lines in a file.
You can use the head command followed by file name.
head <file name> or head /etc/proxychains4.conf
We can also specify how much line we want to specify.
head -n 20 /etc/proxychains4.conf
Grabbing that tail
To see the last few line in a file we can use the tail command.
To specify how lines to view we can use the -n command.
tail -n 20 /etc/proxychains4.conf
To number lines, we can use the nl utility followed by the file name. Here is an example.
Replacing a text in a file
Using the sed command we can replace a text inside a file, Take a look at the below image.
sed s/mysql/MySql/g here.txt
- s – search
- mysql – the term to search
- MySql – Change mysql to MySql
- g – replace globally
Controlling the display with more and less
The more command followed by the file name displays more content, Whereas the less command followed by the file name will display less content on the display.
Hope you learned some new stuff today. Wait for part 3 it will be great. See you guys in the next post ❤️