Linux Basic Series-day5

Source: Internet
Author: User
Tags yum repolist

Network management

Ifconfig Network Management Tools

Ifconfig relies on the command to use some option properties, not only can be used to obtain network interface configuration information, but also modify these configurations, but the Ifconfig modified by the usual temporary configuration, that is, the system restarts after the failure.

Command format:

ifconfig [Options] [parameters]

Note: Ifconfig does not follow any options and parameters, indicating the network card information that the query is currently in effect

Common options:

<device> up starts the specified network device or NIC. Note: Ifup can be used instead

<device> down to turn off the specified network device or NIC. Note: Ifdown can be used instead

-A displays all interface information (query)

Add <address> temporarily adds an IP address

Del <address> temporarily delete an IP address

Example configuration:

Ifconfig eth0 up eth0 NIC

Ifconfig eth0 down eth0 NIC

Ifconfig eth0 Add 192.168.1.1 for the NIC eth0 configuration address an address of 192.168.1.1, when the network card itself has an IP address, will be a sub-interface to append an IP

Ifconfig eth0 del 192.168.1.1 Delete 192.168.1.1 address for Nic Eth0

Route Gateway Configuration

The route command is used to display and set the network routing table in the Linux kernel, and the routing is primarily static.

Command format:

Route [options] [parameters]

Note: Query routing information is not represented with any options and parameters after route

Common options:

-V Displays detailed routing information

Add adds the specified route record or gateway

Del deletes the specified route record or gateway

GW Set Default gateway

The network interface represented by the Dev Route record

Example configuration:

Route add-net 192.168.1.0 netmask 255.255.255.0 Add a routing to 192.168.1.0

Route del-net 192.168.1.0 netmask 255.255.255.0 Delete a route to 192.168.1.0

Route add default GW 192.168.1.250 Specifies that the gateway is 192.168.1.250

Route del default GW 192.168.1.250 Delete the defaults gateway 192.168.1.250

DNS Configuration

Modifying the DNS server is simple and requires only modifying the/etc/resolv.conf configuration file.

[[Email protected] ~] #  #  Generated by NetworkManagernameserver 114.114.114.114 #修改ip地址即可更改dns, modified save immediately effective 202.102.152.3

Domain name resolution Priority: The priority of/etc/hosts is higher than the resolution priority of the configured DNS

Network configuration file

Configuration file Modification Network: A network interface profile is a software interface that controls a single network device

Configuration file Path:/etc/sysconfig/network-scripts/ifcfg-<name>

Note: name refers to the names of the devices or connections controlled by the profile

Configuration file standard variable (default DHCP get address):

In addition to the red note entries, the other entries suggest deleting

[[Email protected] ~]#cat/etc/sysconfig/network-scripts/ifcfg-eno16777736Hwaddr=00:0c:29: 9A:CD:CC #网卡mac地址TYPE=Ethernet #网络类型bootproto=DHCP #网络连接类型是动态dhcp或静态static
Defroute=Yespeerdns=yespeerroutes=Yesipv4_failure_fatal=Noipv6init=yesipv6_autoconf=Yesipv6_defroute=Yesipv6_peerdns=yesipv6_peerroutes=Yesipv6_failure_fatal=NoNAME=eno16777736 #网络连接的名字UUID=d7eceeef-e67e-48a7-8150-f186fc2f7a5d #网络唯一标识onboot=yes#网卡开机是否启动

Profile standard variables (manually configure static addresses):

[[Email protected] ~] # cat/etc/sysconfig/network-scripts/ifcfg-eno16777736 hwaddr=00:0c:29: 9a:cd:cctype=Ethernetbootproto=static #静态地址NAME=eno1677 7736ONBOOT=yesipaddr=192.168.1.105 #ip地址 NETMASK=255.255.255.0#掩码 dns1=114.114.114.114 #指定dnsGATEWAY=192.168.1.1 #指定网关           

Note: In static settings, IP address, mask, gateway, etc. can be specified in multiple groups

Note: When DNS can specify multiple servers, queries are queried in order

