linux菜鳥必搭的初步環(huán)境 一:初步的環(huán)境有以下幾點 1:配置上網(wǎng) 2:光盤自動掛載 3:關(guān)閉iptables和selinux 4:安裝VMaretools 5:配置yum源 6: Xshell的使用 7:虛擬機(jī)克隆之后需要修改的內(nèi)容 8:解決常用的依賴關(guān)系 二:實驗步驟 1:配置上網(wǎng) 1-1虛擬機(jī)選擇橋接(自動)  之后打開Linux操作系統(tǒng),(以下演示操作是在Linux6.5系統(tǒng)上),在桌面上右鍵單擊===>Openin Terminal打開終端。 1-1.1 1 2 3 4 5 6 7 | [root@xuegod63 ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
TYPE=Ethernet
UUID=d4f368ad-2ad3-490e-a177-c2100814c333
ONBOOT=yes #這里由“on”改為“yes”
NM_CONTROLLED=yes
BOOTPROTO=none
|
#退出并保存,這樣虛擬機(jī)就可以開機(jī)自動連接網(wǎng)絡(luò)了,可以自動連接網(wǎng)絡(luò)了,就意味著可以上網(wǎng)了?NO 你還不能上網(wǎng),因為你還沒有配置IP。當(dāng)然,你也可以選擇DHCP自動分配IP地址的。 1-2.2配置ip,生成MAC地址 在終端里面輸入setup,來配置靜態(tài)IP [root@xuegod63 ~]#setup 回車之后會出現(xiàn)下圖 



Tab鍵或者方向鍵移動光標(biāo)到OK 回車,接下來選擇 save===save&&quit===quit 重啟網(wǎng)卡并查看 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | 1234567891011121314151617 [root@xuegod63 ~]#/etc/init.d/network restart
正在關(guān)閉接口 eth0: 設(shè)備狀態(tài): 3 (斷開連接)
[確定]
關(guān)閉環(huán)回接口: [確定]
彈出環(huán)回接口: [確定]
彈出界面 eth0:活躍連接狀態(tài):激活的
活躍連接路徑:/org/freedesktop/NetworkManager/ActiveConnection/ 3
[root@xuegod63~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00 :0C: 29 :CC:F0:C7
inet addr: 192.168 . 1.115 Bcast: 192.168 . 1.255 Mask: 255.255 . 255.0
inet6 addr:fe80::20c:29ff:fecc:f0c7/ 64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU: 1500 Metric: 1
RX packets: 66836 errors: 0 dropped:0overruns: 0 frame: 0
TX packets: 436 errors: 0 dropped:0overruns: 0 carrier: 0
collisions: 0 txqueuelen: 1000
RX bytes: 4487674 ( 4.2 MiB) TX bytes: 30395 ( 29.6 KiB)
|
#這里,我們可以在啟動項中選擇network網(wǎng)卡進(jìn)行重啟,當(dāng)然,也可以選擇服務(wù)中的network進(jìn)行對網(wǎng)卡重啟(service network restart)。 #這里我們?yōu)槭裁匆貑⒕W(wǎng)卡呢?原因是,重啟網(wǎng)卡是對剛配置的靜態(tài)IP數(shù)據(jù)的更新,只有將這些數(shù)據(jù)的重新更新,新配置的IP地址才會生效。 #小經(jīng)驗,在我們的實際工作中,由于是搭建的服務(wù)器是給用戶用,因此我們都不會使用重啟“restart”,因為重新啟動的過程是先將服務(wù)關(guān)閉再進(jìn)行重啟,那么關(guān)閉的時候,用戶那邊就會斷開一段時間,這個時候就有可能在用戶造成一些損失了,從而得不償失。那使用什么呢?我們都會使用重新加載“reload”這樣就沒用戶那邊網(wǎng)絡(luò)或者服務(wù)就不會斷開了 測試網(wǎng)絡(luò)是否連通性 1 2 | 12345678 [root@xuegod63 ~]# ping www.baidu.com PINGwww.a.shifen.com ( 115.239 . 210.27 ) 56 ( 84 ) bytes of data. 64 bytesfrom 115.239 . 210.27 : icmp_seq= 1 ttl= 44 time= 40.0 ms 64 bytesfrom 115.239 . 210.27 : icmp_seq= 2 ttl= 44 time= 39.2 ms ^C ---www.a.shifen.com ping statistics --- 2 packetstransmitted, 2 received, 0 % packet loss, time 1775ms rttmin/avg/max/mdev = 39.226 / 39.637 / 40.048 / 0.411 ms
#這樣網(wǎng)絡(luò)就通了
|
2光盤自動掛載 配置光盤自動掛載,首先要確保本地鏡像已連接,如下圖 
如果這里不是當(dāng)初安裝系統(tǒng)的鏡像,要先點擊瀏覽,找到當(dāng)初安裝系統(tǒng)時的鏡像文件。 1 | 123456789101112131415 [root@xuegod63 ~]#vim /etc/fstab # /etc/fstab # Created by anaconda on Fri Aug 2816 : 57 : 55 2015 # # Accessible filesystems, by reference, aremaintained under '/dev/disk' # See man pages fstab( 5 ), findfs( 8 ),mount( 8 ) and/or blkid( 8 ) for more info # UUID=a6e6bc63-38d8-4bbe-aecc-1fdf1e1c423d/ ext4 defaults 1 1 UUID=fe91d8b8-7b28-4dde-b046-c63b05cacb68/boot ext4 defaults 1 2 UUID=336ca73e-ebbc-4f39-be51-9d70ed7e9ab5swap swap defaults 0 0 tmpfs /dev/shm tmpfs defaults 0 0 devpts /dev/pts devpts gid= 5 ,mode= 620 0 0 sysfs /sys sysfs defaults 0 0 proc /proc proc defaults 0 0 dev/sr0 /mnt iso9660 defaults 0 0
|
#這里,我們要知道,/etc下存到都是我們系統(tǒng)服務(wù)的配置文件,打開fstab文件后,直接shift+ g 到文件最后一行,按下小寫的“O” 寫入上面的紅色部分。退出并保存,即可。
注意:如果掛載點不存在,自己創(chuàng)建一個即可 3關(guān)閉iptables和selinux 3-1關(guān)閉iptables 1 | 123456 [root@xuegod63 ~]#/etc/init.d/iptablesstop iptables: Settingchains to policy ACCEPT: filter [ OK ] iptables: Flushingfirewall rules: [ OK ] iptables:Unloading modules: [ OK ] [root@xuegodEN ~]#iptables–F #清空防火墻規(guī)則 [root@xuegodEN ~]#chkconfig iptables off #設(shè)置防火墻開機(jī)自動關(guān)
|
3-2關(guān)閉selinux 首先查看selinux狀態(tài) [root@xuegod63 ~]# getenforce Enforcing #強(qiáng)制開啟 然后修改/etc/selinux/config配置文件 1 | 1234567891011 [root@xuegod63 ~]# vim /etc/selinux/config # This filecontrols the state of SELinux on the system. # SELINUX= cantake one of these three values: # enforcing - SELinux security policy isenforced. #這里是開啟 # permissive - SELinux prints warningsinstead of enforcing. # disabled - No SELinux policy is loaded.#這里是關(guān)閉 SELINUX=disabled # SELINUXTYPE= cantake one of these two values: # targeted - Targeted processes areprotected, # mls - Multi Level Security protection. SELINUXTYPE=targeted
|
#在上面的配置文件中把原來是強(qiáng)制開啟enforcing改為關(guān)閉disabled。這樣我們保存退出就OK了 1 2 3 4 5 6 |
4 :安裝Vmaretools
12345 [root@xuegod63~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda2 9 .7G 3 .6G 5 .6G 39 % / tmpfs 503M 224K 503M 1 % /dev/shm/dev/sda1 194M 28M 157M 15 % /boot
#這里我們可以看到,我們的光盤并沒有掛載。然后選擇虛擬機(jī)===安裝Vmwaver Tools
12345678 [root@xuegod63 ~]# mount /dev/sr0 /mnt mount:block device /dev/sr0 is write- protected , mounting read-only [root@xuegod63~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda2 9 .7G 3 .6G 5 .6G 39 % / tmpfs 503M 224K 503M 1 % /dev/shm/dev/sda1 194M 28M 157M 15 % /boot/dev/sr0 3 .1G 3 .1G 0 100 % /mnt
|
#這里同學(xué)們就要問了,”為什么要掛載光盤呢?”,原因有,我們linux中使用的軟件本身就是自帶在光盤當(dāng)中,在開始的系統(tǒng)中,我們的wvaretools所用到的軟件包就存放在光盤當(dāng)中,在實際系統(tǒng)中,光盤是不會進(jìn)行掛載的,所以我們要對光盤進(jìn)行掛載。 1 2 | 復(fù)制并解壓
123 [root@xuegod63~]#cp VMwareTools- 9.6 . 1 - 1378637 .tar.gz /tmp [root@xuegod63~]# cd /tmp/ [root@xuegod63tmp]# tar –zxvf VMwareTools- 9.6 . 1 - 1378637 .tar.gz
|
1 2 3 4 |
安裝并驗證命令是否成
1234 [root@xuegod63tmp]# cd /vmare-tools-distrib/ [root@xuegod63vmare-tools-distrib]# ./vmare-tools-distrib -d [root@xuegod63vmare-tools-distrib]# echo $? 0
#“./vmwaver-install.pl –d”中的加上 –d 就不用一直按回車了,直接等著安裝完成后 1 重啟就可以了。輸入“echo $?”就表示對上一節(jié)命令的驗證,結(jié)果出現(xiàn)“ 0 ”就表示上一節(jié)命令的成功,出現(xiàn)“ 1 ”的話,就表示上一節(jié)命令出現(xiàn)出現(xiàn)錯誤了
|
Reboot重啟之后就可以使用了。真的重啟就可以用了嗎?不,還不能用的,我們還要將光盤卸載下來啊,還有相關(guān)鏡像的。 注意!安裝完成vmwaverTools之后要重新設(shè)置下下圖所示 改

為 
5:配置yum源 1 2 3 4 5 6 7 | 12345678910 [root@xuegod63 ~]# cd /etc/yum.repos.d/ [root@xuegod63 yum.repos.d]# ls rhel-source.repo [root@xuegod63 yum.repos.d]# vimrhel-source.repo #注意:這里配置文件一定要以.repo結(jié)尾否則無效 [local-Server] name=local-Server #名字隨便起 baseurl=file: ///mnt #這里是本地yum源的位置路徑,即本地鏡像的掛載位置,file后面必須是3個”/”斜杠 enabled=1 gpgcheck=1 #這里可以都改成“1” gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
123456789101112131415161718 [root@xuegod63yum.repos.d]# yum clean all #清空YUM緩存 Loaded plugins:product-id, refresh-packagekit, security, subscription-manager This system is notregistered to Red Hat Subscription Management. You can use subscription-managerto register. Cleaning repos:rhel6. 5 -yum-sourceCleaning upEverything [root@xuegod63 yum.repos.d]# yum --list #重新生成可安裝包列表 yum install –y zsh 安裝一個zsh的包 這里就自動解決依賴關(guān)系 [root@xuegodENyum.repos.d]# yum install lrzsz -y Loaded plugins:product-id, refresh-packagekit, security, subscription-manager This system is notregistered to Red Hat Subscription Management. You can use subscription-managerto register. Setting up InstallProcess ResolvingDependencies --> Runningtransaction check ---> Packagelrzsz.x86_64 0 : 0.12 . 20 - 27.1 .el6 will be installed --> FinishedDependency Resolution ……… Installed: lrzsz.x86_64 0 : 0.12 . 20 - 27.1 .el6
Complete!
yum源配置完成
|
6:Xshell的使用 前提是本機(jī)已經(jīng)安裝Xmanager,打開下圖圖標(biāo) 雙擊打開 






[root@xuegod63 ~]#rpm -ivh /mnt/Packages/lrzsz-0.12.20-27.1.el6.i686.rpm #直接安裝一下軟件,按rz就可以上傳文件了 7:虛擬機(jī)克隆之后需要修改的內(nèi)容 虛擬機(jī)克隆完成之后為了解決克隆的新機(jī)不能上網(wǎng)的問題需要做以下操作, 首先 [root@xuegod63 ~]# vim/etc/sysconfig/network-scripts/ifcfg-eth0 
然后 [root@xuegodEN ~]#rm -rf/etc/udev/rules.d/70-persistent-net.rules #這個文件不用擔(dān)心刪除之后,reboot會重新生成的 8:解決常用的依賴關(guān)系 1 | 12 [root@xuegod63 ~]# yum install gcc gcc-c++ glibc* glib2-develbzip2-devel gd-devel gettext bison flex mailx cluster-glue-libs-develcluster-glue resource-agents docbook-dtds docbook-style-xsl cmake pacemakercurl* php-pear *iconv openssl* pcre* zlib* fuse-devel ncurses* apr* perl* ruby*lua* libtool-ltdl-devel libuuid-devel libxml* libjpeg* libpng* freetype* -y
|
#這里我們列出了,我們需要用的一些軟件包,直接用yum來安裝常用的軟件,安裝以上的各個開發(fā)軟件之后,在大多數(shù)的實驗環(huán)境中就不會出現(xiàn)依賴性關(guān)系的錯誤了 原文地址:http://xuegodlinux.blog.51cto.com/10844319/1715529
|