zoukankan      html  css  js  c++  java
  • 《鸟哥的Linux私房菜》笔记——04. 简单命令行

    键入命令

    [dmtsai@study ~]$ command  [-options]  parameter1  parameter2 ...
                         指令     選項        參數(1)     參數(2)
    

    注意:有时也可以使用 + 放置于选项或参数之前
    例如:

    zill@zill-pc:~$ date +%Y/%m/%d
    2017/10/09
    zill@zill-pc:~$ date +%H:%M
    17:32
    

    几个程序

    • 顯示日期與時間的指令: date
    • 顯示日曆的指令: cal
    • 簡單好用的計算機: bc(进入交互界面后 scale=number 设置小数点位数)

    几个按键

    • [Tab]:主要用于自动补全
    • [Ctrl]-c:中断当前程序
    • [Ctrl]-d:通常代表「键盘输入结束(End Of File, EOF 或 End Of Input)」的意思; 也可以代替 exit 的输入
    • [Shift]+{[PageUP]|[Page Down]}:向前翻页|向后翻页

    关于帮助文档

    1. man

    [dmtsai@study ~]$ LANG="en_US.utf8"
    # 還記得這個咚咚的用意吧?前面提過了,是為了『語系』的需要啊!下達過一次即可!
    
    [dmtsai@study ~]$ man date
    DATE(1)                          User Commands                         DATE(1)
    # 請注意上面這個括號內的數字
    NAME  <==這個指令的完整全名,如下所示為date且說明簡單用途為設定與顯示日期/時間
           date - print or set the system date and time
    
    SYNOPSIS  <==這個指令的基本語法如下所示
           date [OPTION]... [+FORMAT]                            <==第一種單純顯示的用法
           date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]   <==這種可以設定系統時間的用法
    
    DESCRIPTION  <==詳細說明剛剛語法談到的選項與參數的用法
           Display the current time in the given FORMAT, or set the system date.
    
           Mandatory arguments to long options are mandatory for short options too.
    
           -d, --date=STRING  <==左邊-d為短選項名稱,右邊--date為完整選項名稱
                  display time described by STRING, not 'now'
    
           -f, --file=DATEFILE
                  like --date once for each line of DATEFILE
    
           -I[TIMESPEC], --iso-8601[=TIMESPEC]
                  output  date/time  in  ISO  8601  format.   TIMESPEC='date' for date only (the
                  default), 'hours', 'minutes', 'seconds', or 'ns' for  date  and  time  to  the
                  indicated precision.
    ....(中間省略)....
           # 找到了!底下就是格式化輸出的詳細資料!
           FORMAT controls the output.  Interpreted sequences are:
    
           %%     a literal %
    
           %a     locale's abbreviated weekday name (e.g., Sun)
    
           %A     locale's full weekday name (e.g., Sunday)
    ....(中間省略)....
    ENVIRONMENT  <==與這個指令相關的環境參數有如下的說明
           TZ     Specifies the timezone, unless overridden by command line parameters.  
                  If neither is specified, the setting from /etc/localtime is used.
    
    EXAMPLES     <==一堆可用的範本
           Convert seconds since the epoch (1970-01-01 UTC) to a date
    
                  $ date --date='@2147483647'
    ....(中間省略)....
    
    DATE STRING  <==上面曾提到的 --date 的格式說明!
           The --date=STRING is a mostly free format human readable date string such as "Sun, 29
           Feb 2004 16:21:42 -0800" or "2004-02-29 16:21:42" or even "next  Thursday".   A  date
           string  may  contain  items  indicating calendar date, time of day, time zone, day of
    
    AUTHOR  <==這個指令的作者啦!
           Written by David MacKenzie.
    
    COPYRIGHT  <==受到著作權法的保護!用的就是 GPL 了!
           Copyright © 2013 Free Software Foundation, Inc.  License GPLv3+: GNU GPL version 3 or
           later <http://gnu.org/licenses/gpl.html>.
           This  is free software: you are free to change and redistribute it.  There is NO WAR‐
           RANTY, to the extent permitted by law.
    
    SEE ALSO  <==這個重要,你還可以從哪裡查到與date相關的說明文件之意
           The full documentation for date is maintained as a Texinfo manual.  If the  info  and
           date programs are properly installed at your site, the command
    
                  info coreutils 'date invocation'
    
           should give you access to the complete manual.
    
    GNU coreutils 8.22                        June 2014                                  DATE(1)
    

    表格的第一行,可以看到「DATE(1)」,其中(1)代表「一般使用者可以使用的指令」。常见代号及含义(可以通过 man man 获得更详细的说明):

    代號 代表內容
    1 使用者在shell環境中可以操作的指令或可執行檔
    2 系統核心可呼叫的函數與工具等
    3 一些常用的函數(function)與函式庫(library),大部分為C的函式庫(libc)
    4 裝置檔案的說明,通常在/dev下的檔案
    5 設定檔或者是某些檔案的格式
    6 遊戲(games)
    7 慣例與協定等,例如Linux檔案系統、網路協定、ASCII code等等的說明
    8 系統管理員可用的管理指令
    9 跟kernel有關的文件

    可以使用 man -f 指令 查找相关指令(名称完全相同)。
    可以使用 man -k 指令 搜索相关指令。

    2. info page

    Linux 里额外提供的一种线上求助的方法,和 man 的用途差不多,但与man page输出全部信息不同,info page阅读起来更友好。

    3. /usr/share/doc

    关于关机

    如果要看目前有誰在線上,可以下達『who』這個指令,而如果要看網路的連線狀態,可以下達 『 netstat -a 』這個指令,而要看背景執行的程序可以執行『 ps -aux 』這個指令。

    • 將資料同步寫入硬碟中的指令: sync(目前的 shutdown/reboot/halt 等等指令均已在关机前对 sync 进行了调用)
    • 慣用的關機指令: shutdown
    • 重新開機,關機: reboot, halt, poweroff

    还可以使用管理工具 systemctl 关机

    [root@study ~]# systemctl [指令]
    指令項目包括如下:
    halt       進入系統停止的模式,螢幕可能會保留一些訊息,這與你的電源管理模式有關
    poweroff   進入系統關機模式,直接關機沒有提供電力喔!
    reboot     直接重新開機
    suspend    進入休眠模式
    
  • 相关阅读:
    Kinect关于PlayerIndex和SkeletonId之间的关系。
    记一次“应用程序之间的通信”过程(1/2)
    C# p-Inovke C++动态链接库
    我写了本破书-swift语言实战晋级
    swift语言实战晋级-第9章 游戏实战-跑酷熊猫-9-10 移除平台与视差滚动
    swift语言实战晋级-第9章 游戏实战-跑酷熊猫-7-8 移动平台的算法
    Swift语言实战晋级-第9章 游戏实战-跑酷熊猫-5-6 踩踏平台是怎么炼成的
    Swift语言实战晋级-第9章 游戏实战-跑酷熊猫-4 熊猫的跳和打滚
    Swift语言实战晋级-第9章 游戏实战-跑酷熊猫-3 显示一个动态的熊猫
    Swift语言实战晋级-第9章 游戏实战-跑酷熊猫-2 创建熊猫类
  • 原文地址:https://www.cnblogs.com/hiwangzi/p/7642371.html
Copyright © 2011-2022 走看看