Changes to the configuration file when manually modified do not take effect immediately, you need to restart the network service.

[[Email protected] ~] # systemctl Restart NetworkManager

In addition to modifying the configuration file, you can also use the NMCLI command to configure the network, NMCLI will directly write configuration information to the configuration file, do not explain

Package Management

RPM Package Management tool

The RPM command is a management tool for RPM packages. RPM was originally a red Hat Linux distribution program designed to manage Linux packages and is popular because it follows GPL rules and is powerful and convenient. is gradually being adopted by other distributions.

The RPM management tool cannot resolve dependencies and must manually install the dependent packages, but most packages have a dependency package, that is, the prerequisite for installing a package is that several dozens of additional packages need to be installed in advance, so RPM is only suitable for simple management.

Command format:

RPM [Options] [parameters]

Common options:

-Q uses the Ask mode, and when any problems are encountered, the RPM instruction asks the user first, and all query options require this option to mate

-A queries all installed packages

-e< Package > or--erase< package > delete a specified package

-f< File > query file belongs to package

-I displays information about the package

-i< Package > or--install< package > install the specified package

-l Display the file list of the package

-R Displays the package's Association information

-u< Package > or--upgrade< package > upgrade a specified package

-V Show Instruction execution process

-VV detailed instruction execution process for easy troubleshooting

Common examples:

[[Email protected] ~]#Rpm-qa #查询所有已经安装的软件包, the output information has been omitted [[Email protected] ~]#rpm-ql gcc #查询gcc安装后能产生哪些文件, output information omitted [[Email protected] ~]#rpm-qf/usr/share/info/gcc.info.gz #查看该文件属于哪个软件包Gcc-4.8.2-16. El7.x86_64[[email protected]-python ~]#rpm-qi gcc #查询gcc的包信息, including version, platform, developer, etc., output information has been omitted [[email protected] Packages]#rpm-ivh dhcp-4.2.5-27.el7.centos.x86_64.rpm #安装dhcp Preparing ...################################# [100%]Updating/Installing ...1:dhcp-12:4.2.5-27.el7.centos################################# [100%][[email protected] Packages]#RPM-EVH dhcp-4.2.5-27.el7.centos.x86_64 #卸载dhcp Preparing ...################################# [100%]Cleaning up/removing ...1:dhcp-12:4.2.5-27.el7.centos################################# [100%][[email protected] Packages]#rpm-qr dhcp-4.2.5-27.el7.centos.x86_64 #查看已经安装了的dhcp包有哪些依赖关系, the output information has been omitted 

Yum Package management tool

The Yum command is a RPM-based package manager developed by Redhat, which enables system administrators to interactively and automatically manage RPM packages, automate the download of RPM packets from a specified server, install them automatically, handle dependency relationships, and install all dependent software packages at once. No need to cumbersome to download, install.

Yum provides commands for finding, installing, and deleting one, a group, or even all of the packages.

The implementation of the Yum command relies on the Yum service to run, and Yum installs the packages and updates from the network package repository, so using Yum requires reading the relevant information from a source configuration file.

Yum Source config file:/etc/yum.repos.d/<name>.repo,name name itself, suffix must be repo

[[email protected] Packages] #  [DVD] #yum源的库名字, defined by itself, preferably as a file name =dvd #yum源的库的说明信息, custom baseurl=file:///mnt #yum源的库的地址, file://represents the local library,/MNT represents the path, in addition to Http://ip/path, Ftp://ip/path and other remote libraries, Remote libraries require file sharing with related services Gpgcheck=0 #是否进行gpg签名校验enable=1 #开启该yum源配置, The default is to open, do not write this line

The following Yum command, all use the above repo file information,/mnt the corresponding system image is mounted, the general system image is encapsulated in the common service package.

Command format:

Yum [options] [parameters]

Common options:

Install the RPM package

Update updates RPM Package

Check-update Check if an updated RPM package is available

Remove removes the specified RPM package

List displays information about the package

Search Check the package information

Info displays description and summary information for the specified RPM package

