linux下面关闭讨厌的比比声音
经常使用tab键的时候都会比比的叫,这不影响老婆大人休息吗!去掉它在/etc/inputrc里面添加一句set bell-style none 就OK
了。当然也可以在每个用户家目录里的
.inputrc里面添加这个(如果没有就自己建立一个)
世界终于清静了
经常使用tab键的时候都会比比的叫,这不影响老婆大人休息吗!去掉它在/etc/inputrc里面添加一句set bell-style none 就OK
了。当然也可以在每个用户家目录里的
.inputrc里面添加这个(如果没有就自己建立一个)
世界终于清静了
不确定是不是中邪了,今天看到gentoo提示可以升级xorg以后就一直想者升级。终于没能挡
住诱惑,开始了升级。。。。1.3升级到1.5r3
查看了下需要更新的东西,好像很多哦,如下
simon@HomeC1 ~ $ sudo emerge -pv xorg-server
These are the packages that would be merged, in order:
Calculating dependencies… done!
[ebuild U ] x11-proto/xproto-7.0.14 [7.0.10] 149 kB
[ebuild U ] x11-proto/inputproto-1.5.0 [1.4.2.1] 57 kB
[ebuild U ] x11-libs/xtrans-1.2.3 [1.0.3] USE=”-debug” 102 kB
[ebuild U ] x11-proto/randrproto-1.2.2 [1.2.1] 62 kB
[ebuild U ] x11-proto/xf86driproto-2.0.4 [2.0.3] 43 kB
[ebuild U ] x11-proto/renderproto-0.9.3 [0.9.2] 53 kB
[ebuild U ] x11-libs/libdrm-2.4.5 [2.3.0] USE=”-debug” 551 kB
[ebuild N ] x11-proto/dri2proto-1.99.3 42 kB
[ebuild U ] x11-libs/libXau-1.0.4 [1.0.3] USE=”-debug” 223 kB
[ebuild U ] x11-proto/xextproto-7.0.4 [7.0.2] 78 kB
[ebuild U ] x11-apps/rgb-1.0.3 [1.0.1] USE=”-debug” 102 kB
[ebuild U ] x11-libs/libX11-1.1.5 [1.1.4] USE=”ipv6 xcb -debug” 1,548 kB
[ebuild U ] x11-libs/libXext-1.0.4 [1.0.3] USE=”-debug” 259 kB
[ebuild U ] x11-libs/libXrender-0.9.4 [0.9.2] USE=”-debug” 222 kB
[ebuild U ] x11-libs/libXxf86vm-1.0.2 [1.0.1] USE=”-debug” 235 kB
[ebuild U ] x11-libs/libXfont-1.3.4 [1.3.1-r1] USE=”ipv6 -debug” 558 kB
[ebuild U ] media-libs/mesa-7.3-r1 [6.5.2-r1] USE=”nptl -debug -doc -motif -pic -xcb” VIDEO_CARDS=”-intel -mach64 -mga -none -r128 -radeon -s3virge -savage -sis (-sunffb) -tdfx -trident -via” 3,323 kB
[ebuild U ] x11-apps/xauth-1.0.3 [1.0.2] USE=”ipv6 -debug” 110 kB
[ebuild U ] x11-misc/xkeyboard-config-1.5 [1.1] 559 kB
[ebuild U ] x11-apps/xinit-1.0.8-r4 [1.0.5-r1] USE=”hal pam -debug -minimal” 115 kB
[ebuild U ] x11-drivers/xf86-input-mouse-1.4.0 [1.2.3] USE=”-debug” 286 kB
[ebuild N ] x11-libs/libpciaccess-0.10.5 USE=”-debug -minimal” 255 kB
[uninstall ] x11-base/xorg-server-1.3.0.0-r6 USE=”dri ipv6 nptl xorg -3dfx -debug -dmx -kdrive -minimal -sdl -xprint” INPUT_DEVICES=”keyboard mouse -acecad -aiptek -calcomp -citron -digitaledge -dmc -dynapro -elo2300 -elographics -evdev -fpit -hyperpen -jamstudio -joystick -magellan -microtouch -mutouch -palmax -penmount -spaceorb -summa -synaptics -tek4957 -ur98 -vmmouse -void -wacom” VIDEO_CARDS=”nvidia -apm -ark -chips -cirrus -cyrix -dummy -epson -fbdev -fglrx -glint -i128 -i740 (-impact) -imstt -intel -mach64 -mga -neomagic (-newport) -nsc -nv -r128 -radeon -rendition -s3 -s3virge -savage -siliconmotion -sis -sisusb (-sunbw2) (-suncg14) (-suncg3) (-suncg6) (-sunffb) (-sunleo) (-suntcx) -tdfx -tga -trident -tseng -v4l -vesa -vga -via -vmware -voodoo”
[blocks b ] Tags cannot enclose tags x11-base/xorg-server-1.5 (
晚上11:30现在已经开始更新了,希望能一次成功啥都不用改动 现场直播哦,不断更新
凌晨0:10分更新完了,重新生成配置文件
,拷贝到/etc/Xorg里面startx启动,启动成功。但是键盘鼠标不能使用,搜索了一下需要安装 xf86-input-evdev,直接emerge xf86-input-evdev 安装好后就可以使用了。
需要注意的是如果你把xdm或啥的桌面管理器添加到了启动里面,得在初始化时按I键进入交互模式,把这个给关掉,不然进去了就鼠标键盘都失灵,看你怎么加xf86-input-evdev
1、必须将Movies文件夹重命名为_Movies,不然会黑屏
2、在启动时需要后添加参数 -opengl,如/mnt/w3/war3.exe -opengl
转到gentoo后发现startx后经常会出现说:
NVIDIA: could not open the device file /dev/nvidiactl (Permission denied).
NVIDIA: Direct rendering failed; attempting indirect rendering.
的错误,原因很明显,就是权限不足,可以直接更改
/dev/nvidiactl的权限为666以上如:sudo chmod 666 /dev/nvidia* 。
我前面也是这样解决的,但是这样做有个很大的缺点:每重新启动一次就需要重新指定下权限
当然,可以使用脚本的办法来解决这个问题,每次启动后就指定权限。
但是这样是治标不治本的解决方法。到网上查了下:原来是因为使用的帐号没有加入到video用户组,直接加入用户组就可以了-_-!,好囧。sudo usermod -G wheel,video,game simon。simon是我的用户名^-^
已经困扰我好几天的问题了,想在fvwm里面使用托盘,但是老是不成功,试了好几个tray程序,如trayer等,都不能完美的swallow。但是单独使用是没有问题的。但我希望能swallow到fvwmbuttons里面(因为我用的fvwmbuttons做的taskbar)。
今天再次仔细的阅读了stalonetray的man页。然后终于成功了,HOHO,非常的完美,只需要一个参数p参数就OK。表示使用父颜色。如下:
*FvwmTopBar: (100×25+885+0,Swallow(NoClose, UseOld) `stalonetray` `Exec exec stalonetray -p`)
Gentoo下面配置xorg是非常容易的,步骤如下:
emerge xorg-x11 安装好xorg
然后 只需要Xorg -configure 一下就会自动产生xorg的配置文件,不过要注意的是产生的新配置文件是在/root里面
下一步测试新配置文件
X -config /root/xorg.conf.new
正常情况下是不会启动成功的:),因为还没安装卡的驱动
emerge nvidia-drivers (这里因为我的是n卡所以用的nvidia-drivers,根据自己的情况看)
安装显卡驱动
安装完以后再
Xorg -configure
X -config /root/xorg.conf.new
看看是不是成功了呢?反正我是没成功(好事多磨哦)
看失败原因(直接会显示在屏幕上,如果你有 兴趣也可以去/var/log/里看xorg的log)
Failed to load module “wfb” (module does not exist, 0)
解决方法如下:
执行
eselect opengl set nvidia
然后再
Xorg -configure
X -config /root/xorg.conf.new
一下,终于成功了,看到了几个简陋的窗口
其实gentoo的文档资源是非常的丰富的,只要遇到问题你去gentoo上面查找一般都能找到howto。当然,google更是好老师,遇到问题就去Google一般都能找到答案
这里是维护时常用的一些命令,放在这里,备忘
注:大部分非原创,只是收集到这里而已
* 实时查看正在执行的sql语句
1./usr/sbin/tcpdump -i eth0 -s 0 -l -w – dst port 3306 | strings | egrep -i ‘SELECT|UPDATE|DELETE|INSERT|SET|COMMIT|ROLLBACK|CREATE|DROP|ALTER|CALL’
* 查看http连接
1.netstat -n | awk ‘/^tcp/ {++state[$NF]} END {for(key in state) print key,”\t”,state[key]}’
* 查看SYN状态的http连接
1.netstat -an | grep SYN | awk ‘{print $5}’ | awk -F: ‘{print $1}’ | sort | uniq -c | sort -nr | more
* 查看TIME_WAIT状态的http连接
1.netstat -tna | cut -b 49- |grep TIME_WAIT | sort |more
2.netstat -an | grep TIME_WAIT | awk ‘{print $5}’ | awk -F: ‘{print $1}’ | sort | uniq -c | sort -nr | more
* 查看ESTABLISHED状态的http连接
1.netstat -an | grep ESTABLISHED | awk ‘{print $5}’ | awk -F: ‘{print $1}’ | sort | uniq -c | sort -nr | more
2.netstat -an | grep “:80″ | grep ESTABLISHED | sort | more
* 批量kill进程
1.ps -efww|grep sqlr-listener|grep -v grep|cut -c 9-15|xargs kill -9
* 查看活动的php-cgi连接数
1.netstat -anpo|grep php-cgi|wc -l
* 按ip查看httpd连接数
1.netstat -anlp | grep 80 | grep tcp | awk {‘print $5′} | awk -F: {‘print $1′}| sort |uniq -c | sort -nr
* 禁IP
1.iptables -A INPUT -s IP地址 -j REJECT
2.iptables -A INPUT -s IP地址/24 -j REJECT
3.route add -net IP地址 netmask 255.255.255.0 reject
* 调试命令
1.strace -p pid
* 跟踪指定的进程pid.
1.gdb -p pid
* 跟踪指定的进程pid.
* 批量查找文件并删除
1.find . -name test.php -exec rm {} \;
2.find . -name test.php | xargs rm -rf
* 更改某一目录下所有目录的权限, 不包括文件, aaa 是目录名
1.find aaa -type d -exec chmod 755 {} \;
* 替换文件内容
1.sed -i ‘s/b/strong/g’ index.html
此命令搜索 index.html 文件中的 b 并将其替换为 strong。
在实际的服务器使用中,我们经常遇到的一个情况就是服务器无响应,有可能是由于apache或者是mysql等服务过载造成服务器无响应。九王爷就遇到过几次这种情况,好几次说服务器没响应,ssh也上不去,只好请机房的人员帮助重启机器。重启机器后发现log等服务还是在运行的,也就是说服务器不是真的死机了,而是反应不过来,如果当时能ssh上去看看的话就能找到原因了。所以希望能在apache等没反应以后还能ssh上服务器
这就需要将ssh的运行优先级给调高一些,而我又是个懒人,希望能每次重启后自动的就把优先级给调整了。查看sshd_conf里面没有相应的选项,就只好在启动脚本里面打主意了。
查看启动脚本/etc/init.d/sshd ,修改里面的
$SSHD $OPTIONS && success || failure
为
nice -n -2 $SSHD $OPTIONS && success || failure
使用-2优先级是希望sshd服务的优先级高于apache等的0,但低于log等的-5
sudo /etc/init.d/sshd restart
一下,然后
ps -aeo cmd,pid,nice |grep sshd
看下优先级是不是变成-2了呢?
转的CU上一条大牛的,转载这里备忘(以前是不转过来的,但是最近发现很多文章所在网站都死掉了,因为没保存,很多好文也没有了)原文地址 http://blog.chinaunix.net/u2/82938/showart_1839189.html
用fuser杀掉进程
一,为什么要使用fuser?
先说 fuser的作用,
fuser能识别出正在对某个文件或端口访问的进程
大家想一下,还有哪个命令具备这个功能?
没错,是lsof,
我们前面讲过, lsof能够找出正在对指定文件访问的进程,
那么它们两者之间有何区别?
fuser有一个特别的用法在于它可以一次杀死那些正在访问指定文件的进程
二,如何使用fuser?
1,如何用fuser得到正在使用指定文件的进程?
用法: fuser 文件
说明:它会把正在使用当前文件的进程id列出
[root@localhost lhd]# umount /
umount: /: device is busy.
(In some cases useful info about processes that use
the device is found by lsof(8) or fuser(1))
[root@localhost lhd]# fuser /
/: 1rc 2rc 3rc 4rc 5rc 6rc 7rc 80rc 82rc 84rc 85rc 153rc 157rc 158rc
160rc 165rc 168rc 203rc 204rc 205rc 253rc 441rc 444rc 516rc 521rc 524rc 582rc 583rc
584rc 633rc 1052rc 1392rc 1394rc 1417rc 1597rc 1609rc 1617rc 1620rc 1683rc 1744rc 1783r 1785rc
1788rc 1806r 1808r 1810rc 1811rc 1812rc 1813rc 1814rc 1815rc 1848rc 1886rc 1899rc 1900rc 2001rc
……太多不一一列出
说明:
这些进程号后面的rc是什么意思?
c 将此文件作为当前目录使用。
e 将此文件作为程序的可执行对象使用。
r 将此文件作为根目录使用。
s 将此文件作为共享库(或其他可装载对象)使用
2,如何列出进程的详细信息,而不仅仅是进程id?
用 -v参数即可
说明: -v: 含义是:verbose output,详细的输出信息
例子:
[root@dev ~]# fuser /var/log
/var/log: 4196c
[root@dev ~]# fuser -v /var/log
USER PID ACCESS COMMAND
/var/log: root 4196 ..c.. bash
3,如何列出进程所属的用户?
用 -u参数即可
说明: -u: 含义:display user IDs,显示用户id
例子:
[root@dev ~]# fuser -u /var/log
/var/log: 4196c(root)
4,如何杀死所有正在访问指定文件的进程?
用 -k参数即可
说明: -k:含义: kill processes accessing the named file
例子:
[root@localhost lhd]# fuser -v /root/install.log
用户 进程号 权限 命令
/root/install.log: root 3185 f…. tail
[root@localhost lhd]# fuser -k /root/install.log
/root/install.log: 3185
[root@localhost lhd]# fuser -v /root/install.log
说明: -k参数能够杀死所有的正在访问指定文件的进程,所以用来杀进程时非常方便
说明之二: fuser如何杀死的进程?
它发送的是这个信号:SIGKILL
三,多学一点知识
1,fuser可以列出它所知的信号:
用 -l参数即可
例子:
[root@dev ~]# fuser -l
HUP INT QUIT ILL TRAP ABRT IOT BUS FPE KILL USR1 SEGV USR2 PIPE ALRM TERM
STKFLT CHLD CONT STOP TSTP TTIN TTOU URG XCPU XFSZ VTALRM PROF WINCH IO PWR SYS
UNUSED
2,fuser可以发送它已知的信号给访问的指定文件进程而代替-k参数默认发送的SIGKILL
例如:只是挂起进程,那么发送HUP信号就可以了
例子:
[root@localhost lhd]# fuser -v /root/install.log
用户 进程号 权限 命令
/root/install.log: root 3347 f…. tail
[root@localhost lhd]# fuser -k -SIGHUP /root/install.log
/root/install.log: 3347
[root@localhost lhd]# fuser -v /root/install.log
原来的ssh是不会超时的, 但是不知道从什么时候起, 出现了ssh 超时现象:只要putty连续3分钟左右没有输入, 就自动断开, 然后必须重新登陆, 很麻烦.
在网上查了很多资料, 发现原因有多种, 环境变量TMOUT引起,ClientAliveCountMax和ClientAliveInterval设置问题或者甚至是防火墙的设置问题. 所以可以这么尝试:
1, echo $TMOUT
如果显示空白,表示没有设置, 等于使用默认值0, 一般情况下应该是不超时. 如果大于0, 可以在如/etc/profile之类文件中设置它为0.
Definition: TMOUT: If set to a value greater than zero, the value is interpreted as the number of seconds to wait for input after issuing the primary prompt. Bash terminates after waiting for that number of seconds if input does not arrive.
2. ClientAliveInterval 60
在/etc/ssh/sshd_config中增加ClientAliveInterval 60, ClientAliveInterval指定了服务器端向客户端请求消息的时间间隔, 默认是0, 不发送.而ClientAliveInterval 60表示每分钟发送一次, 然后客户端响应, 这样就保持长连接了.这里比较怪的地方是:不是客户端主动发起保持连接的请求(如FTerm, CTerm等),而是需要服务器先主动.
另外,至于ClientAliveCountMax, 使用默认值3即可.ClientAliveCountMax表示服务器发出请求后客户端没有响应的次数达到一定值, 就自动断开. 正常情况下, 客户端不会不响应.
ClientAliveCountMax
Sets the number of client alive messages (see below) which may be
sent without sshd(8) receiving any messages back from the client.
If this threshold is reached while client alive messages are
being sent, sshd will disconnect the client, terminating the ses-
sion. It is important to note that the use of client alive mes-
sages is very different from TCPKeepAlive (below). The client
alive messages are sent through the encrypted channel and there-
fore will not be spoofable. The TCP keepalive option enabled by
TCPKeepAlive is spoofable. The client alive mechanism is valu-
able when the client or server depend on knowing when a connec-
tion has become inactive.
The default value is 3. If ClientAliveInterval (see below) is
set to 15, and ClientAliveCountMax is left at the default, unre-
sponsive SSH clients will be disconnected after approximately 45
seconds. This option applies to protocol version 2 only.
ClientAliveInterval
Sets a timeout interval in seconds after which if no data has
been received from the client, sshd(8) will send a message
through the encrypted channel to request a response from the
client. The default is 0, indicating that these messages will
not be sent to the client. This option applies to protocol ver-
sion 2 only.
3. 启用putty keepalive
putty -> Connection -> Seconds between keepalives ( 0 to turn off ), 默认为0, 改为60.
4. 上述3个方法应该能解决大部分问题, 如果不行, 请 man sshd_config, 然后尝试更改其他设置吧.