linux13&14

################

####软件安装####

################

####1.软件名称识别####

[abrt-addon-ccpp]-[2.1.11-19].[el7].[x86_64].rpm ##rpm结尾的适用与redhat操作系统

       ||                                   ||         ||                       ||

    软件名称                           软件版本                   软件适用系统 64位

####2.如何安装软件####

1.rpm

rpm -ivh name.rpm ##安装 ,-v显示过程,-h指定加密方式为hash

-e name ##卸载

-ql name ##查询软件生成文件

-qlp name.rpm ##查询软件安装后会生成什么文件

-qa ##查询系统中安装的所有软件名称

-qa |grep name ##查询软件是否安装

eg:

[root@localhost software]# rpm -qa |grep google

google-chrome-stable-21.0.1180.89-154005.x86_64

google-crosextra-caladea-fonts-1.002-0.4.20130214.el7.noarch

google-crosextra-carlito-fonts-1.103-0.2.20130920.el7.noarch

-q name ##。。。。

-qp name.rpm ##查询软件安装包安装后的名字

-qf filename ##查看filename属于那个安装包

-ivh name.rpm --force ##强制安装

-qi name ##查看软件信息

-Kv name.rpm ##检测软件包是否被篡改

-qp name.rpm --scripts ##检测软件在安装或卸载过程中执行的动作

2.yum

yum

上层软件管理工具,最重要的功能是可以解决软件的倚赖关系

yum能够投入使用的前提是必须要有yum源,以及配置源的指向文件

###server源端####

1.从网络上下本机系统版本匹配的iso镜像文件

rhel-server-7.1-x86_64-dvd.iso

eg:

rhel-server-7.2-x86_64-dvd.iso

2.把rhel-server-7.1-x86_64-dvd.iso挂在到/mnt以便访问镜像中的文件

mount rhel-server-7.1-x86_64-dvd.iso /mnt

eg:

[root@localhost mnt]# mkdir /iso

[root@localhost mnt]# mount rhel-server-7.2-x86_64-dvd.iso /iso

mount: /dev/loop0 写保护,将以只读方式挂载

3.配置本机yum源指向

rm -fr /etc/yum.repos.d/*

vim /etc/yum.repos.d/yum.repo

[Server]

name=rhel7.1

baseurl=file:///mnt

gpgcheck=0

eg:

[server]

name=rhel7.2

baseurl=file:///iso

gpgcheck=0

4.安装资源共享服务

yum install httpd -y

systemctl stop firewlsh-plugin-11.2.202.451-release.x86_64.rpmld

systemctl disable firewalld

systemctl start httpd

systemctl enable httpd

eg:

[root@localhost yum.repos.d]# yum install httpd -y

已加载插件:langpacks

server                                                   | 4.1 kB     00:00     

(1/2): server/group_gz                                     | 136 kB   00:00     

(2/2): server/primary_db                                   | 3.6 MB   00:00     

正在解决依赖关系

--> 正在检查事务

---> 软件包 httpd.x86_64.0.2.4.6-40.el7 将被 安装

--> 正在处理依赖关系 httpd-tools = 2.4.6-40.el7,它被软件包 httpd-2.4.6-40.el7.x86_64 需要

--> 正在处理依赖关系 /etc/mime.types,它被软件包 httpd-2.4.6-40.el7.x86_64 需要

--> 正在处理依赖关系 libapr-1.so.0()(64bit),它被软件包 httpd-2.4.6-40.el7.x86_64 需要

--> 正在处理依赖关系 libaprutil-1.so.0()(64bit),它被软件包 httpd-2.4.6-40.el7.x86_64 需要

--> 正在检查事务

---> 软件包 apr.x86_64.0.1.4.8-3.el7 将被 安装

---> 软件包 apr-util.x86_64.0.1.5.2-6.el7 将被 安装

---> 软件包 httpd-tools.x86_64.0.2.4.6-40.el7 将被 安装

---> 软件包 mailcap.noarch.0.2.1.41-2.el7 将被 安装

--> 解决依赖关系完成

依赖关系解决

================================================================================

 Package             架构           版本                   源              大小

================================================================================

正在安装:

 httpd               x86_64         2.4.6-40.el7           server         1.2 M

为依赖而安装:

 apr                 x86_64         1.4.8-3.el7            server         103 k

 apr-util            x86_64         1.5.2-6.el7            server          92 k

 httpd-tools         x86_64         2.4.6-40.el7           server          82 k

 mailcap             noarch         2.1.41-2.el7           server          31 k

事务概要

================================================================================

安装  1 软件包 (+4 依赖软件包)

总下载量:1.5 M

安装大小:4.3 M

Downloading packages:

--------------------------------------------------------------------------------

总计                                               5.2 MB/s | 1.5 MB  00:00     

Running transaction check

Running transaction test

Transaction test succeeded

Running transaction

  正在安装    : apr-1.4.8-3.el7.x86_64                                      1/5

  正在安装    : apr-util-1.5.2-6.el7.x86_64                                 2/5

  正在安装    : httpd-tools-2.4.6-40.el7.x86_64                             3/5

  正在安装    : mailcap-2.1.41-2.el7.noarch                                 4/5

  正在安装    : httpd-2.4.6-40.el7.x86_64                                   5/5

  验证中      : mailcap-2.1.41-2.el7.noarch                                 1/5

  验证中      : httpd-tools-2.4.6-40.el7.x86_64                             2/5

  验证中      : apr-1.4.8-3.el7.x86_64                                      3/5

  验证中      : apr-util-1.5.2-6.el7.x86_64                                 4/5

  验证中      : httpd-2.4.6-40.el7.x86_64                                   5/5

已安装:

  httpd.x86_64 0:2.4.6-40.el7                                                   

作为依赖被安装:

  apr.x86_64 0:1.4.8-3.el7                 apr-util.x86_64 0:1.5.2-6.el7       

  httpd-tools.x86_64 0:2.4.6-40.el7        mailcap.noarch 0:2.1.41-2.el7       

完毕!

[root@localhost yum.repos.d]# systemctl status firewlsh-plugin-11.2.202.451-release.x86_64.rpmld

firewlsh-plugin-11.2.202.451-release.x86_64.rpmld.service

   Loaded: not-found (Reason: No such file or directory)

   Active: inactive (dead)

[root@localhost yum.repos.d]# systemctl status firewalld.service

firewalld.service - firewalld - dynamic firewall daemon

   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled)

   Active: active (running) since 二 2017-04-04 21:48:05 EDT; 32min ago

 Main PID: 483 (firewalld)

   CGroup: /system.slice/firewalld.service

           └─483 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid

4月 04 21:48:05 localhost systemd[1]: Started firewalld - dynamic firewall...n.

Hint: Some lines were ellipsized, use -l to show in full.

[root@localhost yum.repos.d]# systemctl stop firewalld.service

5.建立共享目录,并挂在镜像文件到共享目录上

mkdir /var/www/html/rhel7.1

umount /mnt

mount rhel-server-7.1-x86_64-dvd.iso /var/www/html/rhel7.1

eg:

[root@localhost yum.repos.d]# mkdir /var/www/html/rhel7.2

[root@localhost yum.repos.d]# umount /iso

[root@localhost yum.repos.d]# mount /mnt/rhel-server-7.2-x86_64-dvd.iso /var/www/html/rhel7.2

6.测试

在浏览器中输入:http://本机ip/rhel7.1

可以看到镜像中的内容

7.修改本机yum源指向

eg:

[server]

name=rhel7.2

baseurl=file:///var/www/html/rhel7.2

gpgcheck=0

8.开机自动挂在iso

eg:

vim /etc/rc.d/rc.local

mount rhel-server-7.1-x86_64-dvd.iso /var/www/html/rhel7.2

:wq

chmod +x /etc/rc.d/rc.local

9.第三方软件仓库的搭建

把所有的rpm软件包放到一个目录中,这个目录中只能存在rpm文件

createrepo -v /rpm存放目录

vim /etc/yum.repos.d/xxx.repo

[Software]

name=software

baseurl=file:///rpm存放目录

gpgcheck=0

eg:

[root@localhost yum.repos.d]# mkdir /software

[root@localhost yum.repos.d]# createrepo -v /software/

Saving Primary metadata

Saving file lists metadata

Saving other metadata

Generating sqlite DBs

Starting other db creation: Tue Apr  4 22:35:43 2017

Ending other db creation: Tue Apr  4 22:35:45 2017

Starting filelists db creation: Tue Apr  4 22:35:45 2017

Ending filelists db creation: Tue Apr  4 22:35:46 2017

Starting primary db creation: Tue Apr  4 22:35:46 2017

Ending primary db creation: Tue Apr  4 22:35:48 2017

Sqlite DBs complete

[root@localhost yum.repos.d]# vim /etc/yum.repos.d/soft.repo

[SOFTWARE]

name=SOFTWARE

baseurl=file:///software

gpgcheck=0

####client指向端####

vim /etc/yum.repos.d/xxxx.repo ##仓库指向文件位置

[xxxx] ##自定义软件仓库名称

name=xxxx ##自定义软件仓库描述

baseurl=ftp://|http://|file:// ##仓库位置

gpgcheck=0 ##不检测gpgkey

##gpgkey表示软件的出品logo

例子:

vim /etc/yum.repos.d/yum.repo

[Server]

name=rhel7.1

baseurl=ftp://172.25.0.254/pub/rhel7.1

gpgcheck=0

:wq

yum clean all ##清空yum缓存识别新配置

####yum命令####

yum install softwarename ##安装

repolist ##列出设定yum源信息

remove softwarename ##卸载

list softwarename ##查看软件源中是否有次软件

list all ##列出所有软件名称

list installd ##列出已经安装的软件名称

list available ##列出可以用yum安装的软件名称

clean all ##清空yum缓存

search softwareinfo ##根据软件信息搜索软件名字

whatprovides filename ##在yum源中查找包含filename文件的软件包

update ##更新软件

history ##查看系统软件改变历史

reinstall softwarename ##重新安装

info softwarename ##查看软件信息

groups list ##查看软件组信息

groups info softwaregroup ##查看软件组内包含的软件

groups install softwaregroup ##安装组件

groups remove softwaregroup ##卸载组件

eg:

[root@foundation60 mnt]# yum list httpd  ###查看软件源中是否有httpd软件

Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-

              : manager

This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

Installed Packages

httpd.x86_64                         2.4.6-40.el7                          @fuwu

[root@foundation60 mnt]# yum search dhcp  ##根据软件信息搜索dhcp软件名字

Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-

              : manager

This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

============================== N/S matched: dhcp ===============================

dhcp-common.x86_64 : Common files used by ISC dhcp client and server

dhcp-libs.i686 : Shared libraries used by ISC dhcp client and server

dhcp-libs.x86_64 : Shared libraries used by ISC dhcp client and server

dhclient.x86_64 : Provides the ISC DHCP client daemon and dhclient-script

dhcp.x86_64 : Dynamic host configuration protocol software

dnsmasq.x86_64 : A lightweight DHCP/caching DNS server

  Name and summary matches only, use "search all" for everything.

[root@foundation60 mnt]# yum clean all ##清空yum缓存

Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-

              : manager

This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

Cleaning repos: fuwu

Cleaning up everything

[root@localhost yum.repos.d]# yum search httpd

已加载插件:langpacks

SOFTWARE                                          | 2.9 kB     00:00     

server                                            | 4.1 kB     00:00     

SOFTWARE/primary_db                                 | 1.1 kB   00:00     

========================== N/S matched: httpd ===========================

httpd.x86_64 : Apache HTTP Server

httpd-devel.x86_64 : Development interfaces for the Apache HTTP server

httpd-manual.noarch : Documentation for the Apache HTTP server

httpd-tools.x86_64 : Tools for use with the Apache HTTP Server

libmicrohttpd.i686 : Lightweight library for embedding a webserver in

                   : applications

libmicrohttpd.x86_64 : Lightweight library for embedding a webserver in

                     : applications

mod_auth_mellon.x86_64 : A SAML 2.0 authentication module for the Apache

                       : Httpd Server

mod_dav_svn.x86_64 : Apache httpd module for Subversion server

  名称和简介匹配 only,使用“search all”试试。

############################

####14.linux中设备的访问####

############################

####1.设备访问####

1.设备识别

/dev/xdxn ##硬盘设备/dev/sda1

/dev/cdrom ##光驱

/dev/mapper/* ##虚拟设备

2.设备的使用

##《设备的发现》##

fdisk -l ##查看真实存在的设备

cat /proc/partitions ##系统能够识别的设备

blkid ##系统能够挂载使用的设备id

df ##查看设备被系统使用的情况

eg:

[root@foundation60 ~]# blkid  ##系统能够挂载使用的设备id

/dev/sda1: UUID="6C40B6F240B6C25E" TYPE="ntfs"

/dev/sda5: LABEL="d" UUID="0008A6E9000E477F" TYPE="ntfs"

/dev/sda6: UUID="8896c46e-7a25-4cbd-845c-0ee6995da1f3" TYPE="xfs"

/dev/sda7: UUID="6da8ea05-711b-414e-8d31-0fff0158e927" TYPE="swap"

/dev/sda8: UUID="b26863f3-1628-4e3e-a96e-e78603bf1184" TYPE="xfs"

/dev/loop0: UUID="2015-10-30-11-11-49-00" LABEL="RHEL-7.2 Server.x86_64" TYPE="iso9660" PTTYPE="dos"

/dev/loop0p1: UUID="2015-10-30-11-11-49-00" LABEL="RHEL-7.2 Server.x86_64" TYPE="iso9660" PTTYPE="dos"

/dev/loop0p2: SEC_TYPE="msdos" LABEL="ANACONDA" UUID="8F82-0858" TYPE="vfat"

/dev/sdb1: UUID="A23D-B188" TYPE="vfat"

##《设备的使用》##

1.设备的挂载

mount 设备 挂载点

mount /dev/sdb1 /mnt #把系统中第二块硬盘的第一个分区挂载到/mnt目录上

eg:    ##将u盘挂载到/mnt目录上

[root@foundation60 ~]# df

Filesystem     1K-blocks     Used Available Use% Mounted on

/dev/sda8      447672760 13798544 433874216   4% /

devtmpfs         1902740        0   1902740   0% /dev

tmpfs            1915788      224   1915564   1% /dev/shm

tmpfs            1915788     8996   1906792   1% /run

tmpfs            1915788        0   1915788   0% /sys/fs/cgroup

/dev/sda6         505580   149244    356336  30% /boot

tmpfs             383160       28    383132   1% /run/user/1000

/dev/loop0p1     3947824  3947824         0 100% /run/media/kiosk/RHEL-7.2 Server.x86_64

/dev/sdb1       30141184   653008  29488176   3% /run/media/kiosk/A23D-B188

[root@foundation60 ~]# mount /dev/sdb1 /mnt/

[root@foundation60 ~]# ls /mnt  ##u盘内容

hadoop  picture3  picture4  System Volume Information  westos  截图  毕设

2.卸载设备

umout 设备|挂载点

如出现以下情况:

[root@foundation0 ~]# umount /dev/sdb1

umount: /home/kiosk/Desktop/photo: target is busy.

        (In some cases useful info about processes that use

         the device is found by lsof(8) or fuser(1))

解决:

fuser -kvm 设备|挂载点 -k kill ,-v显示详细信息,-m扫描设备

####2.软硬链接###

ls -i ##查看文件节点号

ln -s /file /file1 ##软链接,只有名字

[root@foundation41 mnt]# ln -s /mnt/file /opt/

ln: failed to create symbolic link ‘/opt/file’: File exists

ln /file /file1 ##硬链接,复制过去

eg:

[root@foundation41 mnt]# rm -fr *

[root@foundation41 mnt]# touch file1

[root@foundation41 mnt]# ls -li file1

807414022 -rw-r--r-- 1 root root 0 Mar 31 15:27 file1

[root@foundation41 mnt]# ln -s /mnt/file1  /opt/

[root@foundation41 mnt]# ls -li file1

807414022 -rw-r--r-- 1 root root 0 Mar 31 15:27 file1

[root@foundation41 mnt]# ls -li /opt/file1

2860346 lrwxrwxrwx 1 root root 10 Mar 31 15:28 /opt/file1 -> /mnt/file1

[root@foundation41 mnt]# rm -fr /mnt/file1

[root@foundation41 mnt]# ls -l /opt/

total 0

lrwxrwxrwx  1 root root 10 Mar 31 15:28 file1 -> /mnt/file1

drwxr-xr-x. 2 root root  6 Mar  9  2015 rh

[root@foundation41 mnt]# cat /opt/file1

cat: /opt/file1: No such file or directory

[root@foundation41 mnt]# rm -fr /opt/file1

[root@foundation41 mnt]# touch file

[root@foundation41 mnt]# ln /mnt/file /opt/

[root@foundation41 mnt]# ls -li /mnt/file

807414022 -rw-r--r-- 2 root root 0 Mar 31 15:30 /mnt/file

[root@foundation41 mnt]# ls -li /opt/file

807414022 -rw-r--r-- 2 root root 0 Mar 31 15:30 /opt/file

[root@foundation41 mnt]# rm -fr /mnt/file

####3.文件查找####

1.locate filename ##在文件数据库中搜索filename信息,updatedb更新文件数据库

[root@foundation60 ~]# touch /boot/westos

[root@foundation60 ~]# locate westos

[root@foundation60 ~]# updatedb    ##默认每小时更新一次

[root@foundation60 ~]# locate westos

/boot/westos

[root@foundation60 ~]# rm -fr /boot/westos

[root@foundation60 ~]# locate westos

/boot/westos

2.find

find 查找位置 -条件 条件值  -exec 动作 {} ;

-name  ##名字

-not 条件

-user  ##用户

-group  ##组

-size   ##大小

-perm   ##权限

--maxdepth  ##最大层

--mindepth  ##最小层

-a   ##并且

-o  ##或者

-type f 文件

  d 目录

c 字符设备

b 块设备

s 套节字

l 链接

find /mnt -user student

find /mnt -group linux

find /mnt -user student -a -group linux

find /mnt -user student -o -group linux

find /mnt -user student -a -group linux

find /mnt -user student

find /mnt -user student -a -not -group linux

dd if=/dev/zero of=/mnt/file1 bs=1024 count=10

dd if=/dev/zero of=/mnt/file2 bs=1024 count=20

dd if=/dev/zero of=/mnt/file3 bs=1024 count=30

find /mnt -size 10k

find /mnt -size -10k  ##-小于

find /mnt -size +10k  ##+大于

eg:

[root@foundation60 ~]# find /etc/ -name passwd

/etc/passwd

/etc/pam.d/passwd

[root@foundation60 mnt]# find /etc/ -maxdepth 1 -name passwd  ##-maxdepth

/etc/passwd

[root@foundation60 mnt]# find /etc/ -mindepth 2 -name passwd  ##-mindepth

/etc/pam.d/passwd

[root@foundation60 mnt]# chown kiosk file1

[root@foundation60 mnt]# chown kiosk:kiosk file3

[root@foundation60 mnt]# chgrp kiosk file5

[root@foundation60 mnt]# ls -l

total 0

-rw-r--r-- 1 kiosk root  0 Apr  3 17:42 file1

-rw-r--r-- 1 root  root  0 Apr  3 17:42 file2

-rw-r--r-- 1 kiosk kiosk 0 Apr  3 17:42 file3

-rw-r--r-- 1 root  root  0 Apr  3 17:42 file4

-rw-r--r-- 1 root  kiosk 0 Apr  3 17:42 file5

[root@foundation60 mnt]# find /mnt -user root -a -group kiosk ##-a是 并且

/mnt/file5

[root@foundation60 mnt]# find /mnt -user root -o -group kiosk  ##-o或者

/mnt

/mnt/file2

/mnt/file3

/mnt/file4

/mnt/file5

[root@foundation60 mnt]# find /etc/ -maxdepth 1 -name passwd

/etc/passwd

[root@foundation60 mnt]# find /etc/ -mindepth 2 -name passwd

/etc/pam.d/passwd

[root@foundation60 mnt]# ls -l /dev/sda

brw-rw---- 1 root disk 8, 0 Apr  3 15:34 /dev/sda

[root@foundation60 mnt]# ls -l /usr/include/gdbm/dbm.h

lrwxrwxrwx. 1 root root 8 Mar 15 22:09 /usr/include/gdbm/dbm.h -> ../dbm.h

[root@foundation60 mnt]# find / -type b

/dev/sdb1

/dev/sdb

/dev/loop0p2

/dev/loop0p1

/dev/loop0

/dev/sda8

/dev/sda7

/dev/sda6

/dev/sda5

/dev/sda3

/dev/sda2

/dev/sda1

/dev/sda

/dev/sr0

find: ‘/run/user/1000/gvfs’: Permission denied

[root@foundation60 mnt]# ls -l /dev/sda

brw-rw---- 1 root disk 8, 0 Apr  3 15:34 /dev/sda

[root@foundation60 mnt]# find /etc/ -maxdepth 1 -name passwdC

[root@foundation60 mnt]# ls -l /usr/include/gdbm/dbm.h

lrwxrwxrwx. 1 root root 8 Mar 15 22:09 /usr/include/gdbm/dbm.h -> ../dbm.h

[root@foundation60 mnt]# chmod 600 file1

[root@foundation60 mnt]# chmod 640 file2

[root@foundation60 mnt]# chmod 664 file3

[root@foundation60 mnt]# chmod 740 file4

[root@foundation60 mnt]# chmod 777 file5

[root@foundation60 mnt]# find /mnt/ -perm 777

/mnt/file5

[root@foundation60 mnt]# find /mnt/ -perm -777

/mnt/file5

[root@foundation60 mnt]# find /mnt/ -perm -666

/mnt/file5

[root@foundation60 mnt]# find /mnt/ -perm /666

/mnt/

/mnt/file1

/mnt/file2

/mnt/file3

/mnt/file4

/mnt/file5

[root@foundation60 mnt]# find /mnt/ -perm -444

/mnt/

/mnt/file3

/mnt/file5

[root@foundation60 mnt]# find /mnt/ -perm -666 -exec ugo-r {} ;

find: ‘ugo-r’: No such file or directory

[root@foundation60 mnt]# find /mnt/ -perm -666 -exec chmod ugo-r {} ;

[root@foundation60 mnt]# ls -l file5

--wx-wx-wx 1 root kiosk 0 Apr  3 17:42 file5

[root@foundation60 mnt]# find /mnt/ -perm -666 -exec cp {} /mnt/ ;

[root@foundation60 mnt]# find /etc/ -name *.conf -exec cp {} /mnt/ ;

cp: cannot stat ‘/etc/extlinux.conf’: No such file or directory

[root@foundation60 mnt]# find / -group mail -exec cp -cp {} /mnt/mailbackup ;

原文地址:https://www.cnblogs.com/yangying2017/p/6669780.html