【Linux補(bǔ)坑】致那些我還不熟悉的Linux知識(shí)點(diǎn)

正文之前

今天居然周六了???臥槽,難怪實(shí)驗(yàn)室就一個(gè)學(xué)姐和一個(gè)同級(jí)的小姐姐。。。。要知道我這個(gè)房間里面就能坐23個(gè)人啊。。。不過無所謂啦,安靜點(diǎn)更好。今天也感覺不到自己該做啥,所以就來把Linux的一些坑填上,開始一丟丟的Linux進(jìn)階好了。。

正文

這是一個(gè)把握整體的硬件方面的命令集。

下面是我的服務(wù)器的展示:

root@zhangzhaobo:~# free -m
              total        used        free      shared  buff/cache   available
Mem:            481          61         252           2         168         405
Swap:           510           0         510
root@zhangzhaobo:~# df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            214M     0  214M   0% /dev
tmpfs            49M  2.6M   46M   6% /run
/dev/vda1        25G  1.9G   22G   9% /
tmpfs           241M     0  241M   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           241M     0  241M   0% /sys/fs/cgroup
tmpfs            49M     0   49M   0% /run/user/0
root@zhangzhaobo:~# fdisk -l
Disk /dev/vda: 25 GiB, 26843545600 bytes, 52428800 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x941390d7

Device     Boot    Start      End  Sectors  Size Id Type
/dev/vda1  *        2048 51382271 51380224 24.5G 83 Linux
/dev/vda2       51382272 52428799  1046528  511M 82 Linux swap / Solaris
root@zhangzhaobo:~# top
top - 20:08:07 up 11:35,  1 user,  load average: 0.00, 0.00, 0.00
Tasks:  72 total,   1 running,  39 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.2 us,  0.2 sy,  0.0 ni, 99.7 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :   492884 total,   258028 free,    62768 used,   172088 buff/cache
KiB Swap:   523260 total,   523260 free,        0 used.   415312 avail Mem

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
  934 root      20   0   43964   4016   3464 R   0.3  0.8   0:00.03 top
    1 root      20   0   77432   8600   6708 S   0.0  1.7   0:02.52 systemd
    2 root      20   0       0      0      0 S   0.0  0.0   0:00.02 kthreadd
    4 root       0 -20       0      0      0 I   0.0  0.0   0:00.00 kworker/0:0H
    6 root       0 -20       0      0      0 I   0.0  0.0   0:00.00 mm_percpu_wq
    7 root      20   0       0      0      0 S   0.0  0.0   0:00.03 ksoftirqd/0
    8 root      20   0       0      0      0 I   0.0  0.0   0:02.51 rcu_sched
    9 root      20   0       0      0      0 I   0.0  0.0   0:00.00 rcu_bh
   10 root      rt   0       0      0      0 S   0.0  0.0   0:00.00 migration/0
   11 root      rt   0       0      0      0 S   0.0  0.0   0:00.21 watchdog/0
   12 root      20   0       0      0      0 S   0.0  0.0   0:00.00 cpuhp/0
   13 root      20   0       0      0      0 S   0.0  0.0   0:00.00 cpuhp/1
   14 root      rt   0       0      0      0 S   0.0  0.0   0:00.15 watchdog/1
   15 root      rt   0       0      0      0 S   0.0  0.0   0:00.00 migration/1
   16 root      20   0       0      0      0 S   0.0  0.0   0:00.10 ksoftirqd/1
   18 root       0 -20       0      0      0 I   0.0  0.0   0:00.00 kworker/1:0H
   19 root      20   0       0      0      0 S   0.0  0.0   0:00.00 kdevtmpfs
   20 root       0 -20       0      0      0 I   0.0  0.0   0:00.00 netns
   21 root      20   0       0      0      0 S   0.0  0.0   0:00.00 rcu_tasks_kthre
   22 root      20   0       0      0      0 S   0.0  0.0   0:00.00 kauditd
   24 root      20   0       0      0      0 S   0.0  0.0   0:00.10 khungtaskd
   25 root      20   0       0      0      0 S   0.0  0.0   0:00.00 oom_reaper
   26 root       0 -20       0      0      0 I   0.0  0.0   0:00.00 writeback
   27 root      20   0       0      0      0 S   0.0  0.0   0:00.00 kcompactd0
   28 root      25   5       0      0      0 S   0.0  0.0   0:00.00 ksmd
   29 root       0 -20       0      0      0 I   0.0  0.0   0:00.00 crypto
   30 root       0 -20       0      0      0 I   0.0  0.0   0:00.00 kintegrityd
   31 root       0 -20       0      0      0 I   0.0  0.0   0:00.00 kblockd
   32 root       0 -20       0      0      0 I   0.0  0.0   0:00.00 ata_sff
root@zhangzhaobo:~# w
 20:13:26 up 11:40,  1 user,  load average: 0.61, 0.31, 0.12
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
root     pts/0    202.114.6.11     20:04    6.00s  0.10s  0.00s w
root@zhangzhaobo:~# cat /proc/cpuinfo
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 62
model name      : Intel(R) Xeon(R) CPU E5-2630L v2 @ 2.40GHz
stepping        : 4
microcode       : 0x1
cpu MHz         : 2399.998
cache size      : 4096 KB
physical id     : 0
siblings        : 1
core id         : 0
cpu cores       : 1
apicid          : 0
initial apicid  : 0
fpu             : yes
fpu_exception   : yes
cpuid level     : 13
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon rep_good nopl cpuid pni pclmulqdq ssse3 cx16 pcid sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm pti fsgsbase tsc_adjust smep erms xsaveopt
bugs            : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass
bogomips        : 4799.99
clflush size    : 64
cache_alignment : 64
address sizes   : 46 bits physical, 48 bits virtual
power management:

processor       : 1
vendor_id       : GenuineIntel
cpu family      : 6
model           : 62
model name      : Intel(R) Xeon(R) CPU E5-2630L v2 @ 2.40GHz
stepping        : 4
microcode       : 0x1
cpu MHz         : 2399.998
cache size      : 4096 KB
physical id     : 1
siblings        : 1
core id         : 0
cpu cores       : 1
apicid          : 1
initial apicid  : 1
fpu             : yes
fpu_exception   : yes
cpuid level     : 13
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon rep_good nopl cpuid pni pclmulqdq ssse3 cx16 pcid sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm pti fsgsbase tsc_adjust smep erms xsaveopt
bugs            : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass
bogomips        : 4799.99
clflush size    : 64
cache_alignment : 64
address sizes   : 46 bits physical, 48 bits virtual
power management:

具體的信息懶得一個(gè)個(gè)去打了。。。反正需要的時(shí)候查一查,網(wǎng)絡(luò)編程程序猿嗎。。。知道是什么用就OK了 。。

實(shí)用命令:grep

這個(gè)管道命令可以用于檢索文件中的內(nèi)容是否符合我們的需求。比如說我把上面cat /proc/cpuinfo出來的信息放在一個(gè)叫做test.log的文件中。我要檢索出來是幾核的??常規(guī)是cat,然后在一個(gè)個(gè)去查找。。但是現(xiàn)在有了grep那就不一樣了。

root@zhangzhaobo:/home/ubuntu# grep -n "core" test.log
12:core id         : 0
13:cpu cores       : 1
39:core id         : 0
40:cpu cores       : 1
root@zhangzhaobo:/home/ubuntu# cat test.log | grep "core"
core id         : 0
cpu cores       : 1
core id         : 0
cpu cores       : 1

我們只需要檢索關(guān)鍵字,對(duì)應(yīng)的哪一行就會(huì)完全的給我們打出來。方便不???至于-n 這個(gè)參數(shù)呢,代表著我同時(shí)要輸出行號(hào)。下面我沒有用-n就沒有顯示行號(hào)有木有?

另外還有個(gè)我不怎么常用的小試用命令。那就是more,這個(gè)可以讓我們一行行的讀取文件。每一次enter都會(huì)往下拉一行。要退出這種閱讀模式,輸入q即可。

另外還有一個(gè)統(tǒng)計(jì)命令:wc,可以對(duì)文件統(tǒng)計(jì)行。

root@zhangzhaobo:/home/ubuntu# wc test.log
  53  316 2047 test.log
root@zhangzhaobo:/home/ubuntu# wc -l test.log
53 test.log
root@zhangzhaobo:/home/ubuntu# wc -c test.log
2047 test.log
root@zhangzhaobo:/home/ubuntu# wc -m test.log
2047 test.log
root@zhangzhaobo:/home/ubuntu# wc -w test.log
316 test.log

至于參數(shù)的含義,通過man wc就可以知道了

至于find命令我不多說,大家自己看教程。我大概展示下我目前最滿意的用法:

root@zhangzhaobo:/home# find . -name "*.log"
./install_bbr.log
./ubuntu/test.log
root@zhangzhaobo:/home# ls
bbr.sh           shadowsocks-all.sh    ss.json
install_bbr.log  shadowsocks_r_qr.png  ubuntu

這是菜鳥教程的find命令學(xué)習(xí)網(wǎng)頁(yè): Linux find命令

其他的我這個(gè)教程也沒啥好看的了,大部分都是網(wǎng)站服務(wù)器的配置啥的。。我也不喜歡看。。所以就不看了。。

正文之后

到此為止,準(zhǔn)備吃飯健身去了!

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容