ubuntu karmic 下关闭笔记本触摸板的办法

Posted 2 years, 4 months ago at 9:26 pm. 5 comments

此问题困扰3月有余,笔记本打字总是碰到触摸板,所以我一直关掉,用小鼠标。但升级 karmic 后鼠标设置中没有关掉触摸板选项,看了文章若干,都是在 xorg 折腾,终于找到最简单的办法

#!/bin/sh
if xinput list-props "SynPS/2 Synaptics TouchPad" | grep "Device Enabled" | grep 1
then
modprobe -r psmouse
else
modprobe psmouse
fi

以上代码另存为 toggleTouchpad.sh,然后加执行权限

sudo chmod +x toggleTouchpad.sh

每次执行,关闭或者打开触摸板。

linux 学习笔记

Posted 3 years, 2 months ago at 9:00 am. 0 comments

限制 ssh root 登录和尝试次数

vi /etc/ssh/sshd_config

# #LoginGraceTime 2m
# PermitRootLogin no
# #StrictModes yes
# MaxAuthTries 4

解压 .7z 文件

sudo apt-get install p7zip
p7zip -d putyourfilename.7z

-d : decompress

mysql 备份

mysqldump -u user -p [database] > database.sql

Securing your PHP with Suhosin

1) Grab Suhosin source from the web

user#wget -c http://download.suhosin.org/suhosin-0.9.27.tgz

2) Extract and compile

user#tar xzvf suhosin-0.9.27.tgz

user#cd suhosin-0.9.27

user#phpize

user#./configure

user#make

user#make install

3) Now add extension module in php.ini configuration

user#vi /etc/php.ini

extension=suhosin.so

4) Restart your web server

user#service httpd restart

5) Check your php version to indicates that Suhosin is there

user#php -v
PHP 5.1.6 (cli) (built: Jul 16 2008 19:53:00)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies
with XCache v1.2.2, Copyright (c) 2005-2007, by mOo
with Suhosin v0.9.27, Copyright (c) 2007, by SektionEins GmbH

scp 比 ftp 安全

scp file.txt user@domain.com:/home/user

Wine 不显示中文的解决办法

Posted 3 years, 2 months ago at 8:59 am. 0 comments

其实就是没有中文字体而已…

打开 /usr/share/fonts/truetype/wqy

WQY 字体拷贝到 /home/guoshuang/.wine/drive_c/windows/Fonts

很久没有写ubuntu的日志了

Posted 3 years, 2 months ago at 4:36 pm. 1 comment

其实是一年整了,自从blog搬家从 asp 转 php,换服务器,分站点之后,一直都没在这里写东西。其实在

http://wiki.guoshuang.com/Special:Search/Ubuntu

有一些。半瓶子总是逛荡…少写一点,可以多看一些,:)

一直用 mintlinux 多一些,刚开始是为了好看,受限制驱动默认就有等缘故。一旦牵扯到 www 开发还是 linux 方便本地测试。做图和打游戏、看带字幕的电影则常常回到 win,毕竟 wine+opengl 图显示老是怪怪的。

BTW:firebug 确实不错,刚才调整这里的 css,要不是firebug,很难找到少了一个 </div>,:)

ubuntu 安装时提示“正在等待报头” waiting for headers

Posted 3 years, 10 months ago at 12:40 pm. 2 comments

可能是因为某次 update 或者apt-get install 时间太长被我中断的缘故,安装 sql 时总是报告 0% 正在等待报头…

本来以为是源的问题,但换了几个源都是如此。

sudo nautilus

找到 /var/cache/apt/archives 目录,删掉除了(partial目录的所有文件),重新 update 安装即可。

可能是因为不完整包的原因。

修改 ubuntu 分区,增加空间

Posted 3 years, 11 months ago at 3:19 pm. 0 comments

一开始分区是 / 3G,/home 大约12G,很快发现系统 3G 空间根本不够!

df -h

查看空间使用情况。

用 ubuntu 安装盘(livecd)启动,系统-系统管理-分区编辑器,实际上就是

sudo gparted

resize 分区即可。需要一些时间。如果还有其它 linux 系统也可以在那里修改分区,前提是必须将此分区 unmount。

ubuntu 安装多媒体支持

Posted 3 years, 11 months ago at 3:12 pm. 0 comments

再也不需要东找西找了,加入这个 Medibuntu 源就行了。主要是 win32codecs

