8 10 2023 Basic Linux CMD

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 9

Basic Linux cmd.

File system
[here slash / mean root directory/folder]
[like bin directory store all program file like ls - what function
will run and how will run - these files are written ]
------------------------------------------------------
write a cmd in terminal
ls -l / [file system]
------------------------------------------------------
/bin - Basic programs or commands [ls, cd, mv ...]
essential user commands here.
boot - file of or for boot loader [in parrot]
/sbin - System Program [fdisk, sysctl, mkfs
[display system binary information]
dev - device information [parrot]
/etc - host file - here can make changes in host/network files/configuration
[same in window, Linux - kali, ubuntu, parrot]
[ Apache server/web server - local host ]
media
mnt - mount - cd/dvd/ shows attachment with system
[resource mount with Linux machine -it will display here ]
opt - [addon packages information]

lib - shared libraries structure/information


/temp - Temporary files
/usr/bin - installed Applications [apt,nmap...
/usr/share - Application support and data files
/home - Personal Directories of User's [/home]
[home directories has user functions]
/root - Home directory of super user [admin]
[here we can access admin data/privilege]
srv - data for service from system
usr - utility application programs'
var - ftp server / create local repository
[host file configuration]
[create/manage default repository]
---------------------------------------------

ip addr [To check the IP address of the device ]


ifconfig
ping 8.8.8.8 [To check to communicate with ip [8.8.8.8 google DNS]
arp -e [in Linux] arp -a [in win]
sudo apt-get update [To update system]
sudo apt-get upgrade [upgrades all the packets]
sudo su [ENTER IN SUPER USER]
history [HISTORY OF CMD]
clear [clear kernel]
cd [cd mean change director/reach in dir]

cd .. [one step back]


cd Desktop [ reach desktop]
----------------------------------------------
[share the folder between host win or vm kali ]
virtual Machine settings-options-share folder-always enabled-
add {folder path} - ok - play virtual machine - open terminal
[write below cmds]
cd Desktop
mk share
sudo vmhgfs-fuse .host:/share share -o allow_other -o uid=1000
------------ --------------
mkdir share [make folder]
cd share [enter in folder]
ls [list of file/folder]
pwd [ present working dir {home/kali}]
--------------------------
uname [system name]
uname -r [os version]
uname -a [all details about system]
ls /home/ [ display - all users name ]
id user [id om - shows - uid , gid, groups ]
[uid-user id , gid- group id, groups - group no.]
id root [ uid -o, gid -0, group - ]
[ root is administrative account ]
sudo su ro sudo -i [login in root user with
basic user password- enter ]
exit or su user or su om [ exit and enter in local user ]

whoami [ shows user name]

passwd user [ passwd om - for password change]


passwd root [ same for root]
[ insert - current - new - retype new ]

sudo su
su useradd omk [create new user - omk ]
passwd omk [provide password]

ls /home/ [ for user details]


su omk
ls /omk [no privilege]
id omk
sudo su ro sudo -i
userdel omk

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

mkdir cyber [make folder/dir]


rmdir cyber
mkdir {1..10} [1 to 10 folder will create]
rmdir {1..10} [1 to 10 folder will remove]
mkdir {a..z} [a to z folder will create]
rmdir {a..z} [a to z folder will remove]

rmdir * [in present dir - all dir will remove]

---------------------
man ls [provide manual of any linux cmd]
help [show basic cmd and there use]

---------------------
touch file.txt [to create file]
cat file.txt [used to see the text/word]

cat > file.txt [ write/add text/word in the file]


hi, all this is cyber security class. If there is any doubt, feel free to ask. thanks

[To save and quit the cat command - press CTRL + D or ctrl+z
You will now return
to your shell prompt.]

rm file.txt [remove file]


----------------------------------------
cp file.txt Desktop [cp means copy file to desktop]
mv file.txt Desktop [mv means move file to desktop]
------------------------------------------------------
nano - Linux file editor
pluma - file editor software
======================================================
important -
------------------------------------------------------
ls -l file.txt [provide authentication rule]

like
-rw-r--r-- 1 kali kali 0 Jul 18 01:08 file.txt

[d if dir is there, -rw-r--r-- permission/privileges,


1 is id, kali is user, kali - group
0 is size,Jul 18 01:08 date and time, file.txt is file/dir name]

chmod 777 file.txt [use to change mode/permissions]


[meaning of 777]
or
chmod 755 file/dir [default mode]

[ admin/user rwx 4+2+1 =7 ]


[ group rw 4+2 =6 ]
[ public/other r 4 =4]

[x and 1 means execute ]


[w and 2 means write ]
[r and 4 means read ]
execute - performing an action on them, like deleting, moving,
or editing

Each permission (rwx) can be controlled at three levels:


u - admin/user = yourself
g - group = can be people in the same project
o - public/other = everyone on the system.
----------------------------------------

----------------------------------------
whoami [in root or user]

pwd [ present working dir {home/kali}]

cal [see calendar]


----------------------------------------
vi editor
vi file.txt
cat file.txt

==========================================
open Metasploit -------

https://www.geeksforgeeks.org/linux-metasploit-command/
==============================================================
==============================================================
==============================================================
==============================================================
==============================================================
ping 192.168.44.128 [check connectivity with ip/domain name]
nmap 192.168.44.129
-------------------------------------------------------------
host
open/close ports
operating system information
service running on the network
running processes on a network
identify vulnerabilities
-------------------------------------------------------------
https://www.interviewbit.com/blog/nmap-commands/
https://www.varonis.com/blog/nmap-commands
-------------------------------------------------------------
=============================================================
=============================================================
=============================================================
Basic Nmap commands
-------------------------------------------------------------
nmap -sn 192.168.44.128 [ vm Metasploit ip ]
[use for ping scan performance/host is up, it means machine is on]

nmap -sn 8.8.8.8 [google dns server ip]


[-sn send a syn packet to detect
system is on/off]

nmap -sn 192.168.44.130 [vm window machine ip ]


┌──(kali㉿kali)-[~]
└─$ nmap -sn 192.168.44.130
Starting Nmap 7.93 ( https://nmap.org ) at 2023-07-18 03:31 EDT
Note: The host seems down. If it is really up, but blocking our ping probes,
try -Pn
Nmap done: 1 IP address (0 hosts up) scanned in 3.00 seconds

[using invasion technique to bypass


firewall/antivirus etc ]
[arp address resolution protocol
[48 bit] - scan, ]
--------------------------------------
arp -e [provide arp table]

──(kali㉿kali)-[~]
└─$ arp -e
Address HWtype HWaddress Flags Mask Iface
192.168.44.2 ether 00:50:56:fa:5e:d0 C eth0
192.168.44.130 ether 00:0c:29:68:18:4b C eth0
192.168.44.254 ether 00:50:56:f7:75:f9 C eth0

[if arp table is not there then, he


do not know which ip belong to which
mac addr] so we take this scenarios
advantage and raise arp request through
nmap,so we will do arp request
broadcast to target ip, target identity its is
ip then in rply send mac addr, in this
method be can know target
machine on/off
]
ping is block syn packet block or not
through firewall.,

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

┌──(kali㉿kali)-[~]
└─$ sudo nmap -sn 192.168.44.130 -PR
[sudo] password for kali:
[sudo] password for kali:
Starting Nmap 7.93 ( https://nmap.org ) at 2023-07-18 03:56 EDT
Nmap scan report for 192.168.44.130
Host is up (0.00035s latency).
MAC Address: 00:0C:29:68:18:4B (VMware)
Nmap done: 1 IP address (1 host up) scanned in 0.22 seconds

[-PR use arp]


-------------------------------------
hobs - host of the points
[path router]
=======================================
┌──(kali㉿kali)-[~]
└─$ nmap -sn traceroute facebook.com
Starting Nmap 7.93 ( https://nmap.org ) at 2023-07-18 04:02 EDT
Failed to resolve "traceroute".
Nmap scan report for facebook.com (157.240.198.35)
Host is up (0.012s latency).
Other addresses for facebook.com (not scanned): 2a03:2880:f144:82:face:b00c:0:25de
rDNS record for 157.240.198.35: edge-star-mini-shv-01-del1.facebook.com
Nmap done: 1 IP address (1 host up) scanned in 15.07 seconds
--------------------------------
If I want to change the dns server ...
by default we using 8.8.8.8 dns 's
getaway server
but we want change dns server

--------------------------
-n [can cut name resolution part]
-Pn [we so not want to use ping
means do not want to send icmp
packet use]
[so -Pn block ping scan ]

ping send icmp packets


[ICMP (Internet Control Message
Protocol) is an error-reporting
protocol that network devices
such as routers use to generate
error messages to the source IP
address when network problems
prevent delivery of IP packets.]

============================================
============================================
┌──(kali㉿kali)-[~]
└─$ nmap -n facebook.com -Pn
Starting Nmap 7.93 ( https://nmap.org ) at 2023-07-18 04:12 EDT
Nmap scan report for facebook.com (157.240.198.35)
Host is up (0.014s latency).
Other addresses for facebook.com (not scanned): 2a03:2880:f144:82:face:b00c:0:25de
Not shown: 998 filtered tcp ports (no-response)
PORT STATE SERVICE
80/tcp open http
443/tcp open https

Nmap done: 1 IP address (1 host up) scanned in 4.92 seconds


==================================
==================================
==================================
==================================
----------------------------------
port scan -ports state are
---------------------------------
---------------------------------
open - indicate port service and
listening

close - indicate probes [signal] send


but no service running on port

filter - indicate- no sign probe are


received / state could not establish/
[probe are dropped some kind of
filtering]

unfaltering - mean - probes were


received but state could not be
establish [received but not identify
that post is on/off]

open/filtered- port is open but


filtered [antivirus/firewall blocking]

close/filtered [filter or could be


close - on/off not defined]
==================================
==================================
nmap -sT facebook.com -Pn
[-sT - TCP scan, -Pn without ping]
[ press shift to check recent
scanning status in percentage ]
nmap -sT facebook.com
nmap -sU facebook.com -Pn
[-sU - UDP scan, -Pn without ping]
nmap -sU facebook.com
=================================
=================================
=================================

nmap <target ip>


[• Basic Scan: Perform a basic TCP port
scan on a target:]
nmap -p <port1,port2,port3> <target ip>
[• Scan Specific Ports: Specify specific
ports to scan on a target:]

nmap -p- <target ip>


[Scan All Ports:]

nmap -O <target ip>


[OS detection]

nmap -A <target>
[Aggressive Scan:]

nmap -p 53 --script dns-enum <target>


[DNS Enumeration]

nmap <network>/24
[Scan Network Range:]

nmap -F <target>
[Fast Scan:]

Output Results to File:


[nmap -oN <output_file.txt> <target>]

You might also like