Linux官方教程
# 查看系统是32位还是64位
getconf LONG_BIT
cat /proc/cpuinfo | grep flags | grep ' lm ' | wc -l
lscpu
4核4线程
# lscpu
Architecture: x86_64
CPU 运行模式: 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 4
On-line CPU(s) list: 0-3
每个核的线程数:1
每个座的核数: 4
Socket(s): 1
NUMA 节点: 1
厂商 ID: GenuineIntel
CPU 系列: 6
型号: 158
步进: 11
CPU MHz: 800.000
BogoMIPS: 6185.06
虚拟化: VT-x
L1d 缓存: 32K
L1i 缓存: 32K
L2 缓存: 256K
L3 缓存: 6144K
NUMA node0 CPU(s): 0-3
6核12线程
Architecture: x86_64
CPU 运行模式: 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 12
On-line CPU(s) list: 0-11
每个核的线程数:2
每个座的核数: 6
Socket(s): 1
NUMA 节点: 1
厂商 ID: AuthenticAMD
CPU 系列: 25
型号: 33
Model name: AMD Ryzen 5 5600X 6-Core Processor
步进: 0
CPU MHz: 4591.230
CPU max MHz: 3700.0000
CPU min MHz: 2200.0000
BogoMIPS: 7386.44
虚拟化: AMD-V
L1d 缓存: 32K
L1i 缓存: 32K
L2 缓存: 512K
L3 缓存: 32768K
NUMA node0 CPU(s): 0-11
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc cpuid extd_apicid aperfmperf pni pclmulqdq monitor ssse3 fma cx16 sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt tce topoext perfctr_core perfctr_nb bpext perfctr_llc mwaitx cpb cat_l3 cdp_l3 hw_pstate ssbd ibrs ibpb stibp vmmcall fsgsbase bmi1 avx2 smep bmi2 erms invpcid cqm rdt_a rdseed adx smap clflushopt clwb sha_ni xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local clzero irperf xsaveerptr arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold avic v_vmsave_vmload vgif umip pku ospke vaes vpclmulqdq rdpid overflow_recov succor smca
8核8线程
[root@host-10-10-17-13 ~]# lscpu
Architecture: aarch64
CPU op-mode(s): 64-bit
Byte Order: Little Endian
CPU(s): 8
On-line CPU(s) list: 0-7
Thread(s) per core: 1
Core(s) per socket: 1
Socket(s): 8
NUMA node(s): 1
Vendor ID: HiSilicon
Model: 0
Model name: Kunpeng-920
Stepping: 0x1
CPU max MHz: 2600.0000
CPU min MHz: 2600.0000
BogoMIPS: 200.00
L1d cache: 512 KiB
L1i cache: 512 KiB
L2 cache: 4 MiB
L3 cache: 256 MiB
NUMA node0 CPU(s): 0-7
Vulnerability Itlb multihit: Not affected
Vulnerability L1tf: Not affected
Vulnerability Mds: Not affected
Vulnerability Meltdown: Not affected
Vulnerability Spec store bypass: Not affected
Vulnerability Spectre v1: Mitigation; __user pointer sanitization
Vulnerability Spectre v2: Not affected
Vulnerability Srbds: Not affected
Vulnerability Tsx async abort: Not affected
Flags: fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cp
uid asimdrdm jscvt fcma dcpop asimddp asimdfhm
96核96线程
root@44ff3bb0ad1d:~# lscpu
Architecture: aarch64
Byte Order: Little Endian
CPU(s): 96
On-line CPU(s) list: 0-95
Thread(s) per core: 1
Core(s) per socket: 48
Socket(s): 2
NUMA node(s): 4
Vendor ID: 0x48
Model: 0
Stepping: 0x1
CPU max MHz: 2600.0000
CPU min MHz: 200.0000
BogoMIPS: 200.00
L1d cache: 64K
L1i cache: 64K
L2 cache: 512K
L3 cache: 49152K
NUMA node0 CPU(s): 0-23
NUMA node1 CPU(s): 24-47
NUMA node2 CPU(s): 48-71
NUMA node3 CPU(s): 72-95
Flags: fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma dcpop asimddp asimdfhm
192核192线程
[ma-user@notebook-87136e07-6a9a-4138-beec-742972f7b62f MyDocuments]$ lscpu
Architecture: aarch64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 192
On-line CPU(s) list: 0-191
Thread(s) per core: 1
Core(s) per socket: 48
Socket(s): 4
NUMA node(s): 8
Vendor ID: HiSilicon
Model: 0
Model name: Kunpeng-920
Stepping: 0x1
BogoMIPS: 200.00
L1d cache: 12 MiB
L1i cache: 12 MiB
L2 cache: 96 MiB
L3 cache: 192 MiB
NUMA node0 CPU(s): 0-23
NUMA node1 CPU(s): 24-47
NUMA node2 CPU(s): 48-71
NUMA node3 CPU(s): 72-95
NUMA node4 CPU(s): 96-119
NUMA node5 CPU(s): 120-143
NUMA node6 CPU(s): 144-167
NUMA node7 CPU(s): 168-191
Flags: fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma dcpop asimddp asimdfhm
yoyo@yoyo:/sys/devices/system/cpu$ lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Address sizes: 39 bits physical, 48 bits virtual
Byte Order: Little Endian
CPU(s): 8
On-line CPU(s) list: 0-7
Vendor ID: GenuineIntel
Model name: 11th Gen Intel(R) Core(TM) i7-1195G7 @ 2.90GHz
CPU family: 6
Model: 140
Thread(s) per core: 2
Core(s) per socket: 4
Socket(s): 1
Stepping: 2
BogoMIPS: 5836.79
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr
sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology tsc_reli
able nonstop_tsc cpuid pni pclmulqdq vmx ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe p
opcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch i
nvpcid_single ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi ept vpid ept_ad fsgsbase
tsc_adjust bmi1 avx2 smep bmi2 erms invpcid avx512f avx512dq rdseed adx smap avx512ifma
clflushopt clwb avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves avx512vb
mi umip avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg avx512_vpopcntdq rdpi
d movdiri movdir64b fsrm avx512_vp2intersect flush_l1d arch_capabilities
Virtualization features:
Virtualization: VT-x
Hypervisor vendor: Microsoft
Virtualization type: full
Caches (sum of all):
L1d: 192 KiB (4 instances)
L1i: 128 KiB (4 instances)
L2: 5 MiB (4 instances)
L3: 12 MiB (1 instance)
Vulnerabilities:
Itlb multihit: Not affected
L1tf: Not affected
Mds: Not affected
Meltdown: Not affected
Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl and seccomp
Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Spectre v2: Mitigation; Enhanced IBRS, IBPB conditional, RSB filling
Srbds: Not affected
Tsx async abort: Not affected
# 查看内存
free -m
free -h
[root@localhost ~]# free -h
total used free shared buff/cache available
Mem: 63G 5.4G 5.4G 621M 52G 44G
[root@host-10-10-17-13 ~]# free -h
total used free shared buff/cache available
Mem: 30Gi 745Mi 29Gi 47Mi 867Mi 27Gi
Swap: 4.0Gi 0B 4.0Gi
[ma-user@notebook-87136e07-6a9a-4138-beec-742972f7b62f MyDocuments]$ free -h
total used free shared buff/cache available
Mem: 755Gi 12Gi 494Gi 4.0Gi 247Gi 735Gi
Swap: 0B 0B 0B
解决c++: internal compiler error: 已杀死 (program cc1plus)
查看SWAP交换空间
free -m
yoyo@yoyo:~$ free -m
total used free shared buff/cache available
Mem: 7846 311 7440 0 94 7358
Swap: 2048 207 1840
新增临时交换空间
# count的大小就是增加的swap空间的大小,1G是块大小为1G,所以空间大小是bs*count=6G
sudo dd if=/dev/zero of=/swapfile bs=1G count=6
# 把空间格式化成swap格式
sudo mkswap /swapfile
# 修改权限
su chmod 0600 /swapfile
# 使用swap空间
sudo swapon /swapfile
释放临时SWAP空间
swapoff -a
Ubuntu系统释放磁盘空间的7种简单方法
/home
扩容使用gparted工具,给 /home 分区扩容即可。
# 卸载
sudo umount /mnt/c
# 将c盘挂载到 /mnt/c
sudo mount -t drvfs C:\\ /mnt/c
将开发板挂在到宿主机
# 将ROS主机(树莓派、旭日X3派等)挂在到宿主机(笔记本、服务器)上
# ROS主机路径:/home/wheeltec/wheeltec_robot
# 宿主机路径:/mnt
sudo mount -t nfs 192.168.0.100:/home/wheeltec/wheeltec_robot /mnt
查看系统日志
tail -f /var/log/syslog
查看U盘所在的文件系统
df -h
卸载U盘
umount /media/sinkdream/DA18-EBFA
修复U盘文件系统
sudo dosfsck -v -a /dev/sda1
固态硬盘的速度
yoyo@ubuntu:~$ sudo hdparm -t /dev/loop0
/dev/loop0:
Timing buffered disk reads: 1476 MB in 3.01 seconds = 489.69 MB/sec
机械硬盘的速度
yoyo@ubuntu:~$ sudo hdparm -t /dev/sda1
/dev/sda1:
Timing buffered disk reads: 338 MB in 3.22 seconds = 104.99 MB/sec
Ubuntu系统批量杀死进程方法[转亲测可用]
# 通过端口号查看进程情况
lsof -i :5001
# 查看指定端口号的进程情况
netstat -tunlp | grep 5001
netstat -apn | grep 5001
# 查看进程的status文件
cat /proc/PID号/status
# 查找进程
ps -aux | grep xjserver
# 查找进程
ps -ef | grep xjserver
# 查看进程信息
ps -efw
# 杀死进程
kill -9 PID
# 删除所有的 uwsgi 进程
killall -9 uwsgi
# 杀进程
killall -9 xjserver
# 查看进程所占用内存大小
ps -ef | grep pycharm
# 根据进程ID查看进程情况
top -p PID号
ps -aux | grep pycharm
# nohup防止进程退出
在指令前加上 nohup 指令
ps -ef | grep spiderks.py | xargs kill -9 # 批量删除进程
ps -ef | grep spiderks.py | grep -v grep | awk '{print $2}' | xargs kill -9
| 管道符,用来隔开两个命令,管道符左边命令的输出会作为管道符右边命令的输入。
ps 命令用来列出系统中当前运行的进程, ps -ef 显示所有进程信息,联通命令行。
grep 命令用于过滤/搜索特定字符,grep spiderks.py在这里为搜索过滤所有含有"piderks.py"名称的进程。
grep -v 显示不包含匹配文本的所有行,在这里为筛选出所有不包含grep名称的进程,对上一步的进程再做一次筛选(因为ps -ef列出了所有的命令,包括命令行)。
awk在文件或字符串中基于指定规则浏览和抽取信息;把文件逐行读入,以空格为默认分隔符将每行切片,然后再进行后序处理。这里利用awk '{print $2}'将上一步中过滤得到的进程进行打印,$2表示打印第二个域(PID,进程号) $0表示所有域,$1表示第一个域,$n表示第n个域。
xargs命令是给命令传递参数的过滤器,善于把标准数据数据转换成命令行参数。在这里则是将获取前一个命令的标准输出然后转换成命令行参数传递给后面的kill命令。
kill -9强制关闭进程。
# 查看当前文件夹大小
du -sh
# 查看指定文件大小
du -sk filename
df -h
# 下载服务器文件
scp -r 用户名@服务器IP地址:服务器文件路径 本地路径
# 上传文件到服务器
scp local_file remote_username@remote_ip:remote_file
# 上传文件到docker容器中
scp -P 6013 -r ./mindspore [email protected]:/data/YOYOFile
# 递归创建文件夹
sudo mkdir -p /a/b/c/d
# 删除文件夹
sudo rmdir xxx
# 将一个目录下的文件合并成一个文件
find data/ -name "*seisreal.su" | xargs cat > ./seisreal.su
查看文件大小
# 查看文件夹大小
du -h --max-depth=1 ./work
# 查看当前目录大小
du -h -x --max-depth=1
# 查看文件大小
du -h --max-depth=1 ./work/work.zip
参数解释:
--max-depth:文件级别,类似于 `tree -L 1`
查看文件
# grep过滤文件
ls /usr/lib/x86_64-linux-gnu/ | grep libusb
查看文件属性
file hello
查看x86_64文件属性
yoyo@yoyo:/demo-1/build$ file test.cpython-38-x86_64-linux-gnu.so
test.cpython-38-x86_64-linux-gnu.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=4b5bc89af229afb3a57067c59c6f6b3c3abd97f9, stripped
查看ARM aarch64文件属性
yoyo@yoyo:/demo-1/build$ file test
test: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-aarch64.so.1, for GNU/Linux 3.7.0, BuildID[sha1]=ede486cbaba4f250828603555d45fa84769bcea9, with debug_info, not stripped
# 启动服务,打印详细信息
./xjserver -l4
# 重定向
> 新创建不追加,如果文件不存在,就创建文件;如果文件存在,就将其清空
>> 追加,将输出内容追加到目标文件中
# 要跟踪名为 tcp_server.log 的文件的增长情况,从末尾开始查看文件
tail -f /PATH/TO/tcp_server.log
# 向文本文件中写入内容
echo "deb http://mirrors.163.com/debian/ jessie main non-free contrib" > /etc/apt/sources.list
lsb_release -a
cat /etc/issue
liulinjun@LAPTOP-4DTD5D42:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04.1 LTS
Release: 22.04
Codename: jammy
yoyo@yoyo:~$ cat /etc/issue
Ubuntu 22.04.1 LTS \n \l
# OS详细信息
uname -a
或者
cat /proc/version
# OS发行信息
cat /etc/*release
# 硬件平台
uname -i
# 节点名称
uname -n
# OS名称
uname -o
# 处理器体系结构
uname -p
# OS发行版本号
uname -r
# OS名称
uname -s
# 内核版本
uname -v
[root@host-10-10-17-13 ~]# uname -a
Linux host-10-10-17-13 4.19.90-24.4.v2101.ky10.aarch64 #1 SMP Mon May 24 14:45:37 CST 2021 aarch64 aarch64 aarch64 GNU/Linux
[root@host-10-10-17-13 ~]# uname -i
aarch64
[root@host-10-10-17-13 ~]# uname -n
host-10-10-17-13
[root@host-10-10-17-13 ~]# uname -o
GNU/Linux
[root@host-10-10-17-13 ~]# uname -p
aarch64
[root@host-10-10-17-13 ~]# uname -r
4.19.90-24.4.v2101.ky10.aarch64
[root@host-10-10-17-13 ~]# uname -s
Linux
[root@host-10-10-17-13 ~]# uname -v
#1 SMP Mon May 24 14:45:37 CST 2021
# OS详细信息
cat /proc/version
# OS发行信息
cat /etc/*release
cat /etc/issue
cat /etc/os-release
[root@host-10-10-17-13 ~]# cat /proc/version
Linux version 4.19.90-24.4.v2101.ky10.aarch64 ([email protected]) (gcc version 7.3.0 (GCC)) #1 SMP Mon May 24 14:45:37 CST 2021
[root@host-10-10-17-13 ~]# cat /etc/*release
Kylin Linux Advanced Server release V10 (Sword)
DISTRIB_ID=Kylin
DISTRIB_RELEASE=V10
DISTRIB_CODENAME=juniper
DISTRIB_DESCRIPTION="Kylin V10"
DISTRIB_KYLIN_RELEASE=V10
DISTRIB_VERSION_TYPE=enterprise
DISTRIB_VERSION_MODE=normal
NAME="Kylin Linux Advanced Server"
VERSION="V10 (Sword)"
ID="kylin"
VERSION_ID="V10"
PRETTY_NAME="Kylin Linux Advanced Server V10 (Sword)"
ANSI_COLOR="0;31"
Kylin Linux Advanced Server release V10 (Sword)
lsb_release -a
yoyo@yoyo:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04.1 LTS
Release: 22.04
Codename: jammy
# 查看显卡信息
lshw -c video
# 查看Ip
ip addr show
centos使用yum安装htop
使用yum无法直接安装htop,需要先安装epel-release。
# centos
yum -y install epel-release
yum -y install htop
# ubuntu
sudo apt-get install htop
VIM命令详解
# 显示行数
:set number
或者
:set nu
# 永久显示行数
# 系统范围的初始化配置
/etc/vim/vimrc
# 个人vim初始化配置
~/.vimrc
# 显示行号
set number
# 语法高亮
syntax on
# 隐藏行数
:set nonumber
或者
:set nonu
# 查找
从开头搜索
在命令模式下,输入/你要查找的字符
按下回车,可以看到vim把光标移动到该字符处
再按n(小写)查看下一个匹配
按N(大写)查看上一个匹配(capslock切换大小写,也可以在小写状态下按shift+n)
# 从开头查找
/字符串
# 从末尾查找
?字符串
查看下一个匹配的,按下n(小写n)
查看上一个匹配的,按下N(大写N)
# 关闭高亮
set noh (no highlight search)
撤销:u
恢复撤销:Ctrl + r
定位到65行
vi /PATH/TO/add_tik2.cpp +65
xserver是用来在linux端的GUI程序,显示在当前windows客户端。
例如,启动linux的firefox火狐浏览器
firefox
MobaXterm
wsl上如何使用mobaxterm的xserver
dpkg命令
Linux入门教程
dpkg 命令使用
dpkg命令的英文全称是“Debian package”,故名意思是Debian Linux系统用来安装、创建和管理软件包的实用工具。
dpkg -i package.deb
dpkg -r package.deb
或者
dpkg --remove package.deb
dpkg -P package
# 安装前,列出与该包先关联的文件
# 安装后,可以用此命令查看软件安装到什么地方
dpkg -L package
dpkg --unpack package.deb
dpkg -l
# 显示软件包的版本
dpkg -l package
dpkg -c package.deb
dpkg -s package
dpkg -S keyword
dpkg –unpack package.deb
dpkg --configure package
Ubuntu cpu测试(频率、负载)
Ubuntu环境下利用Stress对CPU进行满载及半载压力测试
sudo apt-get install stress
cd /sys/devices/system/cpu
cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c
cat /proc/cpuinfo
或者
lscpu
# 4核8线程,以8线程满载压测
stress --cpu 8
通过ldconfig工具寻找系统内可供调用的动态库。而这些库所在位置是由一个叫做 /etc/ld.so.conf.d/
目录下以 .conf
结尾的文件定义。这些文件里写的路径往往是 /usr/local/lib
,/lib/x86_64-linux-gnu
之类的路径。也就是说我们的库只要在类似 /usr/local/lib
,/lib/x86_64-linux-gnu
的路径下,ldconfig就可以找到这些库。
root@root:/etc/ld.so.conf.d$ ls -l
total 20
-rw-r--r-- 1 root root 38 Mar 6 2022 fakeroot-x86_64-linux-gnu.conf
-rw-r--r-- 1 root root 50 Oct 12 09:57 intel-mkl.conf
-rw-r--r-- 1 root root 182 Nov 24 08:21 ld.wsl.conf
-rw-r--r-- 1 root root 44 Dec 16 2020 libc.conf
-rw-r--r-- 1 root root 100 Mar 4 2022 x86_64-linux-gnu.conf
root@root:/etc/ld.so.conf.d$ cat x86_64-linux-gnu.conf
# Multiarch support
/usr/local/lib/x86_64-linux-gnu
/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu