Ubuntu操作系统学习笔记之五(Ubuntu常用指令)

待我称王封你为后i 2023-10-16 19:49 62阅读 0赞

CenterCenter 1

日期时间

date

说明: 查看/设置 当前系统时间
格式: date [OPTION]… [+FORMAT]
格式化显示: +%Y-%m-%d

Center 2

hwclock/clock
说明: 显示硬件时钟时间. 即OS有个时间 硬件上也有个时间
例子
Center 3

cal
说明: calendar, 查看日历
Center 4

uptime
说明: 查看系统运行时间及负载
例子
Center

输出 查看

echo

说明: 显示输入的内容
Center 5
cat
说明: 显示文件内容, 一次性全部显示

head
说明: 显示头几行, 缺省10行
格式: head [OPTION]… [FILE]…
-n : 指定显示的行数

tail

说明: 显示末尾几行,缺省10行
-n : 指定显示的行数
-f : 追踪显示文件更新.即一致阻塞住, 文件一旦被追加内容 则里面显示出来
补充: -f 一般用户查看日志

more

说明:向下翻, 空格 为往下翻页, 回车为往下翻行, 退出请按q

less

说明: 上下方向键翻行, PageUp PageDown 翻页
Center 6

提示:按q 表示退出。

查看硬件信息

lspci

说明: 查看PCI设备
-v : 详细信息, verbose

  1. [wuqinfei@wuqinfei ~]$ lspci
  2. 00:00.0 Host bridge: Intel Corporation 440FX - 82441FX PMC [Natoma] (rev 02)
  3. 00:01.0 ISA bridge: Intel Corporation 82371SB PIIX3 ISA [Natoma/Triton II]
  4. 00:01.1 IDE interface: Intel Corporation 82371AB/EB/MB PIIX4 IDE (rev 01)
  5. 00:02.0 VGA compatible controller: InnoTek Systemberatung GmbH VirtualBox Graphics Adapter
  6. 00:03.0 Ethernet controller: Intel Corporation 82540EM Gigabit Ethernet Controller (rev 02)
  7. 00:04.0 System peripheral: InnoTek Systemberatung GmbH VirtualBox Guest Service
  8. 00:05.0 Multimedia audio controller: Intel Corporation 82801AA AC'97 Audio Controller (rev 01)
  9. 00:07.0 Bridge: Intel Corporation 82371AB/EB/MB PIIX4 ACPI (rev 08)
  10. 00:0d.0 SATA controller: Intel Corporation 82801HM/HEM (ICH8M/ICH8M-E) SATA Controller [AHCI mode] (rev 02)

lsusb
说明: 查看USB设备

lsmod

说明: 查看加载的模块(驱动)

关机 重启

shutdown

说明: 关闭 或 重启 计算机
格式: shutdown [OPTION]… TIME [MESSAGE]
-h : 关机
-r : 重启
例子
shutdown -h now 立即关机
shutdown -h +10 10分钟后关机
shutdown -h 23:30 23:30 时 关机

shutdown -r now 立即重启

poweroff

说明: 立即关闭计算机

reboot

说明: 立即重启计算机

归档 压缩

zip

说明: 使用zip算法 将 文件及目录 压缩进一个文件.

unzip

说明: 解压缩
[wuqinfei@wuqinfei MyDir]$ ls
backup_etc.zip

[wuqinfei@wuqinfei MyDir]$ upzip backup_etc.zip
[wuqinfei@wuqinfei MyDir]$ ls -l
total 356
-rw-rw-r—. 1 wuqinfei wuqinfei 348457 Jan 14 21:51 backup_etc.zip
drwxrwxr-x. 123 wuqinfei wuqinfei 12288 Jan 14 21:52 etc

gzip

说明: 使用gzip压缩

tar

说明: 归档 打包, 非压缩. 即将 文档及目录 整合成一个文件
示例
打包: -c —create
tar -cfv out.tar /etc 将 /etc 整个打包到 ./out.tar
解包: -x —extract
tar -xvf out.tar etc 将out.tar 解包到 ./etc
先打包后gzip压缩: -z —gzip
tar -cvzf out.tar.gz /etc

查找

locate

说明: locate keyword
快速在数据库中查找 文件及目录, 简单查找
格式: locate [OPTION]… [PATTERN]…
注意: 此命令需要预先建立数据库(将所有文件建立索引), 数据库默认每天更新一次; updatedb命令可手动更新数据库 (非常慢)

  1. [wuqinfei@wuqinfei MyDir]$ locate .cnf
  2. /etc/my.cnf
  3. /etc/pki/tls/openssl.cnf
  4. /usr/share/doc/kpathsea-2007/kpathsea_defaults/texmf-kpathsea-defaults.cnf
  5. [wuqinfei@wuqinfei MyDir]$ touch ak48.txt
  6. [wuqinfei@wuqinfei MyDir]$ locate ak48.txt
  7. [wuqinfei@wuqinfei MyDir]$ updatedb
  8. updatedb: can not open a temporary file for `/var/lib/mlocate/mlocate.db'
  9. [wuqinfei@wuqinfei MyDir]$ su -
  10. Password:
  11. [root@wuqinfei ~]# updatedb
  12. [root@wuqinfei ~]# su wuqinfei
  13. [wuqinfei@wuqinfei root]$ locate ak48.txt
  14. /home/wuqinfei/MyDir/ak48.txt
  15. find
  16. 说明: 高级查找, 支持很多查找条件
  17. find 查找位置 查找参数
  18. 查找条件
  19. -name 名称
  20. -perm permission
  21. -user
  22. -group
  23. -ctime create time
  24. -type 文件类型
  25. -size
  26. 举例
  27. find . -name *wuqin*
  28. find / -name *.conf
  29. find / -perm 777
  30. find / -type d
  31. find / -name "wuqin*" -exec ls -l {} \ ;
  32. 将 find / -name "wuqin*" 的结果做为参数
  33. 传递给 "-exec" 与 " {} \ ;"之间的命令执行



发表评论

表情:
评论列表 (有 0 条评论,62人围观)

还没有评论,来说两句吧...

相关阅读