How to save History in linux


How to save History in Linux :
————————————–
We can save history by using command script in command prompt.

Output Details :
——————-
chaitanya-GA-78LMT-S2 ~ # ls
history.log
Check with vim history.log  –> You can see what you have done from total day history will be save.

history

Start the Script :
——————–
chaitanya-GA-78LMT-S2 ~ # script history.log
Script started, file is history.log

Exit the Script :
——————-
Press Ctrl+d
chaitanya-GA-78LMT-S2 ~ # exit
Script done, file is history.log

Advertisements

How to save History in linux


How to save History in Linux :
————————————–
We can save history by using command script in command prompt.

Output Details :
——————-
chaitanya-GA-78LMT-S2 ~ # ls
history.log
Check with vim history.log  –> You can see what you have done from total day history will be save.

history

Start the Script :
——————–
chaitanya-GA-78LMT-S2 ~ # script history.log
Script started, file is history.log

Exit the Script :
——————-
Press Ctrl+d
chaitanya-GA-78LMT-S2 ~ # exit
Script done, file is history.log

How to save History in linux


How to save History in Linux :
————————————–
We can save history by using command script in command prompt.

Output Details :
——————-
chaitanya-GA-78LMT-S2 ~ # ls
history.log
Check with vim history.log  –> You can see what you have done from total day history will be save.

history

Start the Script :
——————–
chaitanya-GA-78LMT-S2 ~ # script history.log
Script started, file is history.log

Exit the Script :
——————-
Press Ctrl+d
chaitanya-GA-78LMT-S2 ~ # exit
Script done, file is history.log

How to save History in linux


How to save History in Linux :
————————————–
We can save history by using command script in command prompt.

Output Details :
——————-
chaitanya-GA-78LMT-S2 ~ # ls
history.log
Check with vim history.log  –> You can see what you have done from total day history will be save.

history

Start the Script :
——————–
chaitanya-GA-78LMT-S2 ~ # script history.log
Script started, file is history.log

Exit the Script :
——————-
Press Ctrl+d
chaitanya-GA-78LMT-S2 ~ # exit
Script done, file is history.log

Shell Script for Checking Disk Space


Shell Script for Checking Disk Space :
————————————————-
df Displays the amount of disk space available on the file system containing each file name argument. If no file name is given, the space available on all currently mounted file systems is shown. Read man page of df if you are new to df command

Output Details :
——————–
chaitanya-GA-78LMT-S2 ~ # ./2.sh
5% /dev/sda1
0% none
1% udev
0% none
1% none
1% none

diskspace

Script for Disk Space :
—————————-
#!/bin/sh
df -H | grep -vE ‘^Filesystem|tmpfs|cdrom’ | awk ‘{ print $5 ” ” $1 }’ | while read output;
do
echo $output
usep=$(echo $output | awk ‘{ print $1}’ | cut -d’%’ -f1  )
partition=$(echo $output | awk ‘{ print $2 }’ )
if [ $usep -ge 90 ]; then
echo “Running out of space \”$partition ($usep%)\” on $(hostname) as on $(date)” |
mail -s “Alert: Almost out of disk space $usep%”
fi
done

Vsftpd Installation on Ubuntu


#!/bin/bash

Clear

Updating System
sudo apt-get update

Installation Vsftpd
sudo apt-get -y install vsftpd

Configure Vsftpd in /etc/vsftpd.conf
echo “anonymous_enable=NO” >> /etc/vsftpd.conf
echo “local_enable=YES” >> /etc/vsftpd.conf
echo “write_enable=YES” >> /etc/vsftpd.conf
echo “chroot_local_user=YES” >> /etc/vsftpd.conf
echo “allow_writeable_chroot=YES” >> /etc/vsftpd.conf

Configure the User’s Home Directory
mkdir /home/ftp/
chown root:root /home/FTPS

Re-Starting Vsftpd Service
sudo service vsftpd restart

Checking Vsftpd Version
vsftpd -v

Installation is completed
Please check ftp localhost

