Commands

The following sections illustrate the basic Linux commands.

The ls command

ls command lists all of the files and directories that exist in the current working directory. So it's similar to the dir command in Windows machines; it just lists all of the files and directories that exist in the current directory: Thecommand lists all of the files and directories that exist in the current working directory. So it's similar to thecommand in Windows machines; it just lists all of the files and directories that exist in the current directory:

ls

Desktop , Documents , Downloads , and Music : And, as we execute this command, the output for it lists all of the directories, such as, and





ls with some options. We going to use ls and then use -l , and that will show us more information about the files. It's basically the same command that we ran before, but, as we can see in the following screenshot, we now get more information. We can see the total entries that exist in the current working directory, and we can see the same directories that we saw before, but we can also see the dates that they were created or modified. We can see the user responsible for them, and its root use, and we can also see permissions: Let's runwith some options. We going to useand then use, and that will show us more information about the files. It's basically the same command that we ran before, but, as we can see in the following screenshot, we now get more information. We can see the total entries that exist in the current working directory, and we can see the same directories that we saw before, but we can also see the dates that they were created or modified. We can see the user responsible for them, and its root use, and we can also see permissions:





ls command. We will learn more about permissions in the next chapters. Permissions specify which users can do what (read, write, execute). This is just an example of thecommand.

The man command

man command. It stands for manual. The man command can be used to query and get the manual of any other command. For example, we just used the ls command to list all of the directories that exist in the current working directory: One of the most important commands, which is going to become handy to you in the future, is thecommand. It stands for. Thecommand can be used to query and get the manual of any other command. For example, we just used thecommand to list all of the directories that exist in the current working directory:

man ls

ls command. And, as we can see, it's showing us that ls is used to list content, because it lists files and directories. We can also see that this command actually takes options, so it takes more options than just the ls command: After running this command, it will show us the manual for thecommand. And, as we can see, it's showing us thatis used to list content, because it lists files and directories. We can also see that this command actually takes options, so it takes more options than just thecommand:





-- , and you type in the full option. So, for example, the -- all option does not ignore entries starting with a dot. If we type in or press the Enter key, the manual will just keep going down so you can read more information. These are all of the options that you can do with the command. We can see, for example, that the -l uses a long listing format. To quit this command, we just type in q , so we're out of the manual. In the preceding screenshot, we can see the format of the options in Linux; it's either a letter abbreviation, or, and you type in the full option. So, for example, theoption does not ignore entries starting with a dot. If we type in or press thekey, the manual will just keep going down so you can read more information. These are all of the options that you can do with the command. We can see, for example, that theuses a long listing format. To quit this command, we just type in, so we're out of the manual.

The help command

--help . We will use ls again, and do a --help command. Now, man and --help work on almost every command, so you can use man ls , or ls -help , and it will always show you the help or the manual page of the program. So, after we execute the preceding command, in the following screenshot, we can see the help page for using ls , and it tells us all of the options for the ls command: Another really useful option is. We will useagain, and do acommand. Now,andwork on almost every command, so you can use, or, and it will always show you the help or the manual page of the program. So, after we execute the preceding command, in the following screenshot, we can see the help page for using, and it tells us all of the options for thecommand:









- or a -- , and we enter the option name as we did before. On top, it shows information about what the command does, and it gives the format of the command, so it should be used in this particular format: Usage: ls . We then enter the options, and then whether we want to do anything to the file. It's very similar to the man command; sometimes, programs will not have man , and they'll just have the help command. Again, it's aor a, and we enter the option name as we did before. On top, it shows information about what the command does, and it gives the format of the command, so it should be used in this particular format:. We then enter the options, and then whether we want to do anything to the file. It's very similar to thecommand; sometimes, programs will not have, and they'll just have thecommand.

man and the name of the command, or the name of the command and --help . Another useful exercise when dealing with the Terminal is that we can press the up and down arrows to go through the history of the command. So, we can switch between the man ls , ls -l , and ls --help commands through the up and down arrow If we have any command or any program that we are not sure how to use, we can always just type inand the name of the command, or the name of the command and. Another useful exercise when dealing with the Terminal is that we can press the up and down arrows to go through the history of the command. So, we can switch between the, andcommands through the up and down arrow

keys.

The Tab button

Tab button on the keyboard. If we are typing a command, or if we are looking for a file and we are just not sure, we can use Tab button to autocomplete. For example, let's suppose that we want to type a filename. Let's first create a file; we just go to Places | Home, because right now, we are going to create a new file. Let's create a new folder, called test . Let's suppose that we are looking to do something with the test folder; the cd command can be used to change the working directory to another directory. Another useful item is thebutton on the keyboard. If we are typing a command, or if we are looking for a file and we are just not sure, we can usebutton to autocomplete. For example, let's suppose that we want to type a filename. Let's first create a file; we just go to, because right now, we are going to create a new file. Let's create a new folder, called. Let's suppose that we are looking to do something with thefolder; thecommand can be used to change the working directory to another directory.

test directory; we can use the command, and then find ourselves in the test directory: cd test/ Let's suppose that we want to go into thedirectory; we can use the command, and then find ourselves in thedirectory:

pwd ; it shows you the current working directory. Just execute it, and, as we can see, we're now in the root/test directory: pwd Another useful command is; it shows you the current working directory. Just execute it, and, as we can see, we're now in thedirectory:

cd , change the directory, and, instead of typing a directory name that we want to go to, we can just type cd .. . Now, if we want to go back, we can just use, change the directory, and, instead of typing a directory name that we want to go to, we can just type

These were just basic commands, there are so many commands in Linux. Again, every program that we install on the system will have a Command Prompt version, and we can access that program through the Command Prompt. A lot of the programs that we're going to use will not even have a graphical interface, so we will have to use them through the Terminal. Again, don't be scared of that; we're going to go over it in the future.

Updating resources

Now that we know how to interact with the Terminal and Linux basics, we will just look at some final steps:

Updating the source list

terminator Installing

Installing required updates

View and then Full-screen, and that will automatically expand everything and put it in proper full screen. Going to the Kali machine, the first thing that I want to show you is viewing the machine in full screen. Just go toand then, and that will automatically expand everything and put it in proper full screen.

apt-get . We usually type in apt-get , and then, if we want to install something, we type apt-get install , followed by the package name (the program name). Before we do any of that, we have to update the sources; the way this program works is through fetching a number of libraries. On a fresh installation, we want to update our sources, so we make sure that it has the latest sources for the libraries, and the latest available programs. We're just going to use apt-get update . This command will not update the system; it will only update the list of available programs that can be installed: Let's look at the package manager in Kali Linux. We can install programs using a command called. We usually type in, and then, if we want to install something, we type, followed by the package name (the program name). Before we do any of that, we have to update the sources; the way this program works is through fetching a number of libraries. On a fresh installation, we want to update our sources, so we make sure that it has the latest sources for the libraries, and the latest available programs. We're just going to use. This command will not update the system; it will only update the list of available programs that can be installed:





Now, everything has been updated, so we can go ahead and start installing programs. We

terminator . The command is as follows: apt-get install terminator are going to look at an example of installing a useful Terminal application called. The command is as follows:

Enter; now, it will ask us if we really want to install this. We will say yes, by typing y and hitting Enter, and this will automatically download the application and install it for us: Press; now, it will ask us if we really want to install this. We will say yes, by typingand hitting, and this will automatically download the application and install it for us:





terminator . To do so, we will go to the Now, we can go ahead and try to use. To do so, we will go to the

Applications on the menu bar toward the left and search terminator . We will right-click to add it to My Favorites, so it shows up in the dock. We are going to open it, it's just another Terminal application. We can increase the size of the text here, and actually run programs through the Terminal, using any of the commands we illustrated previously. The advantage of the Terminator is that we can split the screen and run multiple commands. If we right-click on the screen, we can split it horizontally, and we can have three different windows that can run three different commands or programs at the same time. So, this can be really handy; it can make your life much easier in the future. on the menu bar toward the left and search. We will right-click to add it to, so it shows up in the dock. We are going to open it, it's just another Terminal application. We can increase the size of the text here, and actually run programs through the Terminal, using any of the commands we illustrated previously. The advantage of the Terminator is that we can split the screen and run multiple commands. If we right-click on the screen, we can split it horizontally, and we can have three different windows that can run three different commands or programs at the same time. So, this can be really handy; it can make your life much easier in the future.

One more command involves upgrading our system. In many cases, when we upgrade our system, we face issues such as broken libraries; some of our programs might not work when the libraries they depend on have updated, but the program itself has not. If we face issues, we can restore a previous snapshot; but generally, we just don't upgrade. If there's a new version of Kali, we just import that as another virtual machine, instead of upgrading the existing Kali version.

apt-get upgrade . If you press Enter, it will tell you that a large number of libraries and packages will be upgraded. If you hit Enter again, it will start downloading, installing, and configuring these packages as seen in the following screenshot: Now, if you want to upgrade your system, all you have to do is type in. If you press, it will tell you that a large number of libraries and packages will be upgraded. If you hitagain, it will start downloading, installing, and configuring these packages as seen in the following screenshot:



