Linux常用命令(自用)
1 抓包
tcpdump port 5060 and host 192.168.1.180
tcpdump -i ethx -w 1.pcap -s 0
2. 查看硬盘使用情况
df ./
3.查看进程的cpu,内存等
top
top 然后按1, 显示每个核的cpu使用率
4.查找含有某字符串的文件
grep -rn "hello,world!" *
查找多个字符串
grep -E 'H|ok'
5.修改日期
date -s "2016-03-23 19:21:00"
6.查询文件的路径
locate tnsnames.ora
7.查看文件大小
ls -lht
8.查看文件夹大小
du -sh *
9.查看进程
ps -ef|grep sip_gw
杀死进程 pkill -9 opensips
10. 进程间复制 粘贴
-h --max-depth=1
wireshark 过滤制定内容
tcp contains "http" | 显示payload中包含"http"字符串的tcp封包。 |
16 获取linux版本
17 解压缩
grep "thermcontact" */*.in
ssh后台执行命令
ifdown eth0 停止第一块网卡 ifup eth1 启用第二块网卡 26 预留端口避免占用 27 修改系统 timeout时间 28 网卡没配置好前 查看mac地址 |
vi /etc/iproute2/rt_tables
200 eth0 #add eth0 196.2.9.4
210 eth1 #add eth1 196.2.10.4
215 eth2 #add eth2 196.2.11.4
220 bond0 #add bond0 196.2.15.4
vi /etc/rc.d/rc.local
//此处196.2.10.1为默认网关,故不用配置虚拟地址路由
ip ro add default via 196.2.10.1 dev eth1 proto kernel src 196.2.10.4 table eth1
ip ru add from 196.2.10.4 table eth1
30 mysql 启不来 Starting MySQL..The server quit without updating PID file (/home/mysql/data/localhost.localdomain.pid).
杀掉残存的mysql 进程
31 查看环境变量
echo $JAVA_HOME
32 添加自启动
ubuntu: vi /etc/rc.loal 或 mv new_service.sh /etc/init.d/
redhat vi /etc/rc.d/rc.local
# vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=yourname //在这修改hostname
# vi /etc/hosts
127.0.0.1 localhost.localdomain localhost
127.0.0.1 yourname //在这修改hostname
#hostname ***** //*****为修改的hostname
34 替换字符串
%s#abc#def#g(用def替换文件中所有的abc)
35 解决scp ssh 缓慢
scp
-o GSSAPIAuthentication=no
36
解决vi 中上下左右按键变为ABCD
apt-get
remove vim-common
apt-get
install vim
38 安装64位虚拟机
虚拟机中点击虚拟机-安装VMware-tools
sudo ./vmware-install.pl
一直按回车
安装完成之后reboot
40 更改语言环境
auto eth0
iface eth0 inet static
address 192.168.3.90
gateway 192.168.3.1
netmask 255.255.255.0
11上登陆,运行
mysql > flush privileges;
mysql > show master status;
12上
mysql > stop slave;
mysql > change master to master_host='196.2.9.11',master_user='slave',master_password='omp@123!',master_log_file='updatelog.000001',master_log_pos=199;
其中:最后两项根据96.2.9.上运行show
master status;结果填写
启动slave
mysql > start slave;
mysql > show slave status\G
ubuntu下按tab键出现warning: setlocale: LC_CTYPE: cannot change locale (zhCN.UTF-8";)的解决办法
在文件尾部添加一语句:
export LC_ALL=C
然后重启
49 查看静态库/动态库中的函数
linux
nm -g --defined-only libopencv_imgproc.a
nm -D libsubtitle_service.so
windows
dumpbin /exports libxxx.a
50. ubuntu更新源
记得DNS设置为本地电信的DNS,不然apt-get 会超级慢!!
cp /etc/apt/sources.list /etc/apt/sources.list.bak
vi /etc/apt/sources.list
输入
deb http://mirrors.sohu.com/ubuntu/ precise main restricted universe multiverse
deb http://mirrors.sohu.com/ubuntu/ precise-security main restricted universe multiverse
deb http://mirrors.sohu.com/ubuntu/ precise-updates main restricted universe multiverse
deb http://mirrors.sohu.com/ubuntu/ precise-proposed main restricted universe multiverse
deb http://mirrors.sohu.com/ubuntu/ precise-backports main restricted universe multiverse
deb-src http://mirrors.sohu.com/ubuntu/ precise main restricted universe multiverse
deb-src http://mirrors.sohu.com/ubuntu/ precise-security main restricted universe multiverse
deb-src http://mirrors.sohu.com/ubuntu/ precise-updates main restricted universe multiverse
deb-src http://mirrors.sohu.com/ubuntu/ precise-proposed main restricted universe multiverse
deb-src http://mirrors.sohu.com/ubuntu/ precise-backports main restricted universe multiverse
deb http://ppa.launchpad.net/fcwu-tw/ppa/ubuntu YOUR_UBUNTU_VERSION_HERE main
deb-src http://ppa.launchpad.net/fcwu-tw/ppa/ubuntu YOUR_UBUNTU_VERSION_HERE main
mark 一个可以用的源
deb http://cn.archive.ubuntu.com/ubuntu/ precise main restricted
deb-src http://cn.archive.ubuntu.com/ubuntu/ precise main restricted
deb http://cn.archive.ubuntu.com/ubuntu/ precise-updates main restricted
deb-src http://cn.archive.ubuntu.com/ubuntu/ precise-updates main restricted
deb http://cn.archive.ubuntu.com/ubuntu/ precise universe
deb-src http://cn.archive.ubuntu.com/ubuntu/ precise universe
deb http://cn.archive.ubuntu.com/ubuntu/ precise-updates universe
deb-src http://cn.archive.ubuntu.com/ubuntu/ precise-updates universe
deb http://cn.archive.ubuntu.com/ubuntu/ precise multiverse
deb-src http://cn.archive.ubuntu.com/ubuntu/ precise multiverse
deb http://cn.archive.ubuntu.com/ubuntu/ precise-updates multiverse
deb-src http://cn.archive.ubuntu.com/ubuntu/ precise-updates multiverse
deb http://cn.archive.ubuntu.com/ubuntu/ precise-backports main restricted universe multiverse
deb-src http://cn.archive.ubuntu.com/ubuntu/ precise-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu precise-security main restricted
deb-src http://security.ubuntu.com/ubuntu precise-security main restricted
deb http://security.ubuntu.com/ubuntu precise-security universe
deb-src http://security.ubuntu.com/ubuntu precise-security universe
deb http://security.ubuntu.com/ubuntu precise-security multiverse
deb-src http://security.ubuntu.com/ubuntu precise-security multiverse
51. 安装软件出现问题 pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.
apt-get update 一下 再装
52 . 安装机器后必须做的几件事情
apt-get update
apt-get install vim cmake make openssh-server g++ pkg-config
modify ip address :
auto eth0
iface eth0 inet static
address 192.168.3.90
gateway 192.168.3.1
netmask 255.255.255.0
修改root的ssh权限,vi /etc/ssh/sshd_config
PermitRootLogin no 改为 PermitRootLogin yes
然后重启
ROOT computer : sudo passwd root 填写root用户密码
3.
mkdir /work
chmod +x /etc/rc.local
vi /etc/rc.local
mount -t cifs -o username=us,password=817,nounix,noserverino,vers=3.0 //192.168.1.45/CSource/work /work
5. vim ~/.vimrc
输入 set nu 来显示行号
4. reboot
52 mount
挂载u盘 fdisk -L 查看u盘再是哪个标识符 然后mount /dev/sdb1 /mnt
卸载cd mount -t iso9660 /dev/cdrom /mnt
卸载cd umount /mnt
53 路由设置
实时生效
route add default gw 196.2.15.254
route add -net 172.0.0.0 netmask 255.0.0.0 gw 172.27.253.254
route add -net 10.0.0.0 netmask 255.0.0.0 gw 172.27.250.254
route add -net 10.0.0.0 netmask 255.0.0.0 gw 172.27.251.254
永久生效,需要在/etc/sysconfig/static-routes中设置,设置后重启网卡
any net 0.0.0.0 netmask 0.0.0.0 gw 196.2.15.254
any net 172.0.0.0 netmask 255.0.0.0 gw 172.27.253.254
any net 10.0.0.0 netmask 255.0.0.0 gw 172.27.250.254
any net 10.0.0.0 netmask 255.0.0.0 gw 172.27.251.254
54 查看CPU参数
查看CPU逻辑核心数,即线程数
cat /proc/cpuinfo| grep "processor"| wc -l
查看CPU信息(型号)
cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c
55 ubuntu重启 appache
service apache2 restart
56 安装openssl库
apt-get install libssl-dev
57 configure 设置安装文件夹
./configure --prefix=/usr/local/test
58 查找10天前的文件夹并删除, 如果是文件 则 -type f
find ./ -type d -name "*" -mtime +10
59. 除了某个文件 其他都删除
rm -rf !(cmake)
60 wireshark 过滤包
过滤源ip、目的ip。在wireshark的过滤规则框Filter中输入过滤条件。如查找目的地址为192.168.101.8的包,ip.dst==192.168.101.8;查找源地址为ip.src==1.1.1.1; 端口过滤。如过滤80端口,在Filter中输入,tcp.port==80,这条规则是把源端口和目的端口为80的都过滤出来。使用tcp.dstport==80只过滤目的端口为80的,tcp.srcport==80只过滤源端口为80的包; 协议过滤比较简单,直接在Filter框中直接输入协议名即可,如过滤HTTP的协议; http模式过滤。如过滤get包,http.request.method=="GET",过滤post包,http.request.method=="POST"; 5
连接符and的使用。过滤两种条件时,使用and连接,如过滤ip为192.168.101.8并且为http协议的,ip.src==192.168.101.8 and http。 61 多个TS文件拷贝成一个
copy /b *.ts new.ts 62 apt-get update 出现错误 Failed to fetch cdrom://Ubuntu-Server 16.04.4 LTS _Xenial Xerus
vi /etc/apt/sources.list 注释第一行
deb cdrom:[elementary OS 0.3_Freya_–Daily amd64 (20150208)]/ trusty main restricted 63 linux find 拷贝
find /opt/test/ -type f -name "*.txt" -exec cp {} /tmp \; 64 apt-get 安装指定版本
apt-cache madison libprotobuf-dev #查询可用的版本 apt-get install libprotobuf-dev=2.6.1-1.3 #安装指定的版本 65 windows 文件夹挂载到linux apt-get install samba samba-client
mkdir /work
mount -t cifs -o username=us,password=817,nounix,noserverino //192.168.1.44/CSource/work /work
ubuntu16上挂载windows10文件夹
mount -t cifs -o username=******@sina.com,password=**********,nounix,noserverino,vers=3.0 //192.168.1.45/CSource/work /work
66 安装java
sudo apt install default-jre
sudo apt install default-jdk
67
搭建pptpd https://blog.csdn.net/u013510614/article/details/50259719
其实 最好使用别人写好的脚本一建搭建
68 ssh 登陆原理
1. client 请求 server,说 “我要登陆了”
2. server 给client发送一个公钥
3. client把用户名密码通过这个公钥加密后发送给server
4. server 把收到的密文解密 然后和用户名密码对比
68
Permission denied (publickey). SSH用户名密码登录报错
登录目标机器 打开 /etc/ssh/sshd_config ,修改PasswordAuthentication no 为:
PasswordAuthentication yes
69 service 启动失败 的日志
systemctl status gogs
70 查看mysql数据库所有用户
SELECT DISTINCT CONCAT('User: ''',user,'''@''',host,''';') AS query FROM mysql.user;
创建用户
insert into mysql.user(Host,User,Password) values("localhost","test",password("1234"));
71 frequent command for Vim
移动到行尾 $
移动到行首 0
移动到文件尾 shift +g
移动到文件头 gg
72. 通过网络同步时间 并修改时区
https://blog.csdn.net/yeyuangen/article/details/52103445
73 ll 按时间排序
ll -rt
74 查看显存
watch -n 10 nvidia-smi
75 apt-get 遇到Dependency问题
https://askubuntu.com/questions/140246/how-do-i-resolve-unmet-dependencies-after-adding-a-ppa
76 删除软件
# 删除软件及其配置文件
apt-get --purge remove <package>
# 删除没用的依赖包
apt-get autoremove <package>
# 此时dpkg的列表中有“rc”状态的软件包,可以执行如下命令做最后清理:
dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P
77 linux 下载工具
sudo apt-get install aria2
aria2 http........ 78 pip install 太慢怎么办
使用其他源 pip install torch -i https://pypi.tuna.tsinghua.edu.cn/simple
https://blog.csdn.net/wukai0909/article/details/62427437但这样有点麻烦 这样就可以永久修改了
vi ~/.pip/pip.conf
[global]
index-url = http://pypi.douban.com/simple
[install]
trusted-host=pypi.douban.com
79 环境变量修改
vi ~/.bashrc
export PATH="$PATH:/usr/local/lib"
source ~/.bashrc 80 默认链接目录 默认so目录
include /etc/ld.so.conf.d/*.conf
/usr/local/lisudo ldconfig
81 查看显卡版本
nvidia-smi
查看显卡信息 lspci | grep -i vga 82 ping ipv6
ping -6 ipv6.google.com
ping 2400:da00::dbf:0:100 83 梅林路由器 aria2 无法运行 sh /koolshare/perp/perp.sh start
sh /koolshare/aria2/aria2_run.sh start
Y2e#h6!LYB4mDcY
84 安装 opengl 环境
sudo apt-get install build-essential libgl1-mesa-dev libglu1-mesa-dev mesa-utils
apt-get install ubuntu-desktop
vi /usr/share/lightdm/lightdm.conf.d/50-ubuntu.conf
user-session=ubuntu
autologin-user=root
greeter-show-manual-login=true
vi /root/.profile
注释掉mesg n || true,并且新添加一行:tty -s && mesg n
vi /etc/profile
在末尾添加 export DISPLAY=:0.0
85 安装桌面环境
apt-get install ubuntu-desktop
86 top 查看其中一个线程
top -p pid
87 mtrace 使用
#include <mcheck.h>
#include <stdlib.h>
int main()
{
mtrace(); int * a = new int[];
//delete [] a;
int *b = (int *)malloc(sizeof(int)*);
muntrace();
return ;
}
然后执行mtrace ./test test.log 即可显示泄露的位置,但是只能显示C语言所在的具体行数
88 top 命令 详解
https://www.cnblogs.com/luoyinjie/p/11719760.html
89 移除 \r\n -->\n sed -e s/^M//g $1 > $1.0
^M 是 ctrl+v ctrl+M
90 Docker 学习
91 shell 循环执行 命令
while true ;do ./test.sh; done;
92 linux for 循环 shell
#!/bin/bash
for ((x=1,y=8;x<=8;x++,y--))
do
echo "$x - $y"
done
Linux常用命令(自用)的更多相关文章
- Linux常用命令(一)
Linux常用命令 1. pwd查看当前路径(Print Working Directory) [root@CentOS ~]# pwd/root 2. cd .. 返回上一级 .. 表示上一级 ...
- linux常用命令的介绍
本文主要介绍Linux常用命令工具,比如用户创建,删除,文件管理,常见的网络命令等 如何创建账号: 1. 创建用户 useradd -m username -m 表示会在/home 路径下添加创建用户 ...
- linux——常用命令与脚本
linux常用命令 --文件管理pwd --查看当前目录cd --切换当前目录ls --列出当前目录下的所有文件touch --创建文件mkdir --建立目录rmdir --删除空目录rm --删除 ...
- DOS 和 Linux 常用命令的对比
DOS 和 Linux 常用命令的对比 许多在 shell 提示下键入的 Linux命令都与你在 DOS 下键入的命令相似.事实上,某些命令完全相同. 本附录提供了 Windows的 DOS 提示下的 ...
- 第一章,Linux常用命令
20161124 Linux常用命令1.find find /etc/ -size +50k -lsfind /etc/ -size +50k -ls 2> /dev/null查看目录下大于50 ...
- linux 常用命令大全
linux 常用命令大全 系统信息 arch 显示机器的处理器架构(1) uname -m 显示机器的处理器架构(2) uname -r 显示正在使用的内核版本 dmidecode -q 显示硬件系统 ...
- Linux 常用命令行
Linux常用命令行 第一部分: cd命令 第二部分:文件操作 第三部分:压缩包操作
- [工作需求]linux常用命令以及vim常用命令
一. Linux 常用命令 mkdir dirname新建文件夹 cd ~ 进入自己的家目录 cd dirname 进入名字为dirname的目录: l 显示当前文件夹下的文件 ...
- 对于我的linux常用命令的说明
我所列出的linux常用命令中的选项并不是全部的选项,是一些我们经常用到的linux命令及选项
- Linux 常用命令笔记
Linux 常用命令笔记 1. locate locate:用来定位文件的位置,如:locate a.txt 但是这个命令有延迟,也就是新建的文件不一定能搜索到,如果非要找到新建的文件可以使用 upd ...
随机推荐
- shell命令:getevent和sendevent
1.getevent 输出所有event设备的基本信息 输出格式: 设备名: 事件type 事件code 事件value 注意:这里的数字都是16进制. getevent -c 10 //输出10条信 ...
- fork() 成为负担,需要淘汰 spawn
A fork() in the road - Microsoft Research https://www.microsoft.com/en-us/research/publication/a-for ...
- Android 显示系统:OpenGL简介和Gralloc代码分析
一.OpenGL ES与EGL Android的GUI系统是基于OpenGL/EGL来实现的. 由于OpenGL是通用函数库,在不同平台系统上需要被“本土化”——把它与具体平台的窗口系统建立起关联,F ...
- centos7 更改ip
http://blog.csdn.net/heimerdinger_feng/article/details/71171231 CentOS7在桥接模式下配置静态ip 原创 2017年05月04日 1 ...
- php文件断点上传
前段时间做视频上传业务,通过网页上传视频到服务器. 视频大小 小则几十M,大则 1G+,以一般的HTTP请求发送数据的方式的话,会遇到的问题:1,文件过大,超出服务端的请求大小限制:2,请求时间过长, ...
- mysql物理备份innobackupex
一.全量备份 1.安装xtrabackup # wget https://www.percona.com/downloads/XtraBackup/Percona-XtraBackup-2.4.4/b ...
- php命令行模式下加载的php.ini文件可能和web模式下加载的php.ini不一致
php命令行模式下加载的php.ini文件可能和web模式下加载的php.ini不一致 命令行下查看加载的php.ini的路径: php -i|grep php.ini web模式下查看: <? ...
- iOS-项目重构(浅谈)
如何重构 首先,要对程序的一般架构烂熟于心,尤其是MVC,这是基本.还有就是分离存储和网络请求的逻辑. 对于一些常用的控件尽量分离复用,设置开关函数,适当的时候开启,不要的时候关闭,有必要的话还可以 ...
- flask的jinja2过滤器使用:遍历索引指定标签class属性,实现样式变化
在flask项目中实现上图效果,采用使用自定义过滤器的形式对 span 标签的 class 指定. 1.定义过滤器 # common.py def do_index_class(index): &qu ...
- 【ARM-Linux开发】Linux下查看机器的CPU负载
负载(load)是Linux机器的一个重要指标,直观了反应了机器当前的状态.如果机器负载过高,那么对机器的操作将难以进行. Linux的负载高,主要是由于CPU使用.内存使用.IO消耗三部分构成.任意 ...