
linux
文章平均质量分 55
harryhare
这个作者很懒,什么都没留下…
展开
-
需要sudo 运行的程序的IDE设置
很多这样的情况,一个经典的例子是,开80端口的http server,在IDE中的调试。以python pyCharm 为例,解决方法大致有三种 * 用sudo 打开 IDE * 新建脚本sudo python,然后在pycharm 中用此脚本作为解释器 * 设置net-cap 使程序在bind lower port 时,不再需要root权限参考: 这篇三种方法都有提: http...原创 2018-06-09 09:49:34 · 920 阅读 · 0 评论 -
debconf
https://blog.youkuaiyun.com/fickyou/article/details/50960444转载 2018-05-22 13:29:39 · 1641 阅读 · 0 评论 -
shell运行时间
当然是用time 了不过想到一个无聊的写法t0=`date +%s` && sleep 10 && t1=`date +%s` && echo $((t1-t0))原创 2018-05-17 16:43:51 · 1369 阅读 · 0 评论 -
bashrc profile 相关的几个文件
0.相关文件/etc/bash.bashrc /etc/profile ~/.bashrc ~/.profile另外还会有人提到~/.bash_profile 这个文件和~/.profile 是差不多的,区别只在于~/.profile 兼容性更好,而~/.bash_profile 是bash专用11.文件被使用的时机在上面提到的四个文件最后加入echo $BASH_...原创 2018-04-21 22:23:03 · 203 阅读 · 0 评论 -
ss terminal下客户端sslocal+proxychains或者privoxy
ubuntu16.04 LTS1.sslocal1sslocal -c client.jsonclient.json如下 "server":"111.111.111.111", "server_port":1234, "local_port":1080, "password":"password",原创 2018-03-27 01:39:45 · 18951 阅读 · 0 评论 -
NUMA
0.NUMA基础numa会把内存分为n组,每一组和特定的一组cpu有对应关系,即cpu访问与之相应的内存组会更快 所以,最开始,我们需要指代cpu和内存组的对应关系,可以使用一下命令$ lscpu(省略)NUMA node0 CPU(s): 0,2,4,6,8,10,12,14,16,18NUMA node1 CPU(s): 1,3,5,7,9,11,13,15...原创 2018-04-09 02:00:27 · 1134 阅读 · 0 评论 -
ubuntu server U盘安装过程中出现插入cdrom的情况
首先,U盘安装盘直接把ios放到U盘中,然后解压(windows 可以用7-zip)就可以了,用不着其他工具 另外,有的服务器可能在装系统之前需要设置raid 1然后是,提示需要插入光盘的错误2 3umount /dev/sdc4 #sdc4是我的U盘设备,不同机器可能不一样,可用"ls /dev |grep sd*"查看一下。mkdir /mnt/usb mo转载 2018-01-09 23:45:45 · 2257 阅读 · 0 评论 -
修改hostname 后unable to resolve hostname
1.修改hostnamehostname [newhostname]vim /etc/hostname2.修改host文件vim /etc/hosts原创 2018-01-09 23:31:54 · 518 阅读 · 0 评论 -
spec cpu 2006
编译和运行参考:http://blog.youkuaiyun.com/wangwcnl/article/details/46227935 或者官方版:(注意路径替换为本地路径) file:///L:/cpu2006-1.2/Docs/install-guide-unix.html注意,2006 只有用gcc4 编译 切换gcc版本参见上一篇一些需要安装的东西sudo apt-get i...原创 2018-01-24 15:31:39 · 7530 阅读 · 8 评论 -
gcc 版本切换
Ubuntu14自带GCC的版本是4.8,编译caffe的matlab接口时需要降级到4.7系统使用的gcc版本随着发布版本的不同而不同,在编译Android系统时不同的版本推荐用不同的gcc去编译,那么可不可以改变系统的gcc来适应android编译环境的需求呢?答案是可以的。先看看我们系统用的gcc和g++是什么版本gcc -v可以获得的信息如下gcc version 4.8转载 2018-01-23 15:36:53 · 1203 阅读 · 0 评论 -
apt-get 自动补全包名
转自:http://blog.youkuaiyun.com/seasonkky/article/details/6321150 现象: bash的一般命令补全正常,apt-get install 的包名无法自动补全 解决: 实际上,在运行这句后,就可以自动补全了。。。apt-get install bash-completion原文: Add Bash Completion In Deb原创 2018-01-15 00:12:43 · 2108 阅读 · 0 评论 -
查看当前使用的shell
转自: https://www.cnblogs.com/zfc2201/articles/6032292.html查看当前发行版可以使用的shell[jack@localhost ~]$ cat /etc/shells /bin/sh/bin/bash/sbin/nologin查看当前使用的shell 一、最常用的查看shell的命令,但不能实时反映当前shell[转载 2018-01-14 23:43:06 · 2318 阅读 · 0 评论 -
查找局域网中mac对应的ip
1.nmap找到所有能ping到的ipsudo nmap -sP 192.168.1.1-255 >ping.txt2.用grep 搜mac ,取3行(不包括本身的前面两行)cat ping.txt|grep 44:A8:xx:xx -B 2grep -C n #包括前后n行grep -A n #包括后面n行grep -B n #包括前面n行参考: 1.http://blog.youkuaiyun.com原创 2017-12-17 20:12:20 · 6592 阅读 · 0 评论 -
shell 命令返回值 传递
标准输出方法一:注意cat命令外面的那个引号是反引号,键盘上数字1旁边那个xxx@xxx-desktop:~/temp$ aaa=`cat 123`xxx@xxx-desktop:~/temp$ echo $aaaabc 方法二:xxx@xxx-desktop:~/temp$ ccc=$(cat 123)xxx@xxx-desktop:~/temp$ echo $...原创 2015-02-11 18:32:23 · 18645 阅读 · 0 评论 -
nmap
主要有四种#pingnmap -sP 192.168.0.1-10#udpnmap -sU 192.168.0.1-10#tcp synnmap -sS 192.168.0.1#tcp connectnmap -sT 192.168.0.1原创 2017-05-14 15:37:48 · 381 阅读 · 0 评论 -
ssh 改变默认端口
ssh 改变默认端口希望通过改变端口,突破端口白名单的限制,但是行不通,不过还是把流程记录一下。1.修改配置文件/etc/ssh/sshd_config#Port 22这行的注释解除,并增加新的端口Port 22Port 12342.重启sshd这里有几种方法可以选 如果用putty之类的工具,如果22 端口始终开启,ssh连接似乎不会断开方法一/etc/init.d/sshd restart方原创 2017-11-02 21:03:10 · 494 阅读 · 0 评论 -
linux 入门
安装过程 1.下载putty下面主要是vps 或者云服务的场景,所以先下个putty。如果是本机安装,那么会有个先装 linux 还是 先装windows 的问题:由于安装windows时,windows的引导会覆盖掉Ubuntu 的 grub,所以应该先装windows,后装Ubuntu。2.登录和问题检测密钥:putty 使用pem文件登陆a.用PUTTYG...原创 2014-10-30 02:19:25 · 1354 阅读 · 0 评论 -
systemd systemctl
0.systemd概念可以看下面几篇: https://www.ibm.com/developerworks/cn/linux/1407_liuming_init3/ http://www.ruanyifeng.com/blog/2016/03/systemd-tutorial-commands.html https://jingyan.baidu.com/article/cbcede0...原创 2018-03-23 04:12:55 · 299 阅读 · 0 评论 -
shell 备忘
1.查询命令历史ctrl+r 2.即使目录存在也不会报错 mkdir -p 3.解压时指定位置 tar -zxvf [xxx.tar.gz] -C [dir]原创 2018-06-03 14:15:18 · 174 阅读 · 0 评论 -
bash source 和 export
1.export 影响当前子shell和子shell,不影响父shell直接复制,只影响当前shell$ a=123$ echo $a 123$ export b=123$ echo $b 123$ bash # 子shell$ echo $a $ echo $b 123$ export b=124$ export a=124$ exit # 退出子shell,...原创 2018-06-08 16:11:32 · 295 阅读 · 0 评论 -
vim常用设置
一个例子编辑文件 ~/.vimrc如果没有这个文件,创建一个set numberset tabspace=4set shiftwidth=4set autoindentset pasteset wrapset laststatus=2set rulerset showmatchset hlsearchset ignorecaseset nobackupset nosw...原创 2019-10-01 11:14:37 · 213 阅读 · 0 评论 -
trap
和 kill 是一对$ type traptrap is a shell builtin$ type killkill is a shell builtin$ trap -l 1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL 5) SIGTRAP 6) SIGABRT 7) SIGEMT 8) SIGFPE 9) SIGKILL 1...原创 2018-12-03 15:05:00 · 273 阅读 · 0 评论 -
fork()
fork() 和 锁其实标题中“继承”这个词用得非常不好因为锁这种东西有两个方面:内存中的数据结构内存中的数据结构的可见性由于fork会复制一份堆栈数据,所以锁也肯定是复制了一份,所以锁在新的进程中也是可见的,但是新的进程中看到的只是锁的复制品,和主进程中创建的锁无关具体参考:https://blog.youkuaiyun.com/lyh__521/article/details/45921...原创 2018-11-21 10:02:15 · 1877 阅读 · 0 评论 -
linux 线程和进程区别(浅)
孤儿进程下面的代码执行时,$ ps -ef |grep test3harryhare 26918 26335 0 23:08 pts/14 00:00:00 ./test3harryhare 26919 26918 0 23:08 pts/14 00:00:00 ./test3harryhare 27055 26430 0 23:10 pts/15 00:...原创 2018-11-20 23:23:12 · 217 阅读 · 0 评论 -
虚拟内存分配 和 mmap
虚拟内存分配#include <iostream>#include <cstdio>//#include <cmalloc>using namespace std;const int block_size=1024*原创 2018-11-08 14:02:35 · 637 阅读 · 0 评论 -
打开文件数
sudo sysctl -w kern.maxfiles=65536sudo sysctl -w kern.maxfilesperproc=65536ulimit -n 65536转载 2018-11-05 12:13:59 · 150 阅读 · 0 评论 -
mv 文件夹时。。。
mv source dest是把 source 中的内容 移到dest 下,还是 把source 本身 移到到dest下,只和dest 本身是否已经存在有关。。。以前一直以为和 dir 后面加不加/有关 。。。# dest 不存在$ ls source/a.txt b.txt c.txt$ mv source dest$ ls dest/a.txt b.txt c....原创 2018-11-09 14:21:08 · 2232 阅读 · 1 评论 -
syslog
service 名字 rsyslog配置文件,启动关闭,就是常规那些操作。你都懂的。默认端口514,默认关闭,可以在配置文件中把那几句的注释删掉,重启service 开启网络log。下面两段代码都测试过,可以在/var/log/syslog 中看的程序写入的日志。c 写入 syslog#include <syslog.h> int main(int argc, c...转载 2018-10-24 02:30:14 · 679 阅读 · 0 评论 -
信号 中断 信号量 和 进程间通信
信号是操作系统 对 中断机制的模拟发生信号的命令是kill信号量是线程间同步的东西原创 2018-10-15 20:47:25 · 796 阅读 · 0 评论 -
find 和 grep
两个常用的命令#找指定名字文件find . iname "abc_*.txt"#找指定内容的文件grep -R "aaa"原创 2018-09-29 18:55:45 · 241 阅读 · 0 评论 -
tmux
参考:https://www.cnblogs.com/kevingrace/p/6496899.html安装sudo apt-get install tmux使用进入$ tmux操作ctrl + b +keyfunctionc新panelx关闭当前panel%panel左右布局"panel上学布局space原创 2018-09-28 21:31:46 · 665 阅读 · 0 评论 -
bash脚本备忘
数组$ a=(1 2 3 4 5 a b c d)$ echo ${a[1]}2$ echo ${a[@]}1 2 3 4 5 a b c d$ b[5]="T1"$ b["sth&原创 2018-10-03 15:44:37 · 141 阅读 · 0 评论 -
shell 之 rsync
8.rsync 是个有用的命令,可以看成极简的git 或者高级版的scprsync src_dir dst_dir源路径和目的路径的格式 和 scp 一样 一个复杂例子rsync -vzrtopg --progress -e ssh --delete work@172.16.78.192:/www/* /databack/experiment/rsync链接中有详细的参数...原创 2018-06-08 17:26:30 · 2105 阅读 · 0 评论 -
vim 全文替换的几种写法
%s/aaa/bbb/g.,$s/aaa/bbb/g,$s/aaa/bbb/g1,$s/aaa/bbb/gs 替换 % 全文 $ 最后一行 1 第一行 g global? 就是在前面制定的行中替换所有匹配的字符串,如果不加这个就只匹配每一行中的第一个,此处还可以用c p c 每次替换前会确认 p 不知道。。。参考:https://www.cnblogs.com/fakis...原创 2018-06-08 16:12:52 · 11816 阅读 · 0 评论 -
僵尸进程和孤儿进程
http://blog.youkuaiyun.com/kennyrose/article/details/7532758原创 2017-10-29 16:24:19 · 528 阅读 · 0 评论 -
shell 之 awk
感觉这个教程不错http://awk.readthedocs.org/en/latest/chapter-one.html原创 2015-02-11 17:48:45 · 865 阅读 · 0 评论 -
linux 网络设置
临时设置ip地址sudo ifconfig etho 192.168.1.xxx netmask 255.255.255.0 up路由sudo route add default gw 192.168.1.1dns修改文件 /etc/resolv.conf 增加 nameserver 114.114.114.114永久设置不带桌面ubuntu在文件 /etc/network/interface原创 2016-04-28 15:40:02 · 568 阅读 · 0 评论 -
linux 安装oracle的java jdk
1.到官网找到下载地址,jdk7的地址http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html一般可能会用到wget,好吧,我只会用wget不过,在网页上右键复制的链接地址是不能用的。拿到可用地址的方法:a.用浏览器下载,开始下载后,查到的下载地址是真实地址b.f1原创 2015-02-08 13:40:44 · 718 阅读 · 0 评论 -
linux 查看系统版本
1.cat /etc/issue2.cat /proc/version3.uname -a4.lsb_release -a1和4结果相似2和3结果相似参考:http://blog.youkuaiyun.com/david_xtd/article/details/18888409http://jingyan.baidu.com/articl原创 2015-02-08 19:45:33 · 455 阅读 · 0 评论 -
ssh 使用 pem文件登陆报错
描述: Permissions 06xx for 'test.pem' are too open. It is required that your private key files are NOT accessible by others.解决方法:chmod 600 test.pem原创 2015-02-10 11:55:07 · 6762 阅读 · 0 评论