Tag Archives: linux

Selinux prevents httpd from accessing home directory

I tried to share files via httpd(Apache originally), however it wouldn’t work, saying 403 forbidden.
Apparently we need to set options to permit httpd to follow symbolic links. In /etc/httpd/conf/httpd.conf, ensure there is text below:

(Under <Directory “/var/www/html”>, there should be)
Options Indexes FollowSymLinks MultiViews

But the problem remained. After quite a while I noticed there were some Selinux alerts saying “SELinux is preventing the http daemon from reading users’ home directories.”

Then I disabled selinux(command “setenforce 0” to make it sleep temporarily) and it worked. As Selinux is a kernel-level security mechanism on your system, not a some antivirus or firewall software thing, it may not be wise to throw it away. Check Joshua Brindle (an SELinux developer) ‘s  comments on disabling SELinux here, which states clearly that applications should be fixed to work with SELinux, rather than disabling the OS security mechanism.

So what I do is:

1. According to Selinux log(you can generate it with command “sealert -a /var/log/audit/audit.log”, run “setsebool -P httpd_enable_homedirs on” to enable the literal option(this command takes 20 secs to be done I don’t know why).
2. Still doesn’t work, after some googling I found this, run “chcon -t httpd_user_content_t /home/Viaxl/Music -R” to authorize world rx permissions to apache access (recursively) .

Now they all work right. I found this kind of multi-layer protection, though very complex, is really handful. In this case I only permit http daemon(as a “Target” of Selinux’s conception) to access my Music folder, and this can’t be done precisely by chmod or something.

Linux访问Windows共享 && mplayer播放网络文件

mplayer播放网络文件会顿/卡/lag的情况

大笔记本上装的固态硬盘空间严重紧张,一般都是用小本下电影,小本在学校接了个24寸液晶电视看电影很给力,但是在家还是用大本的屏幕看吧… 实现起来一直困扰我的问题是我最爱用的播放器mplayer在放网络上的文件时会卡,隔一会顿一下,跟tm iPad似的(iPad放除了苹果本来支持的意外的格式–即用第三方解码器–总是会卡,怀疑是苹果故意这么干的…没研究过瞎说的)。之前是放弃用mplayer今天心情好Google了一下,发现有 -cache 这个参数,就是缓存啦,加上 -cache 8192 果断就不卡了。也不能怪我没看那八百页的manual…

本来就想说这,但既然提了我就把容易遇上的问题说全乎了吧,方便出现各种问题Google进来的同学们。(改了一下标题)

怎么mount windows的NTFS分区

需要注意的是之前用来接口NTFS格式的samba现在已经不用了,现在用一个叫cifs的东西… CIFS: Common Internet File System,看名字就知道比什么叫“桑巴”的牛逼 🙂
具体实现为:

mkdir /mnt/[dicname]
mount -t cifs -o username=uuuuuuu,password=xxxxxxx //192.168.1.100/[sharename] /mnt/[dicname]

然后关于mplayer字幕的问题

mplayer的字母乱码(或者下划线)上次也让我蛋疼过一次,好不容易弄明白时隔半年我又忘了又蛋疼了一次。
关键点在于… -font后面写的字体不是字体的路径,不是 /usr/share/fonts/xx..xx ,而是字体的名字,比如 -font “WenQuanYi Zen Hei” (由 fc-list 列出)。可能之前的版本是路径吧Google全写的路径…
有三个需要填的 -sub [字幕路径] -sub [字幕编码] -font [字体名称],如下:

mplayer *CD1* -sub 1.gbk.srt -subcp gbk -font “WenQuanYi Zen Hei” -cache 8192

-cache作用见文首。并不用像很多地方说的要把字幕文件通过 iconv 转成cp936格式,只要-subcp写对了就行。
貌似可以在 ~/.mplayer/config 中设置来不用每次都打一长串,但是我不敢在没有配置文件的情况下再忘掉这怎么工作的了 = =

Network Programming Using Internet Sockets

Socket网络编程略窥一二.. 网络原理课的课程设计

完全是看这篇文章学的, 貌似有中文版但是我点不进去
就不说两句了, 底层的东西, 全是细节, 非要概括的话可以引用原文第五章的小标题来描述这个过程

5.1. getaddrinfo()—Prepare to launch!
5.2. socket()—Get the File Descriptor!
5.3. bind()—What port am I on?
5.4. connect()—Hey, you!
5.5. listen()—Will somebody please call me?
5.6. accept()—”Thank you for calling port 3490.”
5.7. send() and recv()—Talk to me, baby!
5.8. sendto() and recvfrom()—Talk to me, DGRAM-style
5.9. close() and shutdown()—Get outta my face!

我的代码, 这是linux的, windows有点小不一样, 我不知道 :): Continue reading

