git clone https://github.com/dufferzafar/netuse /usr/local/netuse
cd /usr/local/netuse
cp config.py.example config.py
ln -s netuse.py /usr/bin/netuse

Crontab:



vi /usr/bin/netuse
#!/usr/bin/python3  
不存在python3怎么办?
ln -s /usr/bin/python /usr/bin/python3


vi /usr/local/netuse/dumper 把网卡修改成自己的网卡eth1:
# which registers itself as a ppp device.
echo $(cat /sys/class/net/ppp0/statistics/rx_bytes)";"$(date +%s) >> ~/.net/$year/$month/down/$date                                                          
echo $(cat /sys/class/net/ppp0/statistics/tx_bytes)";"$(date +%s) >> ~/.net/$year/$month/up/$date
修改为:

修改为:eth1


标准统计(主要看看vps一天多少流量):
[root@iZ25z0ugwgtZ netuse]# netuse
Downloaded:        5 MB
Uploaded:          0 MB

Data Left:      10235 MB
Days Left:         3 Days
End Date:       2016-06-29 (11:59 PM)

Suggested:      3411 MB (Per Day)

一周一瞥(好像有点问题):
[root@iZ25z0ugwgtZ netuse]# netuse -w
Data downloaded this week:

Traceback (most recent call last):
  File "/bin/netuse", line 277, in <module>
    weekly()
  File "/bin/netuse", line 186, in weekly
    format="{:>5.0f}",
  File "/usr/local/netuse/termgraph.py", line 56, in chart
    print_blocks(labels[i], data[i], step, args)
  File "/usr/local/netuse/termgraph.py", line 63, in print_blocks
    blocks = int(count / step)
ZeroDivisionError: integer division or modulo by zero
git因旧仓库有漏洞,强制升级到新仓库后,强制推送,如果是master和dev后面换一下即可,如果有多个分支:
git push -u origin dev -f
git branch -a
git checkout master
git push -u origin master -f


背景:在windows下提交了一个git更新,想在linux下强制更新(这个linux下的文件也被我改动了),以windows下提交的为准怎么办?还会出错,如下:
Git pull 强制覆盖本地文件,与在git bash下实践OK,AddTime:2016-9-29

来自:http://blog.csdn.net/baple/article/details/49872765


一)出错:
新增文件add commit后,push回原分支失败,报错:
  Counting objects: 20, done.
  Delta compression using up to 24 threads.
  Compressing objects: 100% (11/11), done.
  Writing objects: 100% (11/11), 1.30 KiB, done.
  Total 11 (delta 5), reused 0 (delta 0)
  error: insufficient permission for adding an object to repository database ./objects


二)git本地有修改如何强制更新到远程:
本地有修改和提交,如何强制用远程的库更新更新。我尝试过用git pull -f,总是提示 You have not concluded your merge. (MERGE_HEAD exists)。
我需要放弃本地的修改,用远程的库的内容就可以,应该如何做?傻傻地办法就是用心的目录重新clone一个,正确的做法是什么?

正确的做法应该是:
git fetch --all
git reset --hard origin/master
git fetch 只是下载远程的库的内容,不做任何的合并git reset 把HEAD指向刚刚下载的最新的版本

参考链接:

http://stackoverflow.com/questions/1125968/force-git-to-overwrite-local-files-on-pull
背景:对chkconfig还没用熟悉又来了一个新的,systemctl里的启动参位位置。

来自:https://www.liquidweb.com/kb/how-to-install-memcached-on-fedora-20/

systemctl 命令完全指南:https://linux.cn/article-5926-1.html


rpm -qf  /usr/bin/systemctl
systemd-219-19.el7_2.11.x86_64

yum remove systemd-219-19.el7_2.11  -y
错误:尝试移除受保护的 "systemd",为嘛不让卸载??



我们对service和chkconfig两个命令都不陌生,systemctl 是管制服务的主要工具, 它整合了chkconfig 与 service功能于一体。

systemctl is-enabled iptables.service
systemctl is-enabled servicename.service #查询服务是否开机启动
systemctl enable vsftpd.service #开机运行服务
systemctl disable vsftpd.service #取消开机运行
systemctl start vsftpd.service #启动服务
systemctl stop vsftpd.service #停止服务
systemctl restart vsftpd.service #重启服务
systemctl reload vsftpd.service #重新加载服务配置文件
systemctl status vsftpd.service #查询服务运行状态
systemctl --failed #显示启动失败的服务

注:*代表某个服务的名字,如http的服务名为httpd


例如在CentOS 7 上安装http

[root@CentOS7 ~]# yum -y install httpd
启动服务(等同于service httpd start)
systemctl start httpd.service
停止服务(等同于service httpd stop)
systemctl stop httpd.service
重启服务(等同于service httpd restart)
systemctl restart httpd.service
查看服务是否运行(等同于service httpd status)
systemctl status httpd.service
开机自启动服务(等同于chkconfig httpd on)
systemctl enable httpd.service
开机时禁用服务(等同于chkconfig httpd on)
systemctl disable httpd.service
查看服务是否开机启动 (等同于chkconfig --list)

