如何在非 root 用户权限下安装软件并设置环境变量?
文章目录
情况
使用root用户linux使用root用户linux压缩命令,由于权限足够大,所以做哪些事都好弄
非root用户,权限低时linux系统怎么样,连yuminstall都无法使用,那如何安装软件呢
安装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
之后模拟离线安装
2、使用非root用户登入linux系统
<span class="token comment"># 尝试安装yumdownloader,不行的,需要root权限</span> <span class="token punctuation">[</span>nim01@svngit root<span class="token punctuation">]</span>$ yum <span class="token function">install</span> yumdownloader Loaded plugins: fastestmirror You need to be root to perform this command. <span class="token comment"># 尝试执行wget命令,不行,没有安装</span> <span class="token punctuation">[</span>nim01@svngit root<span class="token punctuation">]</span>$ <span class="token function">wget</span> bash: wget: <span class="token function">command</span> not found <span class="token comment"># 尝试安装wget,不行的,需要root权限</span> <span class="token punctuation">[</span>nim01@svngit root<span class="token punctuation">]</span>$ yum <span class="token function">install</span> <span class="token function">wget</span> Loaded plugins: fastestmirror You need to be root to perform this command.
将我们下载的wget.***.rpm包,上传到linux系统中
Last login: Wed Dec2 09:44:05 2020 <span class="token punctuation">[</span>nim01@svngit ~<span class="token punctuation">]</span>$ <span class="token function">pwd</span> /home/nim01 <span class="token comment"># root已经安装lrzsz了,直接上传</span> <span class="token punctuation">[</span>nim01@svngit ~<span class="token punctuation">]</span>$ rz <span class="token punctuation">[</span>nim01@svngit ~<span class="token punctuation">]</span>$ ll total 548 -rw-r--r--. 1 nim01 nim01 560272 Dec22020 wget-1.14-18.el7_6.1.x86_64.rpm
3、安装rpm包
提取文件
<span class="token comment"># 执行下面指令,从安装包中提取文件</span> <span class="token punctuation">[</span>nim01@svngit ~<span class="token punctuation">]</span>$ rpm2cpio wget-1.14-18.el7_6.1.x86_64.rpm <span class="token operator">|</span> 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
查看
<span class="token comment"># 提取完之后,当前目录多了etc和usr两个目录</span> <span class="token punctuation">[</span>nim01@svngit ~<span class="token punctuation">]</span>$ ll total 548 drwxrwxr-x. 2 nim01 nim01 20 Dec2 10:13 etc drwxrwxr-x. 4 nim01 nim01 30 Dec2 10:13 usr -rw-r--r--. 1 nim01 nim01 560272 Dec22020 wget-1.14-18.el7_6.1.x86_64.rpm
查看
<span class="token comment"># 进入usr/bin目录,可以看到可执行的wget文件</span> <span class="token punctuation">[</span>nim01@svngit ~<span class="token punctuation">]</span>$ <span class="token function">cd</span> usr/ <span class="token punctuation">[</span>nim01@svngit usr<span class="token punctuation">]</span>$ ll total 0 drwxrwxr-x. 2 nim01 nim01 18 Dec2 10:13 bin drwxrwxr-x. 6 nim01 nim01 54 Dec2 10:13 share <span class="token punctuation">[</span>nim01@svngit usr<span class="token punctuation">]</span>$ <span class="token function">cd</span> bin/ <span class="token punctuation">[</span>nim01@svngit bin<span class="token punctuation">]</span>$ ll total 412 -rwxr-xr-x. 1 nim01 nim01 418776 May 162019 <span class="token function">wget</span>
4、设置环境变量
在家目录中,直接编辑.bashrc文件,降低可执行程序的路径到系统PATH中
这样linux使用root用户,可以直接执行wget指令了
<span class="token comment"># .bashrc</span> <span class="token comment"># Source global definitions</span> <span class="token keyword">if</span> <span class="token punctuation">[</span> -f /etc/bashrc <span class="token punctuation">]</span><span class="token punctuation">;</span> <span class="token keyword">then</span> <span class="token keyword">.</span> /etc/bashrc <span class="token keyword">fi</span> <span class="token comment"># Uncomment the following line if you don't like systemctl's auto-paging feature:</span> <span class="token comment"># export SYSTEMD_PAGER=</span> <span class="token comment"># User specific aliases and functions</span> <span class="token function">export</span> PATH<span class="token operator">=</span><span class="token variable">$PATH</span><span class="token keyword">:</span><span class="token variable">$HOME</span>/usr/bin
保存退出后
<span class="token comment"># 执行source,让修改生效</span> <span class="token punctuation">[</span>nim01@svngit ~<span class="token punctuation">]</span>$ <span class="token function">source</span> .bashrc <span class="token comment"># 执行wget,可正常使用</span> <span class="token punctuation">[</span>nim01@svngit ~<span class="token punctuation">]</span>$ <span class="token function">wget</span> wget: missing URL Usage: <span class="token function">wget</span> <span class="token punctuation">[</span>OPTION<span class="token punctuation">]</span><span class="token punctuation">..</span>. <span class="token punctuation">[</span>URL<span class="token punctuation">]</span><span class="token punctuation">..</span>. Try `wget --help' <span class="token keyword">for</span> <span class="token function">more</span> options.
以上是如何在非 root 用户权限下安装软件并设置环境变量?的详细内容。更多信息请关注PHP中文网其他相关文章!

