1. 程式人生 > >linux計算機基礎 DAY04

linux計算機基礎 DAY04

#!紅色字型為重點掌握的概念或需要記憶的操作方法或路徑   使用教學虛擬機器 • 每個學員機上有三臺預先配置好的虛擬機器
– server —— 作為練習用伺服器
– desktop —— 作為練習用客戶機
– classroom —— 提供閘道器/DNS/軟體素材/DHCP等資源 真機:還原與啟動優先虛擬機器classroom  
[[email protected] ~]# rht-vmctl reset classroom
[[email protected] ~]# rht-vmctl reset server
[
[email protected]
~]# rht-vmctl reset desktop 利用root使用者  密碼:redhat 登陸虛擬機器server與虛擬機器desktop  虛擬機器Server:
           1.主機名:server0.example.com
           2.檢視系統版本:RHEL 7.0
           3.檢視第一網絡卡IP地址:172.25.0.11/24  虛擬機器Desktop:
           1.主機名:desktop0.example.com
           2.檢視系統版本:RHEL 7.0
           3.檢視第一網絡卡IP地址:172.25.0.10/24
##############################################
真機:遠端管理    Ctrl + shift + t = 新開一個終端
遠端管理的命令 : ssh  使用者名稱@對方主機的IP地址
[[email protected] ~]# ssh [email protected]
Last login: Fri Jan 12 18:54:00 2018 from 172.25.0.250
[[email protected] ~]# [[email protected] ~]# ssh [email protected]
Last login: Fri Jan 12 18:54:00 2018 from 172.25.0.250
[[email protected]
~]#  
遠端管理常用的選項: -X 遠端管理時可以執行對方的圖形程式 [[email protected] ~]# exit        
登出
Connection to 172.25.0.11 closed. [[email protected] ~]# ssh -X [email protected] [[email protected] ~]#  firewall-config  #防火牆配置工具
[[email protected] ~]#  firefox 常見提示:  該提示為桌面圖形背景報錯,與遠端管理無關
[[email protected] ~]# ssh -X [email protected]
(process:29933): dconf-WARNING **: failed to commit changes to dconf: 無法連線:拒絕連線 [[email protected] ~]# #################################################
真機:
 定義永久的別名: /root/.bashrc (系統級配置檔案) [[email protected] ~]# vim /root/.bashrc
[[email protected] ~]# head -3 /root/.bashrc
# .bashrc
alias  gos='ssh  -X  [email protected]'
alias  god='ssh  -X  [email protected]'   全新開啟一個終端,才會生效
##############################################
軟體包管理 虛擬機器classroom搭建Web服務,將RHEL7.0光碟所有內容共享 真機:
 classroom.example.com/content/rhel7.0/x86_64/dvd/
命令列的下載工具: wget   下載路徑   
 預設下載,到當前路徑下 虛擬機器server:
[[email protected] ~]# wget http://classroom.example.com/content/rhel7.0/x86_64/dvd/Packages/vsftpd-3.0.2-9.el7.x86_64.rpm   在 頁面中  利用  ctrl + f 進行搜尋 vsftpd 
   然後 右擊  vsftpd.....複製連結地址 零散軟體管理
使用rpm命令管理軟體
RPM Package Manager,RPM 包管理器
  – rpm -q   軟體名...                         #查詢本機是否安裝此軟體
  – rpm -ivh 軟體名-版本資訊.rpm    #安裝
  – rpm -e   軟體名...                         #解除安裝 常見提示:此軟體包沒有安裝
package vsftpd is not installed
[[email protected] ~]# rpm -q vsftpd     #查詢是否安裝此軟體
未安裝軟體包 vsftpd ]# rpm -ivh /root/vsftpd-3.0.2-9.el7.x86_64.rpm [[email protected] ~]# rpm -ql vsftpd   #檢視安裝清單
[[email protected] ~]# rpm -q vsftpd    #查詢是否安裝成功 [[email protected] ~]# rpm -e vsftpd    #解除安裝軟體
[[email protected] ~]# rpm -q vsftpd    #查詢是否解除安裝成功
未安裝軟體包 vsftpd
[[email protected] ~]# ###############################################
瞭解:匯入紅帽官方簽名金鑰 ]# wget http://classroom.example.com/content/rhel7.0/x86_64/dvd/RPM-GPG-KEY-redhat-release ]# rpm --import /root/RPM-GPG-KEY-redhat-release ]# rpm -q vsftpd
]# rpm -e vsftpd
]# rpm -ivh /root/vsftpd-3.0.2-9.el7.x86_64.rpm #################################################
安裝軟體包  bind-chroot (搭建DNS伺服器)
]# wget http://classroom.example.com/content/rhel7.0/x86_64/dvd/Packages/
bind-chroot-9.9.4-14.el7.x86_64.rpm
 
]# rpm -ivh /root/bind-chroot-9.9.4-14.el7.x86_64.rpm
錯誤:依賴檢測失敗:
 bind = 32:9.9.4-14.el7 被 bind-chroot-32:9.9.4-14.el7.x86_64 需要 ]# wget http://classroom.example.com/content/rhel7.0/x86_64/dvd/Packages/bind-9.9.4-14.el7.x86_64.rpm ]# rpm -ivh /root/bind-9.9.4-14.el7.x86_64.rpm ]# rpm -ivh /root/bind-chroot-9.9.4-14.el7.x86_64.rpm ]# rpm -q bind-chroot    #查詢是否安裝成功