来自:http://www.linuxidc.com/Linux/2014-11/109236.htm
内存不够的问题会很多:
1) 涉及到编译msyql啥的,会导致内存不够:
http://jackxiang.com/post/8677/
2)买的vps本来内存就小:
http://jackxiang.com/post/8529/
———————————————————————
怀疑Linux上某些进程有内存泄漏,怎么看?

vmstat 1  看下si so,如果长期是0,就不用管了:
(看说明都是vmstat查出来的swpd代表swap的使用量,si、so表示交换分区和内存的写入、写出的量)


[root@iZ25z0ugwgtZ config]# vmstat
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
0  1 494088  33764    220 457276  904  731  1106   737  245  540  1  0 93  6  0

si  每秒从磁盘读入虚拟内存的大小,如果这个值大于0,表示物理内存不够用或者内存泄露了,要查找耗内存进程解决掉。我的机器内存充裕,一切正常。
so  每秒虚拟内存写入磁盘的大小,如果这个值大于0,同上。

《深入理解linux内核》,很薄的一本,里面有详细说明。。。
公网:



内网:



测试访问:
yum list lua-socket
Available Packages
lua-socket.x86_64                                                                 3.0-0.17.rc1.el7




实践来自:https://gohalo.me/post/lua-introduce.html

背景:在centos7下安装gitlab时需要这个库,为此,先作个记录。
EPEL 是yum的一个软件源,里面包含了许多基本源里没有的软件了,但在我们在使用epel时是需要安装它才可以了,下文来介绍CentOS7/RHEL7安装EPEL步骤

EPEL,即Extra Packages for Enterprise Linux的简称,是为企业级Linux提供的一组高质量的额外软件包,包括但不限于Red Hat Enterprise Linux (RHEL), CentOS and Scientific Linux (SL), Oracle Enterprise Linux (OEL)。(关于 : EPEL)
为CentOS7/RHEL7安装EPEL 仓库(repo)
方法一:命令安装

[root@idoseek ~]# yum -y install epel-release
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.unifiedlayer.com
* extras: mirrors.kernel.org
* updates: mirrors.syringanetworks.net
正在解决依赖关系
--> 正在检查事务
---> 软件包 epel-release.noarch.0.7-2 将被 安装
--> 解决依赖关系完成

依赖关系解决

====================================================================================================
Package                     架构                  版本                 源                     大小
====================================================================================================
正在安装:
epel-release                noarch                7-2                  extras                 13 k

事务概要
====================================================================================================
安装  1 软件包

总下载量:13 k
安装大小:22 k
Downloading packages:
epel-release-7-2.noarch.rpm                                                  |  13 kB  00:00:00    
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : epel-release-7-2.noarch                                                         1/1
  验证中      : epel-release-7-2.noarch                                                         1/1

已安装:
  epel-release.noarch 0:7-2                                                                        

完毕!
[root@idoseek ~]#
方法二:手动安装
针对系统架构选择相应的类型:http://dl.fedoraproject.org/pub/epel/7/。我们使用的x86_64,就要进入该目录下寻找相应包,安装方法如下:

# rpm -vih http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-2.noarch.rpm
或者:

# wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-2.noarch.rpm
# rpm -vih epel-release-7-2.noarch.rpm
更新包缓存
此时我们发现/etc/yum.repos.d/下多了两个epel的repo文件:

[root@idoseek ~]# ll /etc/yum.repos.d/
总用量 28
-rw-r--r-- 1 root root 1664 8月  22 12:21 CentOS-Base.repo
-rw-r--r-- 1 root root  649 8月  22 12:21 CentOS-Debuginfo.repo
-rw-r--r-- 1 root root  290 8月  22 12:21 CentOS-fasttrack.repo
-rw-r--r-- 1 root root 1331 8月  22 12:21 CentOS-Sources.repo
-rw-r--r-- 1 root root  156 8月  22 12:21 CentOS-Vault.repo
-rw-r--r-- 1 root root  957 9月   2 12:14 epel.repo
-rw-r--r-- 1 root root 1056 9月   2 12:14 epel-testing.repo
更新元数据缓存:
[root@idoseek ~]# yum clean all && yum makecache

来自:http://www.111cn.net/sys/CentOS/85450.htm
#其中按进程统计句柄数 第一列是打开的句柄数,第二列是进程ID。
lsof -n|awk '{print $2}'|sort|uniq -c|sort -nr
#其中按句柄类型统计句柄数 其中REG代表文件
lsof -n|awk '{print $5}'|sort|uniq -c|sort -nr
#查看总共文件句柄数
lsof|wc -l
#查看网络句柄数 和用netstat统计一样,原理是:linux中一切皆文件(内存、网络、硬盘。。。)
lsof |grep IPv4|wc -l
lsof |grep TCP|wc -l


来自:https://blog.csdn.net/bolg_hero/article/details/77622616
=======================================================================================
背景:有时候出现句柄数不够用的情况,得用awk去统计一下各个进程的句柄数之和是否超过设置的句柄数了,cat /tmp/runProNumFds.txt | awk '{a=a+$1}END{print a}' ,这样好再次重新设置一下句柄的值。
ulimit -n
65535

----查看当前进程打开了多少句柄数

# lsof -n|awk '{print $2}'|sort|uniq -c|sort -nr|more


压力测试时一看这些句柄数的一个情况,如下:
lsof -n|awk '{print $2}'|sort|uniq -c|sort -nr
1063 23973
1030 23975
739 23972
522 23971
139 64672
136 3569
136 3568
136 3454
136 3450
136 3449


