馬哥教育網絡班19期第一周課程練習

1、描述計算機的組成及其功能。

從大體上計算機是由cpu、內存、主板、I/O設備、存儲設備組成
cpu的功能就好像人的大腦,控制身體的。嚴格意義上是用來解釋計算機指令以及處理軟件中的數據的。
內存的功能就好像人的大腦記憶區、來存放眼睛看到的世界。嚴格意義上是用于暫時存放cpu中的運算數據,以及與硬盤等外部存儲器交換的數據
主板的功能就好像人的身體,來鏈接身體的部件,如大腦。嚴格意義上就是提供一系列結合點,供cpu,內存,IO設備,存儲設備鏈接
I/O設備的功能就好像人的眼睛、嘴巴等等。輸入輸出的。嚴格意義上就是通過鍵盤,鼠標等設備向計算機設備輸入,通過顯示器輸出。
存儲設備的功能就好像外部的世界,存儲著各種各樣的數據。嚴格意義上就是存儲數據的硬件,可以通輸入設備改變數據,通過顯示器顯示。

2、按系列羅列Linux的發行版,并描述不同發行版之間的聯系與區別。

  Redhat
       Rhel
       Centos
       Fedora core
 Debian 
        Ubuntu
              mint
 Slackware
         suse
              opensuse
 archLinux
 gentoo 
 聯系:不同的發行版之間都是采用對Linux內核進行的研發
 區別:不同的發型版之間都有不同的風格,程序包管理方式不同。維護方式也是不同的。
一類是商業公司維護的發行版本,一類是社區組織維護的發行版本,
 前者以著名的Redhat(RHEL)為代表,后者以Debian為代表

3、描述Linux的哲學思想,并按照自己的理解對其進行解釋性描述。

  Linux的哲學思想
   1.一切都是文件
       Linux把幾乎所有文件都改成文件形式,硬件也一樣
   2.由眾多目的單一的進程組成,每個進程實現一個功能。
     一個程序由一個或多個進程組成來完成復雜任務
   3.避免跟用戶交互
        來實現自動化的功能
   4.使用純文本文檔來編寫配置文件
        直接能用一款編輯器就能實現修改配置文件

4、說明Linux系統上命令的使用格式;
詳細介紹ifconfig、echo、tty、startx、export、pwd、history、shutdown、poweroff、reboot、hwclock、date命令的使用,并配合相應的示例來闡述。**
(1)ifconfig命令使用格式:

   ifconfig interface [aftype] options | address ...

ifconfig命令是用來顯示和配置網絡接口的

    ifconfig - configure a network interface

ifconfig是用來配置內核的網絡接口,必要是可以用他來設置接口,一般用在調試和系統優化。

     Ifconfig is used to configure the kernel-resident network interfaces.  It is used at boot time to set up interfaces as
   necessary.  After that, it is usually only needed when debugging or when system tuning is needed.

如果ifconfig命令沒給arguments,會顯示當前活動的接口狀態,如果只給了一個接口的參數,
那它就只會顯示那一個接口的狀態,如果只給一個-a的參數。它就會顯示所有接口的狀態,即使沒有的開啟的接口也會顯示。
它可以用來配置一個接口。

   If no arguments are given, ifconfig displays the status of the currently active interfaces.   If  a  single  interface
   argument  is  given, it displays the status of the given interface only; if a single -a argument is given, it displays
   the status of all interfaces, even those that are down.  Otherwise, it configures an interface.

實例
ifconfig eth0 ip=192.168.1.13 netmask 255.255.255.0
這樣設置不是永久保存的??梢杂胹ync命令
(2)echo命令使用格式

  echo [SHORT-OPTION]... [STRING]...

