Posts

Showing posts from June, 2008

Linux - Recursively Delete Files of a Certain Type

find . -name "*.ext" -exec rm '{}' ';'

Linux/Unix - Security and system auditing tool

Image
Lynis is an auditing tool for Unix (specialists). It scans the system and available software, to detect security issues. Beside security related information it will also scan for general system information, installed packages and configuration mistakes.

Linux - CD Buring (BashBurn)

Image
BashBurn is a collection of scripts for CD burning in a Linux console (BashBurn might very well work in *BSD, Solaris etc. but it is developed and tested only under Gentoo Linux). BashBurn was previously named Magma. It’s not the best looking CD-burning application out there, but it does what you want it to do (And if not then probably didn’t want to do it anyway).

Linux - Assign an IP address

Command line
/sbin/ifconfig eth0 192.168.1.3 netmask 255.255.255.0 broadcast 192.168.1.255

GUI
/usr/bin/neat (Gnome)
/usr/sbin/netconfig (Console)


/etc/sysconfig/network

# Static IP address Configuration:
NETWORKING=yes
HOSTNAME=my-hostname # Hostname is defined here and by command hostname
FORWARD_IPV4=true # True for NAT firewall gateways and linux routers. False for everyone else - desktops and servers.
GATEWAY=”XXX.XXX.XXX.YYY” # Used if your network is connected to another network or the internet.

# Or for DHCP configuration: in the same file /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=my-hostname # Hostname is defined here and by command hostname
# Gateway is assigned by DHCP.


/etc/sysconfig/network-scripts/ifcfg-eth0

# Static IP address configuration:
DEVICE=eth0
BOOTPROTO=static
BROADCAST=XXX.XXX.XXX.255
IPADDR=XXX.XXX.XXX.XXX
NETMASK=255.255.255.0
NETWORK=XXX.XXX.XXX.0
ONBOOT=yes

# OR for DHCP configuration:
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=dhcp

Linux - Create Name Based Virtual hosts in Apache

Name-Based Virtual Hosts

NameVirtualHost *

ServerName www.example.com
DocumentRoot /home/www/htdocs/example.com
ServerAdmin webmaster@example.com
ErrorLog /var/log/apache2/www.example.com-error_log
CustomLog /var/log/apache2/www.example.com-access_log common

ServerName www.myothercompany.com
DocumentRoot /home/www/htdocs/myothercompany.com
ServerAdmin webmaster@myothercompany.com
ErrorLog /var/log/apache2/www.myothercompany.com-error_log
CustomLog /var/log/apache2/www.myothercompany.com-access_log common

Linux - Bash Brace Expansion

Brace expansion is enabled via the "set -B" command and the "-B" command line option to the shell and disabled via "set +B" and "+B" on the command line.

Some examples and what they expand to:
{aa,bb,cc,dd} => aa bb cc dd
{0..12} => 0 1 2 3 4 5 6 7 8 9 10 11 12
{3..-2} => 3 2 1 0 -1 -2
{a..g} => a b c d e f g
{g..a} => g f e d c b a
a{0..3}b => a0b a1b a2b a3b
{a,b{1..3},c} => a b1 b2 b3 c

for i in {0..19}
do
echo $i
done

for i in {a..z}
do
echo $i
done

# rm /a/long/path/foo /a/long/path/bar
# rm /a/long/path/{foo,bar}

Linux - Apache redirect www.domain.com to domain.com

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.yourdomain.com$ [NC]
RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L]

溫家寶 總理 Facebook

溫家寶 總理 Facebook

Remark: It is created by his fans !