
linux技术
auvKone
未知攻,焉知防
展开
-
解决mac上安装paramiko失败问题
pip install paramiko失败,部分错误消息如下:building '_openssl' extensioncc -fno-strict-aliasing -fno-common -dynamic -arch i386 -arch x86_64 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE原创 2017-01-08 16:01:13 · 4951 阅读 · 2 评论 -
C++之迭代器
//五种迭代器迭代器种类Input iterator(输入迭代器)读,不能写;只支持自曾运算Output iterator(输出迭代器)写,不能读;只支持自曾运算Forward iterator(前向迭代器)读和写;只支持自增运算Bidirectional iterator(双向迭代器)读和写;支持自增和自减运算原创 2015-06-24 10:09:05 · 499 阅读 · 0 评论 -
linux系统常用命令
date -s "13:59:00"date -s "2014-06-30 "原创 2014-06-30 13:37:34 · 654 阅读 · 0 评论 -
Python vs C++
//C++ PythonNULL None原创 2015-04-30 10:53:02 · 624 阅读 · 0 评论 -
MySQL命令范例
windows上启动MySQL服务:net start mysqlwindows上停止MySQL服务:net stop mysql连接MySQL服务器命令:mysql -u root -p 123456 -h 127.0.0.1使用某一个特定的数据库:use test;显示所有的数据库:show databases;创建数据库:create data原创 2015-05-09 20:16:44 · 554 阅读 · 0 评论 -
Perl脚本示例程序
1.打印环境变量#!/usr/bin/perlwhile(($key, $value) = (each %ENV)){ print "$key=$value\n"}%ENV是一个哈希变量,存储所有的环境变量。原创 2015-04-29 13:49:47 · 1378 阅读 · 0 评论 -
jenkins hash函数源码
http://burtleburtle.net/bob/hash/doobs.html原创 2015-04-02 14:35:39 · 2162 阅读 · 0 评论 -
Perl脚本学习心得
Perl脚本跟C语言语法比较接近。变量变量需要使用$字符, 如下:$pi = 3.14;print $pi . "\n";$arr[0] = 100;print $arr[0] . "\n";原创 2015-04-02 10:17:29 · 1249 阅读 · 0 评论 -
bash脚本学习心得
bash脚本中对空格的要求比较严格,不像C、perl语言那么随意,赋值时等号两边不能有空格。SUCCESS=0area[11]=23原创 2015-04-02 10:11:34 · 619 阅读 · 0 评论 -
Linux编程之错误码
在CentOS系统下,vi /usr/include/asm-generic/errno-base.h#define EPERM1 /* Operation not permitted */#define ENOENT2 /* No such file or directory */#define ESRCH 3 /* No such process */#de原创 2015-03-20 15:36:07 · 707 阅读 · 0 评论 -
使用libcurl发送post请求
C语言代码如下:#include #include #include int main(int argc, char *argv[]){ CURL *curl; CURLcode res; struct curl_httppost *post=NULL; struct curl_httppost *last=NULL; struct curl_slist *h原创 2015-02-12 17:49:37 · 5264 阅读 · 0 评论 -
使用curl命令post数据
curl --data "birthyear=1905&press=%20OK%20" http://www.example.com/when.cgi你发送给服务器端的数据必须是已经被准确地编码了。curl不会自动帮你做此事。例如:如果你想使用包含了空格的数据,你需要使用%20来替换空格等。错误的请求将很可能造成你发送的数据错误,并出现混乱。原创 2015-02-11 10:27:37 · 7465 阅读 · 0 评论 -
openldap使用
添加新用户,文件newentry如下:dn: cn=aaa,dc=pro,dc=comobjectClass: personobjectClass: inetOrgPersoncn: aaasn: aaauserPassword: 123456mail: aaa@pro.comdn: cn=bbb,dc=pro,dc=comobjectClass:原创 2014-04-29 19:04:14 · 621 阅读 · 0 评论 -
使用shell脚本编写cgi
非常简单示例1:recv脚本接收http post数据#!/bin/shread bufecho "Content-type:text/html;charset=UTF-8"echoecho $buf使用curl命令进行测试:curl --data "name=abc" http://10.236.5.128/cgi-bin/recv抓包得到http消息如下:原创 2015-02-11 14:47:50 · 1470 阅读 · 0 评论 -
OpenLDAP配置
1. 修改slapd.confvi /etc/openldap/slapd.confinclude /etc/openldap/schema/core.schemainclude /etc/openldap/schema/cosine.schemainclude /etc/openldap/schema/inetorgperson.schemainclude /etc/open原创 2014-12-12 10:02:57 · 825 阅读 · 0 评论 -
使用Python进行socket通信
//import socketdef talk(data): """Send data to a Daemon, and return the response""" reply = "" s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) try: s.connect(("127.0.原创 2015-05-19 13:45:04 · 751 阅读 · 0 评论 -
tcpdump使用范例
范例1. 只抓IPv4的smtp包,ip[0:1]表示ip头中的第一个字节(从0开始),长度为1;然后右移4位的值等于0x4;-S表示显示seq和ack序号的绝对值,而不是相对值。tcpdump -i eth0 -S '(ip[0:1]>>4 = 0x4) and (tcp port 25)'原创 2015-07-01 17:10:33 · 962 阅读 · 0 评论 -
awk编程总结
注意:如果以命令行的方式提供awk程序,而不是将它写入一个文件中,那么在程序的任何地方都不能出现单引号,否则shell将对它进行解释而导致错误。原创 2015-06-14 17:41:37 · 547 阅读 · 0 评论 -
定位Linux服务器负载高问题
负载高的原因可能为:CPU存在瓶颈内存存在瓶颈磁盘IO存在瓶颈怀疑CPU存在瓶颈使用sar -u命令查看;怀疑内存存在瓶颈使用sar -r命令查看;怀疑磁盘IO存在瓶颈使用sar -b命令查看;原创 2017-01-03 14:54:00 · 2174 阅读 · 0 评论 -
kafka生产者示例(kafka-python producer example)
import multiprocessingimport timefrom kafka import KafkaProducerdef worker(ch): kafka_host = '127.0.0.1' # host kafka_port = 9092 # port producer = KafkaProducer(bootstrap_servers=['{ka原创 2016-11-22 13:12:33 · 7507 阅读 · 1 评论 -
fabric执行远程命令
from fabric.api import env, sudo, taskenv.user = 'raymond'env.password = '123456'env.sudo_password = env.passwordenv.hosts = ['1.1.1.1', '2.2.2.2']env.port = 22@task(default=True)def default():原创 2016-11-18 20:50:02 · 2487 阅读 · 0 评论 -
JBoss AS domain模式配置
1.环境CentOS 6.7; jdk1.8.0_101,安装路径/usr/local/jdk; jboss-as-7.1.1.Final.zip解压路径/usr/local/jboss;java环境变量: cat /etc/profile.d/java.sh JAVA_HOME=/usr/local/jdkJAVA_BIN=$JAVA_HOME/binJRE_HOME=$JAVA_HOM原创 2016-08-27 16:41:09 · 2155 阅读 · 0 评论 -
nginx的yum源
增加yum源cd /etc/yum.repos.d/vim nginx.repo[nginx]name=nginx repobaseurl=http://nginx.org/packages/centos/6/$basearch/gpgcheck=0enabled=1然后: yum makecache yum cle原创 2016-01-08 11:10:46 · 655 阅读 · 0 评论 -
python和unicode
Pragmatic Unicode, http://nedbatchelder.com/text/unipain.html转载 2015-12-22 18:19:56 · 501 阅读 · 0 评论 -
正则表达式参考资料
URL正则:https://mathiasbynens.be/demo/url-regex原创 2015-11-27 19:52:48 · 512 阅读 · 0 评论 -
MBR参考资料
Grub MBR:http://thestarman.pcministry.com/asm/mbr/GRUB.htm原创 2015-11-24 15:42:49 · 799 阅读 · 0 评论 -
ZeroBrane Studio远程调试Lua程序
环境:ZeroBrane Studio安装在Windows 7上,而要调试的程序运行在CentOS上;设置:在windows 7上,打开ZeroBrane Studio,打开需要调试的文件,例如test.lua然后选择Project -> Start Debugger Server,Output中可以看到Debugger server started at WIN:8172,原创 2015-11-03 16:48:13 · 4374 阅读 · 0 评论 -
Google breakpad实战
使用Google breakpad,优点是跨平台,开源。原理图如下:1.下载breakpad源码,build源码:./configure LDFLAGS=-static-libstdc++make2.在App程序中调用异常处理构造函数,示例如下:vi test.cpp#include "client/linux/handler/exception_handler原创 2015-08-13 11:22:41 · 1195 阅读 · 0 评论 -
负载均衡的算法
负载均衡的算法有很多,如下所示:1.轮询(rr):如果我们网络环境中,服务组1中有三台后台服务器,服务组2中有两台后台服务器,并且这两个服务组都采用轮询算法,那么通向服务组1的所有请求都将按照“1、2、3、1、2、3……”的顺序分配到服务组1中的后台服务器,通向服务组2的所有请求都将按“4、5、4、5”的顺序分配到服务组2中的后台服务器。2.最少连接数(lc):这种负载均衡算法将引导APV原创 2015-07-17 11:21:53 · 3445 阅读 · 0 评论 -
sed命令使用
#在文件中查找包含字符串pattern的行并打印,-n表示不打印输入文件的所有行,编辑命令p表示打印匹配行。sed -n '/pattern/p' a.txt#只打印第一行sed -n '1p' a.txt#打印第3~6行sed -n '3,6p' a.txt原创 2014-03-18 10:40:35 · 838 阅读 · 0 评论 -
CentOS x86_64上编译32位demo程序
1.写个hello world的简单程序gcc -m32 a.crpm -import http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7原创 2014-07-16 13:00:33 · 4904 阅读 · 0 评论 -
使用smtp命令发送邮件
[root@localhost postfix]# telnet 10.228.88.8 25Trying 10.228.88.8...Connected to 10.228.88.8.Escape character is '^]'.220 Websense Email Security Gateway service is ready.ehlo a250-Websens原创 2014-10-17 14:20:28 · 5356 阅读 · 0 评论 -
bash编程奇技淫巧
Q1:如何注释掉多行代码?A1:原创 2014-10-30 14:09:14 · 587 阅读 · 0 评论 -
使用gdb调试postfix
交互式gdb调试postfix,需要gdb和screen1.修改main.cf中的debugger_command参数 /etc/postfix/main.cf: debugger_command = PATH=/bin:/usr/bin:/sbin:/usr/sbin; export PATH; HOME=/root; export HOME原创 2014-11-26 11:48:06 · 873 阅读 · 0 评论 -
mount命令示例
1.挂载nfs系统mount -t nfs 10.228.88.9:/home/workspace/ /mnt/nfs -o rw,proto=tcp,soft,intr,retry=2,retrans=5,timeo=600将10.228.88.9下的/home/workspace挂载到/mnt/nfs下,-o指定选项:soft,指定client经过retrans次重发请求后,返原创 2014-12-04 10:49:36 · 3545 阅读 · 0 评论 -
Linux下route命令用法
显示现在所有路由#routeroot@ubuntu:~# routeKernel IP routing tableDestination Gateway Genmask Flags Metric Ref Use Iface10.147.9.0 * 255.255.255.0 U 1转载 2014-03-29 21:35:23 · 1419 阅读 · 0 评论 -
LDAPv3 asn
Lightweight-Directory-Access-Protocol-V3.asn原创 2014-05-29 15:48:54 · 1549 阅读 · 0 评论 -
如何生成SSL证书
首先请确认服务器已经安装了openssl,若尚未安装openssl请先安装openssl。本教程使用openssl提供的一个工具创建服务器私钥和服务器证书以及CA根证书。cd /var/tmpwget http://www.openssl.org/contrib/ssl.ca-0.1.tar.gztar zxvf ssl.ca-0.1.tar.gzcd ssl.ca-01转载 2014-06-19 16:22:34 · 1913 阅读 · 0 评论 -
linux下perforce命令行客户端使用
设置环境变量:export P4PASSWD=abcdefgexport P4CLIENT=dyoldfish.com //这个是workspceexport P4USER=dyoldfishexport P4PORT=192.168.1.198:1666原创 2014-04-04 16:06:40 · 6316 阅读 · 0 评论 -
Makefile.am编写范例
范例1.sbin_PROGRAMS = auth_daemonauth_daemon_SOURCES = authd_main.c authd_debug.cauth_daemon_CFLAGS = -DLDAP_DEPRECATED=1auth_daemon_LDFLAGS = -lldap -leventauth_daemon_LDADD = $(top_s原创 2014-06-27 10:58:54 · 1221 阅读 · 0 评论