User management and network configuration
1. Cases network configuration
Host Name: server0.example.com
IP address: 172.25.0.11
Subnet Mask: 255.255.255.0
Default Gateway: 172.25.0.254
DNS servers: 172.25.254.254
3.2 program
Use nmcli configure basic operation of the network connection,
View network connection, the connection details:
nmcli con show
nmcli con show " connection name "
Modify the network connection parameters:
nmcli con modify"连接名"ipv4.method auto|manual
nmcli con modify " connection name " ipv4.addresses "IP address / mask length [ Default gateway ]" ipv4.dns DNS server address
nmcli con modify"连接名"connection.autoconnect yes|no
3.3 step
This case needs to be achieved in the following steps.
Step a: Configure a fixed host name
1 ) pre-configured, check if the static hostname
[root@server0~]#hostnamectl
Static hostname: n / a // not set static hostname
Transient hostname:server0.example.com
2 ) the specified hostname
[root @ server0 ~] #vim / etc / hostname // establish hostname configuration file
server0.example.com
3 ) After the configuration, the check result
[root@server0~]#hostnamectl
Static hostname: server0.example.com // set static hostname
Icon name:computer
....
Step Two: Configure a static IP address parameters
1 ) view the current host LAN equipment, network connection
[root@server0~]#nmcli connection show
Name UUID type of device
System eth0 5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03 802-3-ethernet eth0
2 ) Modify Connection " the System eth0 configuration"
The arrangement is designated as Manual , specify the IP address, default gateway, the DNS address, and configure the automatic connection:
[root@server0~]#nmcli connection modify "System eth0" ipv4.method manual ipv4.addresses "172.25.0.11/24 172.25.0.254" ipv4.dns 172.25.254.254 connection.autoconnect yes
3 ) to re-activate the connection " System eth0 "
By up command is active connection configuration, when necessary, may be first down and then up :
[root @ server0 ~] #nmcli connection up "System eth0" // activate the connection
Connection successfully activated(D-Bus active
path:/org/freedesktop/NetworkManager/ActiveConnection/1)
Ensure system service NetworkManager boot from the start:
[root@server0~]#systemctl restart NetworkManager
[root@server0~]#systemctl enable NetworkManager
4 ) Check the modification result, confirmation
l Check the IP address:
[root@server0~]#ifconfig eth0
eth0:flags=4163<UP,BROADCAST,RUNNING,MULTICAST>mtu 1500
inet 172.25.0.11 netmask 255.255.255.0 broadcast 172.25.0.255
inet6 fe80::5054:ff:fe00:b prefixlen 64 scopeid 0x20<link>
ether 52:54:00:00:00:0b txqueuelen 1000(Ethernet)
RX packets 1394 bytes 138855(135.6 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 944 bytes 98495(96.1 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
l Check the default gateway address:
[root@server0~]#route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 172.25.0.254 0.0.0.0 UG 1024 0 0 eth0
0.0.0.0 172.25.0.0 255.255.255.0 U 0 0 0 eth0
l Check the DNS server address :
[root@server0~]#cat /etc/resolv.conf
#Generated by NetworkManager
search example.com
Nameserver 172.25.254.254
If you are using nmcli did not specify when modifying network connection ipv4.dns , can directly modify the DNS client configuration file /etc/resolv.conf , make sure to add records to the above.
Step Three: Verify the network configuration.
l via ssh remote access server0 :
[root@room9pc13~]#ssh -X [email protected]
Warning:Permanently added'server0.example.com'(ECDSA)to the list of known hosts.
Last login:Fri Dec 23 19:00:12 2016 from 172.25.0.250
[root @ server0 ~] #hostname // confirm your hostname
server0.example.com
l In the virtual machine server0 on, you can query server0 , desktop0 , Content sites such as:
[root@server0~]#host server0.example.com
server0.example.com has address 172.25.0.11
[root@server0~]#host desktop0.example.com
desktop0.example.com has address 172.25.0.10
desktop0.example.com mail is handled by 10 smtp0.example.com.
[root@server0~]#host content.example.com
content.example.com has address 172.25.254.254
Case 4 : Find and processing file
4.1 problem
This embodiment requires less than two ways to perform the following tasks:
Users find all student files owned
Copy them to the / root / findfiles / folder
4.2 step
This case needs to be achieved in the following steps.
Step one: Make sure to find the specified file
1 ) confirm the new kernel Download
[root@server0~]#find / -user student-type f
the Find: ' / proc / 1853 / Task / 1853 / fdinfo / 6 ' : No such file or directory
the Find: ' / proc / 1853 / fdinfo / 6 ' : No such file or directory
/ Var / spool / mail / student
/home/student/.bash_logout
/home/student/.bash_profile
/home/student/.bashrc
/home/student/.ssh/authorized_keys
/home/student/.config/gnome-initial-setup-done
/home/student/.config/monitors.xml
For the above operating problems / proc information can be ignored.
Step two: processing files found
1 ) Create a destination folder
[root@server0~]#mkdir/root/findfiles
2 files) copy to the destination folder found
Choose one of the following two methods:
[root@server0~]#find / -user student -type f -exec cp -p {} /root/findfiles/ \;
....
or
[root@server0~]#\ cp -p $(find / -user student-type f) /root/findfiles/
....
3 ) verify that the copy Results
[root@server0~]#ls -lh A /root/findfiles/
The total amount of 24K
-rw-------.1 student student 1.7K 7月11 2014 authorized_keys
-rw-r--r--.1 student student 18 1月29 2014.bash_logout
-rw-r--r--.1 student student 193 1月29 2014.bash_profile
-rw-r--r--.1 student student 231 1月29 2014.bashrc
-rw-r--r--.1 student student 4 7月11 2014 gnome-initial-setup-done
-rw-r--r--.1 student student 1.5K 7月11 2014 monitors.xml
-rw-rw----.1 student mail 0 7月11 2014 student
Case 5 : Find and extract the contents of the file
5.1 problem
This embodiment requires the file / usr / share / dict / words to find the string comprising all seismic lines, and meet the following requirements:
The row is found by the original order of the copy to / root / wordlist file
File / root / wordlist Do not include blank lines, and wherein the content of all the lines must be / usr / share / dict / words exact copy of the original file line
5.2 step
This case needs to be achieved in the following steps.
1 ) using the grep command to find the specified keywords, and saved to the specified file by redirecting the output:
[root@serverX~]#grep 'seismic' /usr/share/dict/words > /root/wordlist
2 ) extraction result confirmed
[root@server0~]#cat /root/wordlist
anaseismic
antiseismic
aseismic
aseismicity
bradyseismic
....