安装好FreeBSD后的一些基础配置修改

Posted by 4Aiur on 04/06/2010 in BSD |

安装好FreeBSD后的一些基础配置修改 配置alias [root@FreeBSD ~]# alias alias cp=’cp -i’ alias grep=’grep –color’ alias ll=’ls -lG’ alias mv=’mv -i’ alias rm=’rm -i’ alias vi=’vim’ [root@FreeBSD ~]# 安装sudo [root@FreeBSD ~]# cd /usr/ports/security/sudo [root@FreeBSD /usr/ports/security/sudo]# make [root@FreeBSD /usr/ports/security/sudo]# make install [root@FreeBSD /usr/ports/security/sudo]# make clean 修改man的环境变量,使用less来查看手册 FreeBSD -P pager Specify which pager to use. By default, man uses “more -s”. […]

Tags:

避免相同的程序重复运行

Posted by 4Aiur on 04/06/2010 in Shell |

避免相同的程序重复运行的小函数 逻辑如下: 检查pid文件是否存在,不存在则直接运行程序 如果pid文件存在,则检查进程中是否存在这个pid 进程存在此pid则退出 进程中不存在这一pid,则删除pid文件,程序继续运行 缺点:没有对进程名称进行对比 # Initialize variables app_path=”$(dirname $0)” pid=”${app_path}/run.pid” # Function TestPID () { if [ -f ${pid} ] ; then if ps -p cat ${pid} >/dev/null ; then echo “basename $0 is running! main process id = $(cat ${pid})” ps -p cat ${pid} -o cmd= exit 1 else rm -f […]

Tags:

FreeBSD重启网卡

Posted by 4Aiur on 04/06/2010 in BSD |

FreeBSD重启网卡 # 本地重启: ifconfig le0 down #stop网卡 ifconfig le0 up #start网卡 # 远程重启: /etc/netstart sh /etc/rc /etc/rc.d/netif restart # 重新获取dhcp地址: /sbin/dhclient interface

Tags:

Shell使用printf进行进制转换

Posted by 4Aiur on 04/06/2010 in Shell |

Shell使用printf进行进制转换 localhost:~ 4aiur$ printf “%d\n” \0x64 100 localhost:~ 4aiur$ printf “%x\n” 100 64

Tags:

网络上的一些XEN资料

Posted by 4Aiur on 04/06/2010 in SysAdmin |

网络上的一些XEN资料 北南南北-Xen 初学者指南 鳥哥的 Linux 私房菜- 利用 Xen 設計虛擬機器 xen安装及配置笔记 RedHat 5.0配置XEN虚拟机(上) RedHat 5.0配置XEN虚拟机(下)

Tags: ,

awstats分析windowsmedia日志格式的字段配置

Posted by 4Aiur on 04/06/2010 in SysAdmin |

awstats分析windowsmedia日志格式的字段配置 LogFormat=”c-ip date time c-dns cs-uri-stem c-starttime x-duration c-rate c-status c-playerid c-playerversion c-playerlanguage cs(User-Agent) cs(Referer) c-hostexe c-hostexever c-os c-osversion c-cpu filelength filesize avgbandwidth protocol transport audiocodec videocodec channelURL sc-bytes c-bytes s-pkts-sent c-pkts-received c-pkts-lost-client c-pkts-lost-net c-pkts-lost-cont-net c-resendreqs c-pkts-recovered-ECC c-pkts-recovered-resent c-buffercount c-totalbuffertime c-quality s-ip s-dns s-totalclients s-cpu-util cs-user-name s-session-id s-content-path cs-url cs-media-name c-max-bandwidth cs-media-role s-proxied”

Tags:

工程师的5个级别

Posted by 4Aiur on 04/06/2010 in SysAdmin |

工程师的5个级别 不知问题是五流工程师 看到问题是四流工程师 找出问题是三流工程师 解决问题是二流工程师 一流工程师会提前发现问题,阻止问题发生

ls long listing format各个字段的含义

Posted by 4Aiur on 04/06/2010 in Linux |

ls long listing format各个字段的含义 ls -l total 8 -rw-r–r– 1 root root 2 Jul 27 13:30 bar -rw-rw-r– 1 root root 7056 Jul 27 13:27 foo For each directory that is listed, preface the files with a line ‘total BLOCKS’, where BLOCKS is the total disk allocation for all files in that directory. The block […]

Tags:

使用python计算md5

Posted by 4Aiur on 04/06/2010 in Python |

使用python计算md5 #!/usr/bin/env python3 import os import hashlib # Use hashlib module file = open(“foo”, “rb”) content = file.read() file.close() result = hashlib.md5() result.update(content) md5sum = result.hexdigest() print(md5sum) # Use OS command result = os.popen(“md5sum foo”).readline() md5sum = result.split()[0] print(md5sum)

Tags:

awk应用举例

Posted by 4Aiur on 04/06/2010 in Shell |

打印磁盘INODE最大值 # df -Pi | awk ‘BEGIN{OFS=”\n”;Max=0} {if (NR!=1) {sub(/%/,””,$5); Max=$5>Max?$5:Max}} END{print Max}’ 38 打印磁盘空间最大值 df -P | awk ‘BEGIN{OFS=”\n”;Max=0} {if (NR!=1) {sub(/%/,””,$5); Max=$5>Max?$5:Max}} END{print “diskUsedSpacePercent: “Max,”diskSpaceUpdateTime: “systime()}’ diskUsedSpacePercent: 55 diskSpaceUpdateTime: 1252898042 按netstat中ESTABLISHED状态的连接数量进行排序 netstat -an 2>/dev/null | awk /ESTABLISHED/'{print $5}’ | awk -F: ‘{!ip[$(NF-1)]++} END { for (item in ip) print item,ip[item] | “sort -k2 […]

Tags: ,

Copyright © 2010-2024 4Aiur All rights reserved.
This site is using the Desk Mess Mirrored theme, v2.5, from BuyNowShop.com.