当前位置:   article > 正文

Linux非root用户安装rpm包_linux 普通用户添加rpm

linux 普通用户添加rpm

文章目录

情况

使用root用户,因为权限足够大,所以做什么事都好弄

非root用户,权限低时,连yum install都没法使用,那怎么安装软件呢

安装rpm包

1、以安装wget工具为例

首先在windows浏览器上下载一个wget的rpm包

http://www.rpmfind.net/linux/centos/7.9.2009/os/x86_64/Packages/wget-1.14-18.el7_6.1.x86_64.rpm
  • 1

然后模拟离线安装

2、使用非root用户登录linux系统

# 尝试安装yumdownloader,不行的,需要root权限
[nim01@svngit root]$ yum install yumdownloader
Loaded plugins: fastestmirror
You need to be root to perform this command.

# 尝试执行wget命令,不行,没有安装
[nim01@svngit root]$ wget
bash: wget: command not found

# 尝试安装wget,不行的,需要root权限
[nim01@svngit root]$ yum install wget
Loaded plugins: fastestmirror
You need to be root to perform this command.
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

将我们下载的wget.***.rpm包,上传到linux系统中

Last login: Wed Dec  2 09:44:05 2020
[nim01@svngit ~]$ pwd
/home/nim01
# root已经安装lrzsz了,直接上传
[nim01@svngit ~]$ rz

[nim01@svngit ~]$ ll
total 548
-rw-r--r--. 1 nim01 nim01 560272 Dec  2  2020 wget-1.14-18.el7_6.1.x86_64.rpm
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

3、安装rpm包

提取文件

# 执行下面指令,从安装包中提取文件
[nim01@svngit ~]$ rpm2cpio wget-1.14-18.el7_6.1.x86_64.rpm | cpio -idvm
./etc/wgetrc
./usr/bin/wget
./usr/share/doc/wget-1.14
./usr/share/doc/wget-1.14/AUTHORS
./usr/share/doc/wget-1.14/COPYING
./usr/share/doc/wget-1.14/MAILING-LIST
./usr/share/doc/wget-1.14/NEWS
./usr/share/doc/wget-1.14/README
./usr/share/doc/wget-1.14/sample.wgetrc
./usr/share/info/wget.info.gz
./usr/share/locale/be/LC_MESSAGES/wget.mo
./usr/share/locale/bg/LC_MESSAGES/wget.mo
./usr/share/locale/ca/LC_MESSAGES/wget.mo
./usr/share/locale/cs/LC_MESSAGES/wget.mo
./usr/share/locale/da/LC_MESSAGES/wget.mo
./usr/share/locale/de/LC_MESSAGES/wget.mo
./usr/share/locale/el/LC_MESSAGES/wget.mo
./usr/share/locale/en_GB/LC_MESSAGES/wget.mo
./usr/share/locale/eo/LC_MESSAGES/wget.mo
./usr/share/locale/es/LC_MESSAGES/wget.mo
./usr/share/locale/et/LC_MESSAGES/wget.mo
./usr/share/locale/eu/LC_MESSAGES/wget.mo
./usr/share/locale/fi/LC_MESSAGES/wget.mo
./usr/share/locale/fr/LC_MESSAGES/wget.mo
./usr/share/locale/ga/LC_MESSAGES/wget.mo
./usr/share/locale/gl/LC_MESSAGES/wget.mo
./usr/share/locale/he/LC_MESSAGES/wget.mo
./usr/share/locale/hr/LC_MESSAGES/wget.mo
./usr/share/locale/hu/LC_MESSAGES/wget.mo
./usr/share/locale/id/LC_MESSAGES/wget.mo
./usr/share/locale/it/LC_MESSAGES/wget.mo
./usr/share/locale/ja/LC_MESSAGES/wget.mo
./usr/share/locale/lt/LC_MESSAGES/wget.mo
./usr/share/locale/nb/LC_MESSAGES/wget.mo
./usr/share/locale/nl/LC_MESSAGES/wget.mo
./usr/share/locale/pl/LC_MESSAGES/wget.mo
./usr/share/locale/pt/LC_MESSAGES/wget.mo
./usr/share/locale/pt_BR/LC_MESSAGES/wget.mo
./usr/share/locale/ro/LC_MESSAGES/wget.mo
./usr/share/locale/ru/LC_MESSAGES/wget.mo
./usr/share/locale/sk/LC_MESSAGES/wget.mo
./usr/share/locale/sl/LC_MESSAGES/wget.mo
./usr/share/locale/sr/LC_MESSAGES/wget.mo
./usr/share/locale/sv/LC_MESSAGES/wget.mo
./usr/share/locale/tr/LC_MESSAGES/wget.mo
./usr/share/locale/uk/LC_MESSAGES/wget.mo
./usr/share/locale/vi/LC_MESSAGES/wget.mo
./usr/share/locale/zh_CN/LC_MESSAGES/wget.mo
./usr/share/locale/zh_TW/LC_MESSAGES/wget.mo
./usr/share/man/man1/wget.1.gz
4030 blocks
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53

查看

# 提取完之后,当前目录多了etc和usr两个目录
[nim01@svngit ~]$ ll
total 548
drwxrwxr-x. 2 nim01 nim01     20 Dec  2 10:13 etc
drwxrwxr-x. 4 nim01 nim01     30 Dec  2 10:13 usr
-rw-r--r--. 1 nim01 nim01 560272 Dec  2  2020 wget-1.14-18.el7_6.1.x86_64.rpm
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

查看

# 进入usr/bin目录,可以看到可执行的wget文件
[nim01@svngit ~]$ cd usr/
[nim01@svngit usr]$ ll
total 0
drwxrwxr-x. 2 nim01 nim01 18 Dec  2 10:13 bin
drwxrwxr-x. 6 nim01 nim01 54 Dec  2 10:13 share
[nim01@svngit usr]$ cd bin/
[nim01@svngit bin]$ ll
total 412
-rwxr-xr-x. 1 nim01 nim01 418776 May 16  2019 wget
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

4、设置环境变量

在家目录中,直接编辑.bashrc文件,增加可执行程序的路径到系统PATH
这样,可以直接执行wget指令了

# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi

# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=

# User specific aliases and functions

export PATH=$PATH:$HOME/usr/bin
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

保存退出后

# 执行source,让修改生效
[nim01@svngit ~]$ source .bashrc
# 执行wget,可正常使用
[nim01@svngit ~]$ wget
wget: missing URL
Usage: wget [OPTION]... [URL]...

Try `wget --help' for more options.
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/代码探险家/article/detail/970189
推荐阅读
相关标签
  

闽ICP备14008679号