錯誤的依賴關係                                
error: Failed dependencies: ################################################
Yum軟體包倉庫:可以自動解決依賴關係  服務:為客戶端安裝軟體,並且解決依賴關係   服務端:1.眾多的軟體包   2.倉庫清單(倉庫資料檔案)
               3.搭建Web或FTP服務,共享光碟所有內容
               虛擬機器classroom
  客戶端: 指定服務端位置
  客戶端配置檔案:/etc/yum.repos.d/*.repo
  錯誤的客戶端配置檔案,會影響正確的客戶端配置檔案
 
 重點欄位: []、name、baseurl、enabled、gpgcheck [[email protected] ~]# rm -rf /etc/yum.repos.d/*
[[email protected] ~]# vim /etc/yum.repos.d/dvd.repo
[rhel7]          #倉庫標識
name=rhel7.0     #倉庫描述資訊
baseurl=http://classroom.example.com/content/rhel7.0/x86_64/dvd/      #服務端位置
enabled=1        #是否啟用本檔案
gpgcheck=0       #是否檢測紅帽的簽名認證 [[email protected] ~]# yum repolist   #列出倉庫資訊
[[email protected] ~]# yum -y install httpd  #安裝軟體包
[[email protected] ~]# LANG=en   #切換成英文
                                                      退出在登陸,會變成中文  ################################################
[[email protected] ~]# yum  remove  軟體名     #解除安裝
            
檢測Yum倉庫方式:
[[email protected] ~]# yum  clean all  #清空快取
[[email protected] ~]# yum  repolist ################################################
配置網路 一、配置永久的主機名
[[email protected] /]# vim  /etc/hostname  #修改配置檔案
[[email protected] /]# cat  /etc/hostname
A.tedu.cn
[[email protected] /]# hostname
A.tedu.cn
[[email protected] /]# exit
登出
Connection to 172.25.0.11 closed. [[email protected] ~]# gos [[email protected] ~]# hostname
二、永久配置IP地址、子網掩碼、閘道器地址、DNS伺服器地址 網絡卡配置檔案
  /etc/sysconfig/network-scripts/ifcfg-eth0 方法1:修改網絡卡配置檔案內容
方法2:通過命令nmcli connection  修改網路引數 1.顯示命令識別的網絡卡名
[[email protected] ~]# nmcli connection show 2.執行配置命令,可以重複敲,後敲的命令會覆蓋前面敲的操作
]# nmcli connection modify 'System eth0'  
 ipv4.method manual         
 ipv4.addresses  '172.25.0.100/24  172.25.0.254' 
 ipv4.dns  172.25.254.254               
 connection.autoconnect yes # cat /etc/sysconfig/network-scripts/ifcfg-eth0   nmcli connection 修改  '網絡卡名'
  ipv4.方法  手工配置
  ipv4.地址  'ip地址/子網掩碼    閘道器地址'
  ipv4.dns  DNS伺服器地址
    每次開機  自動啟用配置   
                         
3.啟用配置
]# nmcli connection up 'System eth0'
綜合驗證:
  1.檢視IP地址 子網掩碼 
[[email protected] ~]# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.25.0.100  netmask 255.255.255.0  broadcast 172.25.0.255   2.檢視閘道器  route  -n
[[email protected] ~]# route -n
   Gateway       
      172.25.0.254     3.檢視DNS伺服器地址
   #指定DNS伺服器配置檔案
[[email protected] ~]# cat /etc/resolv.conf 
# Generated by NetworkManager
search tedu.cn
nameserver 172.25.254.254 ##############################################  #通過classroom虛擬的提供的資源,可以讓desktop.server完成客戶端和服務端的操作。