Introduction To Linux - 2
Introduction To Linux - 2
Advantages:
It has 600+ Penetration testing and network security
tools pre-installed.
It is completely free and open source. So you can use it
for free and even contribute for its development.
It supports many languages.
Great for those who are intermediate in linux and have
their hands on Linux commands.
Could be easily used with Raspberry Pi.
/root
cd Downloads
root@kali:~# adduser
sanjibAdding user
`sanjib' ...
Adding new group `sanjib' (1001) ...
Adding new user `sanjib' (1000) with group
`sanjib' ...Creating home directory
`/home/sanjib' ...
Copying files from `/etc/skel'
...Enter new UNIX password:
11
12
15
You can change the directory and look what sanjib has in
the directory Downloads. Currently, the user sanjib has
nothing in that folder; it is empty.
Next you’ll learn about cp command. This command
stands for “copy.”
You can copy a file from one destination to the other. You
have seen that in the home directory you have a file called
VBoxLinuxAdditions.run. Let’s copy this file to the Documents
directory of user sanjib.
You have already reached sanjib, so you have to come
back to the /home
directory first. Issue the command cd .., which will take you
one step back.
root@kali:/home/sanjib# cd ..
root@kali:/home# cp -v VBoxLinuxAdditions.run
/home/sanjib/Documents/
'VBoxLinuxAdditions.run' -
>'/home/sanjib/Documents/
16
root@kali:/home# cd
sanjib/Documents/
root@kali:/home/sanjib/Documents#
ls VBoxLinuxAdditions.run
root@kali:/home/sanjib/Documents#
cp --help
This will tell nano to open the file. You can edit any
portion by pressing Ctrl+O and saving it. Then you can exit
the file by pressing Ctrl+X.
Now you can safely read the new file novel.txt with your
cat
cat novel.txt
Searching Files
cd /etc/apt
hagudu@hagudu-H81M-S1:/etc/apt$ ls
apt.conf.d sources.list sources.list.save
trusted.gpgtrusted.gpg.d
preferences.d sources.list.d trustdb.gpg
trusted.gpg~hagudu@hagudu-H81M-
S1:/etc/apt$
20
deb-src http://in.archive.ubuntu.com/ubuntu/
trusty mainrestricted
deb-src http://in.archive.ubuntu.com/ubuntu/ trusty-
21
You can even filter the source file more distinctly. For
example, you can narrow down your search and tell the
terminal to find the word src only in lowercase by writing
this command:
23
24
25
sanjib@kali#
supassword:
sanjib@kali:~$ cd
Documents/
sanjib@kali:~/Documents$
ls VBoxLinuxAdditions.run
sanjib@kali:~/Documents$
ls -latotal 7048
drwxr-xr-x 2 sanjib sanjib 4096 May 29 10:30 .
drwxr-xr-x 18 sanjib sanjib 4096 Jun 3 09:59 ..
This tells you that the owner of this file is root and the
group name is
root. The starting line is important. It handles file
permissions.
r-xr-xr-x
xman@kali:~$ cd
Documents/
xman@kali:~/Documents
$ ls
xman@kali:~/Documents
$ ls -latotal 8
drwxr-xr-x 2 xman xman 4096 Jun 3 10:33 .
drwxr-xr-x 14 xman xman 4096 Jun
32
Now I’ll create a file using the nano text editor. Here
is the executable file in Python:
#!/usr/bin/python3
print("TYpe your
name.")inputs =
input(">>>>>>")
outputs = inputs
def main():
print(outputs)
if name == ' main ':
main(
)
33
xman@kali:~/Documents
$ ls -latotal 12
drwxr-xr-x 2 xman xman 4096 Jun 3 10:50 .
drwxr-xr-x 15 xman xman 4096 Jun 3 10:42 ..
-rw-r--r-- 1 xman xman 86 Jun 3
10:44 pyfile.pyxman@kali:~/Documents$
rw-r--r--
Now, what does this mean? It means the user xman can
read and write this file, because it is prefixed by rw; here w
stands for write permission.
34
xman@kali:~/Documents$ chmod +x
pyfile.pyxman@kali:~/Documents$ ls -la
total 12
drwxr-xr-x 2 xman xman 4096 Jun 3 10:50 .
drwxr-xr-x 15 xman xman 4096 Jun 3 10:42 ..
-rwxr-xr-x 1 xman xman 86 Jun 3
10:44 pyfile.pyxman@kali:~/Documents$
rwxr-xr-x
35
Let’s execute the file and see how it takes the input and
give the output.
xman@kali:~/Documents$
./pyfile.pyTYpe your name.
>>>>>
>xman
Xman
36
ls -l myfile
-rw-r--r-- 1 sanjib group1 0 2018-05-22 20:03
myfilechown root myfile
ls -l myfile
-rw-r--r-- 1 root group1 0 2018-05-22 20:03 myfile
This will change the owner and the group at the same
go. Now again
37
38