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 ...
随机推荐
- Servlet的运行原理
- MySql数据库的下载和安装卸载
下载:到mysql官网下载 卸载 1.找到mysql安装目录下的my.ini文件 2.找到配置项datadir datadir="D:/develop /MySQL/MySQL Server ...
- 安装完 MySQL 后必须调整的 10 项配置(转)
当我们被人雇来监测MySQL性能时,人们希望我们能够检视一下MySQL配置然后给出一些提高建议.许多人在事后都非常惊讶,因为我们建议他们仅仅改动几个设置,即使是这里有好几百个配置项.这篇文章的目的在于 ...
- 将SSRF升级为RCE(AWS环境)
原文:https://generaleg0x01.com/2019/03/10/escalating-ssrf-to-rce/ 查找域名范围: 在枚举客户端的子域名时.找到了子域名[docs] 打开这 ...
- DOTS原则和愿景
Unity Data Oriented Tech Stack基于一系列原则.这些原则为我们正在努力实现的目标提供了良好的背景.一些原则清楚地反映在代码中.其他则只是我们为自己设定的目标. 默认情况下的 ...
- 学习Yii(2)
Yii拥有很好的手册,还是中文的,官方的手册很详细.还是应该好好看一下.今天就开始跟着项目代码调试. 上次看到入口脚本,学习一定要快,要用心,抓住时间.不然时间拖久了就忘了.延续不上,大打折扣.而且要 ...
- 动态中位数-POJ 3784
题目: 依次读入一个整数序列,每当已经读入的整数个数为奇数时,输出已读入的整数构成的序列的中位数. 输入格式 第一行输入一个整数P,代表后面数据集的个数,接下来若干行输入各个数据集. 每个数据集的第一 ...
- 最新 汽车之家java校招面经 (含整理过的面试题大全)
从6月到10月,经过4个月努力和坚持,自己有幸拿到了网易雷火.京东.去哪儿.汽车之家等10家互联网公司的校招Offer,因为某些自身原因最终选择了汽车之家.6.7月主要是做系统复习.项目复盘.Leet ...
- JavaScript 真值和假值
常见的假值有 值 说明 var a=false; 值为假 var a =0; 值为0 var a=''; 值为空 var a=10/'abc' 算式错误 var a; 未赋值变量 常见的真值有 ...
- 洛谷 题解 P1133 【教主的花园】
$n<=10^5 $ O(n)算法 状态 dp[i][j][k]表示在第i个位置,种j*10的高度的树,且这棵树是否比相邻两棵树高 转移 dp[i][1][0]=max(dp[i-1][2][1 ...