https://help.ubuntu.com/community/Medibuntu

然后

安装多媒体解码器,输入命令

* Xine多媒体引擎解码器

sudo apt-get install libxine1-ffmpeg libxine1-all-plugins libxine1-plugins w32codecs gcc-3.3-base libstdc++5

* Gstreamer多媒体引擎解码器

sudo apt-get install gstreamer0.10-ffmpeg gstreamer0.10-pitfdll gstreamer0.10-plugins-bad gstreamer0.10-plugins-bad-multiverse gstreamer0.10-plugins-ugly gstreamer0.10-plugins-ugly-multiverse gstreamer0.10-esd

* DVD影碟功能支持

sudo apt-get install libdvdnav4 libdvdread3 libdvdcss2

配置电影播放器

sudo apt-get remove totem-mozilla -y
sudo apt-get install smplayer smplayer-themes mozilla-mplayer

配置音乐播放器,输入命令

sudo apt-get install gstreamer0.10-fluendo-mpegdemux gstreamer0.10-gnonlin libflashsupport

grub 错误号码列表

Posted 3 years, 11 months ago at 11:37 am. 0 comments

1. Starting notes

Acknowledgements

Many thanks to Earthwings, penetrode, loyaltonone, pilla, airhead, nephros, yamakawa and all the others for the suggestions on the original thread.

Disclaimer warning

The examples provided are just examples. Be sure to change partition numbers and the like according to your systems specs. Follow the solutions provided by this document at your own risk.

2. Grub loading, please wait…

Situation

Code Listing 2.1: Grub output

GRUB loading stage 1.5
GRUB loading, please wait…

After this message, the system stops. If you attempt to boot the system using a grub floppy, the problem disappears.

Solution

According to The_Bell you could change the boot order in your BIOS.

Tell your BIOS to not boot from your floppy first.

penetrode wrote that this may also be due to bad CFLAGS settings. Although the current grub ebuild filters out -fstack-protector, it can’t hurt to recompile grub with clean CFLAGS if nothing else helps.

Code Listing 2.2: Using a clean CFLAG to rebuild GRUB

# CFLAGS=”-O2 -march=i686 -fomit-frame-pointer -pipe” emerge grub

3. Grub Error 12

Situation

Code Listing 3.1: Grub Output

12 : Invalid device requested.

This error is returned if the device strings syntax is correct but other than that, an error occurred that isn’t defined by any other error.

Solution

When you installed grub in your boot record using the interactive commands, did you execute the two lines below in the grub prompt?

Code Listing 3.2: Interactive installation commands

grub> root (hd0,0)
grub> setup (hd0)

(hd0,0) must be replaced with your boot partition and (hd0) with the HDD you have chosen. Remember that (hd0) will install the bootloader in the Master Boot Record of the first hard disk, the primary master.

4. Grub Error 15

Situation

This error can occur in two different stages of the GRUB configuration, either during the initial configuration (installing GRUB in the master boot record) or after booting the system and attempting to launch Linux (or any other entry).

Code Listing 4.1: Grub Output – Initial Configuration

grub> root (hd0,0)
Filesystem type is xfs, partition type 0×83

grub> setup (hd0)
Checking if “/boot/grub/stage1″ exists… no
Checking if “/grub/stage1″ exists… no

Error 15: File not found

Code Listing 4.2: Grub Output – Booting an Entry

Booting ‘gentoo Linux’

root (hd0,0)
Filesystem type is ext2fs, partition type 0×83
kernel (hd0,0)/boot/kernel-2.4.20 root=/dev/hda3 vga=792

Error 15: File not found
Press any key to continue…

Solution – Initial Configuration

This error is returned if the specified file name cannot be found, but everything else (like the disk/partition info) is OK.

Frequently, the error notes a missing kernel image file. Make sure that the file it is referring to exists on your boot partition.

To find out the exact name of your kernel, boot from the installation cd, mount your root and (if applicable) boot partition. Next, chroot into your Gentoo system and do a listing of the available files to see what kernel images you have available:

Code Listing 4.3: Verifying kernel image existence

# cd /boot
# ls

This will list all the kernels that you’ve got on your boot partition. If your kernel is missing make sure that you compiled a kernel (using genkernel or manually):

Code Listing 4.4: Recompile the kernel

# cd /usr/src/linux/
# make menuconfig
# make

