Del ip route
ip route del 192.168.0.0/16
ip route del 192.168.22.1
ps -aux | less
Options:
-a list of all process runing by all user on the system
-u default info like PID, TTY, TIME and CMD
-x add list of processer that has no controlling terminal
( program lunched during bootup)
ps -ef | less
-e list of information about every process currently
running
-f contains fewer items of information
ps -axjf | less
print the process tree
$ps -axjf | head -n 6
0
2
root
splash
root
2 0.0 0.0
0?
Process
Set
up VNC in linux:
go to the file /vnc/sysconfig /vnc server
Add your name for desktop and give the password
Vncserver -gebmetrt 8008600 n listen tcp local host
/home/.vnc/xstatup file
Add statx
Fador14 : VNC
root@kali:/etc# df -h
Filesystem
Size Used Avail Use% Mounted on
rootfs
504M 5.3M 499M 2% /
udev
10M
0 10M 0% /dev
tmpfs
101M 528K 101M 1% /run
/dev/sr0
3.0G 3.0G
0 100% /lib/live/mount/medium
/dev/loop0
2.7G 2.7G
0 100% /lib/live/mount/rootfs/filesystem.squashfs
tmpfs
504M
0 504M 0% /lib/live/mount/overlay
Find options
find
find
find
find
find
find
find
find
find
find
find
find
find
find
find
find
find
|
.
.
.
.
.
.
.
.
/
/
/
/
/
/
/
/
wc -l
-name "mailcap"
-name "*.old"
-iname "*.old"
-iname 1 "*.old"
-maxdepth 1 -name "*.old"
-maxdepth 2 -name "*.old"
-maxdepth 2 -not -name "*.menu" | head -n 7
-maxdepth 2 -name "*.menu" -o -name "*.old" | head -n 7
-type d | head -n 7
-type f ".*" | head -n 7
-type f -name ".*" | head -n 7
-type f -perm 0655 | head -n 7
-type f -perm 0664 | head -n 7
-type f -perm /u=s | head -n -5
-type f -perm /u=s | head -n 5
-maxdepth 2 -perm /u=s 2>/dev/null
find ~ -empty
cURL
TCPDUMP:
IPTables
IPtable --flush
Iptables --list
Simulate Drop some packet(as root):
# for randomly dropping 10% of incoming packets:
iptables -A INPUT -m statistic --mode random --probability 0.1 -j
DROP
# and for dropping 10% of outgoing packets:
iptables -A OUTPUT -m statistic --mode random --probability 0.1 -j
DROP
Once done, you can use the following for removing these packet-drops:
$ for the incoming packets:
iptables -D INPUT -m statistic --mode random --probability 0.1 -j
DROP
# and for the outgoing packets
iptables -D OUTPUT -m statistic --mode random --probability 0.1 -j
DROP
tar
grep
grep
grep
grep
-e patten
-v ( avoid those line)
-w match whole word
-x whole line
o -i ignore case
ssh
sed
When you copy a DOS file to Unix, you could find \r\n in the end of
each line. This example converts the DOS file format to Unix file
format using sed command.
$sed 's/.$//' filename
Print file content in reverse order
$ sed -n '1!G;h;$p' thegeekstuff.txt
Add line number for all non-empty-lines in a file
$ sed '/./=' thegeekstuff.txt | sed 'N; s/\n/ /'
vim
$ vim filename
press :wq! or wq
Go to the 143rd line of file
$ vim +143 filename.txt
Go to the first match of the specified
$ vim +/search-term filename.txt
Open the file in read only mode.
$ vim -R /etc/passwd
diff
sort
xargs
ls
pwd command
pwd is Print working directory.
cd
Change directory
gzip
bzip2 comma
To
To
unzip
shutdown
shutdown -h now
Shutdown the system after 10 minutes.
shutdown -h +10
Reboot the system using shutdown command.
shutdown -r now
Force the filesystem check during reboot.
shutdown -Fr now
ftp
Both ftp and secure ftp (sftp) has similar commands. To connect to a
remote server and download multiple files, do the following.
$ ftp IP/hostname
ftp> mget *.html
View the file names located on the remote server before downloading,
mls ftp *.txt
crontab
Service
To start a system init script, you can either call the script located in
the directory of /etc/inti.d/service_name or you can user service
command.
Start a service
Service ssh start
Check the status of a service:
# service ssh status
Check the status of all the services.
service --status-all
Restart a service.
# service ssh restart
Ps
Top
free
This Command used to display the free, used, swap memory available in the
system.
$ free
total
used
free
shared buff/cache available
Mem: 6002340
1063124
3672552
261756
1266664
4385284
Swap:
6180860
0
6180860
Options
-g
System GB of RAM.
-t total memory including swap
-b option displays in bytes, -k in kilo bytes, -m in mega bytes.
kill
Terminate a process using PID. You can also use killall, pkill, xkill to
terminate a Linux/unix process.
$ ps -ef | grep ssh
--- 28200 26104 0 11:28 pts/19 00:00:00 grep --color=auto ssh
$ kill -9 28200
rm
cp
mv
cat
view
view
mount
To mount a file system, you should first create a directory and mount it
as shown below.
# mkdir /u1
# mount /dev/sdb1 /u1
view mount:
#mount
chmod
chmod is used to change the permissions for a file or directory.
Permissions are:
read, write and access that is r,w,a
In the binary representations:
read, write, access as 4,2,1
level are
Owner(u), group (g) and others ( a or a)
Full access to user, group and read access to other
chmod ug+rwx file.txt and chmod a+r file.txt
chmod 644 file.txt
remove the access from group
chmod g-rwx file.txt
Change file's permissions recursively in a sub-directories.
$ chmod -R ug+rwx file.txt
chown
Change the owner and group of a file.
Change the owner of file.txt to user1.
$ chown user1 file.txt
Change the file.txt to owner user1 and group u_group
$ chown user1:u_group file.txt
-R to change the ownership recursively.
$ chown -R user1:u_group /home/user1
passwd
mkdir
$ mkdir ~/temp
$ mkdir -p dir1/dir2/dir3/dir4/
ifconfig
To view or configure a network interface on the Linux system.
View all the interfaces along with status.
$ ifconfig -a
Start or stop a specific interface using up and down
$ ifconfig eth0 up
$ ifconfig eth0 down
uname
Displays important information about the system such as Kernel name,
Host name, Kernel release number,Processor type
$ uname -a
Linux 4.4.0-31-generic #50-Ubuntu SMP Wed Jul 13 00:07:12 UTC
2016 x86_64 x86_64 x86_64 GNU/Linux
whereis
Where is spacific service or lib exists
root@kali:~# whereis ftp
ftp: /usr/bin/ftp /usr/bin/X11/ftp /usr/share/man/man1/ftp.1..gz
locate
Search to locate a specfic file.
# locate dmesg
/bin/dmesg
/lib/live/mount/rootfs/filesystem.squashfs/bin/dmesg
/lib/live/mount/rootfs/filesystem.squashfs/usr/lib/klibc/bin/dmesg
man
Display the man page of a specific command.
$ man ls
tail
By default print last 10 lines of a file.
tail file1.txt
you can change the number of lines by -n switch.
tail -n 20 file1.txt
View the file in real time
$ tail -f log-file # press ^C to be out
less
Viewing the big file, but don't load the full file.
$ less file1.log
One you open a file using less command, use following to move .
CTRL+F forward one window
CTRL+B backward one window
su
root@kali:~# echo $0
-bash
root@kali:~# ps -p $$
PID TTY
TIME CMD
17676 pts/1 00:00:00 bash
root@kali:~# echo $SHELL
/bin/bash
mysql
Connect to a remote mysql database.
$ mysql -u root -p -h 192.168.1.2 ==> It will ask password
Or
$ mysql -u root -p<password without space> -h 192.168.1.2
Connect to a local mysql database.
$ mysql -u root -p
ubuntu packet
Package files typically have the extension '.deb' and package manager is
dpkg.
To list all packages installed on the system:
$dpkg -l
To list the files installed by a package, in this case the ufw package,
enter:
$dpkg -L ufw
To check which packet installed a file, dpkg -S can tell
$dpkg -S /etc/host.conf
base-files: /etc/host.conf
Ubuntu
.deb
/etc/apt/sources.list
Red hat/fedora
.rpm
/etc/yum.conf
apt-get install
your_package
dpkg --install
package.deb
apt-get upgrade
apt-get dist-upgrade
apt-get remove yourpackage
apt-get list
dpkg --listfiles yourpackage
dpkg --status yourpackage
dpkg --contents
package.deb
dpkg extract filename
apt-get clean
invoke-rc.d apache
start
Or
Service apache start
(with sysVconfig)
update-rc.d apache
defaults
Or
sysv-rc-conf apache on
( with sysv-rc-conf )
update-rc.d apache
purge
Or
chkconfig httpd on
sysv-rc-conf apache
off
ping
Ping a host to check availability
$ ping -c 5 google.com
Options
-l size
-f Find the PMTU. Prevent ICMP request being fragment by the inbetween router.
-i TTL Time to live
-v TOS type of service
ping6 IPv6 address
date
Set the system date:
# date -s "mm/dd/yyyy hh:dd:ss"
# hwclock systohc
# hwclock --systohc utc
wget
Download any resource that is available by web server.
$ wget http://example.com/resource.html -O new.name
egrep
egrep (which is the same as grep -E) treats +, ?, |, (, and ) as metacharacters.
For example,
grep "+" test-file.txt will returen any line that has + sign
egrep "+" test-file.txt will return every line
fgrep
It will search for simple string rather than a complex pattern; in this case
search is faster.
fgrap "*" test-file.txt will return every line that has * in it.
Pgrep
Process-ID Global Regular Expressions Print will return the process ID of a
process.
root@kali:/var/log# pgrep ssh
3082
6478
18268