随笔分类 -  linux

摘要:cat filename | tr '\n\r' '\n' > test 阅读全文
posted @ 2014-02-18 14:32 sunsweet 阅读(646) 评论(0) 推荐(0)
摘要:method 1)$ export MYSQL_PS1="\u@\h [\d]> "method 2)mysql> prompt \u@\h [\d]>method 3)$ mysql --prompt="\u@\h [\d]> " -u root -pyour-passwordmethod 4)$ vi ~/.my.cnf[mysql]prompt=\\u@\\h [\\d]>\\_ 阅读全文
posted @ 2013-11-14 15:41 sunsweet 阅读(362) 评论(0) 推荐(0)
摘要:Swappinessis a property of theLinux kernelthat changes the balance between swapping out runtime memory, as opposed to dropping pages from the systempage cache. Swappiness can be set to values between 0 and 100 inclusive. A low value means the kernel will try to avoid swapping as much as possible whe 阅读全文
posted @ 2013-10-18 10:49 sunsweet 阅读(342) 评论(0) 推荐(0)
摘要:$ free -m total used free shared buffers cachedMem: 1002 769 232 0 62 421-/+ buffers/cache: 286 715Swap: 1153 0 1153第一部分Mem行:total 内存总数: 1002Mused 已经使用的内存数: 769Mfree 空闲的内存数: 232Msha... 阅读全文
posted @ 2013-10-18 09:28 sunsweet 阅读(245) 评论(0) 推荐(0)
摘要:As already discussed, a new process is created through fork() and if a new executable is to be run then exec() family of functions is called after fork(). As soon as this new process is created, it gets queued into the queue of processes that are ready to run.If only fork() was called then it is hig 阅读全文
posted @ 2013-10-17 16:16 sunsweet 阅读(407) 评论(0) 推荐(0)
摘要:《APUE》上提到了三个时间Real time, User time和Sys time。这三者是什么关系呢?在使用time(1)命令的时候,为什么real time < user time + sys time?(由于笔者的虚拟机为单核,显示的结果不会出现此种情况。附网上看到的一种结果如下:$timefooreal0m0.003suser0m0.000ssys0m0.004s$ Real指的是实际经过的时间,User和Sys指的是该进程使用的CPU时间。1. Real是墙上时间(wall clock time),也就是进程从开始到结束所用的实际时间。这个时间包括其他进程使用的时间片和进程 阅读全文
posted @ 2013-10-17 09:54 sunsweet 阅读(1962) 评论(0) 推荐(0)
摘要:安装完php php-fpm nginx 后访问php出现file not found错误,html就没问题配置文件server 段如下server { listen 80; server_name 192.168.1.11; root /home/www; location ~ .*\.php$ { try_files $uri =404; fastcgi_pass 127.0.0.1:9000; fastcgi_index inde... 阅读全文
posted @ 2013-10-12 11:41 sunsweet 阅读(8588) 评论(0) 推荐(0)
摘要:linux下删除乱码文件名, 不废话:1. ls -i 列出文件的节点ID, 如: 1234567892. find ./ -inum 123456789 -print -exec rm -rf {} \; 阅读全文
posted @ 2013-09-18 15:53 sunsweet 阅读(161) 评论(0) 推荐(0)
摘要:序号任务命令组合1删除0字节文件find . -type f -size 0 -exec rm -rf {} \;find . type f -size 0 -delete2查看进程,按内存从大到小排列ps -e -o “%C : %p : %z : %a”|sort -k5 -nr3按cpu利用率从大到小排列ps -e -o “%C : %p : %z : %a”|sort -nr4打印说cache里的URLgrep -r -a jpg /data/cache/* | strings | grep “http:” | awk -F’http:’ ‘{print “http:”$2;}’5查看 阅读全文
posted @ 2013-09-17 13:28 sunsweet 阅读(169) 评论(0) 推荐(0)
摘要:一般用pushd dir pop命令切换目录,但是能存储的目录太少,今天发现一个更好的方法,使用符号链接跳转实际上这个手工解决方案总结起来是在一个隐藏文件夹下(例如 ~/.marks)储存符号链接.这里有4个shell函数:jump, mark, unmark, 和marks:export MARKPATH=$HOME/.marksfunction jump { cd -P "$MARKPATH/$1" 2>/dev/null || echo "No such mark: $1"}function mark { mkdir -p "$MA 阅读全文
posted @ 2013-08-26 20:27 sunsweet 阅读(363) 评论(0) 推荐(0)
摘要:linux内核配置有一项tcp_keepalive_time,即tcp的保活定时器。当网络上两个建立连接的进程都没有数据向对方发送的时候,tcp会隔段时间发送一次保活数据,以保持连接,间隔时间就是tcp_keepalive_time设置的。默认是7200秒。在优化web服务器时,应该将数值设置的小一点,当客户关机,崩溃的时候可以更快的发现,而没必要等待2个小时才察觉,这样可以更快的清理无效的连接。http的keepalive : 默认http服务器在完成一个http响应以后会关闭这个连接,设置此项以后会保活一段时间,继续用此连接继续接受客户的请求。这样有效的减少了系统建立tcp连接的开销,但是 阅读全文
posted @ 2013-07-03 11:05 sunsweet 阅读(269) 评论(0) 推荐(0)
摘要:#!/bin/bashvariable="This is a fine mess."echo "$variable"# Regex matching with =~ operator within [[ double brackets ]].if [[ "$variable" =~ T.........fin*es* ]]# NOTE: 从bash V3.2开始,正则表达式不再用引号引起来then echo "match found" # match foundfi#!/bin/bashinput=$1if [[ 阅读全文
posted @ 2013-06-29 20:30 sunsweet 阅读(170) 评论(0) 推荐(0)
摘要:debian /etc/network/interfaces# This file describes the network interfaces available on your system# and how to activate them. For more information, see interfaces(5).# The loopback network interfaceauto loiface lo inet loopback# The primary network interfaceauto eth0iface eth0 inet static a... 阅读全文
posted @ 2013-06-28 12:34 sunsweet 阅读(258) 评论(0) 推荐(0)
摘要:yum installntpdatesudo crontab -e 添加01 6 * * * /usr/sbin/ntpdate asia.pool.ntp.org 每天6点1分同步时间hwclock --systohc硬件时钟与内核时钟同步,硬件时钟被内核时钟赋值hwclock --hctosys内核时钟与硬件时钟同步,内核时钟被硬件时钟赋值时间服务器:time.scau.edu.cn 阅读全文
posted @ 2013-05-31 14:44 sunsweet 阅读(208) 评论(0) 推荐(0)
摘要:添加eth0:1 192.168.1.117ifconfig eth0:1 192.168.1.117 broadcast 192.168.1.225 netmask 255.255.255.0 uproute add -host 192.168.1.117 dev eth0:1添加eth0:2 192.168.1.118ifconfig eth0:2 192.168.1.118 broadcast 192.168.1.225 netmask 255.255.255.0 uproute add -host 192.168.1.118 dev eth0:2 阅读全文
posted @ 2013-05-26 18:45 sunsweet 阅读(235) 评论(2) 推荐(0)