[Part 5]Kali Linux Basics: Viewing, Creating and Editing Files
This topic continue back from Part 4 Kali Linux Basics. In this lesson, we are going to be covering the viewing, creating and editing files function. This lesson sounds exactly like what it is. Basically, we are going to talk about how to view, create and edit files. Mainly, we are just going to be learning how to create quick text documents and commands needed to view,create and editing files.
Commands we will be learning:
- echo
- cat
- replacing vs appending (>vs>>)
- touch
- nano (terminal text editor)
- mouse pad (GUI text editor) / (in the old version which is known as gedit)
First command: echo
We can just echo hello out to the terminal and it will just say hello back. What we can do with an echo? We can use it to write to a file similar to the command in the figure above.Besides, we can list directory and see that the hey.txt file is here.
Second command: cat
This command is used to print out to the screen what is in a file.
Third command is about replacing vs appending (>vs>>)
In the figure above, the greater than symbol (>) just simply replace the text in the hey.txt file. What we can do to append the text in the file? We can use two greater symbol(>>) to append the text in hey.txt. Now, we cat the file and the file is append the newly added word to the end of it/another line. This command is incredibly useful when we are either adding stuff to a list and just want to combine our lists or when we are just simply create a series of commands to send it in the terminal all at once.
Next command: touch
We can use another command called touch to create a new file and you can see the Nfile.txt is in there with the ls command. In addition, if we cat the Nfile.txt, there is nothing inside because we haven’t add anything into the file yet.
Next command: nano
Nano is a terminal text editors and there are other text editors like vi and vim. Personally, I like the nano text editor the most but it depends on your own preferences which one to use. I encourage you all to play around with it and pick the one that really suite you.
We can write whatever we want in here and we are going to use it for many purpose like create a scripts to create Python scripts, edit shell code, etc. After writing the word in it, we can Hit CTRL X (exit) + CTRL Y (saving) + Hit Enter to save it and exit to terminal.
Now, if we cat the Nfile.txt, we can see the word that we entered before. Thus, this is one of the way for editing.
You can also create file using nano as well which is shown in the figure above.
Next command: mousepad (in the old version which is known as gedit)
Another way of editing the file is using a mousepad which is a GUI text editor. If you are not used to terminal text editor, maybe you can tryout the GUI text editor. By the way, this is more simpler to use as you don’t need to navigate around with your keyboard like I do in the terminal. Then save it and we can see that the word is saved in the file with the cat command. However, there is probably a time where you are at another machine that doesn’t have GUI and you have to use nano. Therefore, you need to get comfortable using both. Lastly, you can also use mousepad to create a file as well.
Thanks for reading.
To be continued… Next lesson we are going to talk the kali services.