Hey buddy i am using Linux as my OS . this notes containing the basics of linux commands , service , tools , configurations & many more.....
Linux Filesystem
In kali linux there are different files in " / " root directory each of them contains different types of files..
•/bin# basic programs (ls, cd, cat, etc.)•/sbin# system programs (fdisk, mkfs, sysctl, etc)•/etc# configuration files like "paswd, shadow , hosts, crontab"•/tmp# temporary files (typically deleted on boot)•/usr/bin# applications (apt, ncat, nmap, etc.)•/usr/share# application support and data files
There are many other directory present as well , but these are some of basics and important directory that we should look before move in.
Basic Linux Commands
Its important that we know basics commands of linux because 95% of the time we spend in terminal or shell .
i am running as root, so i didn't user sudo before any command. if you are using low priv account make sure to use sudo.
Man page
man page is a manual for any command we used, we can read about their switches and descriptions about that commands eg. ( man ls )
manpasswd# show the uses of password commandman-kpasswd# -k search for keyword (like apropos) , show possible command related with passwd apropospasswd# apropos will search possible list of man page for a possible match based on keyword.
Listing Files
lsls/usr/share/wordlists/*# display all items in wordlists dir , we use * wildcard.ls-la# -l for listing format and -a for hidden ls-R# recursive search
Moving Around
pwd# print the current working directory.cd/# go to root directory where all files start.cd~# go to users home directory.cd/usr/share/wordlist# we change the directory to wordlist .cd..# go one directory back and now we are at "share".cd-# same use go back one directory.
Creating Directory
while making directory remember linux is case sensitive.
mkdirnotes# it will create a directory named as "notes"mkdirnewnotes# it will create two new directory new and notes mkdir"new notes"# it will create one new dir "new notes"rmdirnotes# it will remove notes dirrm-rfnotes# it will remove notes forcefullymkdir"new dir"# it will create new dir named as "new dir"cdnew\ dir/# now we are in "new dir" dir, here \ backslash is used for ignoring the empity space b/q new and dir .mkdir-pnotes{maths,phy,chem}# here it create dir notes and inside it create 3 new dir named as maths , phy ,chem .
Finding Files in kali system
which
which $PATH # it will show the path environment for given namewhichpython# show the dir where python is present
locate
sudoupdatedb# update the databse before running the commands.locate*.nse# find all files with .nse extension locatesbd.exe# find file sbd.exe
find
Find is very use-full command when it comes to finding file with different parameters, read man page for find command.
find/-name*.sbd# it will find the file form / dir with name *.sbd .find/-perm-u=s-typef2>/dev/null# find file form / dir with -perm permisson , -u=s denotes look for files that are owned by the root user -type is type f denote looking for regular files , 2 denotes stander error redirected to /dev/null
Managing kali Services
kali comes with default Pre-installed services such as ssh , http, mysql etc.
we can use this services according with our's need.
SSH Service
we can use systemctl or service command for running and stopping the services.
systemctlstartssh# running the ssh systemctlstatusssh# status of sshsystemctlstopssh# stoping servicesshstart# same as previous systemctlenablessh# if we want that ssh automatic start with boot then we enable the service with enable switch , same as disable
HTTP Service is a web server that loads at port 80 on our local-host IP its dir is /var/www/html where it host.
apache is a webserver that comes pre-installed in kali so we are using apache , we can user nginx or python as well.
we can use it as a web-server for downloading files at Victum Machine.
# for apacheserviceapache2startserviceapache2statusserviceapache2stopsystemctlstartapache2# for startsystemctlenableapache2# for enable, it will automatic start afte every rebootsystemctlstopapache2# for stopsystemctldisableapache2# for changing conf. of apachesystemctllist-unit-files# for checking the list of enable & diable services..# for nginxservicenginxstartservicenginxstop
example
┌──(root💀rio)-[~]└─#serviceapache2start┌──(root💀rio)-[~]└─#serviceapache2status●apache2.service-TheApacheHTTPServerLoaded:loaded (/lib/systemd/system/apache2.service; disabled; vendorpreset:disabled)Active:active (running) since Tue 2022-08-09 06:37:07 IST; 5sagoDocs:https://httpd.apache.org/docs/2.4/Process:98385ExecStart=/usr/sbin/apachectlstart (code=exited, status=0/SUCCESS)MainPID:98402 (apache2)Tasks:6 (limit: 14118)Memory:18.5MCPU:95msCGroup:/system.slice/apache2.service├─98402/usr/sbin/apache2-kstart├─98404/usr/sbin/apache2-kstart├─98405/usr/sbin/apache2-kstart├─98406/usr/sbin/apache2-kstart├─98407/usr/sbin/apache2-kstart└─98408/usr/sbin/apache2-kstartAug0906:37:07riosystemd[1]:StartingTheApacheHTTPServer...Aug0906:37:07rioapachectl[98401]:AH00558:apache2:Couldnotreliablydeterminetheserver's fully qualified domain name, using >Aug 09 06:37:07 rio systemd[1]: Started The Apache HTTP Server.┌──(root💀rio)-[~]└─# service apache2 stop
Searching, Installing, and removing Tools
apt update
apt update command will update the list of available packages, including information related to their versions, descriptions, etc so that we can upgrade the system.
aptupdate
apt upgrade
After the APT database has been updated, we can upgrade the installed packages and core system to the latest versions using the apt upgrade command.
aptupgrade-y# upgrade the full packageaptupgrademetsaploit-framework# upgrade single package
apt-cache and apt show
The apt-cache search command displays much of the information stored in the internal cached package database.
aptremovepure-ftpd# remove this package aptpurge--purgepure-ftpd# this option remove the package with no leftover.
dpkg
dpkg used to install offline package
dpkg -i man-db_2.7.0.2-5_amd64.deb # -i install this package
dpkg -r man-db_2.7.0.2-5_amd64.deb # -r remove the package
misc commands
who# show users info in detailswhoami# show your current useruname-a# display kernal informationsukali# for swithching to kali usersuroot# for switching root useradduserjhon# it wiil add user like jhonsujhon# for switching to jhon userdeluserjhon# it will del user jhon sudoshutdownnow-r# for restsrtsudoshutdownnow-c# cancel the previous shoutdownsudoshutdownnow# system shutdownpoweroff# power off systempoweroff-f# forcefullyreboot# reboot system reboot-f# forcefullydate# display date date--set='10 Feb 2017 11:13'# for change datecal# for calanderyes# it will loop yessahil# loop sahil , [ctrl] + c to terminatefactor1024# helps to do maths factor