Clean cleanup Yum Expired cache

RESOLVEDEP show dependencies for RPM packages

Localinstall installing the local RPM package

Localupdate Show local RPM package for update

Deplist Show all dependencies for RPM packages

Groups Package Group Management

Common examples:

[[Email protected] ~]#Yum List #列出所有库所提供的软件包列表[[Email protected] ~]#Yum install vsftpd-y #安装vsftpd[[Email protected] ~]#Yum Remove vsftpd-y #删除vsftpd[[Email protected] ~]#Yum deplist vsftpd #列出vsftpd的依赖关系[[Email protected] ~]#Yum Info vsftpd #查看vsftpd的描述和概要信息[[Email protected] ~]#Yum Groups list #列出所有软件包组[[Email protected] ~]#Yum Groups install KDE #安装KDE软件包组[[Email protected] ~]#Yum Search DHCP #查找并显示dhcp的信息
[[email protected] ~]# yum Clean all #清除缓存信息
[[email protected] ~]# yum Repolist #查看源库的列表, the library can be specified more than one, can be written in a repo file, can also be written separately

Source Code Package Management

The installation of the source code package generally consists of 4 steps: Extract the source code package, configuration (Configure), compile (make), install (makes install), the following will be python3.6.1 as an example explanation

Extract the source code package:

The source code package is generally used in GZ, bz2 (using tar to unpack), and some using XZ (xz-d decompression), zip (unzip decompression)

Configuration (Configure):

After each package decompression, the internal basic has configure file, the following configure file

[[Email protected] ~]#CD PYTHON-3.6.1/[[email protected] Python-3.6.1]#lsaclocal.m4 config.sub Include Mac Modules Programs Python Setup.pybuil D  Configure  install-sh Makefile Objects pybuilddir.txt python-config toolsconfig.guess configure.ac Lib makefile.pre Parser pyconfig.h python-config.pyconfig.log Doc libpython3.6m.a makefile.pre.inchPC pyconfig.h.inchpython-gdb.pyconfig.status Grammar LICENSE Misc pcbuild python readme.rst

Configure is an executable configuration script that has many options for using commands under the source path to be installed./configure–help output detailed list of options

Generally used in one, the--prefix option is to configure the path of software installation, if not configured, after the installation executable file is placed by default in/usr/local/bin, the library file is placed by default in/usr/local/lib, the configuration file is placed by default in/usr/local/etc , the other resource files are placed in the/usr/local/share, and the specified path is stored in the corresponding directory.

[[email protected] Python-3.6.1] # ./configure--prefix=/usr/local/python3 #配置安装路径为/usr/local/python3 

Compile (make):

Execute the Make command under the source code path, when make executes, it searches the current directory for the makefile file, and the makefile file records the details of the source code software compilation, which is performed using environments such as the GCC compilation environment, the Zlib function library, and so on. The lack of a corresponding software environment can lead to compilation failure, the general reason for failure will prompt, the user is generally able to solve the prompt.

[[email protected] Python-3.6.1] #  Make

Compile and install (make install):

The make install installs the last compiled data into the configured directory according to the Install option in makefile, and you want to uninstall the installed source code package, you can use make uninstall (configure configuration and do compile required).

[[email protected] Python-3.6.1] # Make Install

The installation is complete at this point, but the following system's environment variables need to be modified to use python3.6.1

Software post-installation configuration:

Write the execution file path of the python3.6.1 to the environment variable configuration file, and the

[[email protected] Python-3.6.1] # Echo   [[email protected] Python-3.6.1] # Source/etc/profile

Verify:

[[email protected] Python-3.6.1]#pip3-vPip 9.0.1 from/usr/local/python3/lib/python3.6/site-packages (Python 3.6) [[email protected]-python Python-3.6.1]#Python3Python 3.6.1 (default, May 28 2017, 22:15:46) [GCC4.8.2 20140120 (Red Hat 4.8.2-16)] on Linuxtype" Help","Copyright","credits" or "License"  forMore information.>>> exit ()

Linux Basic Series-day5

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.