Recent in Technology

the Kali Linux - The Most Used OS By Hackers - Part 8


     The Command Line     - Part 1


         We have already discussed that Kali is a Debian Based Linux Distro. So Kali commands are actually the same as Debian Linux commands. It's not fancy. Some people think that Kali and Ubuntu have different commands. In fact, it can't be different.

          It is worth mentioning that the previous Kali versions used the bash shell. It's easier now that I've switched to zsh shell. In the past, if you wanted to enter a directory, you could enter it with a cd. Now you can directly enter the directory name. But it's better to do it properly to learn how to use it anywhere. OK?

           When you open Terminal, you should see the form user@host_name. user is the username of the logged in Acc. hostname is the hostname that was set when Kali was installed. The ~ symbol that you see after the : shows the current directory. ~ is the symbol for the home directory, which is the home directory of the current user account. If the user's home directory is in /home/, the / at the front represents the system. The meaning behind / is inside. So /home/ means that it is in the home directory (folder) in the system. In Linux system Folder is used as Directory. From now on, I'll just write it as a directory.

           You can also open it from File Manager. But if you're using Linux, where will you get the Linux taste if you remove the commands from Command? So they do everything they can do using Terminal.

khitminnyo@aio:~#  ls

LS is written in lower case. I asked the system to list the files in the current directory. After ener, a list of what files are inside will be displayed. Files and directories are shown in different colors. Colors may vary depending on your settings. If you use it without doing anything, the executable file will be green, directory (folder) in blue, The files will be displayed in white. Currently, if Kali is installed and there is nothing there, if you open Terminal and type ls, you will only see the Desktop, Documents, Downloads, Music, Movies and other directories in the Home Directory. If you want to find hidden files with dot (.), you have to type ls -al (LS -AL lowercase). Then you will see hidden files such as .bashrc .zshrc. In -al, you will see the permissions. I haven't said that yet here. If you understand an ls, it's fine. If you're on Windows, you can use dir if you don't have Linux setup. If you have installed any Linux such as Ubuntu or Kali from the Win Store, you can use ls.

khitminnyo@aio:~#  cd

          If you want to change from one directory to another, use cd (change directory). (It's the same in Windows.) If we want to move from the current Home directory to the Desktop, we have to type cd Desktop. If you want to go back one step, you can go back to cd .. If you want to go back to the home directory of the current user acc no matter where you are, you have to type ~.

          These commands can be used in Linux (Ubuntu, Debian, Kali, ...) as well as Termux in Android and Terminal in MacOS. It's the same.

          If you want to enter the system, you must type "cd  /" in Terminal.

khitminnyo@aio:~#  cd   /

          I will go into opt from the system. If you want to enter etc from there (system is / at the front and / will be used whenever it means in), then you have to type cd /opt/etc/.

           Note that Linux is very case sensitive. It cannot be missed. Also, if it is a file and not a directory, it cannot be used with cd. Also, you need to know where you are at the terminal. If not, you will only face inconvenience.

khitminnyo@aio:~#  mkdir   directory_name

          As above, you can create a directory with mkdir. (mkdir = make directory.) For example, suppose we want to create a directory called test on the desktop.

khitminnyo@aio:~#  mkdir   ~/Desktop/test

          You can type as above. So, no matter where you are in Terminal, Home (~) (/) Desktop (Desktop) (/) will create a directory called test. If you go to the desktop, you will see the test folder. If you hide it so that you don't see anything on the desktop, you should see it if you open the desktop from File Manager.

khitminnyo@aio:~#  rm   -rf    ~/Desktop/test

         If you type this, the test folder on the desktop will be destroyed. rm (remove) files, move folders, Can be used for renaming and deleting. Let's create and delete a file.

khitminnyo@aio:~#  touch    ~/Desktop/test.txt

          tThe ouch command is used to create files. In the picture above, using touch, a text file named test.txt is created on the desktop. And if you go to Desktop from Terminal, you will see test.txt.

khitminnyo@aio:~#  cd   ~/Desktop  &&  ls

          When you want to use more than one command line, you can use && to continue. (You have to write && , repeated &)

           Then, no matter where you are in the Terminal, you will enter the Desktop and it will be listed by ls. Now that we're on the desktop, let's delete the darn file. Before deleting, I will tell you the command that can be used to see the current location.

khitminnyo@aio:~/Desktop#  pwd

          pwd is the abbreviation of print working directory. The current directory will be displayed. If you look at the image above, you can see that I am currently in ~/Desktop. My acc is khitminnyo so /home/khitminnyo/ is my home directory. So ~ is the same as /home/khitminnyo. (On Mac OS, it will show as /Users/khitminnyo/Desktop. The location of the home directory may vary according to the system configuration (not ours))

           Directory is also correct. When looking with ls, if we find the file we want to delete, we can delete it with rm.

khitminnyo@aio:~#  rm   -rf    text.txt

        Then the text.txt file will be lost. If you want to delete from a different directory, you must add the file location. For example -

khitminnyo@aio:~#  rm   -rf    ~/Desktop/test.txt

         After reading this, you should practice creating a directory, You have to practice entering and exiting. Build means making directory or file.

           If you want to delete everything in a single directory, you must add an asterisk (*).

khitminnyo@aio:~#  rm   -rf    ~/Desktop/*

          If you type the above, everything on the desktop will be deleted.

khitminnyo@aio:~# sudo    rm   -rf    /*

          If you type in the above, everything in the system will be destroyed, so don't type it at all.

           Today we will stop at that. I'm not comfortable typing. I will continue to post the next day.


Thank you for visiting and reading




Return to Main Menu of Kali book ==>> Return to Main Menu of Kali book 
Return to Main Menu of Kali book

Post a Comment