( or )
What to do if you cannot execute CHMOD?
This is a tricky question.. you have just removed execute permission on chmod.
Result of that is you cannot modify file permissions . Not even for chmod itself .
chmod remains usless on your system.
Here is the solution for the problem
sudo /lib/ld-linux.so.2 /bin/chmod 755 /bin/chmod
or
perl -e 'chmod(0755, "/bin/chmod")'
Linux administration , Unix administration , Vmware Vsphere administration , Oracle DBA ,apache, backup, dhcp, dns, kvm, xen, kernel, ldap, kvm, monitoring, ticketing, networking, Mail servers, SAN,troubleshooting
Labels
- Amanda (2)
- Ansible (2)
- Answer these Questions (2)
- antivirus (2)
- apache (3)
- Bash (16)
- Chef (3)
- Citrix (2)
- clusters (2)
- Concept (22)
- DatabaseAdminstration (11)
- DevOps (1)
- dhcp (2)
- Downloads (3)
- ELK (1)
- ELK stack (1)
- encryption (1)
- Free trainings (1)
- Frequently Used Commands (46)
- FTP (1)
- git (1)
- gpg (2)
- Hardware (1)
- httpd (2)
- Interview Questions (53)
- iptables (1)
- IT NEWS (3)
- java (1)
- kibana (2)
- knife (1)
- KVM (2)
- linux (17)
- Linux installations (22)
- Linux Jobs (4)
- Linux Links (2)
- logstash (1)
- Mac (1)
- MediaWiki (1)
- MySql (2)
- Nagios (2)
- Networking (3)
- open Nebula (5)
- Open Source tools (12)
- OpenNMS (1)
- openSSL (1)
- Oracle on Linux (5)
- Performance Monitoring (1)
- php (1)
- postfix (1)
- postgres (1)
- postgres-XL (1)
- Product Reviews (1)
- Python (2)
- rssh (1)
- Samba (2)
- Scripting (16)
- security (4)
- selinux (1)
- Server (1)
- SFTP (1)
- Social Awareness (1)
- Solaris (1)
- SSL (1)
- svn (1)
- TCP/IP (1)
- Technology (1)
- Tips and Tricks (32)
- Training and materials (8)
- Troubleshooting (6)
- Ubuntu (18)
- unix (1)
- virtualization (17)
- Vmware (25)
- Vyatta (1)
- windows7 (1)
- xml (1)
Solution : Backtrack 5 Live blank screen
I have downloaded backtrack 5 DVD and was trying to live boot from my Laptop.
Once i am in text mode and as root user.
I gave command startx
Just to turn command mode to GUI mode .
My system was showing a blank screen .. Searched online but did not find solutions
So I have tried my own troubleshooting methods and found that it was Graphics related issue.
Fix : Hope problem is because you are using a laptop with graphic card and BT is not able to
load specific drivers for your graphic card.
So go to BIOS either disable graphic card or
Change Graphic mode from Switching to discrete
for me it worked !! let me know if you still have problems will come up with other solutions...
Rsync current directory using SSH port to remote host
/usr/bin/rsync -rave "ssh -p 22222 -l root" --delete . 192.168.1.111:/tmp
Bash script to check command-line arguments and set default if not present
if [ -n "$1" ]
# Test whether command-line argument is present (non-empty).
then
lines=$1
else
lines=$LINES # Default, if not specified on command-line.
fi
# Test whether command-line argument is present (non-empty).
then
lines=$1
else
lines=$LINES # Default, if not specified on command-line.
fi
how to encrypt your scripts using sch
Dont want to give your scripts to any one but want to give someone to execute for specific period of time then this is what you are looking for .
We can also give timeline in which the script can be used.
Also you will not be revealing you passwords in the script.
SCH will encrypt shell scripts using RC4 and make executable binary.
http://www.datsi.fi.upm.es/~frosal/sources/shc-3.8.7.tgz
shc [ -e date ] [ -m addr ] [ -i iopt ] [ -x cmnd ]
[ -l lopt ] [ -ACDhTv ] -f script
shc -e date ( script will not run afterdate specified )
-m "Please contact support " (message to display after we run the expired scirpt)
shc -e 01/06/2010 -m "You are late to run this script." -f script.sh
./script.sh.x
http://www.datsi.fi.upm.es/~frosal/sources/shc.html
I have tried to hack the encrypted binary that came as output, but was not successful
I used bashdb and GDB
We can also give timeline in which the script can be used.
Also you will not be revealing you passwords in the script.
SCH will encrypt shell scripts using RC4 and make executable binary.
http://www.datsi.fi.upm.es/~frosal/sources/shc-3.8.7.tgz
shc [ -e date ] [ -m addr ] [ -i iopt ] [ -x cmnd ]
[ -l lopt ] [ -ACDhTv ] -f script
shc -e date ( script will not run afterdate specified )
-m "Please contact support " (message to display after we run the expired scirpt)
shc -e 01/06/2010 -m "You are late to run this script." -f script.sh
./script.sh.x
http://www.datsi.fi.upm.es/~frosal/sources/shc.html
I have tried to hack the encrypted binary that came as output, but was not successful
I used bashdb and GDB
Per user mac based bandwidth monitor for routers
Want to calculate how much bandwidth each user (mac address) is using
./wrtbwmon setup
./wrtbwmon update /tmp/usage.db offpeak
./wrtbwmon publish /tmp/usage.db /www/user/usage.htm /jffs/users.txt
Here is open source solution ClickHere
Below is the script (wrtbwmon )
---------------------------
LAN_IFACE=$(nvram get lan_ifname)
lock()
{
while [ -f /tmp/wrtbwmon.lock ]; do
if [ ! -d /proc/$(cat /tmp/wrtbwmon.lock) ]; then
echo "WARNING : Lockfile detected but process $(cat /tmp/wrtbwmon.lock) does not exist !"
rm -f /tmp/wrtbwmon.lock
fi
sleep 1
done
echo $$ > /tmp/wrtbwmon.lock
}
unlock()
{
rm -f /tmp/wrtbwmon.lock
}
case ${1} in
"setup" )
#Create the RRDIPT CHAIN (it doesn't matter if it already exists).
iptables -N RRDIPT 2> /dev/null
#Add the RRDIPT CHAIN to the FORWARD chain (if non existing).
iptables -L FORWARD --line-numbers -n | grep "RRDIPT" | grep "1" > /dev/null
if [ $? -ne 0 ]; then
iptables -L FORWARD -n | grep "RRDIPT" > /dev/null
if [ $? -eq 0 ]; then
echo "DEBUG : iptables chain misplaced, recreating it..."
iptables -D FORWARD -j RRDIPT
fi
iptables -I FORWARD -j RRDIPT
fi
#For each host in the ARP table
grep ${LAN_IFACE} /proc/net/arp | while read IP TYPE FLAGS MAC MASK IFACE
do
#Add iptable rules (if non existing).
iptables -nL RRDIPT | grep "${IP} " > /dev/null
if [ $? -ne 0 ]; then
iptables -I RRDIPT -d ${IP} -j RETURN
iptables -I RRDIPT -s ${IP} -j RETURN
fi
done
;;
"update" )
[ -z "${2}" ] && echo "ERROR : Missing argument 2" && exit 1
# Uncomment this line if you want to abort if database not found
# [ -f "${2}" ] || exit 1
lock
#Read and reset counters
iptables -L RRDIPT -vnxZ -t filter > /tmp/traffic_$$.tmp
grep -v "0x0" /proc/net/arp | while read IP TYPE FLAGS MAC MASK IFACE
do
#Add new data to the graph. Count in Kbs to deal with 16 bits signed values (up to 2G only)
#Have to use temporary files because of crappy busybox shell
grep ${IP} /tmp/traffic_$$.tmp | while read PKTS BYTES TARGET PROT OPT IFIN IFOUT SRC DST
do
[ "${DST}" = "${IP}" ] && echo $((${BYTES}/1000)) > /tmp/in_$$.tmp
[ "${SRC}" = "${IP}" ] && echo $((${BYTES}/1000)) > /tmp/out_$$.tmp
done
IN=$(cat /tmp/in_$$.tmp)
OUT=$(cat /tmp/out_$$.tmp)
rm -f /tmp/in_$$.tmp
rm -f /tmp/out_$$.tmp
if [ ${IN} -gt 0 -o ${OUT} -gt 0 ]; then
echo "DEBUG : New traffic for ${MAC} since last update : ${IN}k:${OUT}k"
LINE=$(grep ${MAC} ${2})
if [ -z "${LINE}" ]; then
echo "DEBUG : ${MAC} is a new host !"
PEAKUSAGE_IN=0
PEAKUSAGE_OUT=0
OFFPEAKUSAGE_IN=0
OFFPEAKUSAGE_OUT=0
else
PEAKUSAGE_IN=$(echo ${LINE} | cut -f2 -s -d, )
PEAKUSAGE_OUT=$(echo ${LINE} | cut -f3 -s -d, )
OFFPEAKUSAGE_IN=$(echo ${LINE} | cut -f4 -s -d, )
OFFPEAKUSAGE_OUT=$(echo ${LINE} | cut -f5 -s -d, )
fi
if [ "${3}" = "offpeak" ]; then
OFFPEAKUSAGE_IN=$((${OFFPEAKUSAGE_IN}+${IN}))
OFFPEAKUSAGE_OUT=$((${OFFPEAKUSAGE_OUT}+${OUT}))
else
PEAKUSAGE_IN=$((${PEAKUSAGE_IN}+${IN}))
PEAKUSAGE_OUT=$((${PEAKUSAGE_OUT}+${OUT}))
fi
grep -v "${MAC}" ${2} > /tmp/db_$$.tmp
mv /tmp/db_$$.tmp ${2}
echo ${MAC},${PEAKUSAGE_IN},${PEAKUSAGE_OUT},${OFFPEAKUSAGE_IN},${OFFPEAKUSAGE_OUT},$(date "+%d-%m-%Y %H:%M") >> ${2}
fi
done
#Free some memory
rm -f /tmp/*_$$.tmp
unlock
;;
"publish" )
[ -z "${2}" ] && echo "ERROR : Missing argument 2" && exit 1
[ -z "${3}" ] && echo "ERROR : Missing argument 3" && exit 1
USERSFILE="/etc/dnsmasq.conf"
[ -f "${USERSFILE}" ] || USERSFILE="/tmp/dnsmasq.conf"
[ -z "${4}" ] || USERSFILE=${4}
[ -f "${USERSFILE}" ] || USERSFILE="/dev/null"
# first do some number crunching - rewrite the database so that it is sorted
lock
touch /tmp/sorted_$$.tmp
cat ${2} | while IFS=, read MAC PEAKUSAGE_IN PEAKUSAGE_OUT OFFPEAKUSAGE_IN OFFPEAKUSAGE_OUT LASTSEEN
do
echo ${PEAKUSAGE_IN},${PEAKUSAGE_OUT},${OFFPEAKUSAGE_IN},${OFFPEAKUSAGE_OUT},${MAC},${LASTSEEN} >> /tmp/sorted_$$.tmp
done
unlock
# create HTML page
echo "Traffic
Total Usage :
" >> ${3} echo "" >> ${3}
" >> ${3}
echo "
| User | Peak download | Peak upload | Offpeak download | Offpeak upload | Last seen |
|---|
echo "
This page was generated on `date`" 2>&1 >> ${3}
This page was generated on `date`" 2>&1 >> ${3}
echo "" >> ${3}
#Free some memory
rm -f /tmp/*_$$.tmp
;;
*)
echo "Usage : $0 {setup|update|publish} [options...]"
echo "Options : "
echo " $0 setup"
echo " $0 update database_file [offpeak]"
echo " $0 publish database_file path_of_html_report [user_file]"
echo "Examples : "
echo " $0 setup"
echo " $0 update /tmp/usage.db offpeak"
echo " $0 publish /tmp/usage.db /www/user/usage.htm /jffs/users.txt"
echo "Note : [user_file] is an optional file to match users with their MAC address"
echo " Its format is : 00:MA:CA:DD:RE:SS,username , with one entry per line"
exit
;;
esac
How to extract 7zip files in ubuntu
First install 7zip package
sudo apt-get install p7zip
( you will need universal repository to run the above command )
after installing
7z x my7Zzipfile
sudo apt-get install p7zip
( you will need universal repository to run the above command )
after installing
7z x my7Zzipfile
Subscribe to:
Posts (Atom)