Skip to content

Instantly share code, notes, and snippets.

@Albert-W
Last active September 29, 2023 23:43
Show Gist options
  • Save Albert-W/db0b62c1eb812b256ebc968fa9f0ae8e to your computer and use it in GitHub Desktop.
Save Albert-W/db0b62c1eb812b256ebc968fa9f0ae8e to your computer and use it in GitHub Desktop.
Linux命令
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"metadata": {},
"cell_type": "markdown",
"source": "## 系统信息"
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "cat /etc/redhat-release #查看系统信息 ",
"execution_count": 1,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": "CentOS Linux release 7.7.1908 (Core)\n"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "cat /etc/centos-release",
"execution_count": 37,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": "CentOS Linux release 7.7.1908 (Core)\n"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "head /etc/issue # ubuntu 查看系统信息,lsb_release -a",
"execution_count": 90,
"outputs": [
{
"output_type": "stream",
"text": "\\S\nKernel \\r on an \\m\n\n",
"name": "stdout"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "uname -a # 查看内核/操作系统/CPU信息的linux系统信息命令",
"execution_count": 5,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": "Linux DESKTOP-H5LI4PL 4.19.84-microsoft-standard #1 SMP Wed Nov 13 11:44:37 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux\n"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "uname -r #查看内核版本号",
"execution_count": 23,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": "4.19.84-microsoft-standard\n"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "uname -s # 查看内核名称",
"execution_count": 78,
"outputs": [
{
"output_type": "stream",
"text": "Linux\n",
"name": "stdout"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "cat /proc/version #包含GCC的版本信息",
"execution_count": 6,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": "Linux version 4.19.84-microsoft-standard (oe-user@oe-host) (gcc version 8.2.0 (GCC)) #1 SMP Wed Nov 13 11:44:37 UTC 2019\n"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "gcc --version",
"execution_count": 77,
"outputs": [
{
"output_type": "stream",
"text": "gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-39)\nCopyright (C) 2015 Free Software Foundation, Inc.\nThis is free software; see the source for copying conditions. There is NO\nwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n",
"name": "stdout"
}
]
},
{
"metadata": {
"trusted": true,
"scrolled": true
},
"cell_type": "code",
"source": "hostname",
"execution_count": 9,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": "DESKTOP-H5LI4PL\n"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "env",
"execution_count": 10,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": "TERM_PROGRAM=vscode\nNVM_CD_FLAGS=\nGEM_HOME=/home/yichang/gems\nSHELL=/bin/bash\nTERM=xterm-256color\nCONDA_SHLVL=1\nTERM_PROGRAM_VERSION=1.42.1\nCONDA_PROMPT_MODIFIER=(base) \nWSLENV=VSCODE_WSL_EXT_LOCATION/up\nUSER=yichang\nNAME=DESKTOP-H5LI4PL\nNVM_DIR=/home/yichang/.nvm\nWSL_DISTRO_NAME=CentOS\nLS_COLORS=rs=0:di=38;5;27:ln=38;5;51:mh=44;38;5;15:pi=40;38;5;11:so=38;5;13:do=38;5;5:bd=48;5;232;38;5;11:cd=48;5;232;38;5;3:or=48;5;232;38;5;9:mi=05;48;5;232;38;5;15:su=48;5;196;38;5;15:sg=48;5;11;38;5;16:ca=48;5;196;38;5;226:tw=48;5;10;38;5;16:ow=48;5;10;38;5;21:st=48;5;21;38;5;15:ex=38;5;34:*.tar=38;5;9:*.tgz=38;5;9:*.arc=38;5;9:*.arj=38;5;9:*.taz=38;5;9:*.lha=38;5;9:*.lz4=38;5;9:*.lzh=38;5;9:*.lzma=38;5;9:*.tlz=38;5;9:*.txz=38;5;9:*.tzo=38;5;9:*.t7z=38;5;9:*.zip=38;5;9:*.z=38;5;9:*.Z=38;5;9:*.dz=38;5;9:*.gz=38;5;9:*.lrz=38;5;9:*.lz=38;5;9:*.lzo=38;5;9:*.xz=38;5;9:*.bz2=38;5;9:*.bz=38;5;9:*.tbz=38;5;9:*.tbz2=38;5;9:*.tz=38;5;9:*.deb=38;5;9:*.rpm=38;5;9:*.jar=38;5;9:*.war=38;5;9:*.ear=38;5;9:*.sar=38;5;9:*.rar=38;5;9:*.alz=38;5;9:*.ace=38;5;9:*.zoo=38;5;9:*.cpio=38;5;9:*.7z=38;5;9:*.rz=38;5;9:*.cab=38;5;9:*.jpg=38;5;13:*.jpeg=38;5;13:*.gif=38;5;13:*.bmp=38;5;13:*.pbm=38;5;13:*.pgm=38;5;13:*.ppm=38;5;13:*.tga=38;5;13:*.xbm=38;5;13:*.xpm=38;5;13:*.tif=38;5;13:*.tiff=38;5;13:*.png=38;5;13:*.svg=38;5;13:*.svgz=38;5;13:*.mng=38;5;13:*.pcx=38;5;13:*.mov=38;5;13:*.mpg=38;5;13:*.mpeg=38;5;13:*.m2v=38;5;13:*.mkv=38;5;13:*.webm=38;5;13:*.ogm=38;5;13:*.mp4=38;5;13:*.m4v=38;5;13:*.mp4v=38;5;13:*.vob=38;5;13:*.qt=38;5;13:*.nuv=38;5;13:*.wmv=38;5;13:*.asf=38;5;13:*.rm=38;5;13:*.rmvb=38;5;13:*.flc=38;5;13:*.avi=38;5;13:*.fli=38;5;13:*.flv=38;5;13:*.gl=38;5;13:*.dl=38;5;13:*.xcf=38;5;13:*.xwd=38;5;13:*.yuv=38;5;13:*.cgm=38;5;13:*.emf=38;5;13:*.axv=38;5;13:*.anx=38;5;13:*.ogv=38;5;13:*.ogx=38;5;13:*.aac=38;5;45:*.au=38;5;45:*.flac=38;5;45:*.mid=38;5;45:*.midi=38;5;45:*.mka=38;5;45:*.mp3=38;5;45:*.mpc=38;5;45:*.ogg=38;5;45:*.ra=38;5;45:*.wav=38;5;45:*.axa=38;5;45:*.oga=38;5;45:*.spx=38;5;45:*.xspf=38;5;45:\nCONDA_EXE=/home/yichang/miniconda3/bin/conda\nHOSTTYPE=x86_64\nKERNEL_LAUNCH_TIMEOUT=40\nJPY_PARENT_PID=606\nPAGER=cat\n_CE_CONDA=\nPATH=/home/yichang/.rbenv/shims:/home/yichang/.rbenv/bin:/home/yichang/gems/bin:/home/yichang/.rbenv/shims:/home/yichang/.rbenv/bin:/home/yichang/gems/bin:/home/yichang/.nvm/versions/node/v10.16.0/bin:/home/yichang/miniconda3/bin:/home/yichang/miniconda3/condabin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/mnt/c/ProgramData/Anaconda3:/mnt/c/ProgramData/Anaconda3/Library/mingw-w64/bin:/mnt/c/ProgramData/Anaconda3/Library/usr/bin:/mnt/c/ProgramData/Anaconda3/Library/bin:/mnt/c/ProgramData/Anaconda3/Scripts:/mnt/c/Program Files (x86)/NetSarang/Xftp 6:/mnt/c/Program Files (x86)/NetSarang/Xshell 6:/mnt/c/Program Files (x86)/Common Files/Oracle/Java/javapath:/mnt/c/WINDOWS/system32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32/Wbem:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0:/mnt/c/WINDOWS/System32/OpenSSH:/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/mnt/c/Program Files/Git/cmd:/mnt/c/Program Files/Java/jdk1.8.0_201/bin:/mnt/c/Program Files/nodejs:/mnt/c/WINDOWS/system32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32/Wbem:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0:/mnt/c/WINDOWS/System32/OpenSSH:/mnt/c/ProgramData/chocolatey/bin:/mnt/c/Program Files/Docker/Docker/resources/bin:/mnt/c/ProgramData/DockerDesktop/version-bin:/mnt/c/Users/91991/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/91991/AppData/Local/GitHubDesktop/bin:/mnt/c/Program Files/Microsoft VS Code/bin:/mnt/d/electSoftware/LxRunOffline-v3.3.3:/mnt/c/Users/91991/AppData/Roaming/npm:/mnt/c/Users/91991/AppData/Local/Microsoft/WindowsApps:/var/lib/snapd/snap/bin\nCONDA_PREFIX=/home/yichang/miniconda3\nPWD=/mnt/e/codes/GitHub/learnPython/Basic\nLANG=en_US.UTF-8\nNODE_PATH=/home/yichang/.nvm/versions/node/v10.16.0/lib/node_modules\nPS1=[PEXP\\[\\]ECT_PROMPT>\nWSL_INTEROP=/run/WSL/17_interop\nRBENV_SHELL=bash\n_CE_M=\nSHLVL=5\nHOME=/home/yichang\nLOGNAME=yichang\nCONDA_PYTHON_EXE=/home/yichang/miniconda3/bin/python\nXDG_DATA_DIRS=/usr/local/share:/usr/share:/var/lib/snapd/desktop\nVSCODE_IPC_HOOK_CLI=/tmp/vscode-ipc-1fcd284d-7469-4066-bb37-e5bb753e9303.sock\nLESSOPEN=||/usr/bin/lesspipe.sh %s\nCONDA_DEFAULT_ENV=base\nNVM_BIN=/home/yichang/.nvm/versions/node/v10.16.0/bin\nDISPLAY=:0\nCOLORTERM=truecolor\n_=/usr/bin/env\n"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "file /bin/ls #查看系统位数",
"execution_count": 11,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": "/bin/ls: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=aaf05615b6c91d3cbb076af81aeff531c5d7dfd9, stripped\n"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "getconf LONG_BIT #查看系统位数",
"execution_count": 12,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": "64\n"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "echo $SHELL #显示当前shell",
"execution_count": 13,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": "/bin/bash\n"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "uptime # 查看系统运行时间、用户数、负载",
"execution_count": 47,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": " 15:57:04 up 44 min, 0 users, load average: 0.00, 0.00, 0.00\n"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "cat /proc/loadavg",
"execution_count": 92,
"outputs": [
{
"output_type": "stream",
"text": "0.00 0.00 0.00 2/176 1604\n",
"name": "stdout"
}
]
},
{
"metadata": {},
"cell_type": "markdown",
"source": "## 硬件信息"
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "cat /proc/ioports # 查看设备io端口",
"execution_count": 70,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": "0000-0000 : dma1\n0000-0000 : pic1\n0000-0000 : timer0\n0000-0000 : timer1\n0000-0000 : keyboard\n0000-0000 : keyboard\n0000-0000 : rtc0\n0000-0000 : dma page reg\n0000-0000 : pic2\n0000-0000 : dma2\n0000-0000 : fpu\n0000-0000 : ACPI PM1a_EVT_BLK\n0000-0000 : ACPI PM1a_CNT_BLK\n0000-0000 : ACPI PM_TMR\n0000-0000 : ACPI GPE0_BLK\n"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "cat /proc/interrupts # 查看中断",
"execution_count": 71,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": " CPU0 CPU1 CPU2 CPU3 CPU4 CPU5 CPU6 CPU7 \n 8: 0 0 0 0 0 0 0 0 IO-APIC 8-edge rtc0\n 9: 0 0 0 0 0 0 0 0 IO-APIC 9-fasteoi acpi\nNMI: 0 0 0 0 0 0 0 0 Non-maskable interrupts\nLOC: 4 4 2 3 3 3 3 3 Local timer interrupts\nSPU: 0 0 0 0 0 0 0 0 Spurious interrupts\nPMI: 0 0 0 0 0 0 0 0 Performance monitoring interrupts\nIWI: 0 0 0 0 0 0 0 0 IRQ work interrupts\nRTR: 0 0 0 0 0 0 0 0 APIC ICR read retries\nRES: 10348 12992 34512 19532 19262 17096 31846 20527 Rescheduling interrupts\nCAL: 387 429 413 412 300 397 410 196 Function call interrupts\nTLB: 0 0 0 0 0 0 0 0 TLB shootdowns\nHYP: 71136 6053 3880 3341 3661 301 2308 456 Hypervisor callback interrupts\nHRE: 0 0 0 0 0 0 0 0 Hyper-V reenlightenment interrupts\nHVS: 23093 35971 39303 48788 26318 9655 38047 11903 Hyper-V stimer0 interrupts\nERR: 0\nMIS: 0\nPIN: 0 0 0 0 0 0 0 0 Posted-interrupt notification event\nNPI: 0 0 0 0 0 0 0 0 Nested posted-interrupt event\nPIW: 0 0 0 0 0 0 0 0 Posted-interrupt wakeup event\n"
}
]
},
{
"metadata": {},
"cell_type": "markdown",
"source": "### 存储信息"
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "free -h #内存使用量和交换区使用量",
"execution_count": 79,
"outputs": [
{
"output_type": "stream",
"text": " total used free shared buff/cache available\nMem: 6.1G 319M 5.6G 72K 243M 5.6G\nSwap: 2.0G 0B 2.0G\n",
"name": "stdout"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "cat /proc/swaps # 查看所有swap分区的信息",
"execution_count": 73,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": "Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n/swap/file file\t\t2097152\t0\t-2\n"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "swapon -s # 查看所有交换分区",
"execution_count": 51,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": "Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n/swap/file \tfile\t2097152\t0\t-2\n"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "vmstat 5 #不会停止",
"execution_count": 16,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": "procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----\n r b swpd free buff cache si so bi bo in cs us sy id wa st\n 2 0 0 5878128 30684 192452 0 0 34 855 18 64 0 0 100 0 0\n 0 0 0 5878128 30684 192452 0 0 0 0 12 84 0 0 100 0 0\n 0 0 0 5877876 30692 192476 0 0 0 2 13 91 0 0 100 0 0\n 0 0 0 5877876 30692 192484 0 0 0 0 8 75 0 0 100 0 0\n 0 0 0 5877876 30692 192484 0 0 0 5 11 88 0 0 100 0 0\n 0 0 0 5877876 30692 192484 0 0 0 0 7 74 0 0 100 0 0\n\n"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "cat /proc/meminfo",
"execution_count": 15,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": "MemTotal: 6405636 kB\nMemFree: 5879872 kB\nMemAvailable: 5880660 kB\nBuffers: 30676 kB\nCached: 167836 kB\nSwapCached: 0 kB\nActive: 312692 kB\nInactive: 105028 kB\nActive(anon): 219272 kB\nInactive(anon): 8 kB\nActive(file): 93420 kB\nInactive(file): 105020 kB\nUnevictable: 0 kB\nMlocked: 0 kB\nSwapTotal: 2097152 kB\nSwapFree: 2097152 kB\nDirty: 32 kB\nWriteback: 0 kB\nAnonPages: 219516 kB\nMapped: 46452 kB\nShmem: 64 kB\nSlab: 43972 kB\nSReclaimable: 24616 kB\nSUnreclaim: 19356 kB\nKernelStack: 2848 kB\nPageTables: 2976 kB\nNFS_Unstable: 0 kB\nBounce: 0 kB\nWritebackTmp: 0 kB\nCommitLimit: 5299968 kB\nCommitted_AS: 540464 kB\nVmallocTotal: 34359738367 kB\nVmallocUsed: 0 kB\nVmallocChunk: 0 kB\nPercpu: 1888 kB\nAnonHugePages: 71680 kB\nShmemHugePages: 0 kB\nShmemPmdMapped: 0 kB\nHugePages_Total: 0\nHugePages_Free: 0\nHugePages_Rsvd: 0\nHugePages_Surp: 0\nHugepagesize: 2048 kB\nHugetlb: 0 kB\nDirectMap4k: 15360 kB\nDirectMap2M: 2404352 kB\nDirectMap1G: 5242880 kB\n"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "grep MemTotal /proc/meminfo # 查看内存总量",
"execution_count": 22,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": "\u001b[01;31m\u001b[KMemTotal\u001b[m\u001b[K: 6405636 kB\n"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "grep MemFree /proc/meminfo #查看空闲内存量",
"execution_count": 46,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": "\u001b[01;31m\u001b[KMemFree\u001b[m\u001b[K: 5847576 kB\n"
}
]
},
{
"metadata": {
"scrolled": true,
"trusted": true
},
"cell_type": "code",
"source": "df -h #查看各分区使用情况",
"execution_count": 21,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": "Filesystem Size Used Avail Use% Mounted on\n/dev/sdb 251G 14G 225G 6% /\ntools 116G 93G 23G 81% /init\nnone 3.1G 0 3.1G 0% /dev\ntmpfs 3.1G 0 3.1G 0% /sys/fs/cgroup\nnone 3.1G 0 3.1G 0% /run\nnone 3.1G 0 3.1G 0% /run/lock\nnone 3.1G 0 3.1G 0% /run/shm\nnone 3.1G 0 3.1G 0% /run/user\ntmpfs 3.1G 0 3.1G 0% /mnt/wsl\nC:\\ 116G 93G 23G 81% /mnt/c\nD:\\ 56G 17G 40G 29% /mnt/d\nE:\\ 67G 17G 50G 26% /mnt/e\nF:\\ 466G 294G 172G 64% /mnt/f\n"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "mount | column -t # 查看挂接的分区状态,显示为表格",
"execution_count": 49,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": "/dev/sdb on / type ext4 (rw,relatime,discard,errors=remount-ro,data=ordered)\ntools on /init type 9p (ro,relatime,dirsync,aname=tools;fmask=022,loose,access=client,trans=fd,rfd=6,wfd=6)\nnone on /dev type devtmpfs (rw,nosuid,relatime,size=3200340k,nr_inodes=800085,mode=755)\ndevpts on /dev/pts type devpts (rw,nosuid,noexec,noatime,gid=5,mode=620,ptmxmode=000)\nsysfs on /sys type sysfs (rw,nosuid,nodev,noexec,noatime)\ntmpfs on /sys/fs/cgroup type tmpfs (rw,nosuid,nodev,noexec,relatime,mode=755)\ncgroup2 on /sys/fs/cgroup/unified type cgroup2 (rw,nosuid,nodev,noexec,relatime,nsdelegate)\ncgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset)\ncgroup on /sys/fs/cgroup/cpu type cgroup (rw,nosuid,nodev,noexec,relatime,cpu)\ncgroup on /sys/fs/cgroup/cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpuacct)\ncgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)\ncgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory)\ncgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)\ncgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)\ncgroup on /sys/fs/cgroup/net_cls type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls)\ncgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event)\ncgroup on /sys/fs/cgroup/net_prio type cgroup (rw,nosuid,nodev,noexec,relatime,net_prio)\ncgroup on /sys/fs/cgroup/hugetlb type cgroup (rw,nosuid,nodev,noexec,relatime,hugetlb)\ncgroup on /sys/fs/cgroup/pids type cgroup (rw,nosuid,nodev,noexec,relatime,pids)\ncgroup on /sys/fs/cgroup/rdma type cgroup (rw,nosuid,nodev,noexec,relatime,rdma)\nproc on /proc type proc (rw,nosuid,nodev,noexec,noatime)\nbinfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,relatime)\nnone on /run type tmpfs (rw,nosuid,noexec,noatime,mode=755)\nnone on /run/lock type tmpfs (rw,nosuid,nodev,noexec,noatime)\nnone on /run/shm type tmpfs (rw,nosuid,nodev,noatime)\nnone on /run/user type tmpfs (rw,nosuid,nodev,noexec,noatime,mode=755)\ntmpfs on /mnt/wsl type tmpfs (rw,relatime)\nC:\\ on /mnt/c type 9p (rw,noatime,dirsync,aname=drvfs;path=C:\\;uid=1000;gid=1000;symlinkroot=/mnt/,mmap,access=client,msize=65536,trans=fd,rfd=7,wfd=7)\nD:\\ on /mnt/d type 9p (rw,noatime,dirsync,aname=drvfs;path=D:\\;uid=1000;gid=1000;symlinkroot=/mnt/,mmap,access=client,msize=65536,trans=fd,rfd=7,wfd=7)\nE:\\ on /mnt/e type 9p (rw,noatime,dirsync,aname=drvfs;path=E:\\;uid=1000;gid=1000;symlinkroot=/mnt/,mmap,access=client,msize=65536,trans=fd,rfd=7,wfd=7)\nF:\\ on /mnt/f type 9p (rw,noatime,dirsync,aname=drvfs;path=F:\\;uid=1000;gid=1000;symlinkroot=/mnt/,mmap,access=client,msize=65536,trans=fd,rfd=7,wfd=7)\n"
}
]
},
{
"metadata": {},
"cell_type": "markdown",
"source": "### CPU信息"
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "lscpu",
"execution_count": 8,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": "Architecture: x86_64\nCPU op-mode(s): 32-bit, 64-bit\nByte Order: Little Endian\nCPU(s): 8\nOn-line CPU(s) list: 0-7\nThread(s) per core: 2\nCore(s) per socket: 4\nSocket(s): 1\nVendor ID: GenuineIntel\nCPU family: 6\nModel: 142\nModel name: Intel(R) Core(TM) i5-8250U CPU @ 1.60GHz\nStepping: 10\nCPU MHz: 1799.999\nBogoMIPS: 3599.99\nHypervisor vendor: Microsoft\nVirtualization type: full\nL1d cache: 32K\nL1i cache: 32K\nL2 cache: 256K\nL3 cache: 6144K\nFlags: 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 cpuid pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single pti ssbd ibrs ibpb stibp fsgsbase bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap clflushopt xsaveopt xsavec xgetbv1 xsaves flush_l1d arch_capabilities\n"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c # CPU型号",
"execution_count": 26,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": " 8 Intel(R) Core(TM) i5-8250U CPU @ 1.60GHz\n"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "cat /proc/cpuinfo |grep MHz|uniq",
"execution_count": 27,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": "cpu MHz\t\t: 1799.999\n"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "cat /proc/cpuinfo | grep \"physical id\" | sort | uniq | wc -l #物理CPU个数",
"execution_count": 28,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": "1\n"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "cat /proc/cpuinfo | grep \"processor\" | wc -l #逻辑CPU个数",
"execution_count": 29,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": "8\n"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "cat /proc/cpuinfo | grep \"cpu cores\" | wc -l",
"execution_count": 31,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": "8\n"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "cat /proc/cpuinfo |grep \"cores\"|uniq #CPU是几核",
"execution_count": 30,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": "cpu cores\t: 4\n"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "cat /proc/cpuinfo | grep \"siblings\"",
"execution_count": 32,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": "\u001b[01;31m\u001b[Ksiblings\u001b[m\u001b[K\t: 8\n\u001b[01;31m\u001b[Ksiblings\u001b[m\u001b[K\t: 8\n\u001b[01;31m\u001b[Ksiblings\u001b[m\u001b[K\t: 8\n\u001b[01;31m\u001b[Ksiblings\u001b[m\u001b[K\t: 8\n\u001b[01;31m\u001b[Ksiblings\u001b[m\u001b[K\t: 8\n\u001b[01;31m\u001b[Ksiblings\u001b[m\u001b[K\t: 8\n\u001b[01;31m\u001b[Ksiblings\u001b[m\u001b[K\t: 8\n\u001b[01;31m\u001b[Ksiblings\u001b[m\u001b[K\t: 8\n"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "cat /proc/cpuinfo | grep physical | uniq -c",
"execution_count": 33,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": " 1 physical id\t: 0\n 1 address sizes\t: 39 bits physical, 48 bits virtual\n 1 physical id\t: 0\n 1 address sizes\t: 39 bits physical, 48 bits virtual\n 1 physical id\t: 0\n 1 address sizes\t: 39 bits physical, 48 bits virtual\n 1 physical id\t: 0\n 1 address sizes\t: 39 bits physical, 48 bits virtual\n 1 physical id\t: 0\n 1 address sizes\t: 39 bits physical, 48 bits virtual\n 1 physical id\t: 0\n 1 address sizes\t: 39 bits physical, 48 bits virtual\n 1 physical id\t: 0\n 1 address sizes\t: 39 bits physical, 48 bits virtual\n 1 physical id\t: 0\n 1 address sizes\t: 39 bits physical, 48 bits virtual\n"
}
]
},
{
"metadata": {},
"cell_type": "markdown",
"source": "## 网络信息"
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "ifconfig # 查看所有网络接口的属性",
"execution_count": 54,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": "eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500\n inet 172.20.26.40 netmask 255.255.240.0 broadcast 172.20.31.255\n inet6 fe80::215:5dff:fe1b:2793 prefixlen 64 scopeid 0x20<link>\n ether 00:15:5d:1b:27:93 txqueuelen 1000 (Ethernet)\n RX packets 15059 bytes 12477448 (11.8 MiB)\n RX errors 0 dropped 0 overruns 0 frame 0\n TX packets 7505 bytes 18888729 (18.0 MiB)\n TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0\n\nlo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536\n inet 127.0.0.1 netmask 255.0.0.0\n inet6 ::1 prefixlen 128 scopeid 0x10<host>\n loop txqueuelen 1000 (Local Loopback)\n RX packets 12092 bytes 22423610 (21.3 MiB)\n RX errors 0 dropped 0 overruns 0 frame 0\n TX packets 12092 bytes 22423610 (21.3 MiB)\n TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0\n\n"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "route -n #查看路由表",
"execution_count": 43,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": "Kernel IP routing table\nDestination Gateway Genmask Flags Metric Ref Use Iface\n0.0.0.0 172.20.16.1 0.0.0.0 UG 0 0 0 eth0\n172.20.16.0 0.0.0.0 255.255.240.0 U 0 0 0 eth0\n"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "sudo iptables -L # 查看防火墙设置",
"execution_count": 56,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": "[sudo] password for yichang: \r\n"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "cat /etc/sysconfig/network-scripts/ifcfg-eth0 #网卡信息文件 cat /etc/network/interfaces(16.4) #cat /etc/netplan/ (18.4)",
"execution_count": 85,
"outputs": [
{
"output_type": "stream",
"text": "DEVICE=\"eth0\"\nBOOTPROTO=\"dhcp\"\nONBOOT=\"yes\"\nTYPE=\"Ethernet\"\nUSERCTL=\"yes\"\nPEERDNS=\"yes\"\nIPV6INIT=\"no\"\nPERSISTENT_DHCLIENT=\"1\"\n",
"name": "stdout"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "cat /etc/resolv.conf #查看DNS服务器",
"execution_count": 84,
"outputs": [
{
"output_type": "stream",
"text": "# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf:\n# [network]\n# generateResolvConf = false\nnameserver 172.20.16.1\n",
"name": "stdout"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "lsof -i #显示所有打开的端口",
"execution_count": 18,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": "COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME\nnode 25 yichang 19u IPv6 15414 0t0 TCP DESKTOP-H5LI4PL:43971->DESKTOP-H5LI4PL:64432 (ESTABLISHED)\nnode 25 yichang 20u IPv6 15410 0t0 TCP *:43971 (LISTEN)\nnode 25 yichang 39u IPv6 18667 0t0 TCP DESKTOP-H5LI4PL:43971->DESKTOP-H5LI4PL:58757 (ESTABLISHED)\nnode 25 yichang 40u IPv4 18669 0t0 TCP localhost:39444->localhost:ddi-tcp-1 (ESTABLISHED)\nnode 295 yichang 19u IPv6 15415 0t0 TCP DESKTOP-H5LI4PL:43971->DESKTOP-H5LI4PL:64433 (ESTABLISHED)\njupyter-n 606 yichang 7u IPv4 13620 0t0 TCP localhost:ddi-tcp-1 (LISTEN)\njupyter-n 606 yichang 31u IPv4 13684 0t0 TCP localhost:ddi-tcp-1->localhost:39444 (ESTABLISHED)\njupyter-n 606 yichang 32u IPv4 15594 0t0 TCP localhost:53468->localhost:54113 (ESTABLISHED)\njupyter-n 606 yichang 33u IPv4 16532 0t0 TCP localhost:47658->localhost:57153 (ESTABLISHED)\njupyter-n 606 yichang 34u IPv4 16533 0t0 TCP localhost:55522->localhost:34187 (ESTABLISHED)\njupyter-n 606 yichang 36u IPv4 15595 0t0 TCP localhost:55526->localhost:34187 (ESTABLISHED)\njupyter-n 606 yichang 38u IPv4 15596 0t0 TCP localhost:47666->localhost:57153 (ESTABLISHED)\njupyter-n 606 yichang 40u IPv4 15597 0t0 TCP localhost:38656->localhost:50629 (ESTABLISHED)\npython 626 yichang 12u IPv4 14672 0t0 TCP localhost:54113 (LISTEN)\npython 626 yichang 14u IPv4 14674 0t0 TCP localhost:50629 (LISTEN)\npython 626 yichang 16u IPv4 14676 0t0 TCP localhost:34187 (LISTEN)\npython 626 yichang 18u IPv4 14678 0t0 TCP localhost:57153 (LISTEN)\npython 626 yichang 23u IPv4 14682 0t0 TCP localhost:33107 (LISTEN)\npython 626 yichang 31u IPv4 18671 0t0 TCP localhost:34947 (LISTEN)\npython 626 yichang 35u IPv4 1409 0t0 TCP localhost:54113->localhost:53468 (ESTABLISHED)\npython 626 yichang 36u IPv4 15517 0t0 TCP localhost:57153->localhost:47658 (ESTABLISHED)\npython 626 yichang 38u IPv4 1345 0t0 TCP localhost:34187->localhost:55522 (ESTABLISHED)\npython 626 yichang 40u IPv4 1410 0t0 TCP localhost:34187->localhost:55526 (ESTABLISHED)\npython 626 yichang 41u IPv4 1411 0t0 TCP localhost:57153->localhost:47666 (ESTABLISHED)\npython 626 yichang 42u IPv4 1412 0t0 TCP localhost:50629->localhost:38656 (ESTABLISHED)\n"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "netstat -lntp # 查看所有监听端口",
"execution_count": 59,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": "(Not all processes could be identified, non-owned process info\n will not be shown, you would have to be root to see it all.)\nActive Internet connections (only servers)\nProto Recv-Q Send-Q Local Address Foreign Address State PID/Program name \ntcp 0 0 127.0.0.1:57153 0.0.0.0:* LISTEN 626/python \ntcp 0 0 127.0.0.1:54113 0.0.0.0:* LISTEN 626/python \ntcp 0 0 127.0.0.1:34947 0.0.0.0:* LISTEN 626/python \ntcp 0 0 127.0.0.1:50629 0.0.0.0:* LISTEN 626/python \ntcp 0 0 127.0.0.1:34187 0.0.0.0:* LISTEN 626/python \ntcp 0 0 127.0.0.1:33107 0.0.0.0:* LISTEN 626/python \ntcp 0 0 127.0.0.1:8888 0.0.0.0:* LISTEN 606/python \ntcp6 0 0 :::43971 :::* LISTEN 25/node \n"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "netstat -antp #查看所有已经建立的连接",
"execution_count": 42,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": "(Not all processes could be identified, non-owned process info\n will not be shown, you would have to be root to see it all.)\nActive Internet connections (servers and established)\nProto Recv-Q Send-Q Local Address Foreign Address State PID/Program name \ntcp 0 0 127.0.0.1:57153 0.0.0.0:* LISTEN 626/python \ntcp 0 0 127.0.0.1:54113 0.0.0.0:* LISTEN 626/python \ntcp 0 0 127.0.0.1:34947 0.0.0.0:* LISTEN 626/python \ntcp 0 0 127.0.0.1:50629 0.0.0.0:* LISTEN 626/python \ntcp 0 0 127.0.0.1:34187 0.0.0.0:* LISTEN 626/python \ntcp 0 0 127.0.0.1:33107 0.0.0.0:* LISTEN 626/python \ntcp 0 0 127.0.0.1:8888 0.0.0.0:* LISTEN 606/python \ntcp 0 0 127.0.0.1:34187 127.0.0.1:55522 ESTABLISHED 626/python \ntcp 0 0 127.0.0.1:55522 127.0.0.1:34187 ESTABLISHED 606/python \ntcp 0 0 127.0.0.1:8888 127.0.0.1:39510 ESTABLISHED 606/python \ntcp 0 0 127.0.0.1:8888 127.0.0.1:39444 ESTABLISHED 606/python \ntcp 0 0 127.0.0.1:57153 127.0.0.1:47666 ESTABLISHED 626/python \ntcp 0 0 127.0.0.1:53468 127.0.0.1:54113 ESTABLISHED 606/python \ntcp 0 0 127.0.0.1:55526 127.0.0.1:34187 ESTABLISHED 606/python \ntcp 0 0 127.0.0.1:47658 127.0.0.1:57153 ESTABLISHED 606/python \ntcp 0 0 127.0.0.1:34187 127.0.0.1:55526 ESTABLISHED 626/python \ntcp 0 0 127.0.0.1:57153 127.0.0.1:47658 ESTABLISHED 626/python \ntcp 0 0 127.0.0.1:39444 127.0.0.1:8888 ESTABLISHED 25/node \ntcp 0 0 127.0.0.1:39510 127.0.0.1:8888 ESTABLISHED 25/node \ntcp 0 0 127.0.0.1:38656 127.0.0.1:50629 ESTABLISHED 606/python \ntcp 0 0 127.0.0.1:54113 127.0.0.1:53468 ESTABLISHED 626/python \ntcp 0 0 127.0.0.1:47666 127.0.0.1:57153 ESTABLISHED 606/python \ntcp 0 0 127.0.0.1:50629 127.0.0.1:38656 ESTABLISHED 626/python \ntcp6 0 0 :::43971 :::* LISTEN 25/node \ntcp6 0 0 172.20.26.40:43971 172.20.16.1:63443 ESTABLISHED 25/node \ntcp6 0 0 172.20.26.40:43971 172.20.16.1:64433 ESTABLISHED 295/node \ntcp6 0 632 172.20.26.40:43971 172.20.16.1:58757 ESTABLISHED 25/node \ntcp6 0 0 172.20.26.40:43971 172.20.16.1:64432 ESTABLISHED 25/node \n"
}
]
},
{
"metadata": {
"trusted": true,
"scrolled": true
},
"cell_type": "code",
"source": "netstat -s # 查看网络统计信息进程",
"execution_count": 60,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": "Ip:\n 21503 total packets received\n 0 forwarded\n 0 incoming packets discarded\n 20760 incoming packets delivered\n 21107 requests sent out\nIcmp:\n 0 ICMP messages received\n 0 input ICMP message failed.\n ICMP input histogram:\n 3 ICMP messages sent\n 0 ICMP messages failed\n ICMP output histogram:\n destination unreachable: 3\nIcmpMsg:\n OutType3: 3\nTcp:\n 97 active connections openings\n 115 passive connection openings\n 20 failed connection attempts\n 0 connection resets received\n 20 connections established\n 20680 segments received\n 31481 segments send out\n 33 segments retransmited\n 0 bad segments received.\n 22 resets sent\nUdp:\n 32 packets received\n 3 packets to unknown port received.\n 0 packet receive errors\n 32 packets sent\n 0 receive buffer errors\n 0 send buffer errors\n IgnoredMulti: 45\nUdpLite:\nTcpExt:\n 2 invalid SYN cookies received\n 62 TCP sockets finished time wait in fast timer\n 590 delayed acks sent\n 1 delayed acks further delayed because of locked socket\n 8097 packet headers predicted\n 2970 acknowledgments not containing data payload received\n 5639 predicted acknowledgments\n 7 times recovered from packet loss by selective acknowledgements\n Detected reordering 15 times using SACK\n 1 congestion windows recovered without slow start by DSACK\n 33 fast retransmits\n TCPLossProbes: 3\n 9 DSACKs received\n TCPSACKDiscard: 6\n TCPSackMerged: 18\n TCPSackShiftFallback: 16\n TCPRcvCoalesce: 767\n TCPOFOQueue: 1\n TCPAutoCorking: 126\n TCPOrigDataSent: 24092\n TCPHystartTrainDetect: 17\n TCPHystartTrainCwnd: 372\n TCPDelivered: 24177\nIpExt:\n InBcastPkts: 45\n InOctets: 34961660\n OutOctets: 42239602\n InBcastOctets: 3510\n InNoECTPkts: 28058\nSctp:\n 0 Current Associations\n 0 Active Associations\n 0 Passive Associations\n 0 Number of Aborteds \n 0 Number of Graceful Terminations\n 0 Number of Out of Blue packets\n 0 Number of Packets with invalid Checksum\n 0 Number of control chunks sent\n 0 Number of ordered chunks sent\n 0 Number of Unordered chunks sent\n 0 Number of control chunks received\n 0 Number of ordered chunks received\n 0 Number of Unordered chunks received\n 0 Number of messages fragmented\n 0 Number of messages reassembled \n 0 Number of SCTP packets sent\n 0 Number of SCTP packets received\n"
}
]
},
{
"metadata": {},
"cell_type": "markdown",
"source": "## 进程信息"
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "ps # 查看当前进程",
"execution_count": 86,
"outputs": [
{
"output_type": "stream",
"text": " PID TTY TIME CMD\n 638 pts/2 00:00:00 bash\n 1586 pts/2 00:00:00 ps\n",
"name": "stdout"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "ps -ef # 查看所有进程",
"execution_count": 61,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": "UID PID PPID C STIME TTY TIME CMD\nroot 1 0 0 15:12 ? 00:00:00 /init\nroot 16 1 0 15:12 ? 00:00:00 /init\nroot 17 16 0 15:12 ? 00:00:00 /init\nyichang 18 17 0 15:12 pts/0 00:00:00 sh /mnt/c/Users/91991/.vscode/ex\nyichang 23 18 0 15:12 pts/0 00:00:00 sh /home/yichang/.vscode-server/\nyichang 25 23 0 15:12 pts/0 00:00:06 /home/yichang/.vscode-server/bin\nyichang 55 25 0 15:12 pts/0 00:00:00 /home/yichang/.vscode-server/bin\nyichang 295 25 0 15:12 pts/0 00:00:06 /home/yichang/.vscode-server/bin\nyichang 334 295 0 15:12 pts/0 00:00:00 /home/yichang/.vscode-server/bin\nyichang 342 295 0 15:12 pts/1 00:00:00 /bin/bash\nyichang 606 342 0 15:12 pts/1 00:00:08 /home/yichang/miniconda3/bin/pyt\nyichang 626 606 0 15:17 ? 00:00:02 /home/yichang/miniconda3/bin/pyt\nyichang 638 626 0 15:17 pts/2 00:00:00 /usr/bin/bash --rcfile /home/yic\nyichang 918 295 0 15:38 pts/3 00:00:00 /bin/bash\nyichang 1258 638 0 16:08 pts/2 00:00:00 ps -ef\n"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "ps aux # 查看所有进程",
"execution_count": 87,
"outputs": [
{
"output_type": "stream",
"text": "USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND\nroot 1 0.0 0.0 900 552 ? Sl 15:12 0:00 /init\nroot 16 0.0 0.0 900 88 ? Ss 15:12 0:00 /init\nroot 17 0.0 0.0 900 88 ? S 15:12 0:00 /init\nyichang 18 0.0 0.0 113200 2904 pts/0 Ss+ 15:12 0:00 sh /mnt/c/Users\nyichang 23 0.0 0.0 113196 2524 pts/0 S+ 15:12 0:00 sh /home/yichan\nyichang 25 0.1 1.0 933104 68640 pts/0 Sl+ 15:12 0:08 /home/yichang/.\nyichang 55 0.0 0.5 865632 37436 pts/0 Sl+ 15:12 0:00 /home/yichang/.\nyichang 295 0.1 1.6 1086016 103732 pts/0 Sl+ 15:12 0:12 /home/yichang/.\nyichang 334 0.0 0.6 583828 41160 pts/0 Sl+ 15:12 0:00 /home/yichang/.\nyichang 342 0.0 0.1 118752 6852 pts/1 Ss 15:12 0:00 /bin/bash\nyichang 606 0.1 1.0 482144 67604 pts/1 Rl+ 15:12 0:13 /home/yichang/m\nyichang 626 0.0 0.7 553704 48500 ? Rsl 15:17 0:03 /home/yichang/m\nyichang 638 0.0 0.1 118764 6800 pts/2 Ss 15:17 0:00 /usr/bin/bash -\nroot 1320 0.0 0.0 900 88 ? Ss 17:09 0:00 /init\nroot 1321 0.0 0.0 900 88 ? S 17:09 0:00 /init\nyichang 1322 0.0 0.1 118800 6900 pts/3 Ss+ 17:09 0:00 -bash\nyichang 1587 0.0 0.0 155388 4020 pts/2 R+ 17:21 0:00 ps aux\n",
"name": "stdout"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "ps aux | grep python",
"execution_count": 112,
"outputs": [
{
"output_type": "stream",
"text": "yichang 606 0.0 1.0 482400 67972 pts/1 Sl+ 15:12 0:17 /home/yichang/miniconda3/bin/\u001b[01;31m\u001b[Kpython\u001b[m\u001b[K /home/yichang/miniconda3/bin/jupyter-notebook --no-browser\nyichang 626 0.0 0.7 553836 48500 ? Ssl 15:17 0:03 /home/yichang/miniconda3/bin/\u001b[01;31m\u001b[Kpython\u001b[m\u001b[K -m bash_kernel -f /home/yichang/.local/share/jupyter/runtime/kernel-90e10cf8-fddc-40c5-8c80-0b48bf24ff7f.json\nyichang 638 0.0 0.1 118764 6800 pts/2 Ss 15:17 0:00 /usr/bin/bash --rcfile /home/yichang/miniconda3/lib/\u001b[01;31m\u001b[Kpython\u001b[m\u001b[K3.7/site-packages/pexpect/bashrc.sh\nyichang 1782 0.0 0.0 112728 2236 pts/2 S+ 21:15 0:00 grep --color=auto \u001b[01;31m\u001b[Kpython\u001b[m\u001b[K\n",
"name": "stdout"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "pstree # centos中无",
"execution_count": 88,
"outputs": [
{
"output_type": "stream",
"text": "bash: pstree: command not found\n",
"name": "stdout"
},
{
"output_type": "error",
"ename": "",
"evalue": "127",
"traceback": []
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "pwdx 638 #查看进程占用的目录",
"execution_count": 93,
"outputs": [
{
"output_type": "stream",
"text": "638: /mnt/e/codes/GitHub/learnPython/Basic\n",
"name": "stdout"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "chkconfig –list #列出所有系统服务",
"execution_count": 68,
"outputs": [
{
"ename": "",
"evalue": "1",
"output_type": "error",
"traceback": []
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "chkconfig –list | grep on # 列出所有启动的系统服务程序",
"execution_count": 69,
"outputs": [
{
"ename": "",
"evalue": "1",
"output_type": "error",
"traceback": []
}
]
},
{
"metadata": {},
"cell_type": "markdown",
"source": "## 用户与组"
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "w # 查看活动用户",
"execution_count": 62,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": " 16:08:20 up 56 min, 0 users, load average: 0.00, 0.00, 0.00\nUSER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT\n"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "id #查看指定用户信息",
"execution_count": 63,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": "uid=1000(yichang) gid=1000(yichang) groups=1000(yichang),1001(docker)\n"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "last #查看用户登录日志",
"execution_count": 64,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": "\nwtmp begins Thu Feb 20 14:50:12 2020\n"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "groups #用户所在组信息",
"execution_count": 81,
"outputs": [
{
"output_type": "stream",
"text": "yichang docker\n",
"name": "stdout"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "cut -d: -f1 /etc/passwd # 查看系统所有用户",
"execution_count": 65,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": "root\nbin\ndaemon\nadm\nlp\nsync\nshutdown\nhalt\nmail\noperator\ngames\nftp\nnobody\nsystemd-network\ndbus\npolkitd\nrpc\nrpcuser\nnfsnobody\nsshd\npostfix\nchrony\nyichang\noprofile\n"
}
]
},
{
"metadata": {
"trusted": true,
"scrolled": true
},
"cell_type": "code",
"source": "cat /etc/passwd",
"execution_count": 82,
"outputs": [
{
"output_type": "stream",
"text": "root:x:0:0:root:/root:/bin/bash\nbin:x:1:1:bin:/bin:/sbin/nologin\ndaemon:x:2:2:daemon:/sbin:/sbin/nologin\nadm:x:3:4:adm:/var/adm:/sbin/nologin\nlp:x:4:7:lp:/var/spool/lpd:/sbin/nologin\nsync:x:5:0:sync:/sbin:/bin/sync\nshutdown:x:6:0:shutdown:/sbin:/sbin/shutdown\nhalt:x:7:0:halt:/sbin:/sbin/halt\nmail:x:8:12:mail:/var/spool/mail:/sbin/nologin\noperator:x:11:0:operator:/root:/sbin/nologin\ngames:x:12:100:games:/usr/games:/sbin/nologin\nftp:x:14:50:FTP User:/var/ftp:/sbin/nologin\nnobody:x:99:99:Nobody:/:/sbin/nologin\nsystemd-network:x:192:192:systemd Network Management:/:/sbin/nologin\ndbus:x:81:81:System message bus:/:/sbin/nologin\npolkitd:x:999:998:User for polkitd:/:/sbin/nologin\nrpc:x:32:32:Rpcbind Daemon:/var/lib/rpcbind:/sbin/nologin\nrpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin\nnfsnobody:x:65534:65534:Anonymous NFS User:/var/lib/nfs:/sbin/nologin\nsshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin\npostfix:x:89:89::/var/spool/postfix:/sbin/nologin\nchrony:x:998:995::/var/lib/chrony:/sbin/nologin\nyichang:x:1000:1000::/home/yichang:/bin/bash\noprofile:x:16:16:Special user account to be used by OProfile:/var/lib/oprofile:/sbin/nologin\n",
"name": "stdout"
}
]
},
{
"metadata": {
"trusted": true,
"scrolled": true
},
"cell_type": "code",
"source": "lslogins",
"execution_count": 83,
"outputs": [
{
"output_type": "stream",
"text": " UID USER PROC PWD-LOCK PWD-DENY LAST-LOGIN GECOS\n 0 root 5 root\n 1 bin 0 bin\n 2 daemon 0 daemon\n 3 adm 0 adm\n 4 lp 0 lp\n 5 sync 0 sync\n 6 shutdown 0 shutdown\n 7 halt 0 halt\n 8 mail 0 mail\n 11 operator 0 operator\n 12 games 0 games\n 14 ftp 0 FTP User\n 16 oprofile 0 Special user account to be use\n 29 rpcuser 0 RPC Service User\n 32 rpc 0 Rpcbind Daemon\n 74 sshd 0 Privilege-separated SSH\n 81 dbus 0 System message bus\n 89 postfix 0 \n 99 nobody 0 Nobody\n 192 systemd-network\n 0 systemd Network Management\n 998 chrony 0 \n 999 polkitd 0 User for polkitd\n 1000 yichang 12 \n65534 nfsnobody 0 Anonymous NFS User\n",
"name": "stdout"
}
]
},
{
"metadata": {
"trusted": true,
"scrolled": true
},
"cell_type": "code",
"source": "cut -d: -f1 /etc/group # 查看系统所有组",
"execution_count": 66,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": "root\nbin\ndaemon\nsys\nadm\ntty\ndisk\nlp\nmem\nkmem\nwheel\ncdrom\nmail\nman\ndialout\nfloppy\ngames\ntape\nvideo\nftp\nlock\naudio\nnobody\nusers\nutmp\nutempter\ninput\nsystemd-journal\nsystemd-network\ndbus\npolkitd\nrpc\nssh_keys\ncgred\nrpcuser\nnfsnobody\nsshd\npostdrop\npostfix\nchrony\nyichang\ndocker\nstapusr\nstapsys\nstapdev\noprofile\n"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "crontab -l # 查看当前用户的计划任务服务",
"execution_count": 67,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": "no crontab for yichang\n"
},
{
"ename": "",
"evalue": "1",
"output_type": "error",
"traceback": []
}
]
},
{
"metadata": {},
"cell_type": "markdown",
"source": "## 文件信息"
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "alias # 查看别名",
"execution_count": 94,
"outputs": [
{
"output_type": "stream",
"text": "alias egrep='egrep --color=auto'\nalias fgrep='fgrep --color=auto'\nalias grep='grep --color=auto'\nalias jupy='jupyter notebook --no-browser'\nalias l.='ls -d .* --color=auto'\nalias ll='ls -alh --color=auto'\nalias ls='ls --color=auto'\nalias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'\n",
"name": "stdout"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "ll # 查看目录",
"execution_count": 95,
"outputs": [
{
"output_type": "stream",
"text": "total 849K\ndrwxrwxrwx 1 yichang yichang 512 Feb 20 20:29 \u001b[0m\u001b[48;5;10;38;5;21m.\u001b[0m\ndrwxrwxrwx 1 yichang yichang 512 Feb 6 20:31 \u001b[48;5;10;38;5;21m..\u001b[0m\n-rwxrwxrwx 1 yichang yichang 33 Jul 18 2019 \u001b[38;5;34m2.txt\u001b[0m\ndrwxrwxrwx 1 yichang yichang 512 Jul 18 2019 \u001b[48;5;10;38;5;21m3.txt\u001b[0m\n-rwxrwxrwx 1 yichang yichang 99 Jul 18 2019 \u001b[38;5;34mini.txt\u001b[0m\ndrwxrwxrwx 1 yichang yichang 512 Feb 20 19:21 \u001b[48;5;10;38;5;21m.ipynb_checkpoints\u001b[0m\n-rwxrwxrwx 1 yichang yichang 57K Feb 20 20:29 \u001b[38;5;34mLinux信息查看命令.ipynb\u001b[0m\n-rwxrwxrwx 1 yichang yichang 15 Jul 19 2019 \u001b[38;5;34mmytest2.py\u001b[0m\ndrwxrwxrwx 1 yichang yichang 512 Jul 19 2019 \u001b[48;5;10;38;5;21m__pycache__\u001b[0m\n-rwxrwxrwx 1 yichang yichang 621 Oct 7 14:47 \u001b[38;5;34msysargv.py\u001b[0m\ndrwxrwxrwx 1 yichang yichang 512 Jul 11 2019 \u001b[48;5;10;38;5;21m.vscode\u001b[0m\n-rwxrwxrwx 1 yichang yichang 11K Aug 14 2019 \u001b[38;5;34m切片用法.ipynb\u001b[0m\n-rwxrwxrwx 1 yichang yichang 109K Oct 12 14:34 \u001b[38;5;34m基础1变量.ipynb\u001b[0m\n-rwxrwxrwx 1 yichang yichang 5.3K Sep 12 12:51 \u001b[38;5;34m基础2语法.ipynb\u001b[0m\n-rwxrwxrwx 1 yichang yichang 26K Sep 12 12:51 \u001b[38;5;34m基础3序列类.ipynb\u001b[0m\n-rwxrwxrwx 1 yichang yichang 38K Sep 12 12:51 \u001b[38;5;34m基础4函数.ipynb\u001b[0m\n-rwxrwxrwx 1 yichang yichang 1.9K Jul 17 2019 \u001b[38;5;34m算法小模块.ipynb\u001b[0m\n-rwxrwxrwx 1 yichang yichang 9.2K Sep 12 14:36 \u001b[38;5;34m进阶-1模块与包.ipynb\u001b[0m\n-rwxrwxrwx 1 yichang yichang 190K Sep 12 12:52 \u001b[38;5;34m进阶-2对象与类.ipynb\u001b[0m\n-rwxrwxrwx 1 yichang yichang 378K Oct 7 12:33 \u001b[38;5;34m进阶-3文件.ipynb\u001b[0m\n",
"name": "stdout"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "pwd",
"execution_count": 96,
"outputs": [
{
"output_type": "stream",
"text": "/mnt/e/codes/GitHub/learnPython/Basic\n",
"name": "stdout"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "du -sh ~/miniconda3/ #指定目录的大小",
"execution_count": 98,
"outputs": [
{
"output_type": "stream",
"text": "3.8G\t/home/yichang/miniconda3/\n",
"name": "stdout"
}
]
},
{
"metadata": {},
"cell_type": "markdown",
"source": "## 命令相关"
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "history|tail -30",
"execution_count": 99,
"outputs": [
{
"output_type": "stream",
"text": " 668 echo $?\n 669 cat /etc/sysconfig/network-scripts/ifcfg-eth0\n 670 echo $?\n 671 ps\n 672 echo $?\n 673 ps aux\n 674 echo $?\n 675 pstree\n 676 echo $?\n 677 ## 硬件信息\n 678 echo $?\n 679 head /etc/issue # ubuntu 查看系统信息,lsb_release -a\n 680 echo $?\n 681 cat /proc/loadavg\n 682 echo $?\n 683 cat /proc/loadavg\n 684 echo $?\n 685 pwdx 638\n 686 echo $?\n 687 alias\n 688 echo $?\n 689 ll\n 690 echo $?\n 691 pwd\n 692 echo $?\n 693 du -sh ./miniconda3/\n 694 echo $?\n 695 du -sh ~/miniconda3/\n 696 echo $?\n 697 history|tail -30\n",
"name": "stdout"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "help",
"execution_count": 100,
"outputs": [
{
"output_type": "stream",
"text": "GNU bash, version 4.2.46(2)-release (x86_64-redhat-linux-gnu)\nThese shell commands are defined internally. Type `help' to see this list.\nType `help name' to find out more about the function `name'.\nUse `info bash' to find out more about the shell in general.\nUse `man -k' or `info' to find out more about commands not in this list.\n\nA star (*) next to a name means that the command is disabled.\n\n job_spec [&] history [-c] [-d offset] [n] or hist>\n (( expression )) if COMMANDS; then COMMANDS; [ elif C>\n . filename [arguments] jobs [-lnprs] [jobspec ...] or jobs >\n : kill [-s sigspec | -n signum | -sigs>\n [ arg... ] let arg [arg ...]\n [[ expression ]] local [option] name[=value] ...\n alias [-p] [name[=value] ... ] logout [n]\n bg [job_spec ...] mapfile [-n count] [-O origin] [-s c>\n bind [-lpvsPVS] [-m keymap] [-f filen> popd [-n] [+N | -N]\n break [n] printf [-v var] format [arguments]\n builtin [shell-builtin [arg ...]] pushd [-n] [+N | -N | dir]\n caller [expr] pwd [-LP]\n case WORD in [PATTERN [| PATTERN]...)> read [-ers] [-a array] [-d delim] [->\n cd [-L|[-P [-e]]] [dir] readarray [-n count] [-O origin] [-s>\n command [-pVv] command [arg ...] readonly [-aAf] [name[=value] ...] o>\n compgen [-abcdefgjksuv] [-o option] > return [n]\n complete [-abcdefgjksuv] [-pr] [-DE] > select NAME [in WORDS ... ;] do COMM>\n compopt [-o|+o option] [-DE] [name ..> set [-abefhkmnptuvxBCHP] [-o option->\n continue [n] shift [n]\n coproc [NAME] command [redirections] shopt [-pqsu] [-o] [optname ...]\n declare [-aAfFgilrtux] [-p] [name[=va> source filename [arguments]\n dirs [-clpv] [+N] [-N] suspend [-f]\n disown [-h] [-ar] [jobspec ...] test [expr]\n echo [-neE] [arg ...] time [-p] pipeline\n enable [-a] [-dnps] [-f filename] [na> times\n eval [arg ...] trap [-lp] [[arg] signal_spec ...]\n exec [-cl] [-a name] [command [argume> true\n exit [n] type [-afptP] name [name ...]\n export [-fn] [name[=value] ...] or ex> typeset [-aAfFgilrtux] [-p] name[=va>\n false ulimit [-SHacdefilmnpqrstuvx] [limit>\n fc [-e ename] [-lnr] [first] [last] o> umask [-p] [-S] [mode]\n fg [job_spec] unalias [-a] name [name ...]\n for NAME [in WORDS ... ] ; do COMMAND> unset [-f] [-v] [name ...]\n for (( exp1; exp2; exp3 )); do COMMAN> until COMMANDS; do COMMANDS; done\n function name { COMMANDS ; } or name > variables - Names and meanings of so>\n getopts optstring name [arg] wait [id]\n hash [-lr] [-p pathname] [-dt] [name > while COMMANDS; do COMMANDS; done\n help [-dms] [pattern ...] { COMMANDS ; }\n",
"name": "stdout"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "help cd",
"execution_count": 101,
"outputs": [
{
"output_type": "stream",
"text": "cd: cd [-L|[-P [-e]]] [dir]\n Change the shell working directory.\n \n Change the current directory to DIR. The default DIR is the value of the\n HOME shell variable.\n \n The variable CDPATH defines the search path for the directory containing\n DIR. Alternative directory names in CDPATH are separated by a colon (:).\n A null directory name is the same as the current directory. If DIR begins\n with a slash (/), then CDPATH is not used.\n \n If the directory is not found, and the shell option `cdable_vars' is set,\n the word is assumed to be a variable name. If that variable has a value,\n its value is used for DIR.\n \n Options:\n -L\tforce symbolic links to be followed\n -P\tuse the physical directory structure without following symbolic\n \tlinks\n -e\tif the -P option is supplied, and the current working directory\n \tcannot be determined successfully, exit with a non-zero status\n \n The default is to follow symbolic links, as if `-L' were specified.\n \n Exit Status:\n Returns 0 if the directory is changed, and if $PWD is set successfully when\n -P is used; non-zero otherwise.\n",
"name": "stdout"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "type grep",
"execution_count": 102,
"outputs": [
{
"output_type": "stream",
"text": "grep is aliased to `grep --color=auto'\n",
"name": "stdout"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "type cd",
"execution_count": 103,
"outputs": [
{
"output_type": "stream",
"text": "cd is a shell builtin\n",
"name": "stdout"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "type pip",
"execution_count": 104,
"outputs": [
{
"output_type": "stream",
"text": "pip is /home/yichang/miniconda3/bin/pip\n",
"name": "stdout"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "whereis grep",
"execution_count": 105,
"outputs": [
{
"output_type": "stream",
"text": "grep: /usr/bin/grep /usr/share/man/man1/grep.1.gz\n",
"name": "stdout"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "whereis pip ",
"execution_count": 106,
"outputs": [
{
"output_type": "stream",
"text": "pip: /home/yichang/miniconda3/bin/pip3.7 /home/yichang/miniconda3/bin/pip /mnt/c/ProgramData/Anaconda3/Scripts/pip.exe /mnt/c/Users/91991/AppData/Local/Microsoft/WindowsApps/pip.exe /mnt/c/Users/91991/AppData/Local/Microsoft/WindowsApps/pip3.exe\n",
"name": "stdout"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "type -p grep",
"execution_count": 107,
"outputs": []
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "type -p pip",
"execution_count": 108,
"outputs": [
{
"output_type": "stream",
"text": "/home/yichang/miniconda3/bin/pip\n",
"name": "stdout"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "",
"execution_count": null,
"outputs": []
}
],
"metadata": {
"_draft": {
"nbviewer_url": "https://gist.github.com/db0b62c1eb812b256ebc968fa9f0ae8e"
},
"gist": {
"id": "db0b62c1eb812b256ebc968fa9f0ae8e",
"data": {
"description": "Linux命令",
"public": true
}
},
"kernelspec": {
"name": "bash",
"display_name": "Bash",
"language": "bash"
},
"language_info": {
"name": "bash",
"codemirror_mode": "shell",
"mimetype": "text/x-sh",
"file_extension": ".sh"
},
"toc": {
"nav_menu": {},
"number_sections": true,
"sideBar": true,
"skip_h1_title": false,
"base_numbering": 1,
"title_cell": "Table of Contents",
"title_sidebar": "Contents",
"toc_cell": false,
"toc_position": {},
"toc_section_display": true,
"toc_window_display": true
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment