Introduction to Linux. (part 2)

Viewing, creating and editing files.

We already looked at the echo command, and if you recall, the echo is used to create a file. We can use echo to write to a file.
cat command prints out to the screen what is in a file.
To append a file: echo “text to add” >> nameofthefile.txt

The above shows how to append (add) to a file and the cat command prints the contents of said file.

Another to create files is the touch command.
Below is how it works:

The created file in the above example is empty, and we could use the echo command to append text into it. An alternative would be to use a tool called nano, it’s a terminal based text editor. There are other text editors, like vim or vi, I prefer nano, but I encourage you to play around and try the other text editors and pick a favorite.
So, to start up nano, use the command nano newfile.txt, it’ll open up the terminal text editor and you can type whatever you want. We’ll be using nano a lot, to create scripts, create python scripts, and to edit shell code as we get into exploit development.

From the above, you can see that the cat result printed out what was typed in nano.

Another way of editing it is using a Graphical Interface, we can use gedit newfile.txt. This is perfect for those who don’t like using the terminal to create or append files.

File can be created, viewed and edited using echo, touch, nano, gedit and cat. You should definitely play around with these tools and command, familiarize yourself with them, ’cause you’ll be using them in almost everything.

Starting and stopping services.

So in Kali thee are a couple of different ways that we can start and stop services and by service, I mean a web server or SSH or maybe a SQL database.
The first service we’ll look at is Apache2 – which is a web server. To get this started, run the command service apache2 start in your terminal and type in your IP address in your web browser search bar.

The below is what you should get:

To stop the Apache2 service, service Apache2 stop
An easy way to spin up a web server would be to use the command python -m SimpleHTTPServer 80. Using python to create a web server is a great feature.

A little ahead of time reading: How to spin up a FTP server using python.

To have your service up permanently, ’cause when you reboot your machine the service stops, service start only hols during that session. Use systemctl enable to permanently have a service running, and systemctl disable to stop a running service. Example: systemctl enable PostgreSQL.
You should definitely run the above command in your terminal. It is important because, it’s going to allow us to run Metasploit an have the PostgreSQL database running whenever we boot our machine.

Installing & Updating.

This is a very important part in the introduction to Linux. We’re going to cover, how to install files, how to install updates and how to get files from Github, these are very very important.

So updating your system from the terminal in Linux: apt update && apt upgrade

NB: I had an error running the above command and had to go google what my error meant and how to fix it. So if you run into any errors at all, in any of the processes, your first thought should be “Google” and I can say you’ll almost always find the solution. At least, i always have. Alternatively, try a hacker community group (check Discord, Reddit or Medium) and you could also tweet your errors and questions (assuming you follow the right niche)

If you just want a specific tool, for example, to install a tool called pip: apt install python-pip. We’re going to be working quite a lot with python and I’ll dedicate a different post section for that as we move along.

After or during your pip install, open up your browser and google GitHub inpacket.
Inpacket is tool (it comes with Kali but this is a stable version)-kit used during exploitation,so make sure you click on the SecureAuthCorp (should be the first in your search result), copy the clone URL (make sure you read through the installation process) and type this in your terminal: git clone paste the copied URL Now, inpacket is cloned in your machine, cd into the cloned file, follow the installation instructions and it should install all the things needed for python related to this program.

These are a few ways to install tools. Most times the tools needed will have to be downloaded from GitHub, so this should give you and idea of how to make update or install tools from GitHub.

Until nest time. Keep learning. Keep hacking! And don’t forget to breathe.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.