歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux技術 >> linux基礎之常用命令(2)

linux基礎之常用命令(2)

日期:2017/3/3 13:57:31   编辑:Linux技術

date

顯示當前系統時間

clock或者hwclock

顯示當前硬件時鐘

hwclock -w :將系統時間同步到硬件時間

hwclock -s :將硬件時間讀取到系統時間

獲得命令的使用幫助

內部命令:

help < command >

外部命令:

< command > - -help:獲取命令的簡單幫助

命令手冊

man < command > 幾乎所有的命令都可以用man查看詳細幫助

[code][root@iZ28g26851kZ ~]# man ls

LS(1)                            User Commands                           LS(1)

NAME
       ls - list directory contents

SYNOPSIS
       ls [OPTION]... [FILE]...

DESCRIPTION
       List  information  about  the FILEs (the current directory by default).  Sort
       entries alphabetically if none of -cftuvSUX nor --sort.

       Mandatory arguments to long options are mandatory for short options too.

       -a, --all
              do not ignore entries starting with .

       -A, --almost-all
              do not list implied . and ..

       --author
              with -l, print the author of each file

       -b, --escape
              print octal escapes for nongraphic characters
注意看第一行

[code]LS(1)                            User Commands                           LS(1)
ls(1)中的(1)代表“章節”,

1:用戶命令 (/bin, /user/bin, /user/local/bin)

2:系統命令

3:庫用戶

4:特殊文件(設備文件)

5:文件格式(配置文件的語法)

6:游戲

7:雜項(Miscellaneous)

8:管理命令(/sbin, /user/sbin, /user/local/sbin)通常只有管理員才能使用

whatis < command >

顯示命令的摘要信息以及出現在哪些章節中
[code][root@iZ28g26851kZ ~]# whatis read
read                 (1p)  - read a line from standard input
read                 (2)  - read from a file descriptor
read                 (3p)  - read from a file
read [builtins]      (1)  - bash built-in commands, see bash(1)

<>:必選

[]:可選

…可以出現多次

|:多選一

{}:分組

man:

[code]    NAME:命令名稱及功能簡要說明
    SYNOPSIS:用法說明,包括可用的選項
    DESCRIPTION:命令功能的詳盡說明,可能包括每一個選項的意義
    OPTIONS:說明每一個選項的意義
    FILES:此命令相關的配置文件
    BUGS:
    EXAMPLES:使用示例
    SEE ALSO:另外參照
翻屏:

[code]    向後翻一屏:space
    向前翻一屏:b
    向後翻一行:enter
    向前翻一行:k
查找:

[code]    /keyword:向後
    ?keyword:向前
    搜索完之後
    n:定位向後一個結果
    N:定位向前一個結果

mkdir

創建目錄空間

-p

當上級目錄不存在時自動創建。 例:mkdir /opt/x/y

如果不加參數p,創建會失敗,因為x文件不存在,這時加上-p就會自動創建x文件

[code][root@iZ28g26851kZ ~]# mkdir /opt/x/y
mkdir: cannot create directory `/opt/x/y': No such file or directory
[root@iZ28g26851kZ ~]# mkdir -p /opt/x/y
[root@iZ28g26851kZ ~]#

-v(verbose)

顯示創建過程

[code][root@iZ28g26851kZ opt]# mkdir -vp x/y/z
mkdir: created directory `x'
mkdir: created directory `x/y'
mkdir: created directory `x/y/z'
[root@iZ28g26851kZ opt]#

使用{}

mkdir -p x/y x/z 等同於 mkdir -p x/{y,z}

tree

查看目錄樹結構
[code][root@iZ28g26851kZ opt]# tree x
x
├── y
│   └── k
└── z

3 directories, 0 files
[root@iZ28g26851kZ opt]#

rmdir(remove directory)

刪除空目錄,空目錄,空目錄,否則會提示目錄不是空的
[code][root@iZ28g26851kZ opt]# rmdir x
rmdir: failed to remove `x': Directory not empty
[root@iZ28g26851kZ opt]#

-p

使用-p參數:當子目錄被刪除之後如果父目錄為空,則也會被刪除

touch

修改文件的時間戳,默認情況下,當文件不存在的時候,會創建該文件

stat

查看文件的狀態(文件名,訪問時間,修改時間,改變時間) 修改時間:指的是內容被修改,

[code][root@iZ28g26851kZ x]# stat test 
  File: `test'
  Size: 9           Blocks: 8          IO Block: 4096   regular file
Device: ca01h/51713d    Inode: 1066408     Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2016-05-04 10:55:47.016036253 +0800
Modify: 2016-05-04 10:55:47.016036253 +0800
Change: 2016-05-04 10:55:47.016036253 +0800

rm

刪除文件

默認刪除文件會提示用戶是否刪除,也就是加了 -i的效果

-f

強制刪除,不進行提示,直接刪除文件

-r

刪除目錄並遞歸刪除目錄下的所有文件

Copyright © Linux教程網 All Rights Reserved