热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

Video Face Swap
使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

热工具

记事本++7.3.1
好用且免费的代码编辑器

SublimeText3汉化版
中文版,非常好用

禅工作室 13.0.1
功能强大的PHP集成开发环境

Dreamweaver CS6
视觉化网页开发工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

Linux管理员的平均年薪在美国为75,000至95,000美元,欧洲为40,000至60,000欧元。提升薪资可以通过:1.持续学习新技术,如云计算和容器技术;2.积累项目经验并建立Portfolio;3.建立职业网络,拓展人脉。

Linux系统管理员的主要任务包括系统监控与性能调优、用户管理、软件包管理、安全管理与备份、故障排查与解决、性能优化与最佳实践。1.使用top、htop等工具监控系统性能,并进行调优。2.通过useradd等命令管理用户账户和权限。3.利用apt、yum管理软件包,确保系统更新和安全。4.配置防火墙、监控日志、进行数据备份以确保系统安全。5.通过日志分析和工具使用进行故障排查和解决。6.优化内核参数和应用配置,遵循最佳实践提升系统性能和稳定性。

Linux的主要用途包括:1.服务器操作系统,2.嵌入式系统,3.桌面操作系统,4.开发和测试环境。Linux在这些领域表现出色,提供了稳定性、安全性和高效的开发工具。

Linux和Windows在虚拟化支持上的主要区别在于:1)Linux提供KVM和Xen,性能和灵活性突出,适合高定制环境;2)Windows通过Hyper-V支持虚拟化,界面友好,与Microsoft生态系统紧密集成,适合依赖Microsoft软件的企业。

学习Linux并不难。1.Linux是一个开源操作系统,基于Unix,广泛应用于服务器、嵌入式系统和个人电脑。2.理解文件系统和权限管理是关键,文件系统是层次化的,权限包括读、写和执行。3.包管理系统如apt和dnf使得软件管理方便。4.进程管理通过ps和top命令实现。5.从基本命令如mkdir、cd、touch和nano开始学习,再尝试高级用法如shell脚本和文本处理。6.常见错误如权限问题可以通过sudo和chmod解决。7.性能优化建议包括使用htop监控资源、清理不必要文件和使用sy

多年来,Linux软件分布依赖于DEB和RPM等本地格式,并深深地根深蒂固。 但是,Flatpak和Snap已经出现,有望成为应用程序包装的通用方法。 本文考试

本指南探讨了用于比较Linux中文本文件的各种方法,Linux是系统管理员和开发人员的关键任务。 我们将介绍命令行工具和视觉差异工具,突出显示其优势和适当的用例。 假设

Linux和Windows在用户账户管理上的主要区别在于权限模型和管理工具。Linux使用基于Unix的权限模型和命令行工具(如useradd、usermod、userdel),而Windows采用自己的安全模型和图形用户界面(GUI)管理工具。
