Flushing iptables rules
Thu, 07/19/2007 - 11:17 — sandipIf you need to flush your firewall iptables rules, do not do a direct `iptables --flush` from a remote machine if the default policy is set to DROP packets, you will lock yourself out.
Run the below script instead:
#!/bin/bash
# flushIptables.sh
/sbin/iptables -P INPUT ACCEPT
/sbin/iptables -P OUTPUT ACCEPT
/sbin/iptables -F
or set the default policy to ACCEPT before flushing.
To find the default policy:
# iptables -L -n | grep policy
- sandip's blog
- Login or register to post comments
Setup Maxemum TV-Guide in Ubuntu
Tue, 07/17/2007 - 04:54 — david23Maxemum TV-Guide is a KDE TV-guide. It is developed in C++, based on QT/KDE and uses XMLTV as it’s back end to grab listings. At present there are backends grabbing TV listings for Australia, Belgium and Luxemburg, Brazil, Britain and Ireland, Denmark, Estonia, Finland, France, Germany, Hungary and Romania, Iceland, Italy, Japan, Netherlands, North America, Norway, Portugal, Reunion Island (France), South Africa, Spain, Sweden and Switzerland.
- david23's blog
- Login or register to post comments
tar with Extended Attributes/xattrs support in RedHat 5
Mon, 07/16/2007 - 08:45 — sandipIf using earlier versions, use "star" to backup and restore files with extended attributes. SELinux and ACLs use these Extended Attributes to store the security contexts and access control lists respectively.
Tar has now been rebuilt in RedHat 5 and added support for Extended Attributes.
--selinux Archive the SELinux attributes of the files and directories --acls Archive the ACL attributes of files and directories --xattrs Archive all Extended Attributes of files and directories. This includes both SELinux and ACL attributes, as well as any other xattr.
- sandip's blog
- Login or register to post comments
Finding setuid and setgid files
Sun, 07/08/2007 - 19:46 — sandipsetuid files when executed inherit the permissions of the owner of the file. So having files with setuid of root is a bad idea.
Here's how to find it and unset it.
Note:
There are some system files like at and crontab that have these bits set and is required for it to run.
# find / -perm +6000 -type f -exec ls -ld {}\; > setuid.txt &
To unset it:
# chmod a-s <file>
- sandip's blog
- Login or register to post comments
Build PHP with Freetype on DirectAdmin
Mon, 07/02/2007 - 11:04 — sandipEasy way to add freetype support on PHP, on a DirectAdmin hosting environment with Fedora as the OS, is to use the rpm versions of freetype and freetype-devel.
-
If not installed already:
# yum install freetype freetype-devel
Edit "/usr/local/directadmin/custom
--with-freetype \
&nbs p; --with-freetype-dir=/usr/lib \
&nbs p; --enable-gd-native-ttf \
Note: /usr/lib is the path to the libttf.so .
# rpm -ql freetype-devel | grep libttf.so
Then run the build:
# ./build clean
# ./build php n
If you need to build and update existing packages:
# ./build clean
# ./build update
# ./build all
Check with phpinfo to confirm.
bash code snippets
Thu, 06/28/2007 - 16:16 — sandipThis is going to be a collection of bash code snippets:
-
Check if the user running the script is root:
# make sure we're running as root
if [ `id -u` != 0 ]; then { echo "Sorry, must be root. Exiting..."; exit; } fi
if (( $? )); then
&nbs p; {
&nbs p; &nbs p; &nbs p; echo "could not executed successfully";
&nbs p; &nbs p; &nbs p; exit;
&nbs p; }
fi;
# Check for proper number of command line args.
EXPECTED_ARGS=1
E_BADARGS=65
if [ $# -ne $EXPECTED_ARGS ]
then
echo "Usage: `basename $0` {arg}"
exit $E_BADARGS
fi
VALUES=("value1" "value2" "value3" "..." "valueN")
for ((i=0; i<${#VALUES[@]}; i++))
do
echo ${VALUES[$i]}
done
How to install Vmware server From Canonical commercial repository in Ubuntu Feisty
Wed, 06/20/2007 - 07:56 — david23VMware Server is a free virtualization product for Windows and Linux servers with enterprise-class support and VirtualCenter management. VMware Server is a robust yet easy to use server virtualization product and is based on proven virtualization technology, which has been used by thousands of customers for more than six years
- david23's blog
- Login or register to post comments
Create and Extract .gz,.bz2 Files in Debian
Wed, 06/20/2007 - 07:55 — david23bzip2 and bunzip2 are file compression and decompression utilities. The bzip2 and bunzip2 utilities are newer than gzip and gunzip and are not as common yet, but they are rapidly gaining popularity. The bzip2 utility is capable of greater compression ratios than gzip. Therefore, a bzip2 file can be 10-20% smaller than a gzip version of the same file. Usually, files that have been compressed by bzip2 will have a .bz2 extension.
- david23's blog
- Login or register to post comments
`yum update kernel` without removing old kernels
Mon, 06/18/2007 - 13:22 — sandipEdit "/etc/yum/pluginconf.d/install
[main]
enabled=1
# this sets the number of package versions which are kept
tokeep=2
- sandip's blog
- Login or register to post comments
Simple serach friendly url rewrite rules
Fri, 06/15/2007 - 10:36 — sandipScenario:
Example:
http://somesite.com/mydir/a
http://somesite.com/mydir/b
http://somesite.com/mydir/c
etc...
To be rewritten as:
http://somesite.com/mydir/vie
http://somesite.com/mydir/vie
http://somesite.com/mydir/vie
etc...
Except:
http://somesite.com/mydir rewrite--> /mydir/home.html
http://somesite.com/mydir/hom
http://somesite.com/mydir/abo
Solution:
These rules should go in an .htaccess file in the "mydir" directory:
DirectoryIndex home.html
Options +FollowSymLinks
RewriteEngine on
RewriteBase /mydir/
RewriteCond %{REQUEST_URI} ^/mydir/(home|about)$
RewriteRule ^.*$ %1.html [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ view.php?p=$1 [L]