zoukankan      html  css  js  c++  java
  • Linux常用命令

    1.日期和时间

    • date,查看和设置系统的日期和时间
      • [root@ipedo home]# date
        Wed Dec  6 17:22:44 CST 2017
    • date -u,来查看UTC时间(格林威治时间)
      • [root@ipedo home]# date -u
        Wed Dec  6 09:22:48 UTC 2017
    • date -s,设置时间,需要切换到root用户才能进行权限更改
    • cal 来打印日历
      • [root@ipedo home]# cal
            December 2017   
        Su Mo Tu We Th Fr Sa
                        1  2
         3  4  5  6  7  8  9
        10 11 12 13 14 15 16
        17 18 19 20 21 22 23
        24 25 26 27 28 29 30
        31
    • uptime,用来查看系统运行了多久,系统的用户,系统的负载
      • [root@ipedo home]# uptime
         17:28:30 up  4:16,  1 user,  load average: 0.04, 0.03, 0.00

    2.输出,查看命令

    • echo:显示输入的内容
      • [root@ipedo home]# echo hello
        hello
      • [root@ipedo home]# echo 11 > 1.txt
        [root@ipedo home]# cat 1.txt
        11
      • [root@ipedo home]# echo 22 >> 1.txt
        [root@ipedo home]# cat 1.txt
        11
        22
    • cat:来显示文件的内容,它直接显示所有的文件内容,很不人性化
      • [root@ipedo home]# cat -n 1.txt
             1  11
             2  22
    • more:用于翻页显示内容,但是只能向下翻页,不能向上翻页
    • less:可以上下来回翻页
    • head:显示文件的头几行(默认10行) -n 来指定显示开头的n行
      • [root@ipedo home]# cat 2.txt
        1
        2
        3
        4
        5
        6
        7
        8
        9
        10
        11
      • [root@ipedo home]# cat 2.txt |head
        1
        2
        3
        4
        5
        6
        7
        8
        9
        10
      • [root@ipedo home]# cat 2.txt |head -11
        1
        2
        3
        4
        5
        6
        7
        8
        9
        10
        11
      • [root@ipedo home]# cat 2.txt |tail
        2
        3
        4
        5
        6
        7
        8
        9
        10
        11
      • [root@ipedo home]# cat 2.txt |tail -11
        1
        2
        3
        4
        5
        6
        7
        8
        9
        10
        11
    • -f:来追踪文件的更新,一般用于查看日志,持续显示新加入的内容

    3.查看硬件信息

    • lspci:用于查看PCI设备
    • lsusb:查看USB设备
    • lsmod:查看当前加载的所有模块(模块即weindows中相当于驱动)
      • [root@ipedo home]# lsmod
        Module                  Size  Used by
        ip6table_filter         2245  0 
        ip6_tables             10301  1 ip6table_filter
        iptable_filter          2173  0 
        ip_tables               9567  1 iptable_filter
        ipv6                  270489  18 
        ppdev                   7297  0 
        parport_pc             19054  0 
        parport                29925  2 ppdev,parport_pc
        e1000                 141447  0 
        vmware_balloon          5811  0 
        sg                     24006  0 
        i2c_piix4              10452  0 
        i2c_core               24608  1 i2c_piix4
        ext4                  339620  2 
        jbd2                   76054  1 ext4
        mbcache                 6017  1 ext4
        sd_mod                 33217  3 
        crc_t10dif               932  1 sd_mod
        sr_mod                 13154  0 
        cdrom                  33416  1 sr_mod
        mptspi                 14375  2 
        mptscsih               31330  1 mptspi
        mptbase                86744  2 mptspi,mptscsih
        scsi_transport_spi     19726  1 mptspi
        pata_acpi               2513  0 
        ata_generic             2805  0 
        ata_piix               20637  0 
        dm_mirror              11969  0 
        dm_region_hash          9644  1 dm_mirror
        dm_log                  8322  2 dm_mirror,dm_region_hash
        dm_mod                 81640  8 dm_mirror,dm_log

    4.关机重启

    • 格式:shutdown [关机/重启] 时间
    • 立即关机:shutdown -h now
    • 立即重启:shutdown -r now
    • 过10分钟关机:shutdown -h 10
    • 过10分钟重启:shutdown -r 10
    • halt:立即关机,reboot:重启

    5.归档压缩

    • zip用于压缩:zip xxx.zip file (把file这个源文件压缩成xxx.zip)
      • [root@ipedo 1]# ls
        1.txt  2.txt
        [root@ipedo 1]# zip 1.zip 1.txt 2.txt
          adding: 1.txt (stored 0%)
          adding: 2.txt (stored 0%)
        [root@ipedo 1]# ls
        1.txt  1.zip  2.txt
    • unzip xxx.zip 是解压文件
      • [root@ipedo 1]# ls
        1.zip
        [root@ipedo 1]# unzip 1.zip
        Archive:  1.zip
         extracting: 1.txt                   
         extracting: 2.txt                   
        [root@ipedo 1]# ls
        1.txt  1.zip  2.txt
    • gzip:也是一种压缩方式
      • [root@ipedo 1]# ls
        1.txt  1.zip  2.txt
        [root@ipedo 1]# gzip 1.txt 2.txt
        [root@ipedo 1]# ls
        1.txt.gz  1.zip  2.txt.gz
    • gunzip:解压缩
      • [root@ipedo 1]# ls
        1.txt.gz  1.zip  2.txt.gz
        [root@ipedo 1]# gunzip 1.txt.gz 
        [root@ipedo 1]# ls
        1.txt  1.zip  2.txt.gz
    • tar:一个归档命令,就是把许多文件打包成一个文件
      • [root@ipedo 1]# ls
        1.txt  1.zip  2.txt
        [root@ipedo 1]# ls
        1.txt  1.zip  2.txt
        [root@ipedo 1]# tar -cvf a.tar 1.txt 2.txt
        1.txt
        2.txt
        [root@ipedo 1]# ls
        1.txt  1.zip  2.txt  a.tar
    • tar -cvf 压缩,tar - xvf解压
      • [root@ipedo 1]# ls
        1.txt  1.zip  2.txt  a.tar
        [root@ipedo 1]# tar -xvf a.tar
        1.txt
        2.txt
        [root@ipedo 1]# ls
        1.txt  1.zip  2.txt  a.tar
    • tar -cvzf:在cvf命令下多了个z命令,急速归档并压缩一个文件,这里调用的是gzip命令 格式 tar -cvzf xxx.tar.gz
      • [root@ipedo 1]# ls
        1.txt  1.zip  2.txt  a.tar
        [root@ipedo 1]# tar -cvzf b.tar.gz 1.txt 2.txt
        1.txt
        2.txt
        [root@ipedo 1]# ls
        1.txt  1.zip  2.txt  a.tar  b.tar.gz
    • tar -xvzf:解压缩
      • [root@ipedo 1]# ls
        1.txt  1.zip  2.txt  a.tar  b.tar.gz
        [root@ipedo 1]# rm -f 1.txt 2.txt 
        [root@ipedo 1]# ls
        1.zip  a.tar  b.tar.gz
        [root@ipedo 1]# tar -xvzf b.tar.gz
        1.txt
        2.txt
        [root@ipedo 1]# ls
        1.txt  1.zip  2.txt  a.tar  b.tar.gz

    6.查找命令(未完)

    •  文件夹查找命令,这句话表示查找“1.txt”文件,然后传送给“ls -l”这个命令去执行,显示详细信息
      • [root@ipedo 1]# ls
        1.txt
        [root@ipedo 1]# find -name "1.txt" -exec ls -l {} ;
        -rw-r--r-- 1 root root 2 Dec  6 19:01 ./1.txt
  • 相关阅读:
    requestAnimationFrame
    js来监控复制粘贴
    nodejs事件循环
    前端路由
    js基础查漏补缺(更新)
    http & https & http2.0
    进度条方案
    移动端适配方案
    性能优化之节流、防抖
    altium designer 里如何设置PCB默认字符默认大小(PCB丝印)
  • 原文地址:https://www.cnblogs.com/fangpengchengbupter/p/7993885.html
Copyright © 2011-2022 走看看