lsof -n|awk '{print $2}'|sort|uniq -c|sort -nr >> /tmp/runProNumFds.txt
简单的把第1列加起来:
cat /tmp/runProNumFds.txt | awk '{a=a+$1}END{print a}'
47465
Awk求和参考自:http://blog.sina.com.cn/s/blog_710844930100pzxj.html

ps aux|grep -E "23975|23972|23973|64672"
root      4374  0.0  0.0 103316   880 pts/1    S+   17:25   0:00 grep -E 23975|23972|23973|64672
www      23972  2.2  0.1  65656 22788 ?        S    15:09   3:00 nginx: worker process                                          
www      23973  3.1  0.1  65656 22784 ?        S    15:09   4:16 nginx: worker process                                          
www      23975  1.9  0.1  65656 22780 ?        S    15:09   2:39 nginx: worker process                                          
root     64672  0.3  0.0 576792  6536 ?        Ss   17:09   0:03 php-fpm: master process (/usr/local/php/etc/php-fpm.conf)  
============================================================================


背景:做一些大量的句柄打开的操作,很有必要看到底打开了多少。如inodity监控啥的。
[root@mongodb11 ~]# ulimit -a
                     ......
open files                      (-n) 1024
                     ......


----查看当前进程打开了多少句柄数
# lsof -n|awk '{print $2}'|sort|uniq -c|sort -nr|more
131 24204 
57 24244  
57 24231   ........
其中第一列是打开的句柄数,第二列是进程ID。





---查看系统默认的最大文件句柄数,系统默认是1024

# ulimit -n

1024



----查看当前进程打开了多少句柄数

# lsof -n|awk '{print $2}'|sort|uniq -c|sort -nr|more

131 24204 

57 24244  

57 24231   ........

其中第一列是打开的句柄数,第二列是进程ID。

可以根据ID号来查看进程名。

# ps aef|grep 24204

nginx  24204 24162 99 16:15 ?    00:24:25 /usr/local/nginx/sbin/nginx -s



Linux有硬性限制和软性限制。可以通过ulimit来设定这两个参数。方法如下,以root用户运行以下命令:

# ulimit -HSn 4096

以上命令中,H指定了硬性大小,S指定了软性大小,n表示设定单个进程最大的打开文件句柄数量。个人觉得最好不要超过4096,毕竟打开的文件句柄数越多响应时间肯定会越慢。设定句柄数量后,系统重启后,又会恢复默认值。如果想永久保存下来,可以修改.bash_profile文件,可以修改 /etc/profile 把上面命令加到最后.

原文:http://leequery.blog.163.com/blog/static/1684220962010101023743567/

更多:http://liuzhigong.blog.163.com/blog/static/1782723752013817916611/
origin 是默认的远程版本库名称
你可以在 .git/config 之中进行修改

事实上 git push origin master 的意思是 git push origin master:master (将本地的 master 分支推送至远端的 master 分支,如果没有就新建一个)
背景:运维这个活其实是系统偏重的活,鄙人一直没做过运维,干了不到一个月,感觉发现其实也有点打杂的感觉,但都是围绕系统、权限、分配多机器、调度、维修、协调、沟通,特别是strace在启动一些服务时启动不了,用它就能很好的定位问题在哪儿。
下面这个主要是讲常用 的一个命令,如下:
运维利器:万能的strace:(批注:这个哥们写得好,赞一个:跟踪进程启动,跟踪命令的执行,根据进程号跟踪,启动时都访问了哪些文件。)
http://www.yunweipai.com/archives/7334.html?utm_source=tuicool&utm_medium=referral

1)跟踪进程启动,主要是系统调用:
strace -tt -f  ./some_server ../conf/some_server.conf

2)通过它启动要跟踪的进程:
strace ls -lh /var/log/messages

3)在运行的some_server服务:
pidof some_server
17553

得到其pid 17553然后就可以用strace跟踪其执行:
strace -p 17553

strace常用选项:
从一个示例命令来看:
strace -tt -T -v -f -e trace=file -o /data/log/strace.log -s 1024 -p 23489

-tt 在每行输出的前面,显示毫秒级别的时间
-T 显示每次系统调用所花费的时间
-v 对于某些相关调用,把完整的环境变量,文件stat结构等打出来。
-f 跟踪目标进程,以及目标进程创建的所有子进程
-e 控制要跟踪的事件和跟踪行为,比如指定要跟踪的系统调用名称
-o 把strace的输出单独写到指定的文件
-s 当系统调用的某个参数是字符串时,最多输出指定长度的内容,默认是32个字节
-p 指定要跟踪的进程pid, 要同时跟踪多个pid, 重复多次-p选项即可。


实例:跟踪nginx, 看其启动时都访问了哪些文件
strace -tt -T -f -e trace=file -o /data/log/strace.log -s 1024 ./nginx



附录:
使用strace追踪多个进程:
http://www.ttlsa.com/tools/use-strace-to-track-multiple-processes/

如何使用strace+pstack利器分析程序性能:
http://www.cnblogs.com/bangerlee/archive/2012/04/30/2476190.html
strace_pstack]# gcc server.c -g -o server
strace_pstack]# gcc client.c -g -o client
[root@iZ25dcp92ckZ strace_pstack]# ./server
listening...
hello
hello
hello
hello

