How to record linux ssh terminal output and replay it for all users

How to record linux ssh terminal output and replay it for all users

we can get it done using script command .you can save all the session from all users login in to your server and there activity. this will help you to troubleshoot the issues .

1-  edit the profile file ( /etc/profile )and insert the below code.

……………………………………………………
if [ "x$SESSION_RECORD" = "x" ]
then
timestamp=$(date +%d-%m-%Y-%T)
session_log=/var/log/session/session.$USER.$$.$timestamp
SESSION_RECORD=started
export SESSION_RECORD
script -t -f -q 2>${session_log}.timing $session_log
exit
fi
……………………………………………………
2- create a directory to record session

Read more

How to check directory size in Linux

How to check directory size in Linux DU command uses for disk uses you can use du command to check directory size. for example you want to check directory size of a folder “database” use -h for size in MB GB etc # du -h ./database/ 17G ./database/

How to update Centos 5 .X and cannot find a valid baseurl for repo

How to update Centos 5 .X and cannot find a valid baseurl for repo

If you are using CentOS 5.x and want to install any software and update CentOS 5.x  . you are getting following error .

root@server1 [~]# yum update -y
Loaded plugins: fastestmirror
Determining fastest mirrors
YumRepo Error: All mirror URLs are not using ftp, http[s] or file.
 Eg. Invalid release/
removing mirrorlist with no valid mirrors: /var/cache/yum/base/mirrorlist.txt
Error: Cannot find a valid baseurl for repo: base

This is because update repositories were moved to the CentOS vault when the operating reached it's end-of-life.

Edit the following file

Read more

iptables port forwarding

iptables port forwarding

I am port forwarding  public ip x.x.x.x  to private ip 192.168.200.200  .

iptables -A INPUT -i eth0 -p tcp –dport 5001 -m state –state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -o eth0 -p tcp –sport 5001 -m state –state ESTABLISHED -j ACCEPT
iptables -t nat -A PREROUTING -i eth0 -p tcp -m tcp –dport 5001 -j DNAT –to-destination 192.168.200.200:5001

Read more

How to Show All NAT Tables Rules IPTABLES

How to Show All NAT Tables Rules IPTABLES iptables -t nat -L iptables -t nat -L -n -v | grep ‘something’ iptables -t nat -L -n -v The netstat-nat command display the natted connections on a Linux iptable firewall yum install netstat-nat # netstat-nat -n To display SNAT connections, run: # netstat-nat -S To display … Read more