In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Linux system network configuration
Test network connectivity: ping 223.5.5.5
First mileage: modify the address information of the network card
Use system commands to modify nmtui
Second mileage: restart the network card service
Centos7: systemctl restart network
Centos6: / etc/init.d/network restart
PS: in the enterprise environment, the network card cannot be restarted casually.
Ifdown enh0 & & ifup eth continuous action
PS: all configurations in the linux system can take effect. Related services must be restarted.
Third mileage: check to make sure that the network card is configured correctly
Address (mask) information configuration:
Centos7: ip address show
Centos6: ifconfig
How to check gateway information:
Centos7: ip route show
Centos6: route-n
PS: all operations must be checked during operation and maintenance
Fourth mileage: modify the gateway settings in the virtual network editor
Vmnet8 (nat)-- nat Settings-- Gateway Settings-- 10.0.0.254
Remotely connect to the Linux operating system
1) install and deploy remote software: xshell
2) Security software configuration process:-
3) establish remote connection configuration:
Address: remote host IP address
Protocol: there are many service names in the host = = project name ssh
Port: service number information in the host = = 22
4) errors often occur in remote connections / how to troubleshoot remote connection problems
Three steps for investigation
1) check whether the remote connection link is unblocked
Ping 10.0.0.200
Analyze the reasons:
An incorrect configuration of Nic address information nmtui
B Virtual software network configuration is incorrect
C the address of the virtual network card is not configured correctly
D re-restore the virtual network configuration
E check whether the virtual service in the system opens the win window properly + rmurf-run window-- services.msc-- Service-- vmware
2) system firewall service linux system firewall / windows firewall
3) SSH remote service is not enabled
Telnet 10.0.0.200 22
Directory structure of the system: everything starts from the root
Use an absolute path to find data: look for data information from the root
Features: better accuracy
C:\ oldboy01\ oldboy02\ oldboy03\ oldboy.txt
C:\ oldboy\ oldboy01\ oldboy02\ oldboy03\ oldboy04\ oldboy.txt
Use relative paths to find data: find data information from the current path
Features: it is more convenient to find data
Oldboy03/oldboy.txt
C:\ oldboy\ oldboy01\ oldboy02\ oldboy03\ oldboy04\ return to the upper layer without seeing olddog.txt
Master the system command prompt
Function: prompt managers to enter commands
[root@oldboyedu ~] #
01 02 03
Composition: consists of three parts: the host name information of the user information system logged in to the system displays the syntax format of the current directory information command
Command space parameter space data information (path / file)
Rm-f oldboy.txt system management basic commands:
A system runs related management commands
Restart the system:
Restart the system, restart in a few minutes
[root@oldboyedu ~] # shutdown-r 5 (minutes)
Shutdown scheduled for Tue 2019-09-03 04:49:30 EDT, use 'shutdown-c' to cancel.
The shutdown system plan will be executed at about 04:49:30 seconds in 2019-09-03. Use 'shutdown-c' to cancel the plan.
Broadcast message from root@oldboyedu.com (Tue 2019-09-03 04:44:30 EDT):
Broadcast restart system message by root@oldboyedu.com
The system is going down for reboot at Tue 2019-09-03 04:49:30 EDT!
The system will restart at 04:49:30 on 2019-09-03.
Cancel restart operation
[root@oldboyedu] # shutdown-c
Broadcast message from root@oldboyedu.com (Tue 2019-09-03 04:50:45 EDT):
Broadcast cancel restart operation message by root@oldboyedu.com
The system shutdown has been cancelled at Tue 2019-09-03 04:51:45 EDT!
The system restart operation has been cancelled
Restart immediately
[root@oldboyedu] # shutdown-r now/0
Shut down the system:
Shut down the system and restart in a few minutes
[root@oldboyedu ~] # shutdown-h 5 (minutes)
Shutdown scheduled for Tue 2019-09-03 05:03:36 EDT, use 'shutdown-c' to cancel.
Broadcast message from root@oldboyedu.com (Tue 2019-09-03 04:58:36 EDT):
The system is going down for power-off at Tue 2019-09-03 05:03:36 EDT!
The system will be shut down at 05:03:36 on 2019-09-03
Shut down the system immediately
[root@oldboyedu] # shutdown-h now/0
B commands related to the system directory
1) create directory command make directory = > mkdir
Mkdir / oldboy/
[root@oldboyedu ~] # mkdir / oldboy/oldboy01/oldboy02/oldboy03
Mkdir: cannot create directory'/ oldboy/oldboy01/oldboy02/oldboy03': No such file or directory
Cannot create a directory; there is no such file or directory
Mkdir-p / oldboy/oldboy01/oldboy02/oldboy03 creates a multi-level directory
PS: when operating a command, when no message is generated, it is the best news.
2) confirm that the directory has been created list = > ls list to display system data information
[root@oldboyedu ~] # ls / oldboy/oldboy01/-lists the data information under the specified directory
Oldboy02
[root@oldboyedu ~] # ls-d / oldboy/oldboy01/-lists whether the specified directory exists
/ oldboy/oldboy01/
3) switch the directory path change directory = > cd
Change directories by absolute path: cd / oldboy/oldboy01/oldboy02/oldboy03
Switch directories by relative path: in the oldboy03 directory-- > cd oldboy04
Cd/cd ~: quickly return to the home directory of the system user
Cd.. Quickly return to the previous directory
Cd.. /.. Quickly return to the superior directory
Cd -: quickly return to the same directory as the last time
Quiz:
Create two multi-level directories
/ oldboy/oldboy01/oldboy02/oldboy03/oldboy04/
/ oldgirl/oldgirl01/oldgirl02/oldgirl03/oldgirl04/
Go to the / oldboy/oldboy01/oldboy02/oldboy03/oldboy04/ directory first
Excuse me: how to switch to the / oldgirl/oldgirl01/oldgirl02/oldgirl03/oldgirl04/ directory
Absolute path switch directory command: cd / oldgirl/oldgirl01/oldgirl02/oldgirl03/oldgirl04/
Relative path switch directory command: cd.. / oldgirl/oldgirl01/oldgirl02/oldgirl03/oldgirl04/
Conclusion:
There is a superior-subordinate relationship between the directory and the directory: using relative path switching, the operation is more efficient.
There is no superior-subordinate relationship between directory and directory: absolute path switching is adopted to make the operation more efficient.
4) View the current path print working directory (output current working directory)-- pwd
[root@oldboyedu oldboy03] # pwd
/ oldboy/oldboy01/oldboy02/oldboy03
C commands related to system files
1) create file information touch
Touch oldboy.txt
2) check whether the confirmation file is created successfully
[root@oldboyedu oldboy] # ls / oldboy
Oldboy oldboy01 oldboy.txt
[root@oldboyedu oldboy] # ls / oldboy/oldboy.txt
/ oldboy/oldboy.txt
[root@oldboyedu oldboy] # ls / oldboy/oldboy01.txt
Ls: cannot access / oldboy/oldboy01.txt: No such file or directory
3) how to view the contents of the file cat cat-look at the contents of the file
[root@oldboyedu oldboy] # cat oldboy.txt-viewing an empty file
[root@oldboyedu oldboy] # cat / etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
:: 1 localhost localhost.localdomain localhost6 localhost6.localdomain6
4) Edit the contents of the file
The first method to edit the contents of a file: vi/vim (not in the default centos7) = = Edit the file
The vi command edits the file:
First mileage: open a file
Vi oldboy.txt
Second mileage: enter an editing mode
Enter the lowercase letter "I"-- enter insert mode insert mode-> start editing the contents of the file
Third mileage: exit editing mode
Enter the keyboard key "esc"
Fourth mileage: save exit / do not save exit
: wq-write (write = = save) quit (exit)
Q-without editing, quit directly
: Q!-the content of the file has been modified and forced to exit
Common problems in vi editing: when the edited file is located in a directory that can only be edited, and cannot be edited in a directory, when the system cannot recognize the Chinese symbol information to edit the file, the name of the file to be edited must be specified after the vi command
The second method of editing the contents of the file: echo = = output the information to the screen
[root@oldboyedu oldboy] # echo "hello world"
Hello world
[root@oldboyedu oldboy] # echo "hello world" > / oldboy/oldboy.txt
[root@oldboyedu oldboy] # cat / oldboy/oldboy.txt
Hello world
File directories are related to some commands system data information for backup copy = > cp copy command
Syntax format: cp parameter source file (backup file required) destination file (file after backup)
Backup file information
Cp / etc/hosts / etc/hosts.bak
Cp / etc/hosts / opt/
Overwrite file problem
If you copy a file normally, you will be prompted to overwrite:
[root@oldboyedu ~] # cp / etc/hosts / opt/
Cp: overwrite'/ opt/hosts'? Y
[root@oldboyedu ~] # cat / opt/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
:: 1 localhost localhost.localdomain localhost6 localhost6.localdomain6
Oldboy
How to force an override:
Method 1:\ cp oldboy01.txt / opt/-ignore the override prompt
Method 2: / usr/bin/cp oldboy01.txt / opt/-ignore the override prompt (still works)
Backup directory information
Cp-r / oldboy/ / tmp/ system data information move operation (cut) move = > mv
Syntax format: mv parameter source file (need to move file) destination path (to what path)
Move file information:
Mv oldboy01.txt / tmp/
Mobile directory information
Mv / oldboy/ / tmp/
Rename operation:
Mv oldboy/ oldgirl/
System data deletion command remove = = rm
Delete file information
Rm-f / oldboy/oldboy01.txt
Delete directory information
Rm-rf / oldboy/
-r Recursively delete the data under the directory
-f forcibly delete directory data information (no confirmation prompt)
Delete root operation:
Rm-rf-- no-preserve-root /
Rm-rf /
Important catalogs of the system
Bin-store command files (binaries) directory
Sbin-directories that superusers can save using the command
Etc-Storage system or service program profile information
Home-user data information is saved to the home directory of slum ordinary users
Root-user data information is saved to the Palace Super Admin root user home directory in the home directory
Mnt-temporary mount point directory
Opt-storing data information generated by third-party software programs
Usr/local
Proc-the data in the directory is stored in memory to store process information and kernel file information
Selinux-save selinux program configuration file information and system security related programs
Tmp-temporary storage data directory / Recycle Bin
Var-save files with frequent data changes (log files)
Official directory structure description: http://www.pathname.com/fhs/pub/fhs-2.3.html
System important file information:
/ etc/
1) Network card configuration file
Configuration file save path: / etc/sysconfig/network-scripts/ifcfg-eth0
Profile information description:
TYPE=Ethernet-define the type of network used
BOOTPROTO=none-whether the IP address can be obtained automatically the server is generally set to a fixed address
None/static: will not let the IP address change the enterprise environment
Dhcp: dynamic acquisition of IP addresses
NAME=eth0-set the Nic name information
DEVICE=eth0
UUID=f3a6f219-0d68-4e9b-b673-3b9205d05afb
-hardware identification number information
ONBOOT=yes-activate the system network card
IPADDR=10.0.0.200-configure IP address information
PREFIX=24-Subnet mask information determines how many hosts in a LAN can be configured with IP addresses
GATEWAY=10.0.0.254-configure gateway information to allow hosts to access the public network
DNS1=223.5.5.5-access domain name-- > ip address information
Visit the domain name of the website, and you can also show whether you can communicate.
Changes to the configuration file to restart the service:
Restart the network card service method 1: centos7
Systemctl restart network restarts all network cards
Restart the network card service mode 2: centos7 centos6
/ etc/init.d/network restart restarts all network cards
Restart the network card service mode 3: restart only the specified network card
Ifdown (interface down) eth0-stop eth0 network card
Ifup (interface up) eth0-start the eth0 network card
Ifdown eth0 & & ifup eth0-restart the specified eth0 network card
2) address Resolution Service profile
Configuration file save path: / etc/resolv.conf
Profile information description:
Nameserver 223.5.5.5
Supplement: common DNS servers
223.5.5.5 DNS 223.6.6.6 Aliyun *
114.114.114.114 Telecom operator DNS
8.8.8.8 Google DNS
Restart network services
The Nic DNS information will be overwritten / synchronized to the resolv.conf file
PS: the configuration information in the file, which will take effect immediately after the configuration is modified
3) Host name profile
Server system hostname naming guidelines:
Address name-computer room name-room cabinet
Bj-pbs-2012A
Sjz
Configuration file save path:
Centos7: / etc/hostname
Centos6: / etc/sysconfig/network
Permanent adjustment: the system must be restarted for the configuration to take effect
Vi / etc/hostname
Oldboy66-ZNB
Temporary adjustment: make the configuration take effect immediately (reconnect)
Hostname oldboy66-ZNB
Centos7 can be temporarily modified with permanent changes.
Hostnamectl set-hostname oldboyedu.com
4) the local resolution profile establishes a relationship between the host name and the IP address
Configuration file save path: / etc/hosts
5) realize automatic mounting of storage device files
Configuration file save path: / etc/fstab
Profile information description:
UUID=97630c81-c2f8-4735-9fe0-4d86e9aee1cd / xfs defaults 0 0
UUID=77c7cc12-e079-42f4-8462-2d76563eb7e5 / boot xfs defaults 0 0
UUID=ec4226e8-169c-4856-b114-30d19c21d82c swap swap defaults 0 0
01 02
01. UUID: hardware identification information = = Storage file information / dev/sda1: UUID= "77c7cc12-e079-42f4-8462-2d76563eb7e5"
/ dev/sda2: UUID= "ec4226e8-169c-4856-b114-30d19c21d82c"
/ dev/sda3: UUID= "97630c81-c2f8-4735-9fe0-4d86e9aee1cd"
6) realize the command file to run automatically when the system is booted.
Configuration file save path: / etc/rc.local (permission execution permission)
Profile information description:
How does the profile take effect:
Chmod + x / etc/rc.d/rc.local-add execution permissions to the configuration file
7) system variable or environment variable profile
Configuration file save path: / etc/profile-configuration variable / environment variable / configuration alias information?
Profile information description:
Method 1:
Vi / etc/profile
Last line: export PATH=$PATH:/tmp
Method 2:
Echo export PATH=$PATH:/tmp > > / etc/profile
PS: in an enterprise environment, adding information to a configuration file, adding information using echo must use > > append information
To make the configuration file effective:
Method 1: reconnect to the server
Method 2: use the command to load the environment variable configuration file immediately
Source / etc/profile
What are variables: use variables in script files to modify script contents flexibly
Set variable: format: variable name = variable value x+y=10 x value 5 y?
Name=oldboy
Call variable: echo $name
Script configuration:
[root@oldboy66 ~] # cat test.sh
Name=olddog
Echo $name 01
Echo $name 02
Echo $name 03
What are environment variables:
1) variables set in system mode
2) system variable names are all uppercase letters
How to modify an environment variable: PATH
Temporary modification:
Export PATH=$PATH:/tmp
Permanent modification:
Modify the configuration file: / etc/profile
The process of executing the principle of the command:
1) execute the command
2) load the system environment variable $PATH-- > / usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
3) enter the directory specified by the environment variable
/ usr/local/sbin
/ usr/local/bin
/ usr/sbin
/ usr/bin
/ root/bin
/ tmp
4) there are corresponding command files in the specified environment directory-- > execute command operations
4) there is no response command file in the specified environment directory-- > command not found / No such file or directory
Common shortcuts:
Ctrl+a-quickly move the cursor to the beginning of the line
Ctrl+e-quickly move the cursor to the end of the line
Ctrl+ ← →-move the cursor quickly left and right according to the word string
Ctrl+w-delete (cut) a contiguous string of information (no space division)
Ctrl+y-paste cut information
Ctrl+u-delete (cut) all string information to the left of the cursor location
Ctrl+k-delete (cut) all string information to the right of the cursor location
Tips for using the vi command:
The skill of moving the cursor quickly
G/shift+g-quickly switch the cursor to the last line
Gg-quickly switch the cursor to the beginning of the file line
10gg-switches the cursor to the specified line
$- quickly switch the cursor to the end of a line
0 / ^-quickly switch the cursor to the beginning of a line
Quickly move the cursor and enter the editing state:
O-place the cursor on a new line below the current line and enter the editing state
O-place the cursor on a new line over the current line and enter the editing state
I-enter the editing state directly at the current position of the cursor
I-switch the cursor to the beginning of a line and enter the editing state
A-switch the cursor to the end of a line and enter the editing state
A-the next character in the current position of the cursor enters the editing state.
C-clear all the content to the right of the cursor and enter the editing state
Cc-clear the entire line and enter the editing state
Quickly edit file content information
Yy-copy the specified content information
Nyy-copy multiple lines of information
P-paste copied or cut information
3p-paste the copied or cut content 3 times
Dd-delete (cut) specify a line of information
Ndd-delete (cut) specify multiple lines of information
DG-delete everything after the line of the cursor (cut)
R-replace the character information where the specified cursor is located
R-enter into replacement mode, you can replace multiple character information
Bottom line function instruction
: set nu-displays file line number information
: set nonu-cancels the display of file line number information
: s/oldboy/oldgirl/-replace the information about the location of the cursor
:% s/oldboy/oldgirl/-replace all specified contents in the file
: 7recover12sUniverse /-replaces the specified line information
: 6 replacements: Oldboyax /-replace the specified line to the last line of the specified content
: 6 the match found in the line is replaced by all the information retrieved in the line.
: 6. Replace the first matching information retrieved in a row.
PS: when the replacement instruction is used, the split symbol can be used / # @
/ searched information-retrieve and filter specified information in the file
N means to retrieve the next matching information
N means to return to the previous matching information
/ searched information\ c-ignore case when retrieving information in files
Special operation skills
U-- undo-undo operation in vi editing
Ctrl+r-- redo-cancel the undo operation in vi editing
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.