0% found this document useful (0 votes)
10 views8 pages

Hacking Course - Class 01 - Linux - Basic Commands PDF

The document describes basic Linux commands, including man to open the command manual, ls to list files, and cd to change directories.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views8 pages

Hacking Course - Class 01 - Linux - Basic Commands PDF

The document describes basic Linux commands, including man to open the command manual, ls to list files, and cd to change directories.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

x u n i L

mm o C c i s a B

R
byetW
stir
Introduction to commands
If you are reading this document, you surely should not
to know the basics about Linux, by the way, the basics are the commands. In case
if you have any questions about any of the mentioned commands
in this document, you can use the command man, which will be
later commented here, to access the manual of
command and get more details about the desired command, using the
following syntax: "man (command)", for example: "man ls", that
I would open the command manual (which will also be mentioned)
subsequently here); or you can also use the option --help no
command.

In this document, we will address some commands that you do not


you can stop knowing if you intend to have a certain mastery
about Linux and/or its distributions, also known as
distros. We will see the commands in detail provided by the very
command the --help option of the mentioned commands.

Commands

man – Opens the manual of a command. For example, to open the


command manual we would execute the following command:

root@kalirmdir manual

The above command would open the dormdir manual, which contains several
Information about the command 'mdir'; including a brief description.
a more detailed description, some options for the command,
credits to the command creators, etc. Anyway, the manual of
commands contain a lot of information about the commands.

ls - The ls command is used to list files and/or directories that


are within certain directories. For example:

root@kaliDocuments

The above command will list the files and other directories that are
presents inside the directory called Documents. The pure command.
above, that means: with no option defined, I would only say the
directory names, without any additional information
such as creation date, creator user, size (if applicable
file), among other information. If you want the listing of
content of the directory along with its respective information, would you have
what to add to the command the option-leaving, then the command
thus

root@kaliListing documents in long format

Now yes, with the above command, the OS would list in addition to the files
(and directories), some information about them.

When you list the contents of a directory, the OS will


to return all files and directories present in the respective
directory, except those that start with a dot ".", these
files are ignored in the listing and the OS will skip them; but if you
If you want the OS to also list these, you will need to add to the
command one of the following options: -a or --all, so the OS would list
the also.

clear - This command by itself already says its function. Yes, it clears the
Linux screen/terminal removing command responses from it
executed previously, which you no longer need,
discarding them, thus, from your terminal using the command clear.

cd - This command is used to change the directory you are in. cd


means 'change directory', which, translated from English, means
change directory. If you are in a calling directory
inside this directory there is another directory called,
example, Windows, and you want to change/enter this directory,
you can run the following command:

root@kalicd Windows

Thus, upon execution of the above command, the“root@kaliof your


terminal, would change to“root@kali:~/Windows#, indicating this
that you entered the directory called Windows that was inside the
caller directory root. Also remembering that this command without
using no parameters or options would take you directly to the directory
root, which is called root.

pwd - This command is used to show the absolute path


of the directory in which you are present. Using the situation
hypothetical mentioned in the explanation of the command cd, in which we enter into
directory called Windows, which was inside another directory
calleroot;If we executed this command, pwd, in this
situation, we would have as feedback:
/root/Windows
This way we could locate ourselves within the OS (Linux).

cat - According to the manual, provided by the comandoman, this


command; it has the function of 'concatenating files and printing them on
standard (terminal) output”. It is equivalent to the DOS TYPE. It serves
also to create new files, for this it is necessary to use the
> parameter (greater than), and right after the name of the file to be
created

root@kali:~# cat > newfile.txt

The command above, when executed, would create a file called


newfile.txt in the directory where it was executed, in this case the directory
root; it would be written in this file, whatever was written after the command,
until the combination CTRL + C was pressed; to finish the
command and save the file. This command can be used,
also, to read the files. To do this, we use the following syntax:
cat file_address. To read the file that we just
to write we can use the following command:

root@kali:~# cat newfile.txt

Yes, that's right! If you've noticed, we only removed the greater than sign.
what" > to read the file. For more information about this command,
please use 'man cat'.

df - This command is used to display and/or list the


hard drive partitions, which are free or in use. As we do not have much of the
What to say about this command here, you can consult its manual for
middle of the commandman.

free - This command shows the memory in use and/or free of


system. An alternative to this command is querying the file
/proc/meminfo system. In this file, we have, in addition to the
information that is displayed with this command, others more
information about memory; such as total memory, memory in
usage, free memory, buffers, among many other information.

mkdir - This extremely simple command has the function of


creation of new directories. The following syntax is used to create one
new directory with this command: "mkdir directory_name". By
For example, to create a directory called newdir, we would use the
next command:

root@kalimkdir novodir

Thus, we would create a directory named newdir inside the directories.


in which we were; in the above case, we would create the new directory
inside the root directory, since it is there that we execute the
command. We can identify this by the ~# afterroot@kali, that
it is not indicating any other directory.

rmdir - This command is used to do the opposite of the command


above (mkdir), it is used to remove/delete a directory, since
that this directory is empty. Its syntax is the same as the command
mkdir. So, to remove the directory we created with the command
mkdir, we would use the following command:

root@kaliRemoving directory novodir

This would delete the directory called newdirthat we had created with the
command mkdir.

rm - This command is used to remove files and/or directories.


Remember that the 'rmdir' command only removes empty directories, and
remove either one of the two. So to delete a file
with the command rm, the syntax is as follows: 'rm filename',
therefore we could delete a file, called arq1.txt, from
current directory with the following command:

root@kalirm arq1.txt

This is how to delete a file. But what if I have a directory,


that is not empty, and I want to delete it? Simple! Just add the
option -r in the command rm so that, instead of deleting a file,
remove a directory. The syntax for this task is as follows: 'rm -r'
name_of_directory. If I want to delete a directory called
Little photos, I could use the command rmdir, if that directory
it was empty; but if it is not, just use the command:

root@kali:~# rm -r Little Photos

This way I would be excluding a directory called Photozinhasde


within the current directory.

shutdown - This is used to turn off, restart, or hibernate the


machine. Although this seems to be a very simple command, and without
options, he has them! And they are very useful. But let's start with
the basics of the command. But first we need to understand the syntax of
command, which is the following:

shutdown [options] [time] [wall]

Well, let's understand what is written right above. Well, the options
You already know what they are, right?! For the shutdown, we have as
main options:

-P - This option indicates that we want to power off, or


Yes, we want to turn off the machine.
-H - This indicates that we want to stop the machine, in other words,
we want the machine to hibernate;

-r - Indicates that we want the machine to restart; we want to give a


reboot in the same;

-c - This option cancels a scheduled shutdown;


But we will understand what this scheduled shutdown is.
Now that we know the main options of this command, let's
understand what this thing called time is in its syntax. Time serves
to define, in minutes, how much time we want for the
the machine should be turned off, restarted, or hibernated. For example, if
if we wanted the machine to be restarted in 5 minutes, I
could you execute the following command:

root@kalishutdown -r 5

By executing the above command, you would be telling the machine:


Madam machine, please restart in 5 minutes.
In summary: 5 minutes after you execute the command your machine
It would restart. If you want to restart the machine now
in which you execute the command, just replace the 5 with 'now', without
quotes.

Alright, but what is wall? Well, the wall is a kind of


alert/message that you can leave before
turn off/restart/hibernate the machine. Let's assume that we will
restart a machine that we hacked, and that we do not want
just restart the machine in 5 minutes, but also leave a
message for her or her owner. For such a feat,
we would execute the following command:

root@kaliI will restart your machine

With the above command, we would restart the machine in 5 minutes and
We would leave the message 'I will restart your machine'. And if after
you scheduled the machine restart, you give up on
restart it? No problem, just execute the following command in
in the system:
root@kalicancel shutdown

The command above will cancel the reboot.


program that you had made earlier;
thus "saving" your machine from rebooting.
Also remembering that, to shut down or hibernate
the machine is just you replacing the -r with the respective option
What you want to do.
Here we end our list of basic Linux commands.
Remembering that Linux is full of very interesting commands.
and that were not mentioned in this document. Of course, I did not list all
the basic commands of Linux, because although the commands may seem
basic for some and 'non-basic' for others, I certainly do not
I remembered all of them.

If you have only read about these commands, it is highly


it is recommended that you put them into practice, research and try
to understand more about these commands, considering that here in this
document, the commands were addressed superficially,
this is, not in depth.

Document prepared to be used as a basis in the Hacking classes taught


by Reset

You might also like