I don’t remember that I told you or not, everything in Linux are files & most of those files are text files. If you want to manipulate linux files then you can do it by just opening them, update & restart the system to see the changes.
Manipulate Linux Files
This article is dedicated to those commands which can manipulate linux files. There are several commands used in the editing of configuration files. To edit the files we will be using an example called NIDS, snort.
This command is used to open a file. type
After the command will be entered then the file be displayed on the screen from the start to the end. This is not the recommended way to manipulate a file.
Hire a Content Writer From here
This command will also sow the file but it will show the file form the beginning
This command will show the first ten lines of the file. If we want to see a desired number of lines from the screen say 40 lines than we have to use the command like this.
head -40 /etc/snort/snort.conf
This will show the first 40 lines of the file.
Tail command shows the last lines of the file. It work as same the Head command. Type the command like this
The command will show the last lines of the file. If the number of last lines needs to watch, then the command will be used as
tail -40 /etc/snort/snort.conf
Display the lines of file with a line Number
This can be a better approach for a file when it is of a very big size. The command ln will be used in this reference. Use the command like this.
This will show all the lines in a file with the line number, now it will be easy for the user to refer to any line via line number.
This command is one of the most powerful command in the Linux. This command can show us only those lines form the file which has a specified string. The line with those string will be shown on the screen. For example a word database is in snort.conf file. If you want to display only those lines which have the word database, then type the command.
cat /etc/snort/ snort.conf | grep database
This command will be executed form right to left. First it will search for the word database from the file snort.conf, then it will show the lines of the file having the word database.
If you find the information useful & got to know something new, please let us know in the comment box. Like our Facebook page for more updates. See you in the next part. Thank You.