This post will introduce how to install a CentOS on VMware 12.
Install CentOS
Custom –> I will install the operating system later.
Good Commands
|
|
Net Configuration
Network modes
- Bridged
- Connect virtual machine to Internet directly by physical netcard.
- Other machines can access virtual machine directly.
- NAT(Net Address Tranform)
- virtual machine can access other machines.
- Other machines can not access virtual machine.
- Host-only
- Like NAT but can not connect to Internet.
- Bridged
Static IP Address
Edit file:
/etc/sysconfig/network-scripts/ifcfg-enoxxxxx
These values should be modified:123456ONBOOT=yesNM_CONTROLLED=noBOOTPROTO=staticIPADDR=xxx.xxx.xxx.xxxNETMASK=xxx.xxx.xxx.xxxGATEWAY=xxx.xxx.xxx.xxxNETMASK
andGATEWAY
must be same with your VMnet8(NAT mode).Edit file:
/etc/resolv.conf
for DNS1nameserver xxx.xxx.xxx.xxxnameserver
must be same with VMnet8 gateway.
Jobs
123456$> cat a.txt & // run in background$> jobs // check jobs in background$> fg %n // switch job to foreground, `n` is job IDctrl + z // switch job to background$> bg %n // continue a job in background$> kill %n // kill a jobProcess
12$> ps -Af // show all processes$> topCut
1$> cut -c 1-5 a.txt // show the 1st - 5th chars in each linesDevice Info
12$> fdisk -l /dev/sda // show infos of `sda` like partitions$> df -ah // show free space of devicesHost name
1$> hostname // show host namechange host name to edit
/etc/hostname
file.Host name to IP address
Edit file/etc/hosts
12127.0.0.1 localhostxxx.xxx.xxx.xxx host1Nested Commands
123$> echo www.baidu.com > a.txt$> echo `cat a.txt`$> ping $(echo $(cat a.txt))Add and Delete users
12$> useradd -m newuser // add new user$> userdel -rf newuser // delete new userEnv variable
123$> echo ${PATH}$> echo "$PATH"$> export mypath=${name:-$PATH} // ternary operatorParameters of scripts
123456$? // return value$# // number of params$n // the n-th param$0 // current name of script$@ // get all paramsshift // left move paramIf
An example ofif
:12345678910111213if [ $# -lt 2 ]; thenecho less than 2!elif [ $# -gt 2 ]; thenecho greater then 2!elseecho good!fiecho ==============echo param number is: $#echo all params are: $@echo the 2nd param is: $2echo current script name is: $0For
An example offor
“12345678lines=5for (( x=1; x<=lines; x=$x+1 )); dofor (( y=1; y<=$x; y=$y+1 )); doecho -n $yedoneechodoneYUM
Repository
123$> mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup$> curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo$> yum makecacheYum Commands
1234567$> yum list // list all packages$> yum list installed // list all installed packages$> yum search xxx // search xxx in repos$> yum remove xxx // remove an installed package xxx$> yum install xxx // install a package$> yum [re]install --downloadonly --downloaddir=/home/xxx wget // download wget packages into /home/xxx$> yum localinstall xxx.rpm // local install a rpmMake ISO file
12$> yum install mkisofs$> mkisofs -r -o xxx.iso yyy // make xxx.iso from dir yyy