Warning: opendir(/vcdata/webroot/manhnd.com/blog.manhnd.com/wp-content/themes/postcard/styles/) [function.opendir]: failed to open dir: Permission denied in /vcdata/webroot/manhnd.com/blog.manhnd.com/wp-content/themes/postcard/includes/theme-options.php on line 39
Tar | Mạnh Nguyễn
Tag Archives: tar
23. Jan, 2009

backup with tar

Sử dụng tar để backup.

- Sử dụng exclude
example:

tar -cvf test.tar /home/manhnd/ –exclude-from /root/exclude.txt

- …

Last update : 21/01/2009

10. Oct, 2008

Install Squid on CentOS / RHEL 5

Use yum command as follows:

# yum install squid

Squid Basic Configuration

Squid configuration file located at /etc/squid/squid.conf. Open file using a text editor:
# vi /etc/squid/squid.conf

At least you need to define ACL (access control list) to work with squid. The defaults port is TCP 3128. Following example ACL allowing access from your local networks 192.168.1.0/24 and 192.168.2.0/24. Make sure you adapt to list your internal IP networks from where browsing should be allowed:
acl our_networks src 192.168.1.0/24 192.168.2.0/24
http_access allow our_networks

Save and close the file. Start squid proxy server:
# chkconfig squid on
# /etc/init.d/squid start

Open TCP port 3128

/sbin/iptables -A INPUT -m state --state NEW,ESTABLISHED,RELATED -m tcp -p tcp --dport 3128 -j ACCEPT

15. Oct, 2007

Making scripts run at boot time with Debian

Debian uses a Sys-V like init system for executing commands when the system runlevel changes – for example at bootup and shutdown time.

If you wish to add a new service to start when the machine boots you should add the necessary script to the directory /etc/init.d/. Many of the scripts already present in that directory will give you an example of the kind of things that you can do.

Here’s a very simple script which is divided into two parts, code which always runs, and code which runs when called with “start” or “stop”.

#! /bin/sh
# /etc/init.d/blah
#

# Some things that run always
touch /var/lock/blah

# Carry out specific functions when asked to by the system
case "$1" in
start)
echo "Starting script blah "
echo "Could do more here"
;;
stop)
echo "Stopping script blah"
echo "Could do more here"
;;
*)
echo "Usage: /etc/init.d/blah {start|stop}"
exit 1
;;
esac

exit 0

Once you’ve saved your file into the correct location make sure that it’s executable “chmod 755 /etc/init.d/blah.

Then you need to add the appropriate symbolic links to cause the script to be executed when the system goes down, or comes up.

The simplest way of doing this is to use the Debian-specific command update-rc.d:


root@skx:~# update-rc.d blah defaults
Adding system startup for /etc/init.d/blah ...
/etc/rc0.d/K20blah -> ../init.d/blah
/etc/rc1.d/K20blah -> ../init.d/blah
/etc/rc6.d/K20blah -> ../init.d/blah
/etc/rc2.d/S20blah -> ../init.d/blah
/etc/rc3.d/S20blah -> ../init.d/blah
/etc/rc4.d/S20blah -> ../init.d/blah
/etc/rc5.d/S20blah -> ../init.d/blah

If you wish to remove the script from the startup sequence in the future run:

root@skx:/etc/rc2.d# update-rc.d -f blah remove
update-rc.d: /etc/init.d/blah exists during rc.d purge (continuing)
Removing any system startup links for /etc/init.d/blah ...
/etc/rc0.d/K20blah
/etc/rc1.d/K20blah
/etc/rc2.d/S20blah
/etc/rc3.d/S20blah
/etc/rc4.d/S20blah
/etc/rc5.d/S20blah
/etc/rc6.d/K20blah

This will leave the script itself in place, just remove the links which cause it to be executed.

You can find more details of this command by running “man update-rc.d