0% found this document useful (0 votes)
31 views7 pages

8-linux-commands (11)

m
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views7 pages

8-linux-commands (11)

m
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 7

Linux Commands

1. help
$ <command> -h / <command> --help
2. manual
$ man <command>
-----------------------------------------------------------
1. ls (list show/ list directory)
$ ls / ls -a / ls -l
2. cd (change directory)
$ cd <name of dire.>
3. pwd (present working directory) -> current location
$ pwd
4. mv (rename / move objects)
$ mv <old-name of object> <new-name of object>
$ mv <source-of-object> <destination-of-object>
5. cp (copy)
$ cp <source-of-object> <destination-of-object>
6. mkdir (make directory)
$ mkdir < Name of direc>
7. touch (create files)
$ touch <file name>
8. cat (list cont. of file)
$ cat <filename>
9. rm (remove object)
$ rm <filename> -> remove the file
$ rm -rf <directory>
10. echo (print anything)
$ echo 'write what to print'

--------------------------------------------
> -> redirection
echo 'hello' > echo.txt
--------------------------------------------
11. sudo (super user do)
$sudo <command>

12. whoami (who are you)


$whoami

13. nano (text editor)


$ nano <filename>

Brace Expressions
{} -> {a..z}

* ->

*.txt

14. locate (find object)


$ updatedb
$ locate <objectname>

15. tar -> tape archive


$ tar -cvf <file name>.tar <file that has to bee archived> -> create a
archive
$ tar -tvf <file name>.tar -> list the contents in archive
$ tar -xvf <file name>.tar -> extract the tar
PERMISSIONS
Numerical Way

r -> read 4
w -> write 2
x -> execute 1
- -> No permissions 0

USER
GROUP
OTHERS

permissions.txt -> rwxr----x

chmod -> used to change permissions


$chmod <numerical permissions> <filename>

chmod 741 permissions.txt

Symbolic way
user -> u
groups -> g
others -> o

chmod -> used to change permissions


$ chmod <permissions> <filename>

permission.txt

16. chmod u=rwx,g=r,o=x permissions.txt

17. chown -> change ownership


$chown <new owner> <file/folder>

18. chgrp -> chaneg group


$chgrp <new group> <file/folder>

19. ifconfig -> used to check network(ipv4/ipv6) in your Kali linux


$ifconfig

PIPE: '|'
command 1 | command 2
output | input

19. grep -> global resource locater


$grep 'expressions'
-i -> ignore case sens.
-v -> inverted match
^' ' -> search at the start of string
' '$ -> search at the end of string

----------------------------------------------------------

Root Direct(/) -> top level directory


bin -> executable progrmas (all normal user)
sbin -> executable progrmas (root user)
dev -> device hadware info
home -> noraml users directory is stored
mnt -> mounting point
proc -> process info
run -> stores tmp data of services
srv -> services data is stored
tmp -> temp files
var -> variable data
boot -> booting files are present
etc -> configuration files are stored
opt -> optional direc.
sys -> kernel based info
usr -> user related info

d -> direc. / folder


'-' -> file
l -> shortcut file/folder

hard link : exact clone and they work on their own


$ln -v [path of the file] [newfilename]

softlink: normal shortcuts


$ln -s [path of the file] [newfilename]

----------------------------------------------------------
IAM -> Identity access management

USER / Group Management

UID -> User ID


0 -> root
1-99 -> predefined acc.
100-999 -> adminis. acc.
1000-10000 -> application acc. normal
10000 ++

GID -> Group ID


0 -> root
1-99 -> system/service/application(sys)/task
100+ -> user created groups

1. adduser:
$adduser <name of user>
2. passwd:
$passwd -l <account name> -> lock a acc.
$passwd -u <account name> -> unlock acc.
3. addgroup:
$addgroup <group name>
4. usermod:
$usermod -a -G <group name> <username>
$usermod -l <new username> <old username>
5. deluser:
$deluser <usernmae> -> delete a specific user
6. delgroup:
$delgroup <groupname> -> delete a group

----------------------------------------------------------
PID -> process id
PPID -> Parent process id

'&' -> use to start the proces in background

1. ps -> check the process (process state)


$ps
$ps -f -> view entire info of process
$ps aux -> more info
$ps -U <user> -> starts user related process

2. kill -> used to terminate a process


$ kill -9 <PID> -> -9 = forefully terminate

3. $xkill -> click the applca. that you wish to terminate

---------------------------------------------------------------------

SERVICES

1. systemctl -> used to work with services


$systemctl -> show all the services

