linux 基本命令 (一)

  UNIX誕生,1970年1月1日bash


    用戶-------->內核-------》硬件less


發行版的名稱/版本由發行方決定ide

   – Red Hat Enterprise Linux 5/6/7ui

   – Suse Linux Enterprise 12spa

   – Debian Linux 7.8操作系統

   – Ubuntu Linux 14.10/15.04命令行


是一套完整Linux系統日誌

   – Linux內核 + 各類外圍軟件ip



CentOS,社區企業操做系統內存


  文件系統:在空間中,數據排列組合存儲的規則


傳統的MBR分區模式

– 1~4個主分區

– 0~3個主分區+1個擴展分區(n個邏輯分區)

注意事項

– MBR分區表只能記錄4個主分區,編號範圍1-4

– 當有必要使用4個以上分區時,須要創建擴展分區(佔

               主分區編號),擴展分區最多隻能有1個

– 擴展分區做爲一箇中間性質的容器,從其中再劃分出

               的分區空間即爲邏輯分區


典型的文件系統類型

– EXT4,第四代擴展文件系統,RHEL6系列默認

– XFS,高級日誌文件系統,RHEL7系列默認

– SWAP,交換空間(虛擬內存)



  目錄結構


       根目錄 / : 全部數據都存放在此目錄下(Linux系統的起點)


    /dev  : 存放設備文件 


    /dev/abc/1.txt



   分區表示


   hd,表示IDE設備

   sd,表示SCSI設備


         /dev/sda5



    Ctrl+ALt: 鼠標出如今真機



完成RHEL7系統的安裝過程後,第一次啓動時會要求進行初始化設置。



 當提示查看協議信息仍是建立用戶時,輸入1並回車。


 接下來輸入2並回車,表示接受許可協議。


 前後輸入兩次c表示繼續,按回車後會進入到歡迎界面。



    點擊「未列出」--------->利用「root」登錄系統



RHEL7基本操做

虛擬控制檯切換( Ctrl + Alt + Fn 組合鍵)

   – tty1 : 圖形桌面

   – tty2~tty6 : 字符控制檯


  右鍵 「在終端中打開」

    

命令行提示標識的含義

– [當前用戶@主機名  當前所在位置]$



– 若當前用戶是root,則最後一個字符爲 #

   [root@svr7 桌面]#


– 不然,最後一個字符爲 $

   [teacher@svr7 桌面]$


查看文本文件的指令:cat


查看系統版本

[root@localhost 桌面]# cat  /etc/redhat-release

Red Hat Enterprise Linux Server release 7.2 (Maipo)


[root@localhost 桌面]# hostname    #查看當前主機名 



  藍色:目錄

  黑色:文本文件

  紅色:壓縮包

  綠色:能夠執行的程序



查看及切換目錄

pwd — Print Working Directory

– 用途:查看當前工做目錄


cd — Change Directory

– 用途:切換工做目錄

– 格式:cd [目標文件夾位置]


ls — List

– 格式:ls [選項]... [目錄或文件名]...


[root@localhost 桌面]# pwd       #顯示當前所在位置


[root@localhost 桌面]# cd   /    #切換路徑


[root@localhost /]# pwd         #顯示當前所在位置

[root@localhost /]# ls


[root@localhost /]# ls /root    #查看/root目錄內容


[root@localhost /]# ls /boot


[root@localhost /]# ls /root  /boot


[root@localhost /]# ls  /dev


  輸出信息提示: 未找到命令

  緣由:

          1.命令有誤

          2.該命令沒有安裝


  命令完整的格式


     命令字      選項        參數

    

   cat     -n      /etc/passwd


   .. 表示父目錄


[root@localhost /]# cd ..


  以 / 開始的 絕對路徑

  以當前爲參照的 相對路徑( 不以 / 開始的路徑)


[root@localhost /]#  cd /etc/pki


[root@localhost pki]#  pwd

[root@localhost pki]#  ls


[root@localhost pki]#  cd  /etc/pki/CA   #絕對路徑

[root@localhost CA]#  pwd

[root@localhost CA]# cd  .. 

[root@localhost pki]#  cd  CA            #相對路徑

[root@localhost CA]#  pwd


[root@localhost /]#  cat  -n  /etc/redhat-release

[root@localhost /]#  cat  -n  /etc/passwd



列出內核版本

[root@svr7 桌面]# uname   -r

3.10.0-327.el7.x86_64



 臨時設置IP的地址

[root@svr7 桌面]# ifconfig


[root@svr7 桌面]# ifconfig eth0


[root@svr7 桌面]# ifconfig eth0 192.168.1.168


[root@svr7 桌面]# ifconfig eth0



ls — List

   – 格式:ls [選項]... [目錄或文件名]...


經常使用命令選項

  – -l :以長格式顯示(顯示目錄內容的詳細屬性)



列出CPU處理器信息

[root@svr7 桌面]# lscpu

[root@svr7 桌面]# cat /proc/cpuinfo

檢查內存大小、空閒狀況

[root@svr7 桌面]# cat /proc/meminfo



[root@svr7 桌面]# ls -l /root


[root@svr7 桌面]# ls -l /boot

[root@svr7 桌面]# ls -l /home

[root@svr7 桌面]# ls -l /tmp

[root@svr7 桌面]# ls -l /opt


關機:poweroff

[root@svr7 ~]# poweroff


重啓:reboot

[root@svr7 ~]# reboot



 補充:


    補全鍵:Tab


[root@svr7 ~]# ifco(tab)


[root@svr7 ~]# if(連續兩次tab)


# cat /et(tab)/red(tab)-r(tab)


# ls /et(tab)/sysco(tab)/netw(tab)-(tab)/ifc(tab)-e(tab)



   查看文本文件內容


   cat :小文件

   less:大文件   按q退出


    查看文本文件部份內容

      

        head   -3   /etc/passwd   #顯示頭多少行

        tail   -4   /etc/passwd   #顯示尾多少行

      

        head   -12   /etc/passwd

        tail   -6   /etc/passwd


        less   /etc/passwd       #按鍵盤上下鍵,能夠滾動


    從文本文件內容中查找,包含指定字符串的行


           grep  '字符串'   文本文件路徑


           grep   'root'   /etc/passwd

           grep   'bin'    /etc/passwd

           grep   'bash'   /etc/passwd


           grep   'hahaxixi'   /etc/passwd

   

   mkdir :建立目錄


   touch:建立文件


     

   Ctrl+c:結束正在運行的程序或指令

相關文章
相關標籤/搜索