And that you copied it to your boot partition:

Code Listing 4.5: Copying the kernel

# cp /usr/src/linux/arch/i386/boot/bzImage /boot

Verify that the name of the kernel is exactly the same as the one mentioned in your grub.conf file. Also make sure that the kernel line in your grub.conf file is referring to that partition (either explicitly or implicitly).

Another reported mistake is to have the BIOS ignore the disk on which the kernel or grub stages reside. Also, the partition on which grub stores its stages should not use a software RAID-5 (or other striping technology) configuration.

Solution – Booting an Entry

First, verify that the root and setup lines you have used are correct.

If you are certain they are valid, then you might be using a flawed GRUB version (0.93.20031222). Upgrade your Portage tree or mask this version of grub:

Code Listing 4.6: Masking Grub

(Execute this from within the chrooted environment)
# echo “=sys-boot/grub-0.93.20031222″ >> /etc/portage/package.mask
# emerge grub -p

You could also try to use the grub-install script as is recommended by the GRUB authors:

Code Listing 4.7: Using grub-install

(The –root-directory is needed if you are using a separate boot
partition,
otherwise you should leave it out)
# grub-install –root-directory=/boot /dev/hda

When all this fails, your boot partition may be corrupt. Check the partition for errors:

Code Listing 4.8: Checking a partition for errors

(Make sure the boot partition, /dev/hda1 in this case, is unmounted)
# fsck -y /dev/hda1

5. Grub Error 17

Situation

Code Listing 5.1: Grub Output

root (hd0,0)
filesystem type unknown partition type 0×7

Error 17 : Cannot mount selected partition

Solution

This error is returned if the partition requested exists, but the filesystem type cannot be recognized by GRUB.

Be sure to check your root(x,y) settings in your grub.conf.

Also, if you are trying to boot Windows, make sure that your grub.conf file has the root (hdX,Y) (or rootnoverify (hdX,Y)) and chainloader (hdX,Y)+1 in it.

6. Grub Error 18

Situation

Code Listing 6.1: Grub Output

kernel (hd1,4)/bzImage root=/dev/hdb7

Error 18: Selected cylinder exceeds max supported by BIOS

Solution

This error is returned when a read is attempted at a linear block address beyond the end of the BIOS translated area. This generally happens if your disk is larger than the BIOS can handle (512MB for (E)IDE disks on older machines or larger than 8GB in general).

Try an update for your BIOS and/or move your boot partition to the front (or at least into the appropriate range).

7. GRUB GRUB GRUB GRUB GRUB …

Situation

Code Listing 7.1: Grub Output

GRUB GRUB GRUB GRUB GRUB GRUB GRUB GRUB GRUB GRUB GRUB GRUB GRUB GRUB GRUB
GRUB GRUB GRUB GRUB GRUB GRUB GRUB GRUB GRUB GRUB GRUB GRUB GRUB GRUB GRUB

Solution

According to airhead this can be caused by having your bios detect your disks automatically. Try to set your bios entry to User Type HDD.

Another possibility is that you had Grub installed on your MBR and tried reinstalling it (for instance due to hard disk changes) but used the wrong setup and root commands.

8. Probing Devices to Guess BIOS Drives. This May Take a Long Time.

Situation

While trying to install grub, it hangs after displaying the following line:

Code Listing 8.1: Grub Output

# grub

Probing devices to guess BIOS drives. This may take a long time.

Solution

One reported cause was an exotic configuration of disk devices, like ultra/non-ultra DMA disks on one cable.

9. When Installing Grub, It Just Hangs

Situation

When installing grub, it hangs:

Code Listing 9.1: Grub Output

# grub
(At this stage, the installation stops)

Solution

If you haven’t got a floppy drive, have you used the –no-floppy switch?

Code Listing 9.2: Installing grub using the –no-floppy switch

# grub –no-floppy

10. Uncompressing Linux… Ok, booting the kernel.

Situation

The system hangs after displaying the following line:

Code Listing 10.1: Linux Output

Uncompressing Linux… Ok, booting the kernel.

Solution

Strictly speaking, this is no grub error. One possible cause is that ACPI is not working correctly but is enabled in the kernel. Try to disable it in your bios or in your kernel.

11. Grub Just Shows a Grub Prompt

Situation

When booting the system, you receive a grub prompt instead of a list of entries you have defined in your grub.conf file.

