Kali Linux – Basic Terminal Uses

March 29, 2022

In our this article we are going to cover the basic uses of Terminal window on Kali Linux. Hence Kali Linux comes with GUI, but terminal is the most powerful thing on Linux systems. There are lots of terminal tools we need to use during security testing, so we need to learn at least the basics of terminal.

Kali Linux default terminal

Let’s learn some basics of terminal. We can work on text based things using terminal window. We can write commands, then press Enter ⤶ key to run/execute the command. Sometime things are messed up then we need to clear the terminal using clear command or CTRL+L to clear the terminal. To open a new terminal window from our current terminal session CTRL+SHIFT+T.

To complete the command or the filename on terminal we can press the TAB key. If there are some files starting with same name then whenever we press TAB key it will display all the options in place. We should open our terminal window and practice these things while reading this article.

For an example we have two files with same name at starting test.sh and test.txt on our home directory. When we press the TAB key then we can see that we got the both options, as we can see in the following screenshot:

If we run a command and then we need to stop it’s execution we need to press CTRL+C key combination. To close the terminal window we can press CTRL+D key combo or use exit command.

We can also shut down and restart our system using terminal window. To shut down our system we need to use poweroff and for restart we need to use reboot command with root privilege.

To check our recently used commands on terminal we can use history command, and to use any command used before (reverse command search) we can use CRTL+R and then type the part of the command then terminal will suggest the command. As we can see in the following screenshot:

CTRL+R, then we just type his and it suggest history

Not only in Kali Linux, Linux in general we need to understand there are lots of redirections in terminal window. For an example we have to write our file list (ls) output on a text (txt) file e need to run following command:

ls> ls-list.txt

We can see the output in the following command:

Using the above command we save the output of ls command on a text file and provide the text file a name (ls-list.txt), and we redirected the output by using a > (grater than) character.

We also do the opposite by redirecting (printing using cat) the text file contents into the terminal window by using the < (less than) character.

cat < ls-list.txt

There is another redirection we need to know is the command pipe. In short, we can combine the output of each command and use it on next command using | character.

command 1 | command 2 | command 3

For an example we need to read a file then short the results and finally use grep command to filter out some text strings. Here we are going to extract files starting with ‘test.‘. So we need to use following commands combining with |

cat ls-list.txt | sort | grep test

We can see in the output in the following screenshot:

Basic Kali Linux Commands

Now, let’s drive into Kali Linux usage and explore some basic Kali Linux (Linux, in general) commands.

Man Pages

Most of the executable programs on the Linux command line contains a formal piece of documentation is called manual pages or Exploring the manuals for the ls command using man

We can see in the top of the above screenshot that ls is ‘User Command’. Man pages are organized by dividing into various sections as following:

  1. User commands.
  2. System administration commands.
  3. Programming interfaces for kernel system calls.
  4. Programming interfaces to the C library.
  5. Special files such as device nodes and drivers.
  6. File formats.
  7. Games and amusements such as screen-savers.
  8. Miscellaneous.

To know more about a command we can search a keyword. For example, we need to learn about the file format of /etc/passwd file. We can apply following command to learn more about this:

man passwd

The above command will show information about passwd command as we can see in the following screenshot:

Also we can use -k flag with man to do a keyword search.

man -k passwd

We can see the output on the following screenshot:

We also can filter out the search by using

We can now look at the exact passwd manual page (5) we are interested in by referencing the appropriate section:

man 5 passwd

Man pages are usually the quickest way to learn more about a Linux command. So we need to take some time and explore the man pages.

Apropos

By using

Check that apropos have similar output like man -k, in fact both are the same.

List

The ls command prints a basic file listing on the directory to the terminal window. We can modify the output results with various flags. Like -a flag is used to display all files (including hidden files) and the -1 option displays each file on a single line, which is very useful for automatic scripts.

Change Directories

Linux does not use Windows-style drive letters (C:). Here, all files, folders, and devices are baby of the root directory, represented by the / character (see our

To return back from a directory to it’s parent/previous directory we can use cd .. command.

Creating Directories

We can use mkdir command followed by the name of our new directory to create a new directory. Directory names can be contains space in middle, but when we are using command line interface it will be easier to work with directory names using underscores or hyphens instead.

To create a new file we can use touch command followed by the name of our new file. Example of mkdir and touch command is shown in the following screenshot:

We also can create multiple directories at a same time using -p flag. -p is capable to create directories inside parent directory. Suppose we need to add 2 directories inside our newly created (above example) directory (which is /home/kali/new_folder/baby-new-folder). We can do it from our home by using -p as shown in the following command:

mkdir -p /home/kali/new_folder/baby-new-folder/{testing,info,exploit}

We can see the output in following screenshot:

Searching for Files

There are three most common Linux commands for searching files on terminal, those are which, locate and find. Utilities of these commands are similar but work and output of these utilities are different.

Which

Locate

The locate command is the quickest way to find the locations of files and directories in Kali Linux. To do the search on a much shorter search time, locate searches a built-in database named locate.db rather than checking the entire hard disk. This database is automatically updated on a regular basis by the cron scheduler. To manually update the locate.db database, we can use the sudo updatedb command.

Find

The find command is the most complex and flexible tool in these three. Understanding it’s syntax sometimes very hard, but it is very powerful than a normal search. In the following screenshot we did the most basic search using find command, where we start our search from root directory (/) and look for the filename starts with sbd.

Where which and locate command searches files by using their names, find can search files by it’s name, type, size, time, permissions etc. find is an complex yet very powerful search tool. We can know more about it here.

In our this part we just covered the basics terminal uses and some basic Linux commands. We will about more commands on our upcoming parts. Hope this article was enjoyable and informative.

Love our articles? Make sure to follow us on Twitter and GitHub, we post article updates there. To join our KaliLinuxIn family, join our Telegram Group. We are trying to build a community for Linux and Cybersecurity. For anything we always happy to help everyone on the comment section. As we know our comment section is always open to everyone. We read each and every comment and we always reply.

Article posted by: https://www.kalilinux.in/2022/03/kali-linux-basic-terminal-uses.html
——————————————————————————————————————–
Infocerts, 5B 306 Riverside Greens, Panvel, Raigad 410206 Maharashtra, India
Contact us – https://www.infocerts.com

This is the article generated by feed coming from KaliLinux.in and Infocerts is only displaying the content.

Open Whatsapp chat
Whatsapp Us
Chat with us for faster replies.