Mon, 2006-12-18 19:20:32 +0800
GNU/Linux man sections
The most common sections under GNU/Linux, and their human readable names, are:
Section The human readable name 1 User commands that may be started by everyone. 2 System calls, that is, functions provided by the kernel. 3 Subroutines, that is, library functions. 4 Devices, that is, special files in the /dev directory. 5 File format descriptions, e.g. /etc/passwd. 6 Games, self-explanatory. 7 Miscellaneous, e.g. macro packages, conventions. 8 System administration tools that only root can execute. 9 Another (Linux specific) place for kernel routine documentation. n (Deprecated) New documentation, that may be moved to a more appropriate section. o (Deprecated) Old documentation, that may be kept for a grace period. l (Deprecated) Local documentation referring to this particular system.
Sat, 2006-12-16 14:46:36 +0800
Delete some certain file in recursive directories
I have many many pitures in recursive directories from Microsoft Windows XP, you know, it always creates a file named "Thumbs.db" to the default picture viewer in Microsoft Windows XP, so I want to delete all these files in my GNU/Linux system. You will know it's so easy to realize this in GNU/Linux or UNIX with the usage of tree and other Shell command.
Write a simple shell script as follows:
#!/bin/bash # rm_ThumbsDOTdb.sh for i in $(tree -a -f -i|grep 'Thumbs.db') do rm -f $i done
Copy this file to a directory in your $PATH and change directory to that you want to deal with and run:
#rm_ThumbsDOTdb.sh
You will get what you want now.
Sat, 2006-12-16 14:35:49 +0800
squid to setup direct proxy server
The simplest application of squid is to setup a direct proxy server, that would let the clients to know the proxy server name(probably the IP address of the proxy server) and the http port. However, it's easy to make this come true, just follow me now.
Prepare
The default user and group of squid would be nobody and nogroup, so the first thing you should do is to add this user (nobody) belongs to the nogroup group. If you have no this default user and group in your system(Slackware would create them while the installation. To check whether you have them in your system, just do the following:
#cat /etc/group | grep nogroupnogroup::99:#cat /etc/passwd | grep nobodynobody:x:99:99:nobody:/:
If you got some messages like above, you got the default user and group now. Or else do the following operation:
#groupadd nogroup#useradd -g nogroup -d / -p passwd nobody
Download, compile and install
Download the latest stable version of squid from squid-cache which probably like squid-x.y-STABLE.tar.gz.
Then compiling and installing squid as follows:
#tar xvfz squid-x.y-STABLE.tar.gz#cd squid-x.y-STABLE#mkdir -p /usr/local/squid#./configure --prefix=/usr/local/squid#make#make install
Configure
The first squid configuration would be /usr/local/squid/etc/squid.conf, sometimes maybe you can use /etc/squid/squid.conf as the configuration file of squid. Anyway, my configuration is shown in the following:
acl deny_ip_01 dst 1.1.1.1 http_access deny deny_ip_01 acl deny_url_01 url_regex http://www.www.www http_access deny deny_url_01 http_port 3128 cache_mgr FlyZhy.Org@Gmail.Com cache_mem 64 MB cache_dir ufs /usr/local/squid/var/cache 1024 16 256 cache_access_log /usr/local/squid/var/logs/access.log cache_log /usr/local/squid/var/logs/cache.log cache_store_log /usr/local/squid/var/logs/store.log pid_filename /usr/local/squid/var/logs/squid.pid #dns_nameservers 211.64.142.7 acl all src 0.0.0.0/0.0.0.0 #acl manager proto cache_object # let 222.195.148.* to use the proxy server #acl wan src 222.195.148.0/255.255.255.255 #acl localhost src 127.0.0.1/255.255.255.255 #acl to_localhost dst 127.0.0.0/8 acl SSL_ports port 443 acl Safe_ports port 80 # http acl Safe_ports port 21 # ftp acl Safe_ports port 443 # https acl Safe_ports port 70 # gopher acl Safe_ports port 210 # wais acl Safe_ports port 1025-65535 # unregistered ports acl Safe_ports port 280 # http-mgmt acl Safe_ports port 488 # gss-http acl Safe_ports port 591 # filemaker acl Safe_ports port 777 # multiling http acl CONNECT method CONNECT #http_access allow manager localhost #http_access allow wan #http_access deny manager http_access deny !Safe_ports http_access deny CONNECT !SSL_ports #http_access deny all http_reply_access allow all icp_access allow all maximum_object_size 4096 KB coredump_dir /usr/local/squid/var/cache
After the configuration of squid.conf, run #/usr/local/squid/sbin/squid -z to create the swap directories etc. According to this configuration you should have the following structure:
#tree -a -f -L 1 /usr/local/squid/usr/local/squid |-- /usr/local/squid/bin |-- /usr/local/squid/etc |-- /usr/local/squid/libexec |-- /usr/local/squid/man |-- /usr/local/squid/sbin |-- /usr/local/squid/share `-- /usr/local/squid/var#tree -a -f -L 2 /usr/local/squid/var/usr/local/squid/var |-- /usr/local/squid/var/cache | |-- /usr/local/squid/var/cache/00 | |-- /usr/local/squid/var/cache/01 | |-- /usr/local/squid/var/cache/02 | |-- /usr/local/squid/var/cache/03 | |-- /usr/local/squid/var/cache/04 | |-- /usr/local/squid/var/cache/05 | |-- /usr/local/squid/var/cache/06 | |-- /usr/local/squid/var/cache/07 | |-- /usr/local/squid/var/cache/08 | |-- /usr/local/squid/var/cache/09 | |-- /usr/local/squid/var/cache/0A | |-- /usr/local/squid/var/cache/0B | |-- /usr/local/squid/var/cache/0C | |-- /usr/local/squid/var/cache/0D | |-- /usr/local/squid/var/cache/0E | |-- /usr/local/squid/var/cache/0F | `-- /usr/local/squid/var/cache/swap.state `-- /usr/local/squid/var/logs |-- /usr/local/squid/var/logs/access.log |-- /usr/local/squid/var/logs/cache.log |-- /usr/local/squid/var/logs/squid.pid `-- /usr/local/squid/var/logs/store.log
Starting squid
After all the preparation, then we modify the /etc/rc.d/rc.local file to make squid running automatically while booting the system:
# squid
if [ -x /usr/local/squid/sbin/squid ]; then
echo -ne "Starting squid ...\n"
echo -ne "\t\tHTTP Proxy Server: 222.195.148.225\n"
echo -ne "\t\tPort: 3128\n"
/usr/local/squid/sbin/squid
Ok, enjoy!
Fri, 2006-12-15 17:32:41 +0800
FTP server with a 200GB harddisk using vsftpd
I have seted up the vsFTPd server with this HowTo that I written. However, I indeed met some problems while setting up a FTP server with a 200GB harddisk using vsftpd.
Harddisk Partition
First I have partitioned the harddisk as follows:
+------------------------------------+ | hda1 | hda2 | hda3 | hda4 | | /boot | Linux Swap | / | N/A | | 100MB | 777MB | others | 10GB | +------------------------------------+
Unfortunately hda3 which is the root partition and is bigger than 180GB got some error while booting the system, then I adjusted the partitions as follows:
+-----------------------------------+ | hda1 | hda2 | hda3 | hda4 | | / | Linux Swap | /home | N/A | | 10GB | 777MB | others | 10GB | +-----------------------------------+
Then I got the result I want and everything was ok.
I installed Slackware Linux 11.0 with the default installation of vsftpd-2.0.5-i486-1.tgz, then I put the same configuration as my vsftpd HowTo. However I got the error like:
OOPS: vsftpd: refusing to run with writable anonymous root
At last, I found the reason of this problem that I always have the following permission of the directory /home/ftp:
drwxr-xr-x 4 flyzhy ftp 96 2006-09-08 12:07 ftp/
It's OK with this permission of this directory, however, if I changed the owner to ftp which is like:
drwxr-xr-x 4 ftp ftp 96 2006-09-08 12:07 ftp/
I got the above error again, at last I changed the permission of this directory to:
dr-xr-xr-x 4 ftp ftp 96 2006-09-08 12:07 ftp/
and everything went to ok, so it's not permitted to have the writable permission if you want someone login your ftp anonymous, also change the permission mode of /ftp/incoming to 777 to let anonymous to upload files.
Here lists the /etc/vsftpd.conf file without the comment lines:
anonymous_enable=YES local_enable=YES write_enable=YES local_umask=022 anon_upload_enable=YES anon_mkdir_write_enable=YES anon_umask=022 dirmessage_enable=YES message_file=.message xferlog_enable=YES connect_from_port_20=YES xferlog_file=/var/log/vsftpd.log xferlog_std_format=YES ftpd_banner=Welcome to OUC-IPL-FTP. ls_recurse_enable=YES listen=YES
Also, if you want to limit the max number of clients and per ip as well as the speed, add the following lines to /etc/vsftdp.conf:
#max_clients=NUMBER #max_per_ip=NUMBER # #anon_max_rate=NUMBER #local_max_rate=NUMBER # bytes #anon_max_rate=5000000 #local_max_rate=5000000
At last, add some lines to /etc/rc.d/rc.local to let the system run vsftpd while booting:
# /etc/rc.d/rc.local
# vsftpd
if [ -x /usr/sbin/vsftpd ]; then
echo -ne "Starting vsftpd ...\n"
/usr/sbin/vsftpd &
fi
After starting the vsftpd program, you can let the system user login the FTP using their own user and password, that would login to their own HOME in the system and also have all the permissions there.
OK, enjoy the FTP world now!
Wed, 2006-12-06 12:54:42 +0800
Linux Kernel is updated to 2.6.19
I realized that the Linux kernel is updated quickly these days, I do not know what wrong with version 2.6.18, however, I got something weired about this version while compiling for supporting Conexant USB ADSL Modem. Luckily it's updated to the better version 2.6.19 and it looks better than before.
Fri, 2006-11-24 16:15:39 +0800
Add static route in GNU/Linux and Microsoft Windows
Sometimes you need to set up multiple routes for your network to access some particular section of ip address using another route. For example, you always use 192.168.0.254 as your default gateway, however, you need to access all the 211.64.*.* addresses via 192.168.0.253 gateway. Change the default route can do this, however, it's boring to change this times and times. Therefore, here gives the perfect solution for GNU/Linux environment as well as Microsoft Windows environment.
- GNU/Linux
- Just use the following commands to add a route:
/sbin/route add -net 211.64.0.0 netmask 255.255.0.0 gw 192.168.0.253
which means to use 192.168.0.253 as its gateway and 255.255.0.0 as its netmask while accessing all the 211.64.*.* ip addresses. Put the above line into your /etc/rc.d/rc.local file to make this occured automatically followed the starting up of the system. - Microsoft Windows
- Click Start then Run and type
cmdand press ENTER followed, and type the following command:route -p add 211.64.0.0 mask 255.255.0.0 192.168.0.253
which is the same meaning as above except that the option -p makes the result permanently effective.
Check out the details for using the command route could be more helpful.
Fri, 2006-11-17 19:29:24 +0800
Burn Flow of FS2410DEV V5.00 From UDragon
There are two ways to burn bootloader, kernel and file system respectively to FS2410DEV V5.00 embedded board which are the following.
First of all, you should install the GIVEIO driver before you burn anything using sjf2410.exe tool. You need two files which are giveio.inf and giveio.sys to do this as follows. (Here I take Microsoft Windows XP as an example)
- Copy GIVEIO.sys file to C:\WINDOWS\system32\drivers\;
- Select the options as follows:
Start -> Control Panel -> Add/Remove Hardware
then a windows appear and click 'Next' to continue:- Choose 'Yes, I have already connected this hardware(Y)' and then click 'Next'
- Choose 'Add a new hardware device' and then click 'Next'
- Choose 'Install the hardware that I manually select from a list(Advanced)' and then click 'Next'
- Choose 'Show all devices' and then click 'Next'
- Click 'Have Disk...'
- Click 'Browse'
- Select giveio.inf file and click 'Open'
- Back to 6st step and then click 'OK'
- Click 'Next'
- Click 'Next'
- Click 'Continue anyway'
- Click 'Finish'
- That's ok to complete installation of GIVEIO driver.
Here explain the two different ways.
Burn 'u2410mon.bin' to 'SST39VF160' Nor Flash
- Connect the Power cable and JTag cable from board to PC;
- Take off the Jumper on the core board to make Nor Flash booting;
- Enter into the DOS mode by 'Start -> Run -> "cmd"' and change directory to the location contains sjf2410.exe and u2410mon.bin from the CD provided by UDragon and type
>sjf2410.exe /f:u2410mon.bin - Then it will display the Flash you can burn as follows:
[SJF Main Menu] 0:K9S1208 prog 1:28F128J3A prog 2:AM29LV800 prog 3:SST39VF160 prog 4:Memory Rd/Wr 5:Exit
Choose 3 to burn u2410mon.bin to Nor Flash SST39VF160; - Then
Available Target Offset: 0x0, 0x40000, 0x80000, 0xc0000 0x100000, 0x140000, 0x180000, 0x1c0000 Input Target Offset:
Type 0 to begin at 0x0; - Wait for a while to write and reset the board to boot from u2410mon.bin in Nor Flash (make sure to take off the Jumper on the core board);
- Before boot from the Nor Flash, open DNW.exe and configure the serial port options first (115200 8N1 0x30800000);
- Connect USB cable first and select 'USB Port -> transmit' on interface of DNW.exe while booting from Nor Flash and it will ask for installing driver for the new device connected by USB cable automatically;
- Then copy secbulk.sys to 'C:\WINDOWS\system32\drivers\' and click 'Next' to continue by the prompting until to the 'Finish' button;
- At last Download and Burn kernel and file system to NAND Flash by USB port or Serial port according to the prompt of DNW.
Burn '2410bios.bin' to 'K9S1208' Nand Flash
- Connect the Power cable and JTag cable from board to PC;
- Keep the Jumper on the core board to make Nand Flash booting;
- Enter into the DOS mode by 'Start -> Run -> "cmd"' and change directory to the location contains sjf2410.exe and 2410bios.bin from the CD provided by UDragon and type
>sjf2410.exe /f:2410bios.bin - Then it will display the Flash you can burn as follows:
[SJF Main Menu] 0:K9S1208 prog 1:28F128J3A prog 2:AM29LV800 prog 3:SST39VF160 prog 4:Memory Rd/Wr 5:Exit
Choose 0 to burn 2410bios.bin to Nand Flash K9S1208; - Then
K9S1208 is detected. ID=0xec76. 0:K9S1208 Program 1:K9S1208 Pr BlkPage 2:Exit
Type 0 to begin to write; - Wait for a while to write and reset the board to boot from 2410bios.bin in Nand Flash (make sure to keep the Jumper on the core board);
- Before boot from the Nand Flash, open DNW.exe and configure the serial port options first (115200 8N1 0x30800000);
- Connect USB cable first and select 'USB Port -> transmit' on interface of DNW.exe while booting from Nor Flash and it will ask for installing driver for the new device connected by USB cable automatically;
- Then copy secbulk.sys to 'C:\WINDOWS\system32\drivers\' and click 'Next' to continue by the prompting until to the 'Finish' button;
- At last Download and Burn kernel and file system to NAND Flash by USB port or Serial port according to the prompt of DNW.
Summary
The summary of the two ways:
Take off Jumper from core board Keep Jumper from core board
| |
\|/ \|/
GIVEIO driver installation GIVEIO driver installation
| |
\|/ \|/
Burn u2410mon.bin to Nor Flash Burn 2410bios.bin to Nand Flash
| |
\|/ \|/
USB device driver installation USB device driver installation
| |
\|/ \|/
USB or Serial transmit kernel and fs USB or Serial transmit kernel and fs
| |
\|/ \|/
Burn to Nand Flash Burn to Nand Flash
Fri, 2006-11-10 16:42:25 +0800
An Example of Sed Usage for multiple lines
This is an example of sed usage for one of my friends. I am shamed that I forgot a lot of knowledge about shell I have learned before
. However, I did solved the problem he met, and here is the question.
There are a batch of .c and .h files which like this:
this is a test for\
this kind of processing\
pa ok.\
this ok.\
tst\n fine.\
this
ok
Here want to delete the \ characters and spaces or TABs at the end of a line with the spaces or TABs at the beginning of the following line. The resulting output for the above example will be the following.
this is a test forthis kind of processingpa ok.this ok.tst\n fine.this ok
Then I wrote a bash script to get to this point and put the output to a new file named the original file followed by a .tmp suffix.
#!/bin/bash
# Usage: delete the \ characters and spaces or TABs at the end of a line
# with the spaces or TABs at the beginning of the following line.
# by Haiyong Zheng
# Email: flyzhy.org@gmail.com
echo -ne "Processing files in the following directory ...\n"
for i in $(ls)
do
sed -e :a -e '/\\\ *$/N;s/\\\s*\n\s*//;ta' ${i} > ${i}.tmp
done
if [ $? -gt 0 ]; then
echo -ne "Something wrong happened, check out pls.\n"
exit 1
else
echo -ne "Done.\n"
fi
After running this script in the directory which contains the files you want to do the operations above, you can copy all the .tmp files to another place, and use the following script to change the name back to the origin.
#!/bin/bash
# Usage: remove all the suffix .tmp for files of the current directory.
# by Haiyong Zheng
# Email: flyzhy.org@gmail.com
echo -ne "Processing files in the following directory ...\n"
pwd
for i in $(ls *.tmp)
do
mv ${i} `basename $i .tmp`
done
if [ $? -gt 0 ]; then
echo -ne "Something wrong happened, check out pls.\n"
exit 1
else
echo -ne "Done.\n"
fi
That's not the most convinient way to solve the problem, therefore, I will modify the script to make it more convinient for users. However, this can be fine to use for the moment.
Tue, 2006-11-07 00:06:40 +0800
Complete Gphoto2 Solution for Kodak C360 on GNU/Linux
It spent me an afternoon and a night to solute the Kodak C360 on GNU/Linux completely, here is the enventual fruit.
- First, make sure that you have something related to USB compiled in your kernel or moduled.
Device Drivers ---> SCSI device support ---> --- SCSI support type (disk, tape, CD-ROM) <*> SCSI disk support # for USB Mass Storage USB support ---> <*> Support for Host-side USB [*] USB device filesystem # for USB devices in /proc/bus/usb/ directory --- USB Host Controller Drivers <*> EHCI HCD (USB 2.0) support <M> OHCI HCD support # use 'lspci|grep USB' to check <*> UHCI HCD (most Intel and VIA) support # it is OHCI or UHCI <*> USB Mass Storage support --- USB Input Devices <*> USB Human Interface Device (full HID) support [*] HID input layer support - Second, make sure the usb file system is automatically mounted while the system starting up.
# /etc/fstab none /proc/bus/usb usbfs defaults 0 0
or you can mount it do the following manually
then use the command#mount -t usbfs none /proc/bus/usblsusbto check the information about USB likeBus 001 Device 002: ID 0d8c:000c C-Media Electronics, Inc. Audio Adapter Bus 001 Device 001: ID 0000:0000
which means that you got your USB devices from /proc/bus/usb/devices. - Third, you should install the libghoto2 and gphoto2 downloaded from Gphoto.Org. Choose the latest version that it holds and do the following
it's noted that if you are using Kodak C360, although it is contained in the list of supported cameras which means you can choose the option --with-drivers=kodak while configuring#tar xvfj libgphoto2-VERSION.tar.bz2#cd libgphoto2-VERSION#./configure --with-drivers=xxx#make && make install#ldconfig#tar xvfj gphoto2-VERSION.tar.bz2#cd gphoto2-VERSION#./configure#make && make installlibgphoto2, it still indicated that you can not use this option while just left it alone using the default or --with-drivers=all to make it recognized by libgphoto2. - At last, connecting your DC with the PC and enjoying
#gphoto2 --list-portsDevices found: 4 Path Description -------------------------------------------------------------- ptpip: PTP/IP Connection usb: Universal Serial Bus usb:001,006 Universal Serial Bus usb:001,002 Universal Serial Bus#gphoto2 --auto-detectModel Port ---------------------------------------------------------- Kodak C360 usb: Kodak C360 usb:001,006#gphoto2 --list-files# list all the files in your camera#gphoto2 --get-all-files# download all the files#gphoto2 --get-file 7-13# choose specified files to download
This proved again that where there is a will, there is a way.








