


How do I install software and set environment variables with non-root user rights?
Article Directory
Condition
Use root userLinux uses root userLinux compression command, because the permissions are large enough, everything can be done easily
How about the Linux system when non-root users have low permissions? Even yuminstall cannot be used, so how to install software
Install rpm package
1. Take installing the wget tool as an example
First download a wget rpm package on the windows browser
http://www.rpmfind.net/linux/centos/7.9.2009/os/x86_64/Packages/wget-1.14-18.el7_6.1.x86_64.rpm
Simulate offline installation afterwards
2. Use a non-root user to log in to the linux system
<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.
Upload the wget.***.rpm package we downloaded to the linux system
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. Install rpm package
Extracting files
<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
Check
<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
Check
<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. Set environment variables
In the home directory, directly edit the .bashrc file and lower the path of the executable program to the system PATH
In this wayLinux uses the root user and can directly execute the wget command
<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
After saving and exiting
<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.
The above is the detailed content of How do I install software and set environment variables with non-root user rights?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











The five basic components of Linux are: 1. The kernel, managing hardware resources; 2. The system library, providing functions and services; 3. Shell, the interface for users to interact with the system; 4. The file system, storing and organizing data; 5. Applications, using system resources to implement functions.

Linux is widely used in servers, embedded systems and desktop environments. 1) In the server field, Linux has become an ideal choice for hosting websites, databases and applications due to its stability and security. 2) In embedded systems, Linux is popular for its high customization and efficiency. 3) In the desktop environment, Linux provides a variety of desktop environments to meet the needs of different users.

The methods for basic Linux learning from scratch include: 1. Understand the file system and command line interface, 2. Master basic commands such as ls, cd, mkdir, 3. Learn file operations, such as creating and editing files, 4. Explore advanced usage such as pipelines and grep commands, 5. Master debugging skills and performance optimization, 6. Continuously improve skills through practice and exploration.

Linux devices are hardware devices running Linux operating systems, including servers, personal computers, smartphones and embedded systems. They take advantage of the power of Linux to perform various tasks such as website hosting and big data analytics.

The Internet does not rely on a single operating system, but Linux plays an important role in it. Linux is widely used in servers and network devices and is popular for its stability, security and scalability.

The disadvantages of Linux include user experience, software compatibility, hardware support, and learning curve. 1. The user experience is not as friendly as Windows or macOS, and it relies on the command line interface. 2. The software compatibility is not as good as other systems and lacks native versions of many commercial software. 3. Hardware support is not as comprehensive as Windows, and drivers may be compiled manually. 4. The learning curve is steep, and mastering command line operations requires time and patience.

The core of the Linux operating system is its command line interface, which can perform various operations through the command line. 1. File and directory operations use ls, cd, mkdir, rm and other commands to manage files and directories. 2. User and permission management ensures system security and resource allocation through useradd, passwd, chmod and other commands. 3. Process management uses ps, kill and other commands to monitor and control system processes. 4. Network operations include ping, ifconfig, ssh and other commands to configure and manage network connections. 5. System monitoring and maintenance use commands such as top, df, du to understand the system's operating status and resource usage.

The average annual salary of Linux administrators is $75,000 to $95,000 in the United States and €40,000 to €60,000 in Europe. To increase salary, you can: 1. Continuously learn new technologies, such as cloud computing and container technology; 2. Accumulate project experience and establish Portfolio; 3. Establish a professional network and expand your network.