[root@iZ25dcp92ckZ strace_pstack]# ./client

ps -elf | grep server | grep -v grep
0 S root     2327417130  0  80   0 -  1041 hrtime 14:58 pts/1    00:00:00 ./server
[root@iZ25dcp92ckZ strace_pstack]# strace -o server.strace -Ttt -p 23274
Process 23274 attached
能看到生成的server.strace 脚本里时间相差1;s不对,nanosleep:


用pstack脚本找到是哪儿调用了nanosleep系统函数导致慢了1s:
[root@iZ25dcp92ckZ strace_pstack]# sh pstack.sh 23274
#0  0x00007f75e5bec480 in __nanosleep_nocancel () from /lib64/libc.so.6
#1  0x00007f75e5bec334 in sleep () from /lib64/libc.so.6
#2  0x0000000000400813 in ha_ha ()
#3  0x0000000000400aea in main ()


[root@iZ25dcp92ckZ strace_pstack]# vi pstack.sh
背景:大学学习c语言够久,但对浮点数是如何存储和读取实现的,突然想到,觉得有点意思,查了下发现还是有点意思的,特摘录如下。
类型float大小为4字节,即32位,内存中的存储方式如下:
符号位(1 bit) 指数(8 bit)尾数(23 bit)
123.456
+1.23456E+2
类型double大小为8字节,即64位,内存布局如下:
符号位(1 bit)指数(11 bit) 尾数(52 bit)
浮点数float保存的字节格式如下:
地址 +0 +1 +2 +3
内容 SEEE EEEE EMMM MMMM MMMM MMMM MMMM MMMM
这里
S 代表符号位,1是负,0是正
E 偏移127的指数(exp),二进制阶码=(EEEEEEEE)-127。
M 24位的尾数(mantissa)。保存在23位中,只存储23位,最高位固定为1。此方法用最较少的位数实现了
较高的有效位数,提高了精度。
零是一个特定值,指数是0 尾数也是0。
浮点数-12.5作为一个十六进制数0xC1480000保存在存储区中,这个值如下: 地址 +0 +1 +2 +3
内容0xC1 0x48 0x00 0x00
浮点数和十六进制等效保存值之间的转换相当简单。下面的例子说明上面的值-12.5如何转换。
浮点保存值不是一个直接的格式,要转换为一个浮点数,位必须按上面的浮点数保存格式表
所列的那样分开,例如:
地址 +0 +1 +2 +3
格式 SEEE EEEE EMMM MMMM MMMM MMMM MMMM MMMM
二进制 11000001 01001000 00000000 00000000
十六进制 C1 48 00 00
从这个例子可以得到下面的信息:
符号位是1 表示一个负数
指数是二进制10000010或十进制130,130减去127是3,就是实际的指数。 尾数是后面的二进制数1001 0000 0000 0000 0000 000
在尾数的左边有一个省略的小数点和1,这个1在浮点数的保存中经常省略,加上一个1和小数
点到尾数的开头,得到尾数值如下:
1.1001 0000 0000 0000 0000 000
接着C语言小数的内存表示,根据指数调整尾数.一个负的指数向左移动小数点.一个正的指数向右移动小数点.因为 指数是3,尾数调整如下:
1100.10000000000000000000
2/3页
结果是一个二进制浮点数,小数点左边的二进制数代表所处位置的2的指数,例如:1100表示
(1*2^3)+(1*2^2)+(0*2^1)+(0*2^0)+ 1*2^(-1)=12.5。
因为设置的符号位表示这数是负的,因此十六进制值0xC1480000表示-12.5。
7F7FFFFF
0111 1111 0111 1111 1111 1111 1111
+
1111 11102=25410
254-127=127
1.111 1111 1111 1111 1111 1111*2127
1111 1111 1111 1111 1111 1111*2104
=(10000 0000 0000 0000 0000 00002-1) *2104
=(224-1) *2104
=3.4E+38
推导出float精度为7位
1111 1111 1111 1111 1111 1111
2^24-1
16777215
1.6777215E7
1.23456789
1111

来自:http://wapwenku.baidu.com/view/958f563c580216fc700afd10.html?ssid=0&from=844b&uid=0&pu=usm@0,sz@1320_1002,ta@iphone_2_5.1_2_6.6&bd_page_type=1&baiduid=D64FEF90FEB247AE244A958817E6D953&tj=www_normal_4_0_10_title#1
背景:最后卡开机画面了,无论咋apt-get重新安装都不行,Ubuntu16.04下没有声音的解决方法,平时用Firefox或Chrome下的Flash插件。最后重新安装后好了。
          由于这个笔记本太老了华硕A8F,还是大学时候的老笔记本了,后来装了Ubuntu16.04发现它运行并不快,再就是Ubuntu16.04的后面版本Ubuntu17.04吧,也是一个过渡版本,
          于是,装了一个Ubuntu17.04的ubuntu 17.04 gnome3版本,觉得性能要好一些,可能和这个gnome3是C写的有关吧,再就是Ubuntu想用这个KDE做手机端,现在没有做得起来,还是回到了gnome3,我觉得是一个明智的选择,其实现在很少有人装Linux,再就是很多装Linux的人都是GEEK,笔记本配置都不会高到哪儿去这才是真实情况啊。
         Ubuntu17.04吧,这个版本的声卡不发声,于是按最后的方法做了一下配置好了,折腾了好久,不容易,这也是开源的一个实实在在的问题,如果自由微软收费合理又系统不错,还是用Win10吧,前提你有钱买好点的硬件。



Intel GMA950,http://blog.chinaunix.net/uid-2595338-id-2139474.html
http://ubuntuforums.org/showthread.php?t=205449
(1)检查系统

aplay -l


应该能看到安装的声卡设备,否则应该就是驱动安装失败了。

etual@Hikari:~$ aplay -l
**** PLAYBACK硬件设备列表 ****
卡 0: Intel [HDA Intel], 设备 0: ALC662 Analog [ALC662 Analog]
  子设备: 0/1
  子设备:#0: subdevice #0
卡 0: Intel [HDA Intel], 设备 1: ALC662 Digital [ALC662 Digital]
  子设备: 1/1
  子设备:#0: subdevice #0

(2)检查一下系统设备是否有检测到声卡

lspci -v


应该能看到类似的:
00:1b.0 Audio device: Intel Corporation NM10/ICH7 Family High Definition Audio Controller (rev 02)
  Subsystem: ASUSTeK Computer Inc. NM10/ICH7 Family High Definition Audio Controller
  Flags: bus master, fast devsel, latency 0, IRQ 29
  Memory at feb3c000 (64-bit, non-prefetchable) [size=16K]
  Capabilities: [50] Power Management version 2
  Capabilities: [60] MSI: Enable+ Count=1/1 Maskable- 64bit+
  Capabilities: [70] Express Root Complex Integrated Endpoint, MSI 00
  Capabilities: [100] Virtual Channel
  Capabilities: [130] Root Complex Link
  Kernel driver in use: snd_hda_intel
  Kernel modules: snd_hda_intel

(3)通过ubuntu的APT-GET安装,好吧,我就是通过这个搞回来的驱动,推荐!
首先,将原来的卸载干净

sudo apt-get --purge remove linux-sound-base alsa-base alsa-utils

千万注意,因为依赖关系,多删除了部分东西,必须装回来,否则重启后就进不了桌面了。
出现进入不了桌面一是ctrl alt f到f7,再就是恢复模式了:http://m.blog.csdn.net/article/details?id=9199939

sudo apt-get install gdm ubuntu-desktop

下面就是安装了

sudo apt-get install linux-sound-base alsa-base alsa-utils


恩,经过漫长的下载安装,重启后,我的UBUNTU又在发出声音了,yeah~~~
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
最后就是修改一下音量,顺便保存一下:

alsamixer

调节好之后保存

sudo alsactl store 0


到此就完毕了,继续听歌,yeah~~~
有兴趣的看看原文吧,还有不少东西的呢:
http://ubuntuforums.org/showthread.php?t=205449



没有声音的原因是因为当前用户没有使用声卡相关设备的权限:

ls -l /dev/snd 查看了一下,发现用户权限为 root 用户组为audio

解决方法为将当前用户加入audio组就可以了。

使用usermod -a -G audio username

就可以解决啦。
实践如下:
[jackxiang@jackX ~]$ ls -l /dev/snd
总用量 0
drwxr-xr-x  2 root root       60 5月  14 23:10 by-path
crw-rw----+ 1 root audio 116,  2 5月  14 23:10 controlC0
crw-rw----+ 1 root audio 116,  8 5月  14 23:10 hwC0D0
crw-rw----+ 1 root audio 116,  9 5月  14 23:10 hwC0D1
crw-rw----+ 1 root audio 116,  4 5月  14 23:10 pcmC0D0c
crw-rw----+ 1 root audio 116,  3 5月  14 23:10 pcmC0D0p
crw-rw----+ 1 root audio 116,  5 5月  14 23:23 pcmC0D1p
crw-rw----+ 1 root audio 116,  7 5月  14 23:10 pcmC0D6c
crw-rw----+ 1 root audio 116,  6 5月  14 23:10 pcmC0D6p
crw-rw----+ 1 root audio 116,  1 5月  14 23:10 seq
crw-rw----+ 1 root audio 116, 33 5月  14 23:10 timer
[jackxiang@jackX ~]$ id
uid=1000(jackxiang) gid=1000(jackxiang) 组=1000(jackxiang),129(wireshark)
[jackxiang@jackX ~]$ usermod -a -G audio jackxiang
usermod: Permission denied.
usermod:无法锁定 /etc/passwd,请稍后再试。
[jackxiang@jackX ~]$ sudo su -

id发现其是jackxiang,不是root,则把jackxiang和root一起加到组里面去:
chmod -R a+rwx /dev/snd
[root@jackX ~]# usermod -a -G audio jackxiang
[root@jackX ~]# usermod -a -G audio root

参考:http://blog.sina.com.cn/s/blog_5ce530a10100kyxf.html

——————————————————————————————
/home/xiangdong/下载/alsa-driver-1.0.25/SUPPORTED_KERNELS
cat /home/xiangdong/下载/alsa-driver-1.0.25/SUPPORTED_KERNELS
The alsa-drivers in this package are designed for the following kernels:

