Afrikaans
Akan
Albanian
Amharic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Hungarian
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranรฎ)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
1
Hello everybody and welcome to part two of
this tutorial. Let's go ahead and save the
2
file. Press control-O to output the file.
It says file filename to write. You can actually
3
modify it here. You can type in some letters
or whatever you want to change the name here.
4
You can even change the extension if you want.
There is no need for the time being. I'm just
5
going to go ahead and save it as "test." Just
press enter. There you go. It says, "wrote
6
one line. Hit control-X to exit. There we
go. Clear the screen. Now, I'm going to use
7
cat command to get a listing of this particular
file, which is far more reasonable than the
8
previous one, which you couldn't read. The
command, by the way, was functioning properly
9
but it was mostly a binary file. Therefore
I mean, it gave you listing but you couldn't
10
really read anything from it. So just go ahead
and type in cat test and there we go. It says,
11
"some random text goes here." That is the
text that we have typed into the test file
12
and you can cat it like this. These things
are very good, especially with files that
13
you want to make sure not to change them in
any way, you don't want to make any accidental
14
changes or anything of the kind and you want
to quickly see what is located within that
15
file. There is another way of doing this.
Basically, it's "ls." Let's go ahead and get
16
over to "cd etc/apt/." "Ls." We have plenty
of files to work with. Let's take sources.list
17
as an example here. So if I do "cat sources.list"
I'm going to get everything that is within
18
that file as before. It is listed in my terminal,
it's here to stay. It's not going anywhere.
19
There is another command which I could use.
Just go ahead and clear the screen. It is
20
called "less." If I type, "less sources.list"
I will be prompted with a new tab where I
21
can actually view things here. Not a new terminal
tab, but a new workspace within the within
22
the terminal itself. When I press Q I exit
and nothing will be displayed here. So very
23
nice in terms of being neat, organized and
so on and so forth. So less and cat are very
24
nice things. You can use, for example, "cat
sources.list" and the command that I have
25
previously mentioned is "grep." "Grep" means
you pull something, grep something from somewhere
26
else. Here's what I mean by it. Type in "cat
sources.list" and you type in a pipe. This
27
symbol here. It's called a pipe which basically
states whatever the output of this is pipe
28
it to whatever command comes here. So, I'm
just going to type in "grep" and let's say
29
I want to type in, "src." Press enter. Excellent.
So it will only print lines that have "src"
30
in them. Linux is case-sensitive. When you
are grepping, it's going to check whether
31
it's lowercase or not. You can give it an
ignore case. You can type this, "-i" to ignore
32
the case. This time, you're going to get the
same output because there are no different
33
things within this file. You get the general
idea. So this is how you would use "cat" with
34
grep to pull things out of a file. Very important.
This is a huge part of the Linux terminal--
35
filtering through text files. Primarily because
we are going to be doing large network scans
36
and we will want to create files from which
we will be able to pool useful information.
37
We will later in turn pass this information
to other tools to do something with. Anyway,
38
just go ahead and clear to screen for the
time being. You also have "echo." Type "echo
39
"I AM ALIVE"." It will echo these words it
literally is an echo. You type something into
40
it and it echoes them here. Let's go back
to the home directory, get a listing and use
41
exactly the same command echo live. By the
way, you can scroll through previous commands
42
by using arrow key. So using the up arrow
key or the down arrow key, you can scroll
43
back through previous commands and you don't
need to retype them. So I am alive. I'm going
44
to insert this. I will use a ">" and type
in "test." This will echo "I AM ALIVE" into
45
test. It has replaced the contents of the
test, which was "some random text goes here"
46
into, "I AM ALIVE." Very nice command to have.
You can change variable names, variable values
47
with echo and so on and so forth. We will
use this a bit more as we progress through
48
the course. I don't really want to get in-depth
here. Primarily because later on when we have
49
clear examples that directly relate to what
we are doing, which is basically testing,
50
then you will see more advanced usage of pretty
much all of these commands-- especially grep.
51
You have "touch."Touch" is a quick way to
create files. So, for example, I can type,
52
"touch file1 file2 file3." Press enter, "ls."
You see, it immediately created three files.
53
That is a very quick method to create any
amount of files. You can specify a folder.
54
You can create this file in home, this one
in var, this one in varlog, and so on and
55
so forth. Down below, you have "mkdir." Type
in, "mkdir" and it makes a directory. So you
56
are making some sort of a directory. Let's
say this the name of this directory will be
57
"placeToBe." If I hit "ls." There we go. It
states that is the does that this file is
58
actually a directory, which is PlaceToBe.
I can even navigate to it and say, "PlaceToBe
59
ls." There is nothing in it but you get the
idea. You can make directories in such a fashion.
60
Now, if I type "chown" it allows you to change
the ownership of a particular file. Since
61
we only have a single user here, which is
root, there isn't really any point in doing
62
so. If we create some of the new users we
could do that. However, we don't need them.
63
I'll just show you how this would work. For
example, if the owner of the file was not
64
root and you want to change it to root, do
the following. Type, "chown," then you would
65
type the username ":" and the user group.
The user group and the username are usually
66
the same on your home PC, unless you have
some bigger servers or something like that.
67
Then just specify the name of the file. You
can type "test." There it will effectively
68
change the ownership of file test to the username
root, who is from the user group root. If
69
I do "ls la" it states who the owners are
and which groups actually owned the files
70
as well. Clear the screen. There is another
more used command. It's called "chmod." This
71
command allows you to change file permissions.
This is something that you will need to use
72
on daily basis and quite often. Primarily
because, you see if I have an executive file
73
in Linux, for example. Let's just go ahead
and type in, "echo hello." I want to that
74
to test and I want to test to test.sh. "Sh"
is basically an executable one, that's a bash
75
script for Linux that in such a way you can
automate tasks. We will deal with it in greater
76
depth as we proceed through the tutorial.
You will need to be acquainted with bash scripting
77
definitely. Bash scripting is very similar
to the terminal itself, so pretty much all
78
the commands used in the terminal, can be
used by scripting as well. You basically just
79
combine a bunch of them in a file. Now, I
want this to be my executable, but you see
80
the way to to start executables is "./" as
stated previously that's the command to start
81
any executable. If I type in test, and press
that, it doesn't give me a list of possibilities.
82
Now, surely test.sh is an executable, but
no you see, it doesn't have a permission to
83
be an executable file. See here the difference,
take a look at this file and take a look at
84
this file. This one is green, this one is
not. Now look at their permissions. So you
85
see, it has a markation that is executable
for all groups, users, etc., while this one
86
up here does not have such permissions. You
need to change that. What you do to change
87
it is, "chmod." You would type in, "+x." If
you want the file to be writable you type,
88
"+w," if you want it to be executable "+x,"
if you want to be able to read the file, "+r,"
89
very simple. There is also a way of doing
this with numbers. You can type in, "755."
90
Don't try remembering all those modes. Whatever
you need go on the internet and check. It
91
can be quite complicated, but these three
you need to know: +x, +r, and +w. Also 777,
92
which is a global mode. This is the mode which
is not recommended for actual usage, but you
93
use "chmode" to actually test or troubleshoot
things. For example, if you want to be absolutely
94
sure that certain actions are not being prevented
due to file permissions, you change the mode
95
of those files to 777, which is the global
mode that anybody can do anything with the
96
file. If you still have an error message you
know that it is absolutely not related to
97
anything in regards to permissions. So, those
four things to do need to know. You can just
98
go ahead and type, "chmod +x test.sh," press
enter. If I do "ls la" once again, you will
99
see that test.sh is now executable. Let me
just run it and there you go. If I run this
100
it's going to echo "hello" on my terminal
screen. There's a bit more to go. Not much
101
more left. There is just one more command
that I would really like show you. This can
102
be a very dangerous command. Indeed, it can
mess you up in ways you can't begin to imagine
103
yet. that is the command "rm." "Rm" is basically
remove. Once you remove things with this command,
104
it's next to impossible to recover pretty
much anything. So, if I type in, "rm test.sh,"
105
it's going to remove it. It's no longer going
to be there. If I go ahead and navigate over
106
to PlaceToBe and I "touch test" to make a
new file there. If I go ahead and say "RM
107
PlaceToBe." It will say "rm cannot remove
place to be because it is a directory." This
108
is a failsafe of the rm. So, you wouldn't
delete a full directory because you will be
109
able to recover it, and that would be really
bad. What you can do is type in, "rm -f PlaceToBe."
110
Cannot remove directory. Okay, no problems.
Sometimes you get stuck. I'm deliberately
111
going to leave this part in the tutorial.
I'll just troubleshoot it. So you type in,
112
"--help." Here you have recursive remove directories
and their contents recursively. So, that's
113
a very nice option. So, let's just go ahead
and do that because this will go into the
114
folder and remove everything within the folder
and the folder itself, hopefully. So, just
115
go ahead and type in, "rm -r PlaceToBe," press
enter. There you go. It has deleted it. There
116
we go, it is no longer there. The "-f" that
I have used is force. It will not ask you
117
any questions. It will delete the folder or
file, which can be also very dangerous. When
118
you're using "rm," you always want to be asked
questions. In any case, as I said, I deliberately
119
left his to show you that even if you get
stuck worry about it. I get stuck all the
120
time. If you don't know what to type in, what
argument to pass, just type in "--help." Take
121
a look at what you can actually type, read
a little bit and then use the options. Try
122
it out, sometimes it will work, sometimes
it won't. More often than not, you will be
123
able to figure it out from the help menu.
If you can't figure it out from help menu,
124
just typed in "man rm" and you can read pretty
much everything there is to know about this
125
command here. If you really can't perform
the task, if you can find anything useful
126
here, forums are your next best bet. Trust
me you will succeed in doing it. In any case,
127
this was a brief introduction some of the
basic commands that we will use. Please make
128
sure that you know what each one of these
commands does, at least basic functions. Later
129
on we will get in-depth, do more advanced
stuff and use more advanced commands by combining
130
them, and so on. In any case, I bid you all
farewell. I hope to see you in the next tutorial.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.