博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Linux常用命令
阅读量:6943 次
发布时间:2019-06-27

本文共 4258 字,大约阅读时间需要 14 分钟。

1.日期和时间

  • date,查看和设置系统的日期和时间
    • [root@ipedo home]# dateWed Dec  6 17:22:44 CST 2017
  • date -u,来查看UTC时间(格林威治时间)
    • [root@ipedo home]# date -uWed 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  910 11 12 13 14 15 1617 18 19 20 21 22 2324 25 26 27 28 29 3031
  • 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 hellohello
    • [root@ipedo home]# echo 11 > 1.txt[root@ipedo home]# cat 1.txt11
    • [root@ipedo home]# echo 22 >> 1.txt[root@ipedo home]# cat 1.txt1122
  • cat:来显示文件的内容,它直接显示所有的文件内容,很不人性化
    • [root@ipedo home]# cat -n 1.txt     1  11     2  22
  • more:用于翻页显示内容,但是只能向下翻页,不能向上翻页
  • less:可以上下来回翻页
  • head:显示文件的头几行(默认10行) -n 来指定显示开头的n行
    • [root@ipedo home]# cat 2.txt1234567891011
    • [root@ipedo home]# cat 2.txt |head12345678910
    • [root@ipedo home]# cat 2.txt |head -111234567891011
    • [root@ipedo home]# cat 2.txt |tail234567891011
    • [root@ipedo home]# cat 2.txt |tail -111234567891011
  • -f:来追踪文件的更新,一般用于查看日志,持续显示新加入的内容

3.查看硬件信息

  • lspci:用于查看PCI设备
  • lsusb:查看USB设备
  • lsmod:查看当前加载的所有模块(模块即weindows中相当于驱动)
    • [root@ipedo home]# lsmodModule                  Size  Used byip6table_filter         2245  0 ip6_tables             10301  1 ip6table_filteriptable_filter          2173  0 ip_tables               9567  1 iptable_filteripv6                  270489  18 ppdev                   7297  0 parport_pc             19054  0 parport                29925  2 ppdev,parport_pce1000                 141447  0 vmware_balloon          5811  0 sg                     24006  0 i2c_piix4              10452  0 i2c_core               24608  1 i2c_piix4ext4                  339620  2 jbd2                   76054  1 ext4mbcache                 6017  1 ext4sd_mod                 33217  3 crc_t10dif               932  1 sd_modsr_mod                 13154  0 cdrom                  33416  1 sr_modmptspi                 14375  2 mptscsih               31330  1 mptspimptbase                86744  2 mptspi,mptscsihscsi_transport_spi     19726  1 mptspipata_acpi               2513  0 ata_generic             2805  0 ata_piix               20637  0 dm_mirror              11969  0 dm_region_hash          9644  1 dm_mirrordm_log                  8322  2 dm_mirror,dm_region_hashdm_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]# ls1.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]# ls1.txt  1.zip  2.txt
  • unzip xxx.zip 是解压文件
    • [root@ipedo 1]# ls1.zip[root@ipedo 1]# unzip 1.zipArchive:  1.zip extracting: 1.txt                    extracting: 2.txt                   [root@ipedo 1]# ls1.txt  1.zip  2.txt
  • gzip:也是一种压缩方式
    • [root@ipedo 1]# ls1.txt  1.zip  2.txt[root@ipedo 1]# gzip 1.txt 2.txt[root@ipedo 1]# ls1.txt.gz  1.zip  2.txt.gz
  • gunzip:解压缩
    • [root@ipedo 1]# ls1.txt.gz  1.zip  2.txt.gz[root@ipedo 1]# gunzip 1.txt.gz [root@ipedo 1]# ls1.txt  1.zip  2.txt.gz
  • tar:一个归档命令,就是把许多文件打包成一个文件
    • [root@ipedo 1]# ls1.txt  1.zip  2.txt[root@ipedo 1]# ls1.txt  1.zip  2.txt[root@ipedo 1]# tar -cvf a.tar 1.txt 2.txt1.txt2.txt[root@ipedo 1]# ls1.txt  1.zip  2.txt  a.tar
  • tar -cvf 压缩,tar - xvf解压
    • [root@ipedo 1]# ls1.txt  1.zip  2.txt  a.tar[root@ipedo 1]# tar -xvf a.tar1.txt2.txt[root@ipedo 1]# ls1.txt  1.zip  2.txt  a.tar
  • tar -cvzf:在cvf命令下多了个z命令,急速归档并压缩一个文件,这里调用的是gzip命令 格式 tar -cvzf xxx.tar.gz
    • [root@ipedo 1]# ls1.txt  1.zip  2.txt  a.tar[root@ipedo 1]# tar -cvzf b.tar.gz 1.txt 2.txt1.txt2.txt[root@ipedo 1]# ls1.txt  1.zip  2.txt  a.tar  b.tar.gz
  • tar -xvzf:解压缩
    • [root@ipedo 1]# ls1.txt  1.zip  2.txt  a.tar  b.tar.gz[root@ipedo 1]# rm -f 1.txt 2.txt [root@ipedo 1]# ls1.zip  a.tar  b.tar.gz[root@ipedo 1]# tar -xvzf b.tar.gz1.txt2.txt[root@ipedo 1]# ls1.txt  1.zip  2.txt  a.tar  b.tar.gz

6.查找命令(未完)

  •  文件夹查找命令,这句话表示查找“1.txt”文件,然后传送给“ls -l”这个命令去执行,显示详细信息
    • [root@ipedo 1]# ls1.txt[root@ipedo 1]# find -name "1.txt" -exec ls -l {} \;-rw-r--r-- 1 root root 2 Dec  6 19:01 ./1.txt

转载于:https://www.cnblogs.com/fangpengchengbupter/p/7993885.html

你可能感兴趣的文章
mySQL优化, my.ini 配置说明
查看>>
函数、返回-Sql Server常用函数之统计、算数、字符串函数-by小雨
查看>>
windows调试器之Visual C++
查看>>
如何删除存在多个重复记录中的一个
查看>>
Android开发之旅:环境搭建及HelloWorld
查看>>
请求浏览器使用chrome查看http请求
查看>>
数据数据包JAVASE----17----网络编程
查看>>
OC基础知识
查看>>
matlab之并行
查看>>
泛型类型通常在Dao和Service 中使用BaseDao<T extends Serializable>的泛型
查看>>
关于java的JIT知识
查看>>
设备编程[置顶] Linux 设备编程
查看>>
冒泡、选择、插入排序
查看>>
SQL简单的日报和月报
查看>>
listView 分页加载数据
查看>>
【体系结构】转移预测器性能的定量评价
查看>>
[置顶] 浅谈软件质量管理
查看>>
Storm-源码分析-Topology Submit-Task
查看>>
POJ 2632 Crashing Robots (坑爹的模拟题)
查看>>
[转载]ubuntu发热问题解决
查看>>