linux学习第一天———centos6基础环境配置

环境:centos6.6

参考链接:https://www.cnblogs.com/liaoyuanyang/p/6746542.html

清空防火墙规则

[[email protected] ~]# iptables -F

[[email protected] ~]# /etc/init.d/iptables save

iptables:将防火墙规则保存到 /etc/sysconfig/iptables:     [确定]

关闭防火墙开启自启

[[email protected] ~]# chkconfig iptables off

关闭selinux

查看selinux状态

[[email protected] ~]# getenforce

Enforcing

彻底关闭selinux

[[email protected] ~]# vi /etc/sysconfig/selinux 

   7 SELINUX=disabled

重启生效

[[email protected] ~]# reboot

临时关闭防火墙

[[email protected] ~]# setenforce 0

配置好静态ip

[[email protected] ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0
HWADDR=00:0C:29:B8:EE:38
TYPE=Ethernet
UUID=e473eca1-519d-4064-a829-95d7c53d67c0
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=none
IPADDR=192.168.188.139 #ip地址
NETMASK=255.255.255.0  #子网掩码
GATEWAY=192.168.188.1   #网关
DNS1=8.8.8.8

~                   

重启生效

[[email protected] ~]# service network restart
正在关闭接口 eth0:                                        [确定]
关闭环回接口:                                             [确定]
弹出环回接口:                                             [确定]
弹出界面 eth0: Determining if ip address 192.168.188.139 is already in use for device eth
0...                                                           [确定]


查看ip地址

[[email protected] ~]# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0C:29:B8:EE:38  
          inet addr:192.168.188.139  Bcast:192.168.188.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:feb8:ee38/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1338 errors:0 dropped:0 overruns:0 frame:0
          TX packets:648 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:117411 (114.6 KiB)  TX bytes:83125 (81.1 KiB)

          Interrupt:18 Base address:0x2000 


配置地址映射关系

[[email protected] ~]# vi /etc/hosts

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

192.168.188.139 xiaomao6.cn xiaomao6

~                                           

修改主机名:

[[email protected] ~]# vi /etc/sysconfig/network

NETWORKING=yes

HOSTNAME=xiaomao6

~                  

查看主机名修改情况

[[email protected] ~]# hostname 

xiaomao6

yum源

一、Yum简介

1、Yum(全称为 Yellow dog Updater, Modified)是一个在Fedora和RedHat以及CentOS中的Shell前端软件包管理器。

2、基于RPM包管理,能够从指定的服务器自动下载RPM包并且安装,可以自动处理依赖性关系,并且一次安装所有依赖的软件包,无须繁琐地一次次下载、安装。

3、本地Yum源的作用是你可以在不联网的情况下,就可以安装Linux需要的所有rpm包(可以理解为离线安装模式)

配置本地yum源

1、右击虚拟机——进入“虚拟机设置”——点击“CD/DVD(IDE)”——点击“浏览”——选中安装时的镜像——勾选上“已连接”——确定

linux学习第一天———centos6基础环境配置

永久挂载光盘

[[email protected] ~]# echo "/dev/sr0 /mnt iso9660 defaults 0 0 " >> /etc/fstab 

[[email protected] ~]# mount -a

mount: block device /dev/sr0 is write-protected, mounting read-only

[[email protected] ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_xiaomao6-lv_root
                       18G  937M   16G   6% /
tmpfs                 499M     0  499M   0% /dev/shm
/dev/sda1             477M   28M  425M   6% /boot

/dev/sr0              4.4G  4.4G     0 100% /mnt

配置本地yum源

[[email protected] ~]# cd /etc/yum.repos.d/

[[email protected] yum.repos.d]# vim rhel6.repo

[rhel6-source]

name=rhel6-source

baseurl=file:///mnt

enabled=1

gpgcheck=0

清空yum缓存

[[email protected] yum.repos.d]# yum clean all

重新生成缓存列表

[[email protected] yum.repos.d]# yum list

安装网络yum

以阿里源为例子

安装下载工具wget

[[email protected] Packages]# rpm -ivh wget-1.12-5.el6.x86_64.rpm 
warning: wget-1.12-5.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing...                ########################################### [100%]

   1:wget                   ########################################### [100%]


下载网络源(要能连外网)

[[email protected] Packages]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Cen
tos-6.repo

重新生成缓存

重新生成缓存列表

[[email protected] ]# yum makecache