学习linux基本命令

  • ls命令运行结果:
root@iZ2ze0ht45qn4m8m1wjfdrZ:~# ls
result.csv  result_gip.csv  result_gzip.csv  urls.txt
root@iZ2ze0ht45qn4m8m1wjfdrZ:~# cd ..
root@iZ2ze0ht45qn4m8m1wjfdrZ:/# ls
bin   etc         initrd.img.old  lost+found  opt   run   sys      usr      vmlinuz.old
boot  home        lib             media       proc  sbin  testing  var
dev   initrd.img  lib64           mnt         root  srv   tmp      vmlinuz
  • cd命令运行结果:
root@iZ2ze0ht45qn4m8m1wjfdrZ:~# cd ..
root@iZ2ze0ht45qn4m8m1wjfdrZ:/# ls
bin   etc         initrd.img.old  lost+found  opt   run   sys      usr      vmlinuz.old
boot  home        lib             media       proc  sbin  testing  var
dev   initrd.img  lib64           mnt         root  srv   tmp      vmlinuz
root@iZ2ze0ht45qn4m8m1wjfdrZ:/# cd bin
root@iZ2ze0ht45qn4m8m1wjfdrZ:/bin#
  • mkdir运行结果:
root@iZ2ze0ht45qn4m8m1wjfdrZ:/# cd tmp
root@iZ2ze0ht45qn4m8m1wjfdrZ:/tmp# ls
Aegis-<Guid(5A2C30A2-A87D-490A-9281-6765EDAD7CBA)>
root@iZ2ze0ht45qn4m8m1wjfdrZ:/tmp# mkdir shj_test
root@iZ2ze0ht45qn4m8m1wjfdrZ:/tmp# ls
Aegis-<Guid(5A2C30A2-A87D-490A-9281-6765EDAD7CBA)>  shj_test
root@iZ2ze0ht45qn4m8m1wjfdrZ:/tmp# rm -rf shj_test
root@iZ2ze0ht45qn4m8m1wjfdrZ:/tmp# ls
Aegis-<Guid(5A2C30A2-A87D-490A-9281-6765EDAD7CBA)>
  • grep
root@iZ2ze0ht45qn4m8m1wjfdrZ:~/shj_test# ls
urls.txt
root@iZ2ze0ht45qn4m8m1wjfdrZ:~/shj_test# cat urls.txt
http://ur.tencent.com/categories/7
http://ur.tencent.com/categories/7/?page=2
http://ur.tencent.com/categories/7/?page=3
root@iZ2ze0ht45qn4m8m1wjfdrZ:~/shj_test# grep -i HTTP urls.txt
http://ur.tencent.com/categories/7
http://ur.tencent.com/categories/7/?page=2
http://ur.tencent.com/categories/7/?page=3
root@iZ2ze0ht45qn4m8m1wjfdrZ:~/shj_test# 
  • ps aux
