Introduction????????
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 ????????
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. ????????
https://odysee.com/@techyrick:d
https://twitter.com/HacklikeHacker
Viewing Files
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.
cat /home/rick/here.txt
![](http://techyrick.com/wp-content/uploads/2023/03/Screenshot-2023-03-28-at-6.04.35-PM-1024x493.webp)
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
![](http://techyrick.com/wp-content/uploads/2023/03/Screenshot-2023-03-28-at-6.12.05-PM-1024x530.webp)
We can also specify how much line we want to specify.
head -n 20 /etc/proxychains4.conf
![](http://techyrick.com/wp-content/uploads/2023/03/Screenshot-2023-03-28-at-6.13.55-PM-1024x778.webp)
Grabbing that tail
To see the last few line in a file we can use the tail command.
tail /etc/proxychains4.conf
![](http://techyrick.com/wp-content/uploads/2023/03/Screenshot-2023-03-28-at-6.17.21-PM-1024x368.webp)
To specify how lines to view we can use the -n command.
tail -n 20 /etc/proxychains4.conf
![](http://techyrick.com/wp-content/uploads/2023/03/Screenshot-2023-03-28-at-6.30.49-PM-1024x626.webp)
Numbering Lines
To number lines, we can use the nl utility followed by the file name. Here is an example.
nl /etc/proxychains4.conf
![](http://techyrick.com/wp-content/uploads/2023/03/Screenshot-2023-03-28-at-6.33.39-PM-1024x709.webp)
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
![](http://techyrick.com/wp-content/uploads/2023/03/Screenshot-2023-03-28-at-6.40.22-PM.webp)
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.
more /etc/proxychains4.conf
![](http://techyrick.com/wp-content/uploads/2023/03/he-1024x735.webp)
less /etc/proxychains4.conf
![](http://techyrick.com/wp-content/uploads/2023/03/Screenshot-2023-03-28-at-6.44.48-PM-1024x726.webp)
Conclusion
Hope you learned some new stuff today. Wait for part 3 it will be great. See you guys in the next post ❤️