- Vanilla 3.0 to 3.2
- Vanilla 2.6.18 to 2.6.39

It's not guaranteed that they work with any newer version than above
or modified kernels by distributors.

It might be eventually possible to build the alsa-drivers with older
modified kernels by distributors (2.6.9+). These kernels have backported
many things from more recent vanilla kernels.

http://blog.csdn.net/ldl22847/article/details/8616921
http://blog.chinaunix.net/uid-30031530-id-5177359.html
http://blog.chinaunix.net/uid-20069582-id-227907.html

太旧了,下面这个版本:
Linux xiangdong-A8F 4.10.0-21-generic  
Ubuntu 10.04是我使用的第一个Linux系统,一开始就碰上这种问题让我很恼火,也折腾很长时间没搞定,终于在Ubuntu中文论坛上找到了yechao1989提供的解决办法,我把它粘过来留着以后自己可能还有用。我的本子是联想天逸F40,声卡为Analog Devices AD1986A。

1.检测声卡

代码:

sudo head -1 /proc/asound/card0/codec#0

2.修改配置文件

代码:

sudo gedit /etc/modprobe.d/alsa-base.conf

找到如下段:

代码:

# Keep snd-pcsp from being loaded as first soundcard

options snd-pcsp index=-2

注销下面语句

代码:

#options snd-pcsp index=-2

添加下面语句

代码:

options snd-hda-intel model=laptop-eapd

3.重启电脑

再试下喇叭,ok啦

但紧接着又出现让人郁闷的问题了,耳机喇叭一起响,按照如下方法也没有用:

打开新立得,安装gnome-alsamixer,运行,在“Headphone Jack Sense”打勾,插上耳机喇叭不再同时响了。

再找找办法吧



这个驱已经Ok了,只做下设置:
/home/xiangdong/下载/alsa-driver-1.0.25/alsa-kernel/Documentation/HD-Audio-Models.txt

AD1986A
=======
  6stack        6-jack, separate surrounds (default)
  3stack        3-stack, shared surrounds
  laptop        2-channel only (FSC V2060, Samsung M50)
  laptop-eapd   2-channel with EAPD (ASUS A6J)
  laptop-automute 2-channel with EAPD and HP-automute (Lenovo N100)
  ultra         2-channel with EAPD (Samsung Ultra tablet PC)
  samsung       2-channel with EAPD (Samsung R65)
  samsung-p50   2-channel with HP-automute (Samsung P50)
如果系统原来已经有 ALSA 驱动,但是没有识别声卡或者声音驱动有问题。那么理论上只需要在两个地方做改动:
添加 /etc/modprobe.d/sound 文件,内容为:
alias snd-card-0 snd-hda-intel
alias sound-slot-0 snd-hda-intel


vi  /etc/modprobe.d/alsa-base.conf
# options snd-pcsp index=-2
options snd-hda-intel model=laptop-eapd
-p, --password PASSWORD       encrypted password of the new account
阅读全文
背景:查了下ansible这块,好像可以通过pip安装,尽管后面是用的yum,但是后面还是得用pip安装ansible的其它模块,特备忘之用。
1、pip下载安装
1.1 pip下载

# wget "https://pypi.python.org/packages/source/p/pip/pip-1.5.4.tar.gz#md5=834b2904f92d46aaa333267fb1c922bb" --no-check-certificate
# wget "https://pypi.python.org/packages/source/p/pip/pip-1.5.4.tar.gz#md5=834b2904f92d46aaa333267fb1c922bb" --no-check-certificate
1.2 pip安装

# tar -xzvf pip-1.5.4.tar.gz
# cd pip-1.5.4
# python setup.py install
# tar -xzvf pip-1.5.4.tar.gz
# cd pip-1.5.4
# python setup.py install
2. pip使用详解
2.1 pip安装包

# pip install SomePackage
  [...]
  Successfully installed SomePackage
# pip install SomePackage
  [...]
  Successfully installed SomePackage
2.2 pip查看已安装的包

# pip show --files SomePackage
  Name: SomePackage
  Version: 1.0
  Location: /my/env/lib/pythonx.x/site-packages
  Files:
   ../somepackage/__init__.py
   [...]
# pip show --files SomePackage
  Name: SomePackage
  Version: 1.0
  Location: /my/env/lib/pythonx.x/site-packages
  Files:
   ../somepackage/__init__.py
   [...]
2.3 pip检查哪些包需要更新

# pip list --outdated
  SomePackage (Current: 1.0 Latest: 2.0)
# pip list --outdated
  SomePackage (Current: 1.0 Latest: 2.0)
2.4 pip升级包

# pip install --upgrade SomePackage
  [...]
  Found existing installation: SomePackage 1.0
  Uninstalling SomePackage:
    Successfully uninstalled SomePackage
  Running setup.py install for SomePackage
  Successfully installed SomePackage
# pip install --upgrade SomePackage
  [...]
  Found existing installation: SomePackage 1.0
  Uninstalling SomePackage:
    Successfully uninstalled SomePackage
  Running setup.py install for SomePackage
  Successfully installed SomePackage
2.5 pip卸载包

$ pip uninstall SomePackage
  Uninstalling SomePackage:
    /my/env/lib/pythonx.x/site-packages/somepackage
  Proceed (y/n)? y
  Successfully uninstalled SomePackage