$systemctl status <service name> -> show status os service


start
stop
enable
disable

2. service -> used to work with services


$service <service name> status
start
stop
restart

---------------------------------------------------------------------
commands to update the system
PS: Yet to be covered in class but are important for
healthy system

sudo apt update


sudo apt upgrade
sudo apt full-upgrade
sudo apt update --fix-missing
sudo apt autoremove
sudo apt autoclean
sudo apt clean
---------------------------------------------------------------------
website -> mosty static, one way interaction
web-applications -> dynamic, multi user interaction

--------------------------------------------------------------------
NETWORKING

IP -> internet prot.

wireless network: -> 2000 devices


192.168/141/155.....

Types of IP:
Priate : IP within the network
Public : Global Comm.
Static : It is constant
Dynamic: Keeps on changing

192.168.0
192.168.1
192.168.171
192.168.159

Versions of IP:
IPv4:

8 8 8 8
192.168.0.131 => 32 bits
1 2 3 4

CLASS: 126
A- 1.0.0.0 to 127.255.255.255 -> 16,777,200/300 Devices - MNC
B- 128.0.0.0 to 191.255.255.255 -> 65535 Devices - small MNC
C- 192.0.0.0 to 223.255.255.255 -> 255 Deviecs - LAN

D - 224.0.0.0 to 239.255.255.255 -> Reserved(Government) ARMY


E - 240.0.0.0 to 255.255.255.255 -> Reserved(Government) Research

1 ----- 255

131 > linux -> disconnected

IPv6:

fe80:ab10:55ed:c97f:41c2:b3b4:21bd:54cd => 128


16 16 16 16 16 16 16 16

====================================================================
MAC Add.
14-AB-C5-44-57-AA -> windows / dell(HP, len, etc)
8 8 8 8 8 8 => 48 bit
first 3 octate: vendor, company, org. (14-AB-C5)
last 3 octates: NIC -> first connection (44-57-AA)
ipv4 -> dynamic IP

wlan0 -> wifi


eth0 -> ethernet
1> macchanger -> spoof mac addre.
#macchanger <option> <interface>
-l eth0
-s eth0
-p eth0
-a eth0
-A eth0
-r eth0

What will happen to mac /perm/ man ? IT will reset


====================================================================
PORTS
65535 -> ports

0 - 1023 -> predefined ports


1024 - 49151 -> Registred Ports
49152 - 65535 -> you can use it
====================================================================
Binary:
0 -> empty
1 -> filled

file -> bits -> network


image -> bits -> netowrk
010

192.168.0.1 => 32 bits


8 8 8 8

00000000.00000000.00000000.00000000 => empty (0)


11111111.11111111.11111111.11111111 => filled up (255)
01001001.10010100.01010101.11111011 => soomwhat filled up 73.185

01 -> one(zero has no value)


10 -> ten(zero has value)

=============================================
1. Binary conversion

1101101 -> binary into decimal

1 1 0 1 1 0 1 -> binary
-------------
6 5 4 3 2 1 0

=> 1*2^6 + 1*2^5 + 0*2^4 + 1*2^3 + 1*2^2 + 0*2^1 + 1*2^0


=> (1 × 2⁶) + (1 × 2⁵) + (0 × 2⁴) + (1 × 2³) + (1 × 2²) + (0 × 2¹) + (1 × 2⁰)
=> 64 + 32 + 0 + 8 + 4 + 0 + 1
=> 109

=============================================
2. Hexa Decimal
0 1 2 3 4 5 6 7 8 9 A B C D E F
10 11 12 13 14 15
A4F6
A 4 F 6 -> hexa
--------
3 2 1 0 -> indexing

=> 10*16^3 + 4*16^2 + 15*16^1 + 6*16^0


=> (10 × 16³) + (4 × 16²) + (15 × 16¹) + (6 × 16⁰)
=> 42230

====================================================================
Subnetting

192.168.0.1 - 192.168.0.255

Class A 0.0.0.0 - 127.255.255.255 => N H H H => 255.0.0.0 => 16M +


Class B 128.0.0.0 - 191.255.255.255 => N N H H => 255.255.0.0 => 65K +
Class C 192.0.0.0 - 223.255.255.255 => N N N H => 255.255.255.0 => 255

CIDR -> classless inter domain routing

192.168.0.1 = 32
8 8 8 8

00000000.00000000.00000000.00000000
8 16 24 32

11111111.11111111.11111111.11111111

10.0.1.1/8
32-8 => 24

129.1.2.31/16
32-16 = 16

192.168.0.1/24

You might also like