Linux Tips Ep 2: commands explained

If it’s your first time viewing this episode of Linux commands explained, I would recommend you to get through the first episode from here.

Today we will learn how to use echo to write words to a file, and copy and move files in Kali Linux using the terminal. We will also talk about how to identify file types in Kali Linux.

echo Command.

Let’s start by explaining what echo is. Echo is a command that displays some text fed to it. Let’s type echo “Hello World” in the terminal and see the output.

The echo command basically displays what has been fed to it.

We can also use echo to echo out the input to the file using the greater than(>) sign that is., echo hello world > file1.txt

The greater than sign basically means instead of the file being echoed and displayed on the terminal it will be saved in the file1.txt and we can use the cat command to view the contents of file1.txt.

If we do an echo how are you > file1.txt It will overwrite the contents of the file1.txt. If you don’t want to overwrite the contents in file1.txt use ‘>>’. This will append the words that will be echoed into file1.txt.

From the image above when we echoed How are you it overwrote our file but when we added double greater than signs the words we added were appended.

Copying Files in Kali Linux.

The cp command abbreviates the copy command in Kali Linux. It takes two arguments namely; the file source and destination to where the file is to be copied that is., cp source destination.

Here we have made a folder called test and we have copied our file1.txt to the test folder.

We can also use the copy command to copy folders and subfolders. This can be done by using the -r in the copy command that is., cp -r test1 test

Here we have created a folder and subfolders using the mkdir command and we have copied them to the test folder.

So our takeaway today in the copying files is that copy takes two arguments; cp source destination.

Moving Files in Kali Linux.

We move files in Linux using the mv command. Move command just like the copy command takes two arguments that is., mv file1 test1

Here we have moved file1 to test2 so basically, this means we can use the mv command to rename files.
Here we have moved our test2 file from the test folder to the test1 folder and we have assigned it a different name called test2.txt.

File command

In Linux, we use the file command to identify the type of file we have and the content it contains that is., file test2.txt

In the first file(test2.txt), there is no data that why it displays empty, and in file1.txt it shows that it has ASCII text which can be read/shown using the cat command.

The image below shows how file command can be used to identify different file types;

Hope you enjoyed and learnt something new.

Happy hacking !!

Share this article
Charles Koome
Charles Koome

I am a cyber security enthusiast and love all kinds of tech stuff. I love playing CTFs and doing penetration testing(websites and mobile applications).

Articles: 9

Leave a Reply

Your email address will not be published. Required fields are marked *