$ pip uninstall SomePackage
  Uninstalling SomePackage:
    /my/env/lib/pythonx.x/site-packages/somepackage
  Proceed (y/n)? y
  Successfully uninstalled SomePackage
3. pip使用实例
3.1 安装redis

# pip install redis
# pip install redis
3.2 卸载redis

# pip uninstall redis
Uninstalling redis:
  /usr/lib/python2.6/site-packages/redis-2.9.1-py2.6.egg-info
.....省略一些内容....
Proceed (y/n)? y
  Successfully uninstalled redis
# pip uninstall redis
Uninstalling redis:
  /usr/lib/python2.6/site-packages/redis-2.9.1-py2.6.egg-info
.....省略一些内容....
Proceed (y/n)? y
  Successfully uninstalled redis
3.3 查看待更新包

pip list --outdate
pygpgme (Current: 0.1 Latest: 0.3)
pycurl (Current: 7.19.0 Latest: 7.19.3.1)
iniparse (Current: 0.3.1 Latest: 0.4)
pip list --outdate
pygpgme (Current: 0.1 Latest: 0.3)
pycurl (Current: 7.19.0 Latest: 7.19.3.1)
iniparse (Current: 0.3.1 Latest: 0.4)
4. 常见错误
4.1 ImportError No module named setuptools
请参考《ImportError No module named setuptools解决》
5. pip参数解释

# pip --help

Usage:  
  pip <command> [options]

Commands:
  install                     安装包.
  uninstall                   卸载包.
  freeze                      按着一定格式输出已安装包列表
  list                        列出已安装包.
  show                        显示包详细信息.
  search                      搜索包,类似yum里的search.
  wheel                       Build wheels from your requirements.
  zip                         不推荐. Zip individual packages.
  unzip                       不推荐. Unzip individual packages.
  bundle                      不推荐. Create pybundles.
  help                        当前帮助.

General Options:
  -h, --help                  显示帮助.
  -v, --verbose               更多的输出,最多可以使用3次
  -V, --version               现实版本信息然后退出.
  -q, --quiet                 最少的输出.
  --log-file <path>           覆盖的方式记录verbose错误日志,默认文件:/root/.pip/pip.log
  --log <path>                不覆盖记录verbose输出的日志.
  --proxy <proxy>             Specify a proxy in the form [user:passwd@]proxy.server:port.
  --timeout <sec>             连接超时时间 (默认15秒).
  --exists-action <action>    Default action when a path already exists: (s)witch, (i)gnore, (w)ipe, (b)ackup.
  --cert <path>               证书.
# pip --help

Usage:  
  pip <command> [options]

Commands:
  install                     安装包.
  uninstall                   卸载包.
  freeze                      按着一定格式输出已安装包列表
  list                        列出已安装包.
  show                        显示包详细信息.
  search                      搜索包,类似yum里的search.
  wheel                       Build wheels from your requirements.
  zip                         不推荐. Zip individual packages.
  unzip                       不推荐. Unzip individual packages.
  bundle                      不推荐. Create pybundles.
  help                        当前帮助.

General Options:
  -h, --help                  显示帮助.
  -v, --verbose               更多的输出,最多可以使用3次
  -V, --version               现实版本信息然后退出.
  -q, --quiet                 最少的输出.
  --log-file <path>           覆盖的方式记录verbose错误日志,默认文件:/root/.pip/pip.log
  --log <path>                不覆盖记录verbose输出的日志.
  --proxy <proxy>             Specify a proxy in the form [user:passwd@]proxy.server:port.
  --timeout <sec>             连接超时时间 (默认15秒).
  --exists-action <action>    Default action when a path already exists: (s)witch, (i)gnore, (w)ipe, (b)ackup.
  --cert <path>               证书.
6. 结束
安装使用一目了然,太简单了。


From:http://www.ttlsa.com/python/how-to-install-and-use-pip-ttlsa/

设备采用长连接与IoT Socket Server保持连接,不断开。每隔0.5秒上传一次数据,报文长度<200B。压测使用50组长连接为基数,从50,100,150,200,250,300,每隔50基数做测试。此事发现:CPU占用率维持在25%左右,出网带宽维持在125kbps,但是入网带宽随着压测而上升到500kbps。由于IDC入网带宽统计严重滞后于出网带宽。出现非实时的出网带宽统计,甚至绘图不完整。只能够推测数值。

但是由于外网带宽总数在1Mbps,所以300台左右时,总带宽大约在600~700kbps左右,此时TeraTerm输入命令已经感觉到了延时。

结论
1Mbps带宽是系统瓶颈,即使采用高配服务器并不能够改善并实现高并发的IO连接数。

但实际上,每0.5秒发送200B,相当于400 B/s = 3.2kbps。而1Mbps支持300台设备,相当于每台占用带宽为3.5kbps。


来自:https://segmentfault.com/q/1010000004214610


300个是125kbps啊,,我说的呢,
3000 = 1250kbps
1250/8 = 416kbps  如果说是要很密集还得x参数
416.66666666666666666666666666667
uerdel删除用户时候提示:userdel: user ** is currently logged in


今天在删除用户账号的时候,发现一个奇怪现象,即:
#userdel -r aaron

userdel: user aaron is currently logged in


