Linux Tips EP 1: commands explained

If you don’t have Linux installed on your pc you should install it first by following the steps here. (I’ll soon make an article on how we can install Kali Linux in virtual box.)

Hey guys, I’ll be doing a Kali Linux series explaining various commands and how they are used. This section will show how we update and upgrade our Linux systems, open the terminal, list files in the terminal, and create and delete files and folders.

To launch the terminal we can either start it by clicking on the terminal icon which can be accessed by clicking the application launcher menu and then clicking on the search bar and typing terminal as shown below and select the konsole terminal;

Alternatively, you can use keyboard combinations to launch the terminal in Kali Linux that is., CTRL + ALT + T. Below is an example of what the terminal looks like;

To update the Linux system we use sudo apt-get update. APT is the Linux package manager and it gets the updates from the Linux repositories.

To upgrade your Linux system we use sudo apt-get upgrade.

You’ll be prompted to continue the upgrade just press y and enter then the upgrade will commence.

To list directories and files in Linux we use the ls command.

In the figure below you can see that there is a different color that differentiates folders and files. This is possible on both zsh shell and bash shell. To know the shell you are currently using you just type echo $0.

We can also use ls to give more information on the listed files and directories. Using ls -l we can get more information about the listed items.

From the image above, using ls -l command shows the size of the file and folders and also the time they were created, the type of the file(file or directory), and the permissions. The first column shows the file type and permissions of the owner group and others I’ll explain this further in the next article. The second column shows the number of files and folders inside that folder. The third column shows the owner of the file while the fourth column shows the group ownership. This means that the owner of me.txt is ‘Mobexler’ and the group owner is ‘mobexlerlight’. The sixth column shows the size of the file and directories in bytes. In order to get the size in a human-understandable format use ls -lh. The seventh column to the ninth column shows the date the file or folder was created and lastly the tenth column shows the file or folder name.

K reps Kilobytes, M reps Megabytes, G reps Gigabytes

Creating and Deleting Directories in Kali Linux

To create folders in Linux, we use the mkdir command. This is said as make directory. To make a directory called test we will type mkdir test and when we ls we will see our test folder has been created.

we can also use mkdir to create a folder and subfolders in one command. To do this we will type mkdir -p test1/test2/test3/test4/test5 this command will create a folder called test1 and inside test1 another folder called test2 will be created and so on.

To delete a folder/directory we use the rm command but since we are deleting a folder we will add -r so that it deletes recursively.

If we use rm only to delete a folder we get an error because in order to delete a folder we have to add a -r option.
After adding the -r option, the folder get successfully deleted from the system.

To delete a directory with subdirectories we use the same rm -r command.

The ls -lR test1/ basically lists the contents of the test1 directory and if there are any folders in there it also lists what those folders containing. In a nutshell it is listng the contents of the directories recursively.

Creating and Deleting Files in Kali Linux

To create files in Linux, we use the touch command. This command creates text files. To create a file called file1 we use touch file1.

We can also use touch to create multiple files that is., touch file2 file3 file4 file5

To delete files we can use the rm command or the shred command. The difference between the rm and shred command is when we use rm it doesn’t remove the fle completely from the hard disk and therefore using forensic tools the delete file can be recovered but using shred to delete files the data cannot be recovered even using forensc tools.

Deleting a file using rm we type rm file1 this deletes file1 and if you want to delete multiple files you just type rm file2 file3 file4

Deleting files using shred we use shred -uz file4 to delete multiple files using shred we use shred -uz file5 me me.txt

We can use shred with -v option for it to be verbose. Verbose means it’ll output everythng that it is doing.

If you want to get more options on how a tool can be used you use the -h or –help option after the tool name e.g., ls –help

You can also use the man command to show you the tools manual by typing man then the tool name eg., man ls and after readng the annual click on q on the keyboard to quit.

Hope you learnt something. Happy Hacking !!!


Discover more from TechED Africa

Subscribe to get the latest posts sent to your email.

Leave a Reply

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

Discover more from TechED Africa

Subscribe now to keep reading and get access to the full archive.

Continue reading