如何在 Linux 上安装/卸载一个文件中列出的软件包?
在某些情况下,你可能想要将一个服务器上的软件包列表安装到另一个服务器上。例如,你已经在服务器 A 上安装了 15 个软件包并且这些软件包也需要被安装到服务器 B、服务器 C 上等等。
我们可以手动去安装这些软件但是这将花费大量的时间。你可以手动安装一俩个服务器,但是试想如果你有大概十个服务器呢。在这种情况下你无法手动完成工作,那么怎样才能解决问题呢?
不要担心我们可以帮你摆脱这样的情况和场景。我们在这篇文章中增加了四种方法来克服困难。
我希望这可以帮你解决问题。我已经在 CentOS7 和 Ubuntu 18.04 上测试了这些命令。
我也希望这可以在其他发行版上工作。这仅仅需要使用该发行版的官方包管理器命令替代本文中的包管理器命令就行了。
如果想要 检查 Linux 系统上已安装的软件包列表,请点击链接。
例如,如果你想要在基于 RHEL 系统上创建软件包列表请使用以下步骤。其他发行版也一样。
<span>#</span><span> rpm </span><span>-</span><span>qa </span><span>--</span><span>last</span><span>|</span><span>head</span><span>-</span><span>15</span><span>|</span><span> awk </span><span>'{print $1}'</span><span>></span><span>/tmp/</span><span>pack1</span><span>.</span><span>txt</span>
<span>#</span><span>cat</span><span>/</span><span>tmp</span><span>/</span><span>pack1</span><span>.</span><span>txt</span>
<span>mariadb</span><span>-</span><span>server</span><span>-</span><span>5.5</span><span>.</span><span>60</span><span>-</span><span>1.el7_5.x86</span><span>_64</span>
<span>perl</span><span>-</span><span>DBI</span><span>-</span><span>1.627</span><span>-</span><span>4.el7.x86</span><span>_64</span>
<span>perl</span><span>-</span><span>DBD</span><span>-</span><span>MySQL</span><span>-</span><span>4.023</span><span>-</span><span>6.el7.x86</span><span>_64</span>
<span>perl</span><span>-</span><span>PlRPC</span><span>-</span><span>0.2020</span><span>-</span><span>14.el7.noarch</span>
<span>perl</span><span>-</span><span>Net</span><span>-</span><span>Daemon</span><span>-</span><span>0.48</span><span>-</span><span>5.el7.noarch</span>
<span>perl</span><span>-</span><span>IO</span><span>-</span><span>Compress</span><span>-</span><span>2.061</span><span>-</span><span>2.el7.noarch</span>
<span>perl</span><span>-</span><span>Compress</span><span>-</span><span>Raw</span><span>-</span><span>Zlib</span><span>-</span><span>2.061</span><span>-</span><span>4.el7.x86</span><span>_64</span>
<span>mariadb</span><span>-</span><span>5.5</span><span>.</span><span>60</span><span>-</span><span>1.el7_5.x86</span><span>_64</span>
<span>perl</span><span>-</span><span>Data</span><span>-</span><span>Dumper</span><span>-</span><span>2.145</span><span>-</span><span>3.el7.x86</span><span>_64</span>
<span>perl</span><span>-</span><span>Compress</span><span>-</span><span>Raw</span><span>-</span><span>Bzip2</span><span>-</span><span>2.061</span><span>-</span><span>3.el7.x86</span><span>_64</span>
<span>httpd</span><span>-</span><span>2.4</span><span>.</span><span>6</span><span>-</span><span>88.el7.centos</span><span>.</span><span>x86_64</span>
<span>mailcap</span><span>-</span><span>2.1</span><span>.</span><span>41</span><span>-</span><span>2.el7.noarch</span>
<span>httpd</span><span>-</span><span>tools</span><span>-</span><span>2.4</span><span>.</span><span>6</span><span>-</span><span>88.el7.centos</span><span>.</span><span>x86_64</span>
<span>apr</span><span>-</span><span>util</span><span>-</span><span>1.5</span><span>.</span><span>2</span><span>-</span><span>6.el7.x86</span><span>_64</span>
<span>apr</span><span>-</span><span>1.4</span><span>.</span><span>8</span><span>-</span><span>3.el7_4.1</span><span>.</span><span>x86_64</span>
方法一:如何在 Linux 上使用 cat 命令安装文件中列出的包?
为实现这个目标,我将使用简单明了的第一种方法。为此,创建一个文件并添加上你想要安装的包列表。
出于测试的目的,我们将只添加以下的三个软件包名到文件中。
<span>#</span><span>cat</span><span>/</span><span>tmp</span><span>/</span><span>pack1</span><span>.</span><span>txt</span>
<span>apache2</span>
<span>mariadb</span><span>-</span><span>server</span>
<span>nano</span>
只要简单的运行 apt 命令 就能在 Ubuntu/Debian 系统上一次性安装所有的软件包。
<span>#</span><span> apt </span><span>-</span><span>y install $</span><span>(</span><span>cat</span><span>/</span><span>tmp</span><span>/</span><span>pack1</span><span>.</span><span>txt</span><span>)</span>
<span>Reading</span><span>package</span><span> lists</span><span>...</span><span>Done</span>
<span>Building</span><span> dependency tree</span>
<span>Reading</span><span> state information</span><span>...</span><span>Done</span>
<span>The</span><span> following packages were automatically installed </span><span>and</span><span> are </span><span>no</span><span> longer required</span><span>:</span>
<span>libopts25 sntp</span>
<span>Use</span><span>'sudo apt autoremove'</span><span> to remove them</span><span>.</span>
<span>Suggested</span><span> packages</span><span>:</span>
<span>apache2</span><span>-</span><span>doc apache2</span><span>-</span><span>suexec</span><span>-</span><span>pristine </span><span>|</span><span> apache2</span><span>-</span><span>suexec</span><span>-</span><span>custom spell</span>
<span>The</span><span> following NEW packages will be installed</span><span>:</span>
<span>apache2 mariadb</span><span>-</span><span>server </span><span>nano</span>
<span>0</span><span> upgraded</span><span>,</span><span>3</span><span> newly installed</span><span>,</span><span>0</span><span> to remove </span><span>and</span><span>24</span><span>not</span><span> upgraded</span><span>.</span>
<span>Need</span><span> to </span><span>get</span><span>339</span><span> kB of archives</span><span>.</span>
<span>After</span><span>this</span><span> operation</span><span>,</span><span>1</span><span>,</span><span>377</span><span> kB of additional disk space will be used</span><span>.</span>
<span>Get</span><span>:</span><span>1</span><span> http</span><span>:</span><span>//in.archive.ubuntu.com/ubuntu bionic-updates/main amd64 apache2 amd64 2.4.29-1ubuntu4.6 [95.1 kB]</span>
<span>Get</span><span>:</span><span>2</span><span> http</span><span>:</span><span>//in.archive.ubuntu.com/ubuntu bionic/main amd64 nano amd64 2.9.3-2 [231 kB]</span>
<span>Get</span><span>:</span><span>3</span><span> http</span><span>:</span><span>//in.archive.ubuntu.com/ubuntu bionic-updates/universe amd64 mariadb-server all 1:10.1.38-0ubuntu0.18.04.1 [12.9 kB]</span>
<span>Fetched</span><span>339</span><span> kB </span><span>in</span><span>19s</span><span>(</span><span>18.0</span><span> kB</span><span>/</span><span>s</span><span>)</span>
<span>Selecting</span><span> previously unselected </span><span>package</span><span> apache2</span><span>.</span>
<span>(</span><span>Reading</span><span> database </span><span>...</span><span>290926</span><span> files </span><span>and</span><span> directories currently installed</span><span>.)</span>
<span>Preparing</span><span> to unpack </span><span>.../</span><span>apache2_2</span><span>.</span><span>4.29</span><span>-</span><span>1ubuntu4.6</span><span>_amd64</span><span>.</span><span>deb </span><span>...</span>
<span>Unpacking</span><span> apache2 </span><span>(</span><span>2.4</span><span>.</span><span>29</span><span>-</span><span>1ubuntu4.6</span><span>)</span><span>...</span>
<span>Selecting</span><span> previously unselected </span><span>package</span><span>nano</span><span>.</span>
<span>Preparing</span><span> to unpack </span><span>.../</span><span>nano_2</span><span>.</span><span>9.3</span><span>-</span><span>2</span><span>_amd64</span><span>.</span><span>deb </span><span>...</span>
<span>Unpacking</span><span>nano</span><span>(</span><span>2.9</span><span>.</span><span>3</span><span>-</span><span>2</span><span>)</span><span>...</span>
<span>Selecting</span><span> previously unselected </span><span>package</span><span> mariadb</span><span>-</span><span>server</span><span>.</span>
<span>Preparing</span><span> to unpack </span><span>.../</span><span>mariadb</span><span>-</span><span>server_1</span><span>%</span><span>3a10.1</span><span>.</span><span>38</span><span>-</span><span>0ubuntu0.18</span><span>.</span><span>04.1</span><span>_all</span><span>.</span><span>deb </span><span>...</span>
<span>Unpacking</span><span> mariadb</span><span>-</span><span>server </span><span>(</span><span>1</span><span>:</span><span>10.1</span><span>.</span><span>38</span><span>-</span><span>0ubuntu0.18</span><span>.</span><span>04.1</span><span>)</span><span>...</span>
<span>Processing</span><span> triggers </span><span>for</span><span> ufw </span><span>(</span><span>0.36</span><span>-</span><span>0ubuntu0.18</span><span>.</span><span>04.1</span><span>)</span><span>...</span>
<span>Setting</span><span> up apache2 </span><span>(</span><span>2.4</span><span>.</span><span>29</span><span>-</span><span>1ubuntu4.6</span><span>)</span><span>...</span>
<span>Processing</span><span> triggers </span><span>for</span><span> ureadahead </span><span>(</span><span>0.100</span><span>.</span><span>0</span><span>-</span><span>20</span><span>)</span><span>...</span>
<span>Processing</span><span> triggers </span><span>for</span><span> install</span><span>-</span><span>info</span><span>(</span><span>6.5</span><span>.</span><span>0.dfsg</span><span>.</span><span>1</span><span>-</span><span>2</span><span>)</span><span>...</span>
<span>Setting</span><span> up </span><span>nano</span><span>(</span><span>2.9</span><span>.</span><span>3</span><span>-</span><span>2</span><span>)</span><span>...</span>
<span>update</span><span>-</span><span>alternatives</span><span>:</span><span>using</span><span>/</span><span>bin</span><span>/</span><span>nano</span><span> to provide </span><span>/</span><span>usr</span><span>/</span><span>bin</span><span>/</span><span>editor </span><span>(</span><span>editor</span><span>)</span><span>in</span><span>auto</span><span> mode</span>
<span>update</span><span>-</span><span>alternatives</span><span>:</span><span>using</span><span>/</span><span>bin</span><span>/</span><span>nano</span><span> to provide </span><span>/</span><span>usr</span><span>/</span><span>bin</span><span>/</span><span>pico </span><span>(</span><span>pico</span><span>)</span><span>in</span><span>auto</span><span> mode</span>
<span>Processing</span><span> triggers </span><span>for</span><span>systemd</span><span>(</span><span>237</span><span>-</span><span>3ubuntu10.20</span><span>)</span><span>...</span>
<span>Processing</span><span> triggers </span><span>for</span><span>man</span><span>-</span><span>db </span><span>(</span><span>2.8</span><span>.</span><span>3</span><span>-</span><span>2ubuntu0.1</span><span>)</span><span>...</span>
<span>Setting</span><span> up mariadb</span><span>-</span><span>server </span><span>(</span><span>1</span><span>:</span><span>10.1</span><span>.</span><span>38</span><span>-</span><span>0ubuntu0.18</span><span>.</span><span>04.1</span><span>)</span><span>...</span>
至于删除,需要使用相同的命令格式和适当的选项。
<span>#</span><span> apt </span><span>-</span><span>y remove $</span><span>(</span><span>cat</span><span>/</span><span>tmp</span><span>/</span><span>pack1</span><span>.</span><span>txt</span><span>)</span>
<span>Reading</span><span>package</span><span> lists</span><span>...</span><span>Done</span>
<span>Building</span><span> dependency tree</span>
<span>Reading</span><span> state information</span><span>...</span><span>Done</span>
<span>The</span><span> following packages were automatically installed </span><span>and</span><span> are </span><span>no</span><span> longer required</span><span>:</span>
<span>apache2</span><span>-</span><span>bin apache2</span><span>-</span><span>data apache2</span><span>-</span><span>utils galera</span><span>-</span><span>3</span><span> libaio1 libapr1 libaprutil1 libaprutil1</span><span>-</span><span>dbd</span><span>-</span><span>sqlite3 libaprutil1</span><span>-</span><span>ldap libconfig</span><span>-</span><span>inifiles</span><span>-</span><span>perl libdbd</span><span>-</span><span>mysql</span><span>-</span><span>perl libdbi</span><span>-</span><span>perl libjemalloc1 liblua5</span><span>.</span><span>2</span><span>-</span><span>0</span>
<span>libmysqlclient20 libopts25 libterm</span><span>-</span><span>readkey</span><span>-</span><span>perl mariadb</span><span>-</span><span>client</span><span>-</span><span>10.1</span><span> mariadb</span><span>-</span><span>client</span><span>-</span><span>core</span><span>-</span><span>10.1</span><span> mariadb</span><span>-</span><span>common mariadb</span><span>-</span><span>server</span><span>-</span><span>10.1</span><span> mariadb</span><span>-</span><span>server</span><span>-</span><span>core</span><span>-</span><span>10.1</span><span> mysql</span><span>-</span><span>common sntp socat</span>
<span>Use</span><span>'apt autoremove'</span><span> to remove them</span><span>.</span>
<span>The</span><span> following packages will be REMOVED</span><span>:</span>
<span>apache2 mariadb</span><span>-</span><span>server </span><span>nano</span>
<span>0</span><span> upgraded</span><span>,</span><span>0</span><span> newly installed</span><span>,</span><span>3</span><span> to remove </span><span>and</span><span>24</span><span>not</span><span> upgraded</span><span>.</span>
<span>After</span><span>this</span><span> operation</span><span>,</span><span>1</span><span>,</span><span>377</span><span> kB disk space will be freed</span><span>.</span>
<span>(</span><span>Reading</span><span> database </span><span>...</span><span>291046</span><span> files </span><span>and</span><span> directories currently installed</span><span>.)</span>
<span>Removing</span><span> apache2 </span><span>(</span><span>2.4</span><span>.</span><span>29</span><span>-</span><span>1ubuntu4.6</span><span>)</span><span>...</span>
<span>Removing</span><span> mariadb</span><span>-</span><span>server </span><span>(</span><span>1</span><span>:</span><span>10.1</span><span>.</span><span>38</span><span>-</span><span>0ubuntu0.18</span><span>.</span><span>04.1</span><span>)</span><span>...</span>
<span>Removing</span><span>nano</span><span>(</span><span>2.9</span><span>.</span><span>3</span><span>-</span><span>2</span><span>)</span><span>...</span>
<span>update</span><span>-</span><span>alternatives</span><span>:</span><span>using</span><span>/</span><span>usr</span><span>/</span><span>bin</span><span>/</span><span>vim</span><span>.</span><span>tiny to provide </span><span>/</span><span>usr</span><span>/</span><span>bin</span><span>/</span><span>editor </span><span>(</span><span>editor</span><span>)</span><span>in</span><span>auto</span><span> mode</span>
<span>Processing</span><span> triggers </span><span>for</span><span> ufw </span><span>(</span><span>0.36</span><span>-</span><span>0ubuntu0.18</span><span>.</span><span>04.1</span><span>)</span><span>...</span>
<span>Processing</span><span> triggers </span><span>for</span><span> install</span><span>-</span><span>info</span><span>(</span><span>6.5</span><span>.</span><span>0.dfsg</span><span>.</span><span>1</span><span>-</span><span>2</span><span>)</span><span>...</span>
<span>Processing</span><span> triggers </span><span>for</span><span>man</span><span>-</span><span>db </span><span>(</span><span>2.8</span><span>.</span><span>3</span><span>-</span><span>2ubuntu0.1</span><span>)</span><span>...</span>
使用 yum 命令 在基于 RHEL (如 Centos、RHEL (RedHat) 和 OEL (Oracle Enterprise Linux)) 的系统上安装文件中列出的软件包。
<span>#</span><span>yum</span><span>-</span><span>y install $</span><span>(</span><span>cat</span><span>/</span><span>tmp</span><span>/</span><span>pack1</span><span>.</span><span>txt</span><span>)</span>
使用以命令在基于 RHEL (如 Centos、RHEL (Redhat) 和 OEL (Oracle Enterprise Linux)) 的系统上卸载文件中列出的软件包。
<span>#</span><span>yum</span><span>-</span><span>y remove $</span><span>(</span><span>cat</span><span>/</span><span>tmp</span><span>/</span><span>pack1</span><span>.</span><span>txt</span><span>)</span>
使用以下 dnf 命令 在 Fedora 系统上安装文件中列出的软件包。
<span>#</span><span> dnf </span><span>-</span><span>y install $</span><span>(</span><span>cat</span><span>/</span><span>tmp</span><span>/</span><span>pack1</span><span>.</span><span>txt</span><span>)</span>
使用以下命令在 Fedora 系统上卸载文件中列出的软件包。
<span>#</span><span> dnf </span><span>-</span><span>y remove $</span><span>(</span><span>cat</span><span>/</span><span>tmp</span><span>/</span><span>pack1</span><span>.</span><span>txt</span><span>)</span>
使用以下 zypper 命令 在 openSUSE 系统上安装文件中列出的软件包。
<span>#</span><span> zypper </span><span>-</span><span>y install $</span><span>(</span><span>cat</span><span>/</span><span>tmp</span><span>/</span><span>pack1</span><span>.</span><span>txt</span><span>)</span>
使用以下命令从 openSUSE 系统上卸载文件中列出的软件包。
<span>#</span><span> zypper </span><span>-</span><span>y remove $</span><span>(</span><span>cat</span><span>/</span><span>tmp</span><span>/</span><span>pack1</span><span>.</span><span>txt</span><span>)</span>
使用以下 pacman 命令 在基于 Arch Linux (如 Manjaro 和 Antergos) 的系统上安装文件中列出的软件包。
<span>#</span><span> pacman </span><span>-</span><span>S $</span><span>(</span><span>cat</span><span>/</span><span>tmp</span><span>/</span><span>pack1</span><span>.</span><span>txt</span><span>)</span>
使用以下命令从基于 Arch Linux (如 Manjaro 和 Antergos) 的系统中卸载文件中列出的软件包。
<span>#</span><span> pacman </span><span>-</span><span>Rs</span><span> $</span><span>(</span><span>cat</span><span>/</span><span>tmp</span><span>/</span><span>pack1</span><span>.</span><span>txt</span><span>)</span>
方法二:如何使用 cat 和 xargs 命令在 Linux 中安装文件中列出的软件包。
甚至,我更喜欢使用这种方法,因为这是一种非常简单直接的方法。
使用以下 apt
命令在基于 Debian 的系统 (如 Debian、Ubuntu 和 Linux Mint) 上安装文件中列出的软件包。
<span>#</span><span>cat</span><span>/</span><span>tmp</span><span>/</span><span>pack1</span><span>.</span><span>txt </span><span>|</span><span>xargs</span><span> apt </span><span>-</span><span>y install</span>
使用以下 apt
命令 从基于 Debian 的系统 (如 Debian、Ubuntu 和 Linux Mint) 上卸载文件中列出的软件包。
<span>#</span><span>cat</span><span>/</span><span>tmp</span><span>/</span><span>pack1</span><span>.</span><span>txt </span><span>|</span><span>xargs</span><span> apt </span><span>-</span><span>y remove</span>
使用以下 yum
命令在基于 RHEL (如 Centos,RHEL (Redhat) 和 OEL (Oracle Enterprise Linux)) 的系统上安装文件中列出的软件包。
<span>#</span><span>cat</span><span>/</span><span>tmp</span><span>/</span><span>pack1</span><span>.</span><span>txt </span><span>|</span><span>xargs</span><span>yum</span><span>-</span><span>y install</span>
使用以命令从基于 RHEL (如 Centos、RHEL (Redhat) 和 OEL (Oracle Enterprise Linux)) 的系统上卸载文件中列出的软件包。
<span>#</span><span>cat</span><span>/</span><span>tmp</span><span>/</span><span>pack1</span><span>.</span><span>txt </span><span>|</span><span>xargs</span><span>yum</span><span>-</span><span>y remove</span>
使用以下 dnf
命令在 Fedora 系统上安装文件中列出的软件包。
<span>#</span><span>cat</span><span>/</span><span>tmp</span><span>/</span><span>pack1</span><span>.</span><span>txt </span><span>|</span><span>xargs</span><span> dnf </span><span>-</span><span>y install</span>
使用以下命令从 Fedora 系统上卸载文件中列出的软件包。
<span>#</span><span>cat</span><span>/</span><span>tmp</span><span>/</span><span>pack1</span><span>.</span><span>txt </span><span>|</span><span>xargs</span><span> dnf </span><span>-</span><span>y remove</span>
使用以下 zypper
命令在 openSUSE 系统上安装文件中列出的软件包。
<span>#</span><span>cat</span><span>/</span><span>tmp</span><span>/</span><span>pack1</span><span>.</span><span>txt </span><span>|</span><span>xargs</span><span> zypper </span><span>-</span><span>y install</span>
使用以下命令从 openSUSE 系统上卸载文件中列出的软件包。
<span>#</span><span>cat</span><span>/</span><span>tmp</span><span>/</span><span>pack1</span><span>.</span><span>txt </span><span>|</span><span>xargs</span><span> zypper </span><span>-</span><span>y remove</span>
使用以下 pacman
命令在基于 Arch Linux (如 Manjaro 和 Antergos) 的系统上安装文件中列出的软件包。
<span>#</span><span>cat</span><span>/</span><span>tmp</span><span>/</span><span>pack1</span><span>.</span><span>txt </span><span>|</span><span>xargs</span><span> pacman </span><span>-</span><span>S</span>
使用下以命令从基于 Arch Linux (如 Manjaro 和 Antergos) 的系统上卸载文件中列出的软件包。
<span>#</span><span>cat</span><span>/</span><span>tmp</span><span>/</span><span>pack1</span><span>.</span><span>txt </span><span>|</span><span>xargs</span><span> pacman </span><span>-</span><span>Rs</span>
方法三 : 如何使用 For 循环在 Linux 上安装文件中列出的软件包
我们也可以使用 for
循环命令来实现此目的。
安装批量包可以使用以下一条 for
循环的命令。
<span>#</span><span>for</span><span> pack </span><span>in</span><span>`cat /tmp/pack1.txt`</span><span>;</span><span>do</span><span> apt </span><span>-</span><span>y install $i</span><span>;</span><span>done</span>
要使用 shell 脚本安装批量包,请使用以下 for
循环。
<span>#</span><span>vi</span><span>/</span><span>opt</span><span>/</span><span>scripts</span><span>/</span><span>bulk</span><span>-</span><span>package</span><span>-</span><span>install</span><span>.</span><span>sh</span>
<span>#</span><span>!</span><span>/bin/</span><span>bash</span>
<span>for</span><span> pack </span><span>in</span><span>`cat /tmp/pack1.txt`</span>
<span>do</span><span> apt </span><span>-</span><span>y remove $pack</span>
<span>done</span>
为 bulk-package-install.sh
设置可执行权限。
<span>#</span><span>chmod</span><span>+</span><span> bulk</span><span>-</span><span>package</span><span>-</span><span>install</span><span>.</span><span>sh</span>
最后运行这个脚本。
<span>#</span><span> sh bulk</span><span>-</span><span>package</span><span>-</span><span>install</span><span>.</span><span>sh</span>
方法四:如何使用 While 循环在 Linux 上安装文件中列出的软件包
我们也可以使用 while
循环命令来实现目的。
安装批量包可以使用以下一条 while
循环的命令。
<span>#</span><span>file</span><span>=</span><span>"/tmp/pack1.txt"</span><span>;</span><span>while</span><span> read </span><span>-</span><span>r pack</span><span>;</span><span>do</span><span> apt </span><span>-</span><span>y install $pack</span><span>;</span><span>done</span><span><</span><span>"$file"</span>
要使用 shell 脚本安装批量包,请使用以下 while
循环。
<span>#</span><span>vi</span><span>/</span><span>opt</span><span>/</span><span>scripts</span><span>/</span><span>bulk</span><span>-</span><span>package</span><span>-</span><span>install</span><span>.</span><span>sh</span>
<span>#</span><span>!</span><span>/bin/</span><span>bash</span>
<span>file</span><span>=</span><span>"/tmp/pack1.txt"</span>
<span>while</span><span> read </span><span>-</span><span>r pack</span>
<span>do</span><span> apt </span><span>-</span><span>y remove $pack</span>
<span>done</span><span><</span><span>"$file"</span>
为 bulk-package-install.sh
设置可执行权限。
<span>#</span><span>chmod</span><span>+</span><span> bulk</span><span>-</span><span>package</span><span>-</span><span>install</span><span>.</span><span>sh</span>
最后运行这个脚本。
<span>#</span><span> sh bulk</span><span>-</span><span>package</span><span>-</span><span>install</span><span>.</span><span>sh</span>
via: https://www.2daygeek.com/how-to-install-uninstall-listed-packages-from-a-file-in-linux/
作者:Magesh Maruthamuthu 选题:lujun9972 译者:way-ww 校对:wxy