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

来源:互联网 发布:sql2005新建数据库 编辑:程序博客网 时间:2024/05/14 20:30


日期时间


    date


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

     

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

 cal
        说明: calendar, 查看日历

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

输出 查看


    echo


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

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

    tail


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

    more


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

    less


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

提示:按q 表示退出。

 

查看硬件信息


    lspci


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


     [wuqinfei@wuqinfei ~]$ lspci         00:00.0 Host bridge: Intel Corporation 440FX - 82441FX PMC [Natoma] (rev 02)         00:01.0 ISA bridge: Intel Corporation 82371SB PIIX3 ISA [Natoma/Triton II]         00:01.1 IDE interface: Intel Corporation 82371AB/EB/MB PIIX4 IDE (rev 01)         00:02.0 VGA compatible controller: InnoTek Systemberatung GmbH VirtualBox Graphics Adapter         00:03.0 Ethernet controller: Intel Corporation 82540EM Gigabit Ethernet Controller (rev 02)         00:04.0 System peripheral: InnoTek Systemberatung GmbH VirtualBox Guest Service         00:05.0 Multimedia audio controller: Intel Corporation 82801AA AC'97 Audio Controller (rev 01)         00:07.0 Bridge: Intel Corporation 82371AB/EB/MB PIIX4 ACPI (rev 08)         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命令可手动更新数据库 (非常慢)

 [wuqinfei@wuqinfei MyDir]$ locate .cnf         /etc/my.cnf         /etc/pki/tls/openssl.cnf         /usr/share/doc/kpathsea-2007/kpathsea_defaults/texmf-kpathsea-defaults.cnf         [wuqinfei@wuqinfei MyDir]$ touch ak48.txt         [wuqinfei@wuqinfei MyDir]$ locate ak48.txt         [wuqinfei@wuqinfei MyDir]$ updatedb         updatedb: can not open a temporary file for `/var/lib/mlocate/mlocate.db'         [wuqinfei@wuqinfei MyDir]$ su -         Password:         [root@wuqinfei ~]# updatedb         [root@wuqinfei ~]# su wuqinfei         [wuqinfei@wuqinfei root]$ locate ak48.txt         /home/wuqinfei/MyDir/ak48.txt

  find         说明: 高级查找, 支持很多查找条件              find  查找位置  查找参数        查找条件            -name       名称            -perm       permission             -user             -group             -ctime      create time             -type       文件类型            -size         举例            find . -name *wuqin*             find / -name *.conf             find / -perm 777             find / -type d             find / -name "wuqin*" -exec ls -l   {}   \ ;                 将 find / -name "wuqin*" 的结果做为参数                传递给 "-exec" 与 " {} \ ;"之间的命令执行






0 0