镜像下载
网络管理
bonding
modprobe bonding
vi /etc/modprobe.d/bonding.conf
alias bond0 bonding
options bond0 mod=1 miimon=100
vi /etc/sysconfig/network-scripts/ifcfg-bond0
TYPE=Bond
ONBOOT=yes
BOOTPROTO=static
DEVICE=bond0
IPADDR=192.168.1.200
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=8.8.8.8
vi /etc/sysconfig/network-scripts/ifcfg-ens33
MASTER=bond0
SLAVE=yes
vi /etc/sysconfig/network-scripts/ifcfg-ens34
MASTER=bond0
SLAVE=yes
ubuntu 22.04 static ip
vi 00-installer-config.yaml
network:
renderer: networkd
ethernets:
ens33:
dhcp4: false
dhcp6: false
optional: true
addresses: [192.168.100.122/24]
routes:
- to: default
via: 192.168.100.1
nameservers:
addresses: [192.168.100.1]
search: []
version: 2
sudo netplan apply
centos 6.5 static ip
vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=static
BROADCAST=192.168.60.255
IPADDR=192.168.60.251
NETMASK=255.255.255.0
NETWORK=192.168.60.0
GATEWAY=192.168.60.1
HWADDR=00:1E:0B:CF:1A:E4
TYPE=Ethernet
centos 7 static ip
vi /etc/sysconfig/network-scripts/ifcfg-enp0s3
HWADDR=08:00:27:98:06:76
TYPE=Ethernet
# Static IP Address #
BOOTPROTO=none
# Server IP #
IPADDR=192.168.1.10
# Netmask #
NETMASK=255.255.255.0
# Default Gateway IP #
GATEWAY=192.168.1.1
# DNS Servers #
DNS1=192.168.1.1
DNS2=8.8.8.8
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
# Disable ipv6 #
IPV6INIT=no
# Device Name #
NAME=enp0s3
DEVICE=enp0s3
# Optional – This is system specific and can be created using ‘uuidgen enp0s3’ command #
UUID=02d4a47b-3dbe-4e0b-ae4b-841a8c58e807
# Activate on Boot #
ONBOOT=yes
# Default Domain Search #
DOMAIN=itzgeek.local
systemctl restart network
fedora静态ip
hostnamectl set-hostname new-name
sudo nmcli connection show
sudo nmcli connection modify 91d78f79-c7cf-32fc-8a91-bc3d587a2461 IPv4.address 192.168.1.127/24
sudo nmcli connection modify 91d78f79-c7cf-32fc-8a91-bc3d587a2461 IPv4.gateway 192.168.1.1
sudo nmcli connection modify 91d78f79-c7cf-32fc-8a91-bc3d587a2461 IPv4.dns 8.8.8.8
sudo nmcli connection modify 91d78f79-c7cf-32fc-8a91-bc3d587a2461 IPv4.method manual
nmcli d
nmcli c s ens33
nmcli c up ens33
nmcli c down ens33
nmcli c delete ens33
nmcli c add type ethernet con-name ens33 ifname ens33 ipv4.method auto
nmcli c modify ens33 ipv4.addr '192.168.1.3/24'
nmcli c add type ethernet con-name ens33 ifname ens33 ipv4.addr 192.168.1.4/24 ipv4.gateway 192.168.1.1 ipv4.method manual
ip addr add 192.168.1.3/24 dev ens33
ip link set ens33 up/down
ip route add default via 192.168.1.1 dev ens33
ip link set ens33 promisc on/off
systemd管理
cp new.service to /lib/systemd/system/
systemctl load new.service
systemctl isolate multi-user.target
systemctl isolate runlevel3.target
systemctl isolate graphical.target
systemctl isolate runlevel5.target
systemd-analyze blame
systemd-cgtop
systemd-cgls
systemctl-cat sshd.service
进程和端口
方法1
-
根据进程名查看进程信息
ps aux|grep mysql
-
根据进程id查看进程占用端口
netstat -anp|grep 7671
方法2
-
根据进程名查看进程信息
ps aux|grep mysql
-
根据id查看网络连接
lsof -i tcp -p 7671
WIN查询端口对应进程的方法
Get-Process -Id (Get-NetTCPConnection -LocalPort 5000).OwningProcess
Get-NetTCPConnection -LocalPort 5000 | Measure-Object
LINUX查询端口对应进程的方法
lsof -i:端口号
netstat -tunpl | grep 端口号
netstat & ss
ss -p
ss -l
ss -a
ss -tna
ss -nlt
tcpdump 抓包
tcpdump tcp -i eth1 -t -s 0 and port 8000 and src net 192.168.1.0/24 -w ./test.cap
tcpdump -XvvennSs 0 -i eth0 tcp[20:2]=0x4745 or tcp[20:2]=0x4854
判断主机是否ping通
ping -c1 -w1 -t5 192.168.0.125>/dev/null 2>&1 && echo ok|| echo down
查看连接数
netstat -n | find /C /I "established"
Get-Counter -Counter \TCPv4\*
查看package files
dnf info gd-devel
rpm -l gd-devel
dpkg -L gd-devel
rpm -qa
-qpi 查看rpm包的描述信息
-qpl 列出rpm包的文件信息
-qpR 查看rpm包的依赖关系
-qf 查找指定文件属于哪个rpm包
-Uvh 升级
-Va 校验所有包 查找丢失文件
man 类型
- 用户命令
- 系统接口
- 库函数
- 特殊文件
- 文件
- 游戏
- 系统软件包
- 系统管理命令
- 内核
查看系统版本信息
- cat /etc/issue
- cat lsb_release -a
- uname -a
- cat /etc/*_issue
- cat /etc/*_release
查看动态链接库的导出函数
nm -D libhello.so|awk '{if($2=="T"){print $3}}'
关闭显示器
sudo vbetool dpms off
bash中输出换行
echo -e "hello\n"
printf "hello\n"
pip更新为国内源
# 清华源
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
# 或:
# 阿里源
pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/
# 腾讯源
pip config set global.index-url http://mirrors.cloud.tencent.com/pypi/simple
# 豆瓣源
pip config set global.index-url http://pypi.douban.com/simple/
查看硬件信息
# 查看CPU
lscpu
cat /proc/cpuinfo
# 查看内存
free -h
lsmem
cat /proc/meminfo
# 查看磁盘分区
df -hT
mount
lsblk
fdisk -l
# 查看opengl版本
glxinfo|grep version
# 查看usb
lsusb
# 查看pci/pcie
lspci
# 查看硬件
lshw
块设备可以随机读写,字符设备只能顺序读写
参数设置
vi /etc/ssh/ssh_config
GSSAPIAuthentication no
vi /etc/ssh/sshd_config
UseDNS no
PubkeyAuthentication no
vi /etc/sysctl.conf
net.core.somaxconn=65535
net.core.netdev_max_backlog=65535
net.ipv4.tcp_max_syn_backlog=65535
net.ipv4.tcp_fin_timeout=10
net.ipv4.tcp_tw_reuse=1
#net.ipv4.tcp_tw_recycle=1
net.core.wmem_default=87380
net.core.wmem_max=16777216
net.core.rmem_default=87380
net.core.rmem_max=16777216
net.ipv4.tcp_keepalive_time=120
net.ipv4.tcp_keepalive_intvl=30
net.ipv4.tcp_keepalive_probes=3
kernel.shmmax=4294967296
kernel.shmmni=4096
kernel.shmall=400000000
kernel.sem=50100 64128000 50100 1280
kernel.sysrq=1
kernel.msgmnb=65536
kernel.msgmax=65536
kernel.msgmni=2048
fs.file-max=7672460
vi /etc/security/limit.conf
* soft nofile 65535
* hard nofile 65535
* soft nproc 131072
* hard nproc 131072
可以简写为
* - nofile 65535
* - nproc 65535
vi /etc/systemd/system.conf
DefaultLimitNOFILE=10240
DefaultLimitNPROC=10240
ubuntu桌面相关
sudo apt install ubuntu-restricted-extras
ssh别名
vi ~/.ssh/config
Host scada
User xxx
Hostname 192.168.1.10
Port 22
PreferredAuthentications publickey
IdentityFile C:\Users\xxxx\.ssh\id_ed25519
ControlPersist yes
TCPKeepAlive yes
Compression yes
ForwardAgent yes
常用软件
sudo apt install git wget curl screen htop vim emacs golang cmake gcc g++ gdb valgrind unzip tree tcpdump telnet redis mosquitto nginx make mercurial sysstat pstack sqlite3
sudo apt install build-essential gradle ruby nodejs npm composer python3-pip mysql postgresql memcached fonts-ancient-scripts unifont
binutils bison, java, php,python,r,lazarus,dotnet,sdl2,sfml,flatpak, tomcat8 mednaffe,visual code,sublime text, wps,qq,freedownloadmanager,nodejs,npm
MyPaint Krita Scribus Plume Creator QuiteRSS NitroShare OpenShot Blender Shotcut SimpleScreenRecorder Neofetch kupfer Liferea Shutter
apt install ubuntu-restricted-extras libdvd-pkg
dpkg-reconfigure libdvd-pkg
debian apt install software-properties-common 才有apt-add-repository这个命令用于安装ppa
sudo add-apt-repository ppa:oibaf/graphics-drivers
sudo add-apt-repository ppa:transmissionbt/ppa
sudo add-apt-repository ppa:kelleyk/emacs
snap install ubuntu-make
umake --list
umake android
tcpdump -i eth0 -s 3000 port 3306 -w ~/sql.pcap
#tcpdump -i any -A -s 3000 port 3306 >~/sql.log
#grep "select * from " ~/sql.log|head
-A 以ASCII格式打印出所有分组,并将链路层的头最小化。
向mysql服务端传输的sql语句就是以ASCII码形式进行传输。我们就可以使用-A参数查看传输的具体sql语句
ssh -NfL *:3305:127.0.0.1:3306 root@a.b.c.d 本地3305映射到远程的3306
ssh -vnNT -R 7689:localhost:3333 wanghao@42.120.40.68 远程7689映射到本地3333
watch -n 2 -t "ps axu|grep apt"
network
nmcli device status # view status
nmcli device wifi list iface # view wifi
nmcli device wifi connect *** password ** # connect wifi
sudo iwconfig wlp9s0 power off
sudo vbetool dpms off
objdump objcopy strace ltrace ftrace readelf eresi ptrace
查看系统TOP(f进入field选择)
top
打印系统进程
ps -efwL
统计每个进程的开销
pidstat -d -r -u -w -l -h -p ALL 5 1
打印进程stack
pstack -p pid
打印进程系统调用
strace -p pid
IO监控
iostat
cpu,disk,net,system资源使用监控
dstat
每个CPU核的使用监控
mpstat
top -T -p `pidof a.out`
top -H
1. dmesg
查看启动中慢的问题
2. systemd-analyze blame
启动时候的服务以及服务所占用的时间
bad interpreter: No such file or directory 解决办法
这个问题一般是由于windows和linux下的换行符不一样导致的。可以使用dos2unix程序解决。或者使用下面sed完成
sed -i -e 's/\r$//' test_script.sh