解决方法:
mv /var/run/utmp /var/run/utmp_old      //将原文件改名
touch > /var/run/utmp        //新创建一同名文件

再次执行删除操作。。。成功删除用户

关于:/var/run/utmp

utmp是一个文件,除了utmp程序你不能编辑这个文件,删掉他的话,当前登陆信息都会丢失。这个文件在每次机器reboot起来后都会重新创建。

更多关于utmp文件介绍请参考下面说明:
/var/run/utmp

  该日志文件记录有关当前登录的每个用户的信息。因此这个文件会随着用户登录和注销系统而不断变化,它只保留当时联机的用户记录,不会为用户保留永久的记录。系统中需要查询当前用户状态的程序,如 who、w、users、finger等就需要访问这个文件。该日志文件并不能包括所有精确的信息,因为某些突发错误会终止用户登录会话,而系统没有及时更新 utmp记录,因此该日志文件的记录不是百分之百值得信赖的。

 (/var/log/wtmp、/var/log/utmp、/var/log/lastlog)是日志子系统的关键文件,都记录了用户登录的情况。这些文件的所有记录都包含了时间戳。这些文件是按二进制保存的,故不能用less、cat之类的命令直接查看这些文件,而是需要使用相关命令通过这些文件而查看。其中,utmp和wtmp文件的数据结构是一样的,而lastlog文件则使用另外的数据结构,关于它们的具体的数据结构可以使用man命令查询。

  每次有一个用户登录时,login程序在文件lastlog中查看用户的UID。如果存在,则把用户上次登录、注销时间和主机名写到标准输出中,然后login程序在lastlog中记录新的登录时间,打开utmp文件并插入用户的utmp记录。该记录一直用到用户登录退出时删除。utmp文件被各种命令使用,包括who、w、users和finger。

  下一步,login程序打开文件wtmp附加用户的utmp记录。当用户登录退出时,具有更新时间戳的同一utmp记录附加到文件中。wtmp文件被程序last使用。


但是,本人自己试验了还是不行,依旧得到同样的提示
      那就暴力删除该用户吧:
      $userdel -r -f XXXX
    提示:userdel: warning: can't remove /var/mail/git: No such file or directory
          userdel: git home directory (/home/git) not found
但是没关系。实际上已成功删除用户。

来自:http://www.2cto.com/os/201408/328936.html
实践发现,ubunut16.0.4里面的chromium没法设置代理的,而是采用了下面这个办法进行命令行设置:
在受支持的桌面环境中运行Chromium时,将使用系统代理设置。但您的系统不受支持,或启动系统配置时出现问题。
但您仍可通过命令行进行配置。如需详细了解各项实验功能和环境变量,请参见 man chromium-browser。

=========================================================================================
先安装再代理 ,安装后可以google: http://jackxiang.com/post/8703/

受支持的桌面环境中运行Chromium时,将使用系统代理设置。但您的系统不受支持,或启动系统配置时出现问题。
但您仍可通过命令行进行配置。如需详细了解各项实验功能和环境变量,请参见 man chromium-browser。


安装好google-chrome(或者chromium也行)后,我们发现浏览器的设置中,代理配置功能失效,显示为:

在受支持的桌面环境中运行google-chrome时,将使用系统代理设置。但您的系统不受支持,或启动系统配置时出现问题。

但您仍可通过命令行进行配置。如需详细了解各项实验功能和环境变量,请参见 man google-chrome。

2、关闭该google-chrome,并重新从命令行启动,加入一个参数:

jackX@thinkpad:~$ google-chrome --proxy-server="socks5://localhost:8787"
chromium-browser --proxy-server="socks5://localhost:8787"

值得注意的是,由于我平常windows环境下使用的代理工具为:chrome+SwitchyOmega插件+MyEntunnel,配置是SSH+socks5,所以一开始没有在–proxy-server参数中指定socks5,导致启动后代理失效。(可通过google-chrome –help了解详细参数)

chrome成功启动后,打开百度输入“ip”,可显示我的代理服务器IP,说明代理成功启用。
[root@jackX ~]# vi /etc/sudoers
在 /etc/sudoers 中添加:
Defaults editor=/usr/bin/vim, env_editor
即可将默认编辑器设置为 vim。
apt-get install vim
root@jack:~# which vim
/usr/bin/vim
[root@jackX ~]# update-alternatives --config editor
有 4 个候选项可用于替换 editor (提供 /usr/bin/editor)。

  选择       路径              优先级  状态
------------------------------------------------------------
* 0            /bin/nano            40        自动模式
  1            /bin/ed             -100       手动模式
  2            /bin/nano            40        手动模式
  3            /usr/bin/vim.basic   30        手动模式
  4            /usr/bin/vim.tiny    10        手动模式

要维持当前值[*]请按<回车键>,或者键入选择的编号:3
update-alternatives: 使用 /usr/bin/vim.basic 来在手动模式中提供 /usr/bin/editor (editor)
From:http://blog.longwin.com.tw/2008/10/ubuntu-debian-modify-default-edit-2008/
chrome和firefox都没法使用Flash:

sudo apt-get install software-center

http://tieba.baidu.com/p/4395787288
分页: 20/40 第一页 上页 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 下页 最后页 [ 显示模式: 摘要 | 列表 ]