echo命令是用來顯示一行的文本的

  echo - display a line of text 
         顯示一行的文本
   Echo the STRING(s) to standard output.
    向標準輸出的字符串
   -n     do not output the trailing newline
           輸出不換行
   -e     enable interpretation of backslash escapes
           反斜線的合理解釋
   -E     disable interpretation of backslash escapes (default)
              關閉反斜線的合理解釋
    If -e is in effect, the following sequences are recognized:
      使用-e了,那就解釋為以下字符
   \\     backslash
           \\為反斜線    
   \a     alert (BEL)
           \a為警告聲
   \b     backspace
          \b為退格鍵
   \c     produce no further output
           最后不輸出換行符       
   \f     form feed
            換頁
   \n     new  line
          換行光標至行首
   \r     carriage return
         光標移至行首,但不換行
   \t     horizontal tab
           插入 tab表格跳位鍵
   \v     vertical tab
            縱向制表
   \0NNN  byte with octal value NNN (1 to 3 digits)
            插入八進制的ASCII字符
   \xHH   byte with hexadecimal value HH (1 to 2digits)
              插入十六進制的ASCII字符
   NOTE:  your shell may have its own version of echo, which usually supersedes the version described here.  Please refer
   to your shell’s documentation for details about the options it supports.
      你的shell可能已經用echo的版本。查看描述的版本信息會有更加完整的信息

實例:
echo $?
會顯示上一個命令的成功還是失敗0:表示成功 1-255表示失敗
echo “hello there”會直接顯示hello there
echo -e “23\b24\n\ao\tds\b”
2\24
o ds 為什么后面的s會還在呢,因為它\b后面根本沒有字符,沒執行

(3)tty

tty的使用格式

 tty [OPTION]...

tty – print the file name of the terminal connected to standard input

 顯示連接到標準輸入的終端

   -s, --silent, --quiet
          print nothing, only return an exit status
   使用靜默模式,不輸出任何信息
   --help display this help and exit
      幫助
   --version
          output version information and exit
           顯示著個版本信息

實例:
直接使用tty

 [root@king-liu ~]# tty
  /dev/pts/0也就是模擬終端
/dev/tty也就是虛擬終端
 /dev/console也就是物理終端

(4)startx
startx的使用格式

 startx [ [ client ] options ... ] [ -- [ server ] [ display ] options ... ]

startx – initialize an X session
初始化X回話,也就打開圖形化界面

   The  startx  script is a front end to xinit that provides a somewhat nicer user interface for running a single session
   of the X Window System.  It is often run with no arguments.
    startx腳本是xinit,運行X窗口系統的單個會話提供了一個良好的用戶界面的前端。
   Arguments immediately following the startx command are used to start a client in the same  manner  as  xinit(1).  
    在爭論之時,先使用startx命令打開一個 xinit。
   The special  argument ’--’ marks the end of client arguments and the beginning of server options.  
   -表示客戶端的結束和著服務器的選擇
    It may be convenient to specify server options with startx to change on a per-session basis the default color depth, 
   the  server’s  notion  of  the  number of dots-per-inch the display device presents, 
   or take advantage of a different server layout, as permitted by the Xorg(1) server and specified in the xorg.conf(5) file. 
    它可以方便的指定服務器選項使用startx來每個會話的基礎上的默認顏色深度的變化,對每英寸點數顯示裝置呈現數量的服務器的概念,
   或利用不同的服務器布局,由xorg允許(1)在xorg服務器和指定的conf(5)文件。
   Some examples of specifying  server  arguments  follow;
    指定一些服務器的例子
   consult the manual page for your X server to determine which arguments are legal.

          startx -- -depth 16

          startx -- -dpi 100

          startx -- -layout Multihead


   To  determine  the client to run, startx first looks for a file called .xinitrc in the user’s home directory.  If that
   is not found, it uses the file xinitrc in the xinit library directory.
   確定客戶端運行,聽的第一個文件,在用戶的家目錄放。如果沒有找到,它在xinit圖書館目錄使用文件放。
   If command line client options are given, they override this behavior and revert to the xinit(1) behavior.  To  deter-
   mine  the server to run, startx first looks for a file called .xserverrc in the user’s home directory.  If that is not
   found, it uses the file xserverrc in the xinit library directory.  If command line  server  options  are  given,  they
   override  this behavior and revert to the xinit(1) behavior.  Users rarely need to provide a .xserverrc file.  See the
   xinit(1) manual page for more details on the arguments.
    如果客戶端命令行選項給出,他們重寫此行為,并恢復到xinit(1)行為。確定我的服務器來運行的,聽的第一個文件,在用戶的家目錄xserverrc。
   如果沒有找到,它在xinit圖書館目錄使用的文件xserverrc。如果命令行服務器選項給出,他們重寫此行為,并恢復到xinit(1)行為。
   用戶很少需要提供xserverrc文件。看到xinit(1)在更細節的手冊頁。
   The system-wide xinitrc and xserverrc files are found in the /etc/X11/xinit directory.
     全系統和xserverrc文件放在/etc/X11目錄/ xinit。
   The .xinitrc is typically a shell script which starts many clients according to  the  user’s  preference.   When  this
   shell  script  exits,  startx  kills  the  server and performs any other session shutdown needed.  Most of the clients
   started by .xinitrc should be run in the background.  The last client should run in the foreground; when it exits, the
   session will exit.  People often choose a session manager, window manager, or xterm as the ’’magic’’ client.
    .xinitrc通常是一個shell腳本,很多會話可以根據用戶的偏好來設置。當這個shell腳本退出,StartX殺死服務器并執行任何其他會話關閉需要。
    大部分的會話開始,應該放在后臺運行。
    最后一個客戶端應該在前臺運行;當它退出時,會話將退出。人們通常選擇會話管理器,窗口管理器,或xterm作為“好極了”客戶。