root@iZ2ze0ht45qn4m8m1wjfdrZ:~# ps aux
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.0  0.5  37808  5940 ?        Ss   Mar23   0:03 /sbin/init
root         2  0.0  0.0      0     0 ?        S    Mar23   0:00 [kthreadd]
root         3  0.0  0.0      0     0 ?        S    Mar23   0:02 [ksoftirqd/0]
root         5  0.0  0.0      0     0 ?        S<   Mar23   0:00 [kworker/0:0H]
root         6  0.0  0.0      0     0 ?        S    Mar23   0:06 [kworker/u2:0]
root         7  0.0  0.0      0     0 ?        S    Mar23   0:37 [rcu_sched]
root         8  0.0  0.0      0     0 ?        S    Mar23   0:00 [rcu_bh]
root         9  0.0  0.0      0     0 ?        S    Mar23   0:00 [migration/0]
root        10  0.0  0.0      0     0 ?        S    Mar23   0:03 [watchdog/0]
root        11  0.0  0.0      0     0 ?        S    Mar23   0:00 [kdevtmpfs]
root        12  0.0  0.0      0     0 ?        S<   Mar23   0:00 [netns]
root        13  0.0  0.0      0     0 ?        S<   Mar23   0:00 [perf]
root        14  0.0  0.0      0     0 ?        S    Mar23   0:00 [khungtaskd]
root        15  0.0  0.0      0     0 ?        S<   Mar23   0:00 [writeback]
root        16  0.0  0.0      0     0 ?        SN   Mar23   0:00 [ksmd]
root        17  0.0  0.0      0     0 ?        SN   Mar23   0:03 [khugepaged]
root        18  0.0  0.0      0     0 ?        S<   Mar23   0:00 [crypto]
root        19  0.0  0.0      0     0 ?        S<   Mar23   0:00 [kintegrityd]
root        20  0.0  0.0      0     0 ?        S<   Mar23   0:00 [bioset]
root        21  0.0  0.0      0     0 ?        S<   Mar23   0:00 [kblockd]
root        22  0.0  0.0      0     0 ?        S<   Mar23   0:00 [ata_sff]
root        23  0.0  0.0      0     0 ?        S<   Mar23   0:00 [md]
root        24  0.0  0.0      0     0 ?        S<   Mar23   0:00 [devfreq_wq]
root        25  0.0  0.0      0     0 ?        S    Mar23   0:06 [kworker/u2:1]
root        28  0.0  0.0      0     0 ?        S    Mar23   0:00 [kswapd0]
root        29  0.0  0.0      0     0 ?        S<   Mar23   0:00 [vmstat]
root        30  0.0  0.0      0     0 ?        S    Mar23   0:00 [fsnotify_mark]
root        31  0.0  0.0      0     0 ?        S    Mar23   0:00 [ecryptfs-kthre
root        47  0.0  0.0      0     0 ?        S<   Mar23   0:00 [kthrotld]
root        48  0.0  0.0      0     0 ?        S<   Mar23   0:00 [acpi_thermal_p
root        49  0.0  0.0      0     0 ?        S    Mar23   0:00 [vballoon]
root        50  0.0  0.0      0     0 ?        S<   Mar23   0:00 [bioset]
root        51  0.0  0.0      0     0 ?        S<   Mar23   0:00 [bioset]
root        52  0.0  0.0      0     0 ?        S<   Mar23   0:00 [bioset]
root        53  0.0  0.0      0     0 ?        S<   Mar23   0:00 [bioset]
root        54  0.0  0.0      0     0 ?        S<   Mar23   0:00 [bioset]
root        55  0.0  0.0      0     0 ?        S<   Mar23   0:00 [bioset]
root        56  0.0  0.0      0     0 ?        S<   Mar23   0:00 [bioset]
root        57  0.0  0.0      0     0 ?        S<   Mar23   0:00 [bioset]
root        58  0.0  0.0      0     0 ?        S<   Mar23   0:00 [bioset]
root        59  0.0  0.0      0     0 ?        S    Mar23   0:00 [scsi_eh_0]
root        60  0.0  0.0      0     0 ?        S<   Mar23   0:00 [scsi_tmf_0]
root        61  0.0  0.0      0     0 ?        S    Mar23   0:00 [scsi_eh_1]
root        62  0.0  0.0      0     0 ?        S<   Mar23   0:00 [scsi_tmf_1]
root        68  0.0  0.0      0     0 ?        S<   Mar23   0:00 [ipv6_addrconf]
root        81  0.0  0.0      0     0 ?        S<   Mar23   0:00 [deferwq]
root        82  0.0  0.0      0     0 ?        S<   Mar23   0:00 [charger_manage
root       122  0.0  0.0      0     0 ?        S<   Mar23   0:00 [bioset]
root       123  0.0  0.0      0     0 ?        S<   Mar23   0:00 [bioset]
root       124  0.0  0.0      0     0 ?        S<   Mar23   0:00 [bioset]
root       126  0.0  0.0      0     0 ?        S<   Mar23   0:00 [bioset]
root       127  0.0  0.0      0     0 ?        S<   Mar23   0:00 [bioset]
root       128  0.0  0.0      0     0 ?        S<   Mar23   0:00 [bioset]
root       129  0.0  0.0      0     0 ?        S<   Mar23   0:00 [bioset]
root       130  0.0  0.0      0     0 ?        S<   Mar23   0:00 [kpsmoused]
root       131  0.0  0.0      0     0 ?        S<   Mar23   0:00 [bioset]
root       132  0.0  0.0      0     0 ?        S<   Mar23   0:00 [ttm_swap]
root       152  0.0  0.0      0     0 ?        S<   Mar23   0:00 [kworker/0:1H]
root       154  0.0  0.0      0     0 ?        S    Mar23   0:00 [jbd2/vda1-8]
root       155  0.0  0.0      0     0 ?        S<   Mar23   0:00 [ext4-rsv-conve
root       197  0.0  0.2  28348  2732 ?        Ss   Mar23   0:01 /lib/systemd/sy
root       205  0.0  0.0      0     0 ?        S    Mar23   0:00 [kauditd]
root       236  0.0  0.3  44656  4064 ?        Ss   Mar23   0:00 /lib/systemd/sy
root       387  0.0  0.2  20396  2712 ?        Ss   Mar23   0:00 /lib/systemd/sy
daemon     388  0.0  0.2  26040  2252 ?        Ss   Mar23   0:00 /usr/sbin/atd -
root       403  0.0  0.2  29004  3020 ?        Ss   Mar23   0:01 /usr/sbin/cron 
message+   409  0.0  0.3  42896  3908 ?        Ss   Mar23   0:00 /usr/bin/dbus-d
root       425  0.0  0.4  32060  4352 ?        Ssl  Mar23   7:53 /usr/local/aegi
syslog     431  0.0  0.3 260624  3392 ?        Ssl  Mar23   0:00 /usr/sbin/rsysl
root       434  0.0  0.6 276188  6248 ?        Ssl  Mar23   0:10 /usr/lib/accoun
root       467  0.0  0.2 707112  2876 ?        Ssl  Mar23   0:01 /usr/sbin/nscd
root       485  0.0  0.1  62744  1980 ?        Ssl  Mar23   0:48 /usr/sbin/aliyu
root       612  0.0  0.0      0     0 ?        S<   Mar23   0:00 [edac-poller]
ntp        795  0.0  0.3  98196  3848 ?        Ss   Mar23   0:38 /usr/sbin/ntpd 
root       817  0.0  0.0   7512   712 ttyS0    Ss+  Mar23   0:00 /sbin/agetty --
root       822  0.0  0.0   7696   668 tty1     Ss+  Mar23   0:00 /sbin/agetty --
root       909  0.1  1.6 124876 16688 ?        Ssl  Mar23  21:21 /usr/local/aegi
root      3029  0.0  0.5  59416  5888 ?        Ss   Mar25   0:00 /usr/sbin/sshd 
root      3150  0.0  0.0      0     0 ?        S    Mar25   0:09 [kworker/0:1]
root     10395  0.0  0.0      0     0 ?        S    09:12   0:00 [kworker/0:0]
root     10469  0.0  0.6  93460  7004 ?        Ss   09:45   0:00 sshd: root@pts/
root     10472  0.0  0.0      0     0 ?        S    09:45   0:00 [kworker/0:2]
root     10473  0.0  0.4  36824  4632 ?        Ss   09:45   0:00 /lib/systemd/sy
root     10474  0.0  0.1  61472  1996 ?        S    09:45   0:00 (sd-pam)
root     10493  0.2  0.4  14004  4392 pts/0    Ss   09:45   0:00 -bash
root     10506  0.0  0.1  29124  1492 pts/0    R+   09:45   0:00 ps aux
  • top命令运行结果:
root@iZ2ze0ht45qn4m8m1wjfdrZ:~/shj_test# top
top - 10:07:36 up 10 days, 17:32,  1 user,  load average: 0.00, 0.00, 0.00
Tasks:  87 total,   1 running,  84 sleeping,   2 stopped,   0 zombie
%Cpu(s):  0.0 us,  0.0 sy,  0.0 ni,100.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :  1016020 total,   624788 free,    33024 used,   358208 buff/cache
KiB Swap:        0 total,        0 free,        0 used.   805396 avail Mem 

  PID USER      PR  NI    VIRT    RES    SHR S %CPU %MEM     TIME+ COMMAND     
    1 root      20   0   37808   5940   4056 S  0.0  0.6   0:03.38 systemd     
    2 root      20   0       0      0      0 S  0.0  0.0   0:00.00 kthreadd    
    3 root      20   0       0      0      0 S  0.0  0.0   0:02.25 ksoftirqd/0 
    5 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 kworker/0:0H
    6 root      20   0       0      0      0 S  0.0  0.0   0:06.20 kworker/u2:0
    7 root      20   0       0      0      0 S  0.0  0.0   0:37.19 rcu_sched   
    8 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcu_bh      
    9 root      rt   0       0      0      0 S  0.0  0.0   0:00.00 migration/0 
   10 root      rt   0       0      0      0 S  0.0  0.0   0:03.08 watchdog/0  
   11 root      20   0       0      0      0 S  0.0  0.0   0:00.00 kdevtmpfs   
   12 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 netns       
   13 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 perf        
   14 root      20   0       0      0      0 S  0.0  0.0   0:00.19 khungtaskd  
   15 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 writeback   
   16 root      25   5       0      0      0 S  0.0  0.0   0:00.00 ksmd        
   17 root      39  19       0      0      0 S  0.0  0.0   0:03.02 khugepaged  
   18 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 crypto      
  • uptime
root@iZ2ze0ht45qn4m8m1wjfdrZ:~/shj_test# uptime
 10:08:23 up 10 days, 17:33,  1 user,  load average: 0.00, 0.00, 0.00
  • touch
root@iZ2ze0ht45qn4m8m1wjfdrZ:~/shj_test# ll
total 12
drwxr-xr-x 2 root root 4096 Apr  3 10:15 ./
drwx------ 9 root root 4096 Apr  3 09:58 ../
-rw-r--r-- 1 root root    0 Apr  3 10:15 test1.log
-rw-r--r-- 1 root root    0 Apr  3 10:20 test2.log
-rw-r--r-- 1 root root  121 Apr  3 10:15 urls.txt
root@iZ2ze0ht45qn4m8m1wjfdrZ:~/shj_test# touch test3.log
root@iZ2ze0ht45qn4m8m1wjfdrZ:~/shj_test# ll
total 12
drwxr-xr-x 2 root root 4096 Apr  3 10:20 ./
drwx------ 9 root root 4096 Apr  3 09:58 ../
-rw-r--r-- 1 root root    0 Apr  3 10:15 test1.log
-rw-r--r-- 1 root root    0 Apr  3 10:20 test2.log
-rw-r--r-- 1 root root    0 Apr  3 10:20 test3.log
-rw-r--r-- 1 root root  121 Apr  3 10:15 urls.txt
root@iZ2ze0ht45qn4m8m1wjfdrZ:~/shj_test# touch -r test1.log test2.log
root@iZ2ze0ht45qn4m8m1wjfdrZ:~/shj_test# ll
total 12
drwxr-xr-x 2 root root 4096 Apr  3 10:20 ./
drwx------ 9 root root 4096 Apr  3 09:58 ../
-rw-r--r-- 1 root root    0 Apr  3 10:22 test1.log
-rw-r--r-- 1 root root    0 Apr  3 10:22 test2.log
-rw-r--r-- 1 root root    0 Apr  3 10:20 test3.log
-rw-r--r-- 1 root root  121 Apr  3 10:15 urls.txt
root@iZ2ze0ht45qn4m8m1wjfdrZ:~/shj_test# touch -t 201804011023.50 test1.log
root@iZ2ze0ht45qn4m8m1wjfdrZ:~/shj_test# ll
total 12
drwxr-xr-x 2 root root 4096 Apr  3 10:20 ./
drwx------ 9 root root 4096 Apr  3 09:58 ../
-rw-r--r-- 1 root root    0 Apr  1 10:23 test1.log
-rw-r--r-- 1 root root    0 Apr  3 10:22 test2.log
-rw-r--r-- 1 root root    0 Apr  3 10:20 test3.log
-rw-r--r-- 1 root root  121 Apr  3 10:15 urls.txt
原文地址:https://www.cnblogs.com/sandysun/p/8759701.html