网站/WordPress从虚拟主机搬家到VPS上

拖了一个月终于着手并且完成了。其实没有什么难的。但是因为我对Linux的了解非常局限,还是花了一番功夫,同时学了很多东西,在这里记一下。没有试图写一篇“手把手教你搬WP”,只是记录一些我觉得有帮助的东西,希望做同样的事情的且同样不是那么牛逼的Linux学习者们有用:)

虽说是WordPress搬家,但是任何一个小型网站搬家都差不多这样了吧,嘿嘿。

如果用cPanel和MySQLAdmin之类的东西可能就很傻瓜,但是第一cPanel太贵了(竟然要425多刀一年,我都笑了),第二VPS都买了必须必须要抓住每一个学Linux的机会啊。

过程如下(断断续续弄了好几天…): Continue reading

爱普生ME-30的Linux驱动, Using Epson ME-30 in Linux (Driver!)

每次想把这破玩意用起来都老费事了
Ubuntu下自动找到的驱动没用, 一切运行行云流水, 提示”processing”有模有样, 打印机也动, 灯还闪, 但是就是不进纸 -_,-

搜了一下在这里下到驱动, 有For Ubuntu 8.04的, 我目前是10.10测试OK, 唯一要注意的是安装结束提示是否设置成默认打印机, 勾选也没用, 自己手动设置一下

Every time I want to use this stupid thing it causes so much trouble
Ubuntu can find driver for it automatically which doesn’t work. Everything went fine, I was notified printing is “Processing”, and the printer also made sounds with its LED blinking, except that the paper wouldn’t go in XD

So I googled and found driver HERE. Have one for Ubuntu 8.04 (I’m 10.10 and it works fine to me). The only thing you should notice is that when the installing ends it asks whether to set ME30 to be default printer, which doesn’t work even you check it. So set it manually.

Update:
Okay… There is an issue when I tried to print images.
1. Can’t print photo, maybe too complex to render…
2. simple image can be printed, like THIS, but the color is.. not only distorted, also like toxic..

我打印图片的时候有问题..
1. 照片打印不能, 可能对于这个驱动来说渲染这么复杂的东西让它不堪重负..
2. 简单的图片可以印出来, 比如这个,  但是颜色不仅失真了而且像中毒了一样..花里糊哨的

恢复被覆盖的MBR实现多系统引导 (在linux之后安装windows)

Windows的安装会覆盖linux的MBR, 看了看关于Grub2(linux使用的引导系统)的文档后发现Grub2可以非常方便的生成启动菜单

首先我们要进到Linux, 弄个LiveCD或者U盘引导的Linux系统盘引导进Linux(不是硬盘上的Linux).
接着执行以下步骤来恢复原Linux的MBR+Grub2 (需要root权限)

1. fdisk -l 查看本硬盘上的分区, 根据大小和文件系统大概可以判断原来的根目录/在哪个分区. 设为/dev/sdXY

2. mount /dev/sdXY /mnt

3. grub-install –root-directory=/mnt/ /dev/sdX    这样就写入Grub2和MBR了 , (注意root前面是两条扛, 我这版式有问题)

更详细点这里

重启进原Linux, sudo update-grub, 如果有”Found Windows 7 (loader) on /dev/sdxx” 就ok了.

如果不行需要自己加入Windows的引导. 我update-grub后就直接找到了win7系统, 但是下面的方法我试过且成功了.

先记一下Grub2的文件结构:

/boot/grub/grub.cfg
取代Grub1的/boot/grub/menu.lst, 最大区别是grub.cfg不应该被修改(虽然你可以), 防止出错. 这个文件是由update-grub生成的

/etc/default/grub
配置文件, 原来menu.lst里改的 现在在这里改

/etc/grub.d/
update-grub所使用的脚本, 包括菜单的外观, 以及在各个分区上寻找各种系统自动加入update-grub的脚本等等.
目录下有文件00_header 05_debian_theme 10_hurd 10_linux 20_memtest86+ 30_os-prober 40_custom, 更详细的说明点这里

其中40_custom是我们需要的, 往文件末端加入

menuentry "Windows" {
set root=(hd0,3)
chainloader +1
}

其中hd0就是sda, 如果你是sdb那就是hd1以此类推, 3是sda3的3. 这个sda3要说明一下, 用fdisk -l列出分区表, 我们要找的不是windows的安装分区, 而是它上面一个100M的分区, 这是windows单独分出来用来引导的. 我的sda3是100M, 所以这里填(hd0,3). 如果没有100M的分区那就按windows分区算吧, 至少win7默认安装是100M这样.

保存后别忘update-grub, OK

[SOLVED] pppoe connection automatically terminated after a few minutes

I’m using Ubuntu Lucia in dorm, the network always automatically disconnected  after a few minutes like:

root@VanXL:/etc/ppp/peers# plog
May 19 13:30:53 VanXL pppd[3087]: Connect: ppp3 <–> wlan0
May 19 13:30:53 VanXL pppd[3087]: Remote message: Authentication success,Welcome!
May 19 13:30:53 VanXL pppd[3087]: PAP authentication succeeded
May 19 13:30:53 VanXL pppd[3087]: peer from calling number 00:18:82:60:CA:A5 authorized
May 19 13:30:53 VanXL pppd[3087]: not replacing existing default route through ppp1
May 19 13:30:53 VanXL pppd[3087]: Cannot determine ethernet address for proxy ARP
May 19 13:30:53 VanXL pppd[3087]: local  IP address 114.230.98.44
May 19 13:30:53 VanXL pppd[3087]: remote IP address 114.230.96.1
May 19 13:30:53 VanXL pppd[3087]: primary   DNS address 61.147.37.1
May 19 13:30:53 VanXL pppd[3087]: secondary DNS address 61.177.7.1
root@VanXL:/etc/ppp/peers# plog
May 19 13:31:08 VanXL pppd[1996]: remote IP address 218.91.20.1
May 19 13:31:08 VanXL pppd[1996]: primary   DNS address 61.147.37.1
May 19 13:31:08 VanXL pppd[1996]: secondary DNS address 61.177.7.1
May 19 13:31:20 VanXL pppd[2716]: No response to 4 echo-requests
May 19 13:31:20 VanXL pppd[2716]: Serial link appears to be disconnected.
May 19 13:31:20 VanXL pppd[2716]: Connect time 3.5 minutes.
May 19 13:31:20 VanXL pppd[2716]: Sent 11128 bytes, received 10199 bytes.
May 19 13:31:27 VanXL pppd[2716]: Connection terminated.
May 19 13:31:27 VanXL pppd[2716]: Modem hangup

Network works fine when i use ChinaNet so i didn’t suppose this to be a hardware (or driver) problem.

and i noticed the “4 echo-request”. after googling, this appears to be a bug.

The other side of the PPP link probably dosen’t support LCP echo. You often see this with cellphone / cellular data card PPPoE implementations.

Put this line in the relevent ppp options file and try again:
lcp-echo-interval 0

(http://superuser.com/questions/109146/ubuntu-pppoe-connection-timeout)

Also you can completely disable this in /etc/ppp/options (search “echo”) if you find it worth nothing like me 😉

The network works perfectly now

东芝T110 征服屏幕亮度

按照上一篇日志中的方法来的, 开始怎么都不成功, 然后对grub2进行了一些探索.. (文档 http://ubuntuforums.org/showthread.php?t=1195275 )我的机器上好像有bug, 无论如何update-grub都无法更新\boot\grub\grub.cfg. 这个问题是我试图更新kernel的时候发现的. 也可能是我kernel没有编译好, 但是怎么会在/etc/default/grub里加指令也不更新grub.cfg呢.. 还是觉得是bug

我的方法写在了 http://swiss.ubuntuforums.org/showthread.php?p=8767786#post8767786 这个贴子的17楼
Gnome和KDE都能完美工作~ =D

东芝T110装Ubuntu死机的问题

终于行得通了..

关键字: 东芝 T110 T115 Ubuntu 乌邦图 死机

Google进来的同学们.. 你们太走运了 你们不知道这篇文档给你们省去多少麻烦..
这个机器安装或者进入Ubuntu的时候会出现Kernel Panic
内容是

[17.529523] Kernel panic – not syncing: HwThreeWire(): CmdReg: 0XFF RE|WE bits are not clear!!
[17.529525]
[17.544365][drm:intelfb_panic] *ERROR* panic occurred, switching back to text console

我Google到了这篇帖子, 和我的机型一样, 问题一样, 并且只有这一个类似结果, 看来东芝是罪魁祸首 (也因为这型号太新了不好兼容), 死机原因是WLAN卡的驱动. 目前还没有找到不会导致Kernel panic的驱动, 他用的是方案是 ndiswrapper + the MSI version of the Windows Driver , Ndiswrapper的用处是在linux下使用Windows的网卡驱动

步骤:

首先要在BIOS下把WIFI禁用掉, 就可以成功安装进入系统了. 然后在 /etc/modprobe.d/blacklist 文件底部加上blacklist rtl8187se 阻止系统使用自带驱动(一用就崩溃).

然后安装ndiswrapper, 不要用apt-get, 有BUG, 请自己下载source来编译.. 详见我的这个帖子(4楼)
引用一下吧 防止丢了..

这是个BUG, [url=http://www.societyofrobots.com/robotforum/index.php?topic=9813.0]这个帖子[/url]的二楼提出了修复此bug的办法

[quote]Well, I fixed the ndiswrapper problem. Turns out to be a bug in the software.
open ntoskernel.h file inside ndiswrapper-1.55/driver and then change the line 878 as follows (31 is changed to 32)
old line:
Code:
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)
new line:
Code:
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)[/quote]

即把ndiswrapper-1.55/driver/ntoskernel.h这个文件的878行作上面的修改就能成功编译了

有的同学说 你为什么不直接apt-get呢, 答案是, 直接编译的版本也有bug.. 我试了, 在[url=https://help.ubuntu.com/community/WifiDocs/Driver/Ndiswrapper]这篇文档[/url]的2.2.1下面有声明.. 不创建kernel模块, 会导致error FATAL: Module ndiswrapper not found when you run modprobe ndiswrapper

装好以后加载上面的那个驱动(ndiswrapper如何使用详见Ubuntu官网的文档) 接着 reboot 再
depmod -a && modprobe ndiswrapper
基本就可以了

WPA貌似不能用, WEP我还没试出来… 但是看人家说的可以用WEP
并且有一个方法是在这里11楼提到

1) 每次开机前先用ndiswrapper加载驱动(必须)
2) sudo rmmod ndiswrapper
3) sudo modprobe rtl8187se

这样就可以用自带驱动了, 很邪门, 但是为什么呢? 作者表示 “Don’t ask me why this works, it just does.”

下面要解决的问题是.. 屏幕亮度不能调, 插耳机外放不关.. 全是驱动问题..天啊

UPDATE:
完美运行!!

环境是KDEdesktop (好像和这个有点关系 以前也是) 原来怎么都连不上 换了上面那个驱动以后完美运行 WPA无误~~ ^^

UPDATE:
rmmod ndis/modprobe rtl以后也无误运行 真不错啊 lucky~ (呸)

看到KDE觉得这才是Ubuntu啊.. ghone(是叫这个么) 太丑太难用了..菜B     KDE大虎逼!