Solution

Mount your boot partition and verify if the grub/grub.conf file exists.

Code Listing 11.1: Mounting and verifying

# mount /dev/hda1 /mnt/gentoo/boot
# cat /mnt/gentoo/boot/grub/grub.conf

Also make sure that the menu.lst symbolic link exists:

Code Listing 11.2: Verifying the symbolic link

# ls -l /mnt/gentoo/boot/grub/menu.lst
lrwxrwxrwx 1 root root 9 Mar 7 14:00 /mnt/gentoo/boot/grub/menu.lst -> grub.conf

If not, recreate the symbolic link:

Code Listing 11.3: Recreating the menu.lst symbolic link

# cd /mnt/gentoo/boot/grub
# ln -snf grub.conf menu.lst

If this is the case, reinstall grub:

Code Listing 11.4: Reinstalling Grub

(Run from within the chrooted environment)
# grub-install –root-directory=/boot /dev/hda

12. Could Not Find Device For /boot/boot: Not Found Or Not a Block Device

Situation

When running grub-install during the GRUB installation, you receive the following error:

Code Listing 12.1: Grub Output

# grub-install –root-directory=/boot /dev/hda
Could not find device for /boot/boot: not found or not a block device

Solution

Check that you didn’t forget the following:

Code Listing 12.2: Updating the mtab file

# grep -v rootfs /proc/mounts > /etc/mtab

13. The System Reboots After Hitting Return At The Grub Menu

Situation

After hitting Return at the Grub menu during the system boot, the system reboots.

Solution

Try disabling framebuffer support in your kernel. If this does not help, disable APM and ACPI.

14. After Hitting Return At The Grub Menu, The Screen Blanks Out

Situation

After hitting Return at the Grub menu during system boot, the screen blanks out, but the system is responsive (for instance, your numlock led is switcheable).

Solution

Turn off framebuffer (typically remove vga=XYZ from your grub.conf) and check the processor architecture in your kernel config.

15. Missing Grub Image

Situation

When booting the system, you do not see that spify Gentoo splashscreen.

Solution

First of all check if the splashscreen file you are referring to in your grub.conf really exists. If that is the case, go and check the grub ebuild. Maybe the patch for the splash image is commented out in the version that you are using.

16. Failing To Boot Windows From a Second Harddrive

Situation

After selecting the Windows entry, the system refuses to boot without any clear reason as to why.

Solution

cyrillic informed us that you can “map” your disks in a different order by changing your grub.conf’s Windows entry like so:

Code Listing 16.1: Mapping disks

title Windows XP
map (hd0) (hd1)
map (hd1) (hd0)
chainloader (hd1,0)+1

17. Grub segfaults when trying to install

Situation

The situation described below is only relevant for grub-0.95.x at the moment of installing grub at the boot sector.

Code Listing 17.1: Installing Grub

grub> root (hd0,0)

grub> setup (hd0)

Segmentation fault

Solution

This is a known bug related to this problem and has been fixed in grub 0.96. It is also known that grub 0.94 r1 and grub 0.94 r2 should work correctly. If that fails too, you can try to emerge grub-static which is currently stable on amd64 and unstable on x86 (~x86). Check out bug #79378 for additional information.

proftpd 错误解决

Posted 3 years, 11 months ago at 9:19 am. 0 comments

ftp 经常连接不上,需要 sudo /etc/init.d/proftpd restart,但显示错误信息

- warning: unable to determine IP address of ‘btwww’
- error: no valid servers configured
- Fatal: error processing configuration file ‘/etc/proftpd/proftpd.conf’

一直以为 warning 和 Fatal 是两回事,但其实就是因为 /etc/hosts 文件中曾经修改过 btwww 的ip(后来注释掉了) ,sudo vim /etc/hosts 加入手工 dns 之后,一切正常。

PROC 文件系统工具

Posted 3 years, 11 months ago at 3:31 pm. 0 comments

proc 并非真正的文件系统,而是内核提供其进程表中的项目状态的方式 (例如,运行、停止或“僵死”)。软件包提供命令行和全屏界面工具,其中全屏工具需要 Ncurses。procps 的网站 http://procps.sf.net/ 上可以找到更多信息。

本软件包包括以下工具:top、uptime、tload、free、vmstat、watch、skill、pmap、 pgrep、slabtop 和 pwdx。

ad 468x60