(5)export

export命令使用格式: 
export [-fnp][變量名稱]=[變量設置值]

-f  代表[變量名稱]中為函數名稱。
-n  刪除指定的變量。變量實際上并未刪除,只是不會輸出到后續指令的執行環境中。
-p  列出所有的shell賦予程序的環境變量。

export-設置和顯示環境變量
在shell中執行程序時,shell會提供一組環境變量。 export可新增,修改或刪除環境變量,供后續執行的程序使用。export的效力僅及于該此登陸操作。
 一個變量創建時,它不會自動地為在它之后創建的shell進程所知。而命令export可以向后面的shell傳遞變量的值。
 當一個shell腳本調用并執 行時,它不會自動得到原為腳本(調用者)里定義的變量的訪問權,除非這些變量已經被顯式地設置為可用。
  export命令可以用于傳遞一個或多個變量的值到 任何后繼腳本。     ----《UNIX教程》

實例
export直接顯示所有的環境變量
export tmp="/tmp" 定義變量tmp為/tmp

(6)pwd
pwd使用格式

 pwd [OPTION]...

pwd – print name of current/working directory 打印名字或工作目錄

 Print the full filename of the current working directory.
  打印當前工作目錄的完整名
   -L, --logical
          use PWD from environment, even if it contains symlinks
    用PWD環境,即使它包含符號鏈接
   -P, --physical
          avoid all symlinks
     避免所有符號鏈接
   --help display this help and exit
     顯示幫助
   --version
          output version information and exit
     輸出版本信息和退出
   NOTE:  your  shell may have its own version of pwd, which usually supersedes the version described here.  Please refer
   to your shell’s documentation for details about the options it supports.
  pwd 顯示當前工作目錄

(7)history:

 history -歷史命令 
 history使用格式
 history [option]  ....

