Linux Problems
文章平均质量分 51
duyiwuer2009
这个作者很懒,什么都没留下…
展开
-
samba 配置
查看 samba 用户pdbedit -L启动/停止/重启/查看状态service smb status/...添加用户及用户目录smbpasswd -a xxx # 必须是已有的系统用户 # 目录默认为系统家目录Linux 上测试[root@TENCENT64 /usr/local/samba/bi原创 2015-04-23 14:38:29 · 765 阅读 · 0 评论 -
Linux 文件锁与 inode
1. 进程 A 排他锁住某文件之后,进程 B 可以修改该文件,但不能锁住该文件。2. 进程 A 排他锁住某文件之后,进程 B 修改该文件之后,因为文件 inode 没有改变,所以依然不能锁住该文件。3. 进程 A 排他锁住某文件之后,进程 B 可以删除该文件,并创建同名文件,此时进程 B 可以锁住该文件。由于 vi, sed 等程序修改文件会改变文件 inode, 所以会导致被 A 进原创 2015-04-24 20:51:42 · 1801 阅读 · 0 评论 -
vi, sed 等程序竟然后改变文件 inode!!!
创建一个文件 lock.txt, 内容只有 "123" 三个字符:> ls -i lock.txt2172299 lock.txt> vi lock.txt"lock.txt" 1L, 5C 已写入原创 2015-04-24 20:35:18 · 1729 阅读 · 3 评论 -
用 Telnet 检查是否能连接远程 TCP 端口
445 为 samba 服务器绑定的端口:telnet 10.12.16.178 445按 【Ctrl+]】进入 Telnet 命令行:欢迎使用 Microsoft Telnet ClientEscape 字符为 'CTRL+]'Microsoft Telnet>说明连接正常!原创 2015-04-23 14:35:03 · 5772 阅读 · 0 评论 -
struct tm 中的 tm_isdst 以及 mktime
tm_isdstmktime() 将 struct tm 描述的时间转换成时间戳,tm_isdst 只是传入的时间是否是 DST(夏令时),tm_isdst 含有:>0: 是 DST=0: 不是 DST性能同事测的传入 1 和 0 的i性能对比:1: 1w 次耗时 2s0: 1w 次耗时 0.02s原创 2015-01-06 15:25:08 · 20080 阅读 · 1 评论 -
Linux core dump
core file 的目录$ cat /proc/sys/kernel/core_pattern/data/corefile/core_%e_%t$ cat /proc/sys/kernel/core_uses_pid1%e, %t 的含义查看 man coreIf the /proc/sys/kernel/core_uses_pid file contains the val原创 2014-12-29 14:49:35 · 658 阅读 · 0 评论 -
Linux 目录和文件的默认访问权限——umask
今天安装 SCons,编译xiangmu原创 2014-10-29 21:49:11 · 4353 阅读 · 0 评论 -
设置网卡混杂模式
~$ sudo ifconfig eth0 promisc # 设置混杂模式~$ sudo ifconfig eth0 -promisc # 取消混杂模式~$ sudo ip link set eth0 promisc on~$ sudo ip link set eth1 promisc off原创 2014-05-23 23:24:26 · 8129 阅读 · 2 评论 -
VMware 常见问题
Ubuntu 安装 VMware tools 时 kernel header原创 2014-05-12 13:10:37 · 2929 阅读 · 0 评论 -
Ubuntu 12.04 LTS 查看网卡硬件信息
$ lspci | grep -i 'eth'02:00.0 Ethernet controller: Intel Corporation 82545EM Gigabit Ethernet Controller (Copper) (rev 01)02:01.0 Ethernet controller: Intel Corporation 82545EM Gigabit Ethernet Con原创 2014-05-19 17:09:41 · 7917 阅读 · 0 评论 -
修改shell环境字符集(locale)
查看 locale:原创 2014-10-29 17:19:12 · 8704 阅读 · 0 评论 -
进程收不到网络数据,但 tcpdump 能抓到包
情景:服务端进程绑定了 udp://0.0.0.0:10004 端口,客户单一直在往服务端发送数据,但是 strace 发现,服务端进程一直都在轮询调用 epoll_wait, 也就是服务端程序一直都没有收到过时间通知。但是通过 tcpdump 抓 udp 10004 端口的数据却能抓到。查看了一下 iptables 的配置:Chain ETH1_UDP (1 references)ta原创 2015-05-22 18:39:22 · 9368 阅读 · 2 评论 -
用户和权限管理
$ sudo chown -vR hwx dir$ sudo chgrp -vR hwx dir$ sudo chown -vR hwx:hwx dir-v: 显示详细信息-R: 递归原创 2013-03-13 13:27:37 · 890 阅读 · 0 评论 -
hping - 使用 TCP/UDP ping 解决防火墙拦截 ICMP ping
使用场景暴露在外网环境的服务通常会只对白名单内的来源机器开放服务使用的端口,比如 B 机器只对 A 机器开放 TCP 8999 端口,这样会导致 A ping B 收不到回包,无法查看 TTL 与丢包率。 hping 能指定 IP/ICMP/TCP/UDP 进行 ping, 对于上述场景,使用 hping 的 TCP 模式即可解决。hping 支持的模式# hping --helpMode原创 2016-09-14 15:50:45 · 15956 阅读 · 0 评论 -
tcpdump 分析 TCP 通信过程
step1: connect(client)14:26:17.213856 IP 172.25.40.208.49040 > 172.25.40.208.9999: S 2796874307:2796874307(0) win 32767 <mss 16396,sackOK,timestamp 166610063 166607508,nop,wscale 2>14:26:17.213876 IP原创 2016-06-20 17:09:28 · 577 阅读 · 0 评论 -
使用 dmesg 和 addr2line 分析程序 core 原因
今天遇到这样一种情况:发现进程 tagent 在发送响应时退出了,退出原因未知,因为没有 core 文件,无从分析。core 文件生成目录和 ulimit 都没有任何问题,就是不生成 core 文件:$ cat /proc/sys/kernel/core_patterncore.%p_%e$ ulimit -cunlimited写了个小程序也能生成 core, 没有 core 文件,只能另觅他径原创 2016-04-13 17:49:55 · 3999 阅读 · 1 评论 -
Ubuntu 12.04 LTS 查看网关地址方法汇总
1. ip route show$ ip route showdefault via 192.168.217.2 dev eth0 metric 100 192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1 192.168.217.0/24 dev eth0 proto kernel sco原创 2014-05-19 16:59:26 · 20449 阅读 · 0 评论 -
Ubuntu 12.04 LTS 修改主机名
1. 编辑 /etc/hostname2. 替换主机名原创 2014-05-19 19:46:18 · 1517 阅读 · 0 评论 -
/etc/fstab 参数详解及如何设置开机自动挂载
某些时候当Linux系统下划分了新的分区后,需要将这些分区设置为开机自动挂载,否则,Linux是无法使用新建的分区的。 /etc/fstab 文件负责配置Linux开机时自动挂载的分区。Windows的文件结构是多个并列的树状结构,最顶部的是不同的磁盘(分区),如:C,D,E,F等。Linux的文件结构是单个的树状结构。最顶部的为根目录,即/。在根目录下,分为多个子目录,包括/bi转载 2013-03-07 02:56:45 · 88592 阅读 · 3 评论 -
【源码包编译】CentOS-5.7安装GTK+(未完)
----------codeblocks依赖的:wx-config --> wxWidgets----------wxWidgets依赖的:GTK+ - version >= 2.4.0----------GTK+查询是否已经安装:rpm -q gtk+rpm -qa | grep gtk没有安装gtk+----------------------原创 2011-11-26 08:45:06 · 11442 阅读 · 1 评论 -
vim只能粘贴50行的问题
在当前用户主目录(~)编辑~/.vimrc(如果不存在,新建这个文件),添加一行:set viminfo='1000,至于为什么要输入输入'1000,这个其实不重要,最主要的是输入http://forum.ubuntu.org.cn/viewtopic.php?f=68&t=93332&view=previous原创 2012-09-16 16:50:00 · 4905 阅读 · 1 评论 -
文件编码批量转换——转换一个目录中所有文本文件的编码
find target -type d -exec mkdir -p utf/{} \;find target -type f -exec iconv -f GBK -t UTF-8 {} -o utf/{} \;target 为目标目录,utf 为转换之后的目录 -c: 强制转换iconv -c -f GBK -t UTF-8 nginx.1 -o nginx.new原创 2012-10-18 19:14:12 · 1627 阅读 · 0 评论 -
查找和替换目录中所有文件中的某个字符串
1、查找目录下包含某个字符串的文件例:查找 dir 目录下所有包含 str 的文件。grep -lr 'str' dir2、vim替换单个文件中所有字符串方法例:替换当前文件中所有 old 为 new:%s/old/new/g3、替换目录下所有文件中到某个字符串——sed结合grep例:要将目录 dir 下面所有文件中的 old 都修改成new,这样做:原创 2012-10-20 01:29:51 · 6759 阅读 · 0 评论 -
Linux时间变慢解决方法
情景:系统为CentOS-5.4,硬件时间正确(查看硬件时间的方法见下面),系统时间每隔24小时会慢20分钟左右Linux将时钟分为系统时钟(System Clock)和硬件(Real Time Clock,简称RTC)时钟两种。系统时间是指当前Linux Kernel中的时钟,而硬件时钟则是主板上由电池供电的那个主板硬件时钟,这个时钟可以在BIOS的Standard BIOS Fetur转载 2012-09-19 21:54:40 · 9160 阅读 · 1 评论 -
fork()引起的printf()输出多次的问题
#include #include #include #include int main(){ pid_t pid; printf("before fork - with line break\n"); printf("before fork - no line break"); //fflush(stdout); if( (pid = fork()) < 0 ) {原创 2012-09-26 12:18:14 · 3129 阅读 · 0 评论 -
FAT32 分区目录普通用户不可访问、中文文件名乱码
/etc/fstab 修改之前:UUID=D9F6-901A /share vfat umask=0077,shortname=winnt 0 0所以,/share 目录权限为 700, 只有 root 有权限/etc/fstab 修改之后:UUID=D9F6-901A /share原创 2013-03-05 17:17:54 · 1808 阅读 · 0 评论 -
Windows 系统创建的 zip 文件在 Linux 下解压后中文名乱码解决
1、软件包系统:64 位 CentOS-6.3软件包:p7zip, convmvsudo yum localinstall convmv-1.15-1.el6.rf.noarch.rpm sudo yum localinstall p7zip-9.20.1-1.el6.rf.x86_64.rpm sudo yum localinstall p7zip-plugins-9.20.原创 2013-03-05 16:14:44 · 1192 阅读 · 0 评论 -
CentOS 6 安装 wine
1、使用第三方 yum 软件库http://blog.csdn.net/duyiwuer2009/article/details/86439192、安装 winesudo yum install wine原创 2013-03-09 16:20:58 · 1149 阅读 · 0 评论 -
CentOS 6 安装 Eclipse CDT
环境OS: CentOS-6.3-x86_64JDK: 1.6.0_41Eclipse: eclipse-java-juno-linux-gtk-x86_64CDT: cdt-master-8.1.0安装1、安装JDK2、安装Eclipse[root@CentOS-6 dl]# tar -xzvf eclipse-java-juno-linux-gtk-原创 2013-03-09 17:07:16 · 4100 阅读 · 0 评论 -
CentOS-6.3 安装 VMware Workstation 9
# ./VMware-Workstation-Full-9.0.0-812388.x86_64.bundle Extracting VMware Installer...done.Gtk-Message: Failed to load module "pk-gtk-module": libpk-gtk-module.so: 无法打开共享对象文件: 没有那个文件或目录Gtk-Message:原创 2013-03-06 23:20:25 · 4451 阅读 · 0 评论 -
软件包管理——yum 深入详解
1、yum 的配置文件(/etc/yum.conf), repo 文件(/etc/yum.repos.d)详解http://www.centos.org/docs/5/html/5.1/Deployment_Guide/c1-yum.html2、yum 特殊参数--installroot=root 指定安装软件时的根目录--enablerepo=repoidglob 暂原创 2013-03-06 19:53:50 · 6209 阅读 · 0 评论 -
CentOS 6(EL 6) 安装第三方 yum 软件库
1、安装 rpmfusion$sudo yum localinstall --nogpgcheck rpmfusion-free-release-6-1.noarch.rpmLoadedplugins: fastestmirror, refresh-packagekit, securityRepositorybase is listed more than once in原创 2013-03-06 20:35:45 · 2491 阅读 · 0 评论 -
为 yum添加其他源
为 yum添加其他源UsingOther Software Repositories,http://www.centos.org/docs/4/html/yum/sn-using-repositories.html更多软件包管理到资料,http://docs.fedoraproject.org/en-US/Fedora/14/html/Software_Management_Guide/i原创 2013-03-06 20:38:17 · 7025 阅读 · 0 评论 -
diff 实现算法
diffhttp://en.wikipedia.org/wiki/DiffLongest common subsequence problemhttp://en.wikipedia.org/wiki/Longest_common_subsequence_problemDiff Strategieshttps://neil.fraser.name/writing/原创 2013-08-28 20:01:10 · 5030 阅读 · 0 评论 -
普通用户为什么能修改自己的密码
/etc/passwd 文件用来存储所有用户的信息,任何用户都可以修改自己的密码,显然,普通用户在执行 /usr/bin/passwd 命令时修改了 /etc/passwd 文件(并不是说可以使用 vi 编辑器修改),但是,通过查看 /etc/passwd 文件的权限,发现普通用户对此文件仅有读权限,是什么原因导致普通用户可以修改 /etc/passwd 文件呢?这是因为 /u原创 2013-05-08 23:28:36 · 2635 阅读 · 0 评论 -
源码阅读工具 lxr 安装配置初探
说明:本文是第一次安装 lxr 的记录文章,适合加深对 lxr 的理解;如果是想迅速使用 lxr 的话,本文中有些地方对 lxr 的配置不太妥当,建议先阅读本文,然后再以 《LXRUserManual-1.2-en_UK-1.4.pdf》 为主实践==================================安装 Apache, MySQL, ctags, mod_perl===原创 2013-05-22 01:42:06 · 7908 阅读 · 1 评论 -
CentOS-6.3(Linux) 命令行 DSL 拨号
$ sudo yum install rp-pppoe$ sudo pppoe-setup[sudo] password for root: Welcome to the PPPoE client setup. First, I will run some checks onyour system to make sure the PPPoE client is installed原创 2013-03-05 20:11:58 · 3127 阅读 · 0 评论 -
为某个用户增加 sudo 权限
修改/etc/sudoers文件方法一(不推荐)#visudo -f /etc/sudoers在root ALL=(ALL) ALL 之后增加tom ALL=(ALL) ALLDefaults:tom timestamp_timeout=2,runaspw# 增加普通账户tom的sudo权限# timestamp_timeout=-1 只需验证一次密码,以后系统自动记忆,这里设的原创 2013-03-05 17:04:28 · 4064 阅读 · 0 评论 -
Linux 将一个用户添加到某一用户组中
将一个用户添加到某一用户组中将一个用户添加到某一用户组中,千万不能直接用:usermod -G groupA这样做会使你离开其他用户组,仅仅做为用户组 groupA 的成员。应该加上 -a 选项:usermod -a -G groupA user(FC4: usermod -G groupA,groupB,groupC user)-a 代表 append转载 2013-03-09 11:38:05 · 35414 阅读 · 0 评论 -
CentOS-5.5下编译安装glibc
----------一些说明1、最好用root2、glibc版本:glibc-2.73、'make'过程中,出现'***'说明是很严重的错误。INSTALL文件摘录如下:To build the library and related programs, type `make'. This willproduce a lot of output, some of which原创 2011-10-12 17:18:41 · 8440 阅读 · 0 评论