Output Details
chaitanya@chaitanya-GA-78LMT-S2:~ > ftp 127.0.0.1
Connected to 127.0.0.1.
220 (vsFTPd 3.0.2)
Name (127.0.0.1:chaitanya): chaitanya
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
drwxr-xr-x    4 1000     1000         4096 Sep 23 14:08 Desktop
drwxr-xr-x    2 1000     1000         4096 Sep 16 16:05 Documents
drwxr-xr-x    2 1000     1000         4096 Sep 22 16:41 Downloads
drwxr-xr-x    2 1000     1000         4096 Sep 16 16:05 Music
drwxr-xr-x    2 1000     1000         4096 Sep 16 16:05 Pictures
drwxr-xr-x    2 1000     1000         4096 Sep 16 16:05 Projects
drwxr-xr-x    2 1000     1000         4096 Sep 16 16:05 Videos
226 Directory send OK.

ftp Command prompt

ftp1

MySQL Backup All Databases


#!/bin/bash
USER=”Mysql_username”
PASSWORD=”Mysql_password”
DATE=$(date +%F)
mkdir -p /home/mysql_backup/$DATE
BKPDIR=”/home/mysql_backup/$DATE”
databases=mysql --user=$USER --password=$PASSWORD -e "SHOW DATABASES;" | tr -d "| " | grep -v Database
for db in $databases; do
if [[ “$db” != “information_schema” ]] && [[ “$db” != _* ]] && [[ “$db” != “performance_schema” ]]; then
echo “Dumping database: $db” >> dump.log
mysqldump –force –opt –user=$USER –password=$PASSWORD –databases $db > $BKPDIR/date +%Y%m%d.$db.sql
gzip $BKPDIR/date +%Y%m%d.$db.sql
fi
done
echo “Backup Seucessfully created on $date” >> dump.log

Path Details
/home/mysql_backup/2015-09-23/20150923.mysql.sql.gz

Output Details
chaitanya-GA-78LMT-S2 home # ls
chaitanya  Chaitu  mysql_backup
chaitanya-GA-78LMT-S2 home # cd mysql_backup/
chaitanya-GA-78LMT-S2 mysql_backup # ls
2015-09-23
chaitanya-GA-78LMT-S2 mysql_backup # cd 2015-09-23/
chaitanya-GA-78LMT-S2 2015-09-23 # ls
20150923.mysql.sql.gz
chaitanya-GA-78LMT-S2 2015-09-23 # vim 20150923.mysql.sql.gz

 

MikroTik Port Fowarding


MikroTik Port Fowarding
Port Fowarding is one of the features of the mikrotik router (RB450g, RB750g, RB1100Ahx and other mikrotik router series). Port Fowarding on mikrotik router is used to redirects from destination address (external ip address/ ip WAN Public) to source address ( internal ip address / IP LAN) based on port number. This technique is most often used to make a host (such us web server, ftp server, ssh server, personal pc and other network devices)  that is on the internal network can be accessed via the external network (the Internet) and protected without going through a dial-up VPN or other type of vpn.

port forwarding

Configure Port Fowarding on Web Server
Standart ports web server is TCP 80 (http) and 443 (https). Many network devices can be accessed via web based by using port TCP 80 and other port, for example cctv, ip camera, dvr, and other. This example will show you how to foward port web server (tcp 9000) to destination NAT.

mikrotik_nat

Fowarding Port using Winbox
Login to Mikrotik Router Using Winbox Application
Go to IP
Firewall
NAT
Click on General Tab
Chain = dstnat Dst
Address = WAN IP Address Mikrotik Router Protocol = TCP
Dst Port = 90005-22-2015 2-49-43 PM

Click on Tab Action
Action = dst-nat
To Address = Internal Destination IP Address (Web Server IP Address)
To Port = default port (Port 80)5-22-2015 2-51-00 PM

Mikrotik Port Fowarding FTP Server, SSH Server, Mail Server, RDP (Remote Desktop Protocol)
FTP Server = 20 & 21 TCP
SSH Server = 22
Mail Server = POP3 – port 110, IMAP – port 143, SMTP – port 25, HTTP – port 80, Secure SMTP (SSMTP) – port 465, Secure IMAP (IMAP4-SSL) – port 585, IMAP4 over SSL (IMAPS) – port 993, Secure POP3 (SSL-POP) – port 995
RDP (Remote Desktop) = TCP port 3389 and UDP port 3389
RSTP (Real Time Streaming Protocol) = TCP port 554, UDP Port 3389

Enter Default Port of Network Protocol that will be Forwarded5-22-2015 3-59-06 PM

If Port Forwarding Not Working
Please Disable (or) Change ftp Port
ssh Port
www Port on IP Service List

5-22-2015 3-58-25 PM