描述:

 history
        環境變量:
            HISTSIZE:命令歷史記錄的條數;
            HISTFILE:~/.bash_history;
            HISTFILESIZE:命令歷史文件記錄歷史的條數;

        history -d OFFSET   刪除指定的歷史命令
        -c 清空歷史命令
        history #: 顯示歷史中最近的#條命令;
        -a: 手動追加當前會話緩沖區的命令歷史至歷史文件中;

    調用歷史中的命令:
        !#: 重復執行第#條指令;
        !!:執行上一條命令
        !string,執行命令歷史中包含此字符的第一條命令

    調用上一條命令的最后一個參數:
        !$: 
        ESC, .
        Alt+.

    控制命令歷史的記錄方式:
        環境變量:HISTCONTROL
            ignoredups:忽略重復的命令;連續且相同方為“重復”;
            ignorespace:忽略所有以空白開頭的命令;
            ignoreboth:ignoredups, ignorespace;

        修改環境變量值的方式:export 變量名="值"
            變量賦值:把賦值符號后面的數據存儲于變量名指向內存空間;

實例:
直接用history可以顯示命令歷史的所有內容
使用history可以說清空命令歷史的所有內容
使用history -d 加數字 可以清除哪一個的命令
(8)shutdown

 shutdown命令的使用格式
 shutdown [OPTION]...  TIME [MESSAGE]

描述:

shutdown - bring the system down
 關機命令
 OPTIONS
   -r     Requests that the system be rebooted after it has been brought down.
      重新啟動
   -h     Requests that the system be either halted or powered off after it has been brought down, with the choice as  to
          which left up to the system.
      對系統進行關機
   -H     Requests that the system be halted after it has been brought down.

   -P     Requests that the system be powered off after it has been brought down.

   -c     Cancels a running shutdown.  TIME is not specified with this option, the first argument is MESSAGE.
     取消之前的關機命令
   -k     Only send out the warning messages and disable logins, do not actually bring the system down.

     只發出警告信息不關機
    TIME: 
            now: 立刻
            +m: 相對時間表示法,從命令提交開始多久之后;例如 +3;
            hh:mm: 絕對時間表示,指明具體時間;

實例
直接 shutdown -c 取消
直接 shutdown -k “the is no shutdown”

(9)poweroff
poweroff的使用格式
reboot [OPTION]…
halt [OPTION]…
poweroff [OPTION]…
poweroff – reboot or stop the system
重新啟動或關機
描述:

  These programs allow a system administrator to reboot, halt or poweroff the system.
這些程序允許系統管理員重新啟動,停機或關機系統。
   When  called  with --force or when in runlevel 0 or 6, this tool invokes the reboot(2) system call itself and directly
   reboots the system.  Otherwise this simply invokes the shutdown(8) tool with the appropriate arguments.
 當使用武力或在運行級別0或6,這個工具調用reboot(2)系統調用本身直接重啟系統。否則,這只簡單地調用了適當的參數的shutdown(8)工具。
   Before invoking reboot(2), a shutdown time record is first written to /var/log/wtmp
    在調用前reboot(2),會把之前的關機時間寫入/var/log/wtmp
   -f, --force
          Does not invoke shutdown(8) and instead performs the actual action you would expect from the name.

   -p, --poweroff
          Instructs the halt command to instead behave as poweroff.

   -w, --wtmp-only
          Does not call shutdown(8) or the reboot(2)  system  call  and  instead  only  writes  the  shutdown  record  to
          /var/log/wtmp

(10)reboot
重啟命令

(11)hwclock
使用格式:

  hwclock [functions] [options]

描述:

   hwclock  is  a  tool  for accessing the Hardware Clock.  You can display the current time, set the Hardware Clock to a
   hwclock是一款訪問硬件時鐘的工具,這是顯示現在的時間,將硬件時鐘設置為指定的時間
   specified time, set the Hardware Clock to the System Time, and set the System Time from the Hardware Clock.
  將硬件時鐘設置為系統時間,并從硬件時鐘設置系統時間。
   You can also run hwclock periodically to insert or remove time from the Hardware Clock to  compensate  for  systematic
   drift (where the clock consistently gains or loses time at a certain rate if left to run).
  你也可以運行hwclock定期插入或從硬件時鐘補償系統漂移消除時間(在時鐘始終獲得或失去的時間在一定的速度如果不運行)。
     -s, --hctosys  硬件時鐘轉軟件時鐘
          Set the System Time from the Hardware Clock.

          Also set the kernel’s timezone value to the local timezone as indicated by the TZ environment  variable  and/or
          /usr/share/zoneinfo,  as tzset(3) would interpret them.  The obsolete tz_dsttime field of the kernel’s timezone
          value is set to DST_NONE. (For details on what this field used to mean, see settimeofday(2).)

          This is a good option to use in one of the system startup scripts.

   -w, --systohc 軟件時鐘轉硬件時鐘
          Set the Hardware Clock to the current System Time.

(12)date
使用格式:

   date [OPTION]... [+FORMAT]
   date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]

描述:

   Display the current time in the given FORMAT, or set the system date.
    顯示現在的時間
   -d, --date=STRING
          display time described by STRING, not ‘now’
 顯示字符串描述的時間,而不是現在
   -f, --file=DATEFILE
          like --date once for each line of DATEFILE

   -r, --reference=FILE
          display the last modification time of FILE
         顯示最后修改時間
   -R, --rfc-2822
          output date and time in RFC 2822 format.  Example: Mon, 07 Aug 2006 12:34:56 -0600
            輸出日期和時間為rfc2822格式,
   --rfc-3339=TIMESPEC
          output  date  and  time in RFC 3339 format.  TIMESPEC=‘date’, ‘seconds’, or ‘ns’ for date and time to the indi-
          cated precision.  Date and time components are separated by a single space: 2006-08-07 12:34:56-06:00
            輸出格式日期和時間為RFC 3339格式,
   -s, --set=STRING
          set time described by STRING
    用字符串描述時間
   -u, --utc, --universal
          print or set Coordinated Universal Time
            打印或設置協調通用時
   --help display this help and exit

       date [MMDDhhmm[[CC]YY][.ss]]:設置
           MM: 月分
           DD:幾號
           hh: 小時
           mm: 分鐘
           YY: 兩位年份
           CCYY: 四位年份
           .ss: 秒鐘

實例:

  date +%F 顯示日期
  可以用man來看參數

5、如何在Linux系統上獲取命令的幫助信息,請詳細列出,并描述man文檔的章節是如何劃分的。
區別內部命令和外部的命令可以使用type

內部命令:
    # help COMMAND
外部命令:
    (1) # COMMAND --help
        # COMMAND -h
    (2) 使用手冊(manual)
        # man COMMAND
    (3) 信息頁
        # info COMMAND
    (4) 程序自身的幫助文檔
        README
        INSTALL
        ChangeLog
    (5) 程序官方文檔
        官方站點:Documentation
    (6) 發行版的官方文檔
    (7) Google
  man文檔的章節
 1  用戶命令,  可由任何人啟動的。
 2  系統調用,  即由內核提供的函數。
 3  例程,   即庫函數。
 4  設備,   即/dev目錄下的特殊文件。
 5  文件格式描述,  例如/etc/passwd。
 6  游戲,   不用解釋啦!
 7  雜項,   例如宏命令包、慣例等。
 8  系統管理員工具, 只能由root啟動。
 9  其他(Linux特定的), 用來存放內核例行程序的文檔。
 n  新文檔,  可能要移到更適合的領域。
 o  老文檔,  可能會在一段期限內保留。
 l  本地文檔,  與本特定系統有關的。

6、請羅列Linux發行版的基礎目錄名稱命名法則及功用規定

    /boot:引導文件存放目錄,內核文件(vmlinuz)、引導加載器(bootloader, grub)都存放于此目錄;
    /bin:供所有用戶使用的基本命令;不能關聯至獨立分區,OS啟動即會用到的程序;
    /sbin:管理類的基本命令;不能關聯至獨立分區,OS啟動即會用到的程序;
    /lib:基本共享庫文件,以及內核模塊文件(/lib/modules);
    /lib64:專用于x86_64系統上的輔助共享庫文件存放位置;
    /etc:配置文件目錄(純文本文件);
    /home/USERNAME:普通用戶家目錄;
    /root:管理員的家目錄;
    /media:便攜式移動設備掛載點;
        cdrom
        usb
    /mnt:臨時文件系統掛載點;
    /dev:設備文件及特殊文件存儲位置;
        b: block device,隨機訪問
        c: character device,線性訪問
    /opt:第三方應用程序的安裝位置;
    /srv:系統上運行的服務用到的數據;
    /tmp:臨時文件存儲位置;
    /usr: universal shared, read-only data;
        bin: 保證系統擁有完整功能而提供的應用程序;
        sbin:
        lib:
        lib64:
        include: C程序的頭文件(header files);
        share:結構化獨立的數據,例如doc, man等;
        local:第三方應用程序的安裝位置;
            bin, sbin, lib, lib64, etc, share

    /var: variable data files
        cache: 應用程序緩存數據目錄;
        lib: 應用程序狀態信息數據;
        local:專用于為/usr/local下的應用程序存儲可變數據;
        lock: 鎖文件
        log: 日志目錄及文件;
        opt: 專用于為/opt下的應用程序存儲可變數據;
        run: 運行中的進程相關的數據;通常用于存儲進程的pid文件;
        spool: 應用程序數據池;
        tmp: 保存系統兩次重啟之間產生的臨時數據;

    /proc: 用于輸出內核與進程信息相關的虛擬文件系統;
    /sys:用于輸出當前系統上硬件設備相關信息的虛擬文件系統;
    /selinux: security enhanced Linux,selinux相關的安全策略等信息的存儲位置;

原創文章,作者:N19_king,如若轉載,請注明出處:http://www.www58058.com/18608

(0)
N19_kingN19_king
上一篇 2016-06-18
下一篇 2016-06-18

相關推薦

  • 密碼保護:第一天

    無法提供摘要。這是一篇受保護的文章。

    Linux干貨 2017-07-15
  • 第七周

    第七周 1 創建一個10G分區,并格式為ext4文件系統;    (1) 要求其block大小為2048, 預留空間百分比為2, 卷標為MYDATA, 默認掛載屬性包含acl;    (2) 掛載至/data/mydata目錄,要求掛載時禁止程序自動…

    Linux干貨 2017-02-20
  • 馬哥教育網絡班21期+第二周課程練習

    Linux上的文件管理類命令都有哪些?其常用的方法及其相關示例。     cp:將源文件或者目錄復制到目標文件或者目錄中。     mv:將文件或目錄重新命名,或者將源文件從源目錄移到目標目錄中。     rm:刪除指定的一個文件或者多個文件或者目錄。       &n…

    Linux干貨 2016-07-16
  • linux用戶管理實戰

    ?1、列出當前系統上所有已經登錄的用戶的用戶名,注意:同一個用戶登陸多次,則只顯示一次即可。 [root@localhost ~]# who |cut -d ‘ ‘ -f1 |sort -u ?2、取出最后登陸到當前系統的用戶的相關信息。 [root@localhost ~]# who |tail -1 ?3、取出當前系統上被用戶當做…

    2018-02-08
  • 制作python模塊安裝包[原創]

     python的第三方模塊越來越豐富,涉及的領域也非常廣,如科學計算、圖片處理、web應用、GUI開發等。當然也可以將自己寫的模塊進行打包或發布。一簡單的方法是將你的類包直接copy到python的lib目錄,但此方式不便于管理與維護,存在多個python版本時會非?;靵y?,F介紹如何編寫setup.py來對一個簡單的python模塊進行打包。 一、…

    Linux干貨 2015-03-27

評論列表(1條)

  • 馬哥教育
    馬哥教育 2016-06-21 22:46

    寫的很用心,非常棒,如果可以在講解一些命令的時候添加一些案例會更加的好,加油!

欧美性久久久久