迁移Linux Mint 18.2 apt命令到Ubuntu Server 16.04 LTS

1、问题描述

这里有两台主机,其中

当在192.168.1.25上输入命令apt的时候这样的:

linuxidc@ubuntu:~$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 08:00:27:5e:65:ca brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.25/24 brd 192.168.1.255 scope global enp0s3
       valid_lft forever preferred_lft forever
    inet6 fe80::a00:27ff:fe5e:65ca/64 scope link 
       valid_lft forever preferred_lft forever
linuxidc@ubuntu:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.3 LTS
Release:    16.04
Codename:   xenial
linuxidc@ubuntu:~$ apt
apt 1.2.24 (amd64)
Usage: apt [options] command

apt is a commandline package manager and provides commands for
searching and managing as well as querying information about packages.
It provides the same functionality as the specialized APT tools,
like apt-get and apt-cache, but enables options more suitable for
interactive use bydefault.

Most used commands:
  list - list packages based on package names
  search - search in package descriptions
  show - show package details
  install - install packages
  remove - remove packages
  autoremove - Remove automatically all unused packages
  update - update list of available packages
  upgrade - upgrade the system by installing/upgrading packages
  full-upgrade - upgrade the system by removing/installing/upgrading packages
  edit-sources - edit the source information file

See apt(8) for more information about the available commands.
Configuration options and syntax is detailed in apt.conf(5).
Information about how to configure sources can be found in sources.list(5).
Package and version choices can be expressed via apt_preferences(5).
Security details are available in apt-secure(8).
                                        This APT has Super Cow Powers.
linuxidc@ubuntu:~$ 

当在192.168.1.4上输入命令apt的时候却是这样的:

linuxidc@linuxidccom ~ $ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: wlp2s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000link/ether 9c:b6:d0:dd:fc:f7 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.4/24 brd 192.168.1.255 scope global dynamic wlp2s0
       valid_lft 246699sec preferred_lft 246699sec
    inet6 fe80::a0fd:f518:e91a:dde0/64 scope link 
       valid_lft forever preferred_lft forever
linuxidc@linuxidccom ~ $ lsb_release -a
No LSB modules are available.
Distributor ID: LinuxMint
Description:    Linux Mint 18.2 Sonya
Release:    18.2
Codename:   sonya
linuxidc@linuxidccom ~ $ apt
apt
Usage: apt command [options]
       apt help command [options]

Commands:
  add-repository   - Add entries to apt sources.list
  autoclean        - Erase old downloaded archive files
  autoremove       - Remove automatically all unused packages
  build            - Build binary or source packages from sources
  build-dep        - Configure build-dependencies for source packages
  changelog        - View a package's changelog check - Verify that there are no broken dependencies clean - Erase downloaded archive files contains - List packages containing a file content - List files contained in a package deb - Install a .deb package depends - Show raw dependency information for a package dist-upgrade - Upgrade the system by removing/installing/upgrading packages download - Download the .deb file for a package edit-sources - Edit /etc/apt/sources.list with your preferred text editor dselect-upgrade - Follow dselect selections full-upgrade - Same as 'dist-upgrade' held - List all held packages help - Show help for a command hold - Hold a package install - Install/upgrade packages list - List packages based on package names policy - Show policy settings purge - Remove packages and their configuration files recommends - List missing recommended packages for a particular package rdepends - Show reverse dependency information for a package reinstall - Download and (possibly) reinstall a currently installed package remove - Remove packages search - Search for a package by name and/or expression show - Display detailed information about a package showhold - Same as 'held' source - Download source archives sources - Same as 'edit-sources' unhold - Unhold a package update - Download lists of new/upgradable packages upgrade - Perform a safe upgrade version - Show the installed version of a package linuxidc@linuxidccom ~ $ apt help install "apt install " is equivalent to "sudo /usr/bin/apt install " linuxidc@linuxidccom ~ $ apt help add-repository "apt add-repository " is equivalent to "sudo add-apt-repository " linuxidc@linuxidccom ~ $ apt help purge "apt purge " is equivalent to "sudo /usr/bin/apt purge " linuxidc@linuxidccom ~ $ 

有没有一种办法让Ubuntu Server 16.04.3 LT系统也拥有Linux Mint 18.2 Sonya那样的apt功能呢?

2、解决方案

让我我们先查找一下apt命令的出处吧。

在主机192.168.1.4上我们输入如下命令

linuxidc@linuxidccom ~ $ whereis apt
apt: /usr/bin/apt /usr/lib/apt /etc/apt /usr/local/bin/apt /usr/share/man/man8/apt.8.gz
linuxidc@linuxidccom ~ $ 

在主机192.168.1.4上我们输入如下命令

linuxidc@ubuntu:~$ whereis apt
apt: /usr/bin/apt /usr/lib/apt /etc/apt /usr/share/man/man8/apt.8.gz
linuxidc@ubuntu:~$ 

通过对比,我们发现Linux Mint 18.2 Sonya系统中的目录/usr/local/bin/下面多了一个apt文件。那么我们假定将Linux Mint 18.2 Sonya系统中的文件/usr/local/bin/apt复制一份放到Ubuntu Server 16.04.3 LT系统中的目录/usr/local/bin/下,会不会有效果��,我们不防试一下。

在主机192.168.1.25上我们输入如下命令

linuxidc@ubuntu:~$ ll
total 36
drwxr-xr-x 4 linuxidc  lwk  4096 Nov 23 00:06 ./
drwxr-xr-x 3 root root 4096 Nov 10 11:20 ../
-rw------- 1 linuxidc lwk 3479 Nov 23 00:03 .bash_history
-rw-r--r-- 1 linuxidc lwk 220 Nov 10 11:20 .bash_logout
-rw-r--r-- 1 linuxidc lwk 3771 Nov 10 11:20 .bashrc
drwx------ 2 linuxidc lwk 4096 Nov 10 11:30 .cache/
-rw-r--r-- 1 linuxidc lwk 655 Nov 10 11:20 .profile
drwx------ 2 linuxidc lwk 4096 Nov 10 11:42 .ssh/
-rw-r--r-- 1 linuxidc lwk 0 Nov 10 11:38 .sudo_as_admin_successful
-rw------- 1 root root 3433 Nov 23 00:00 .viminfo
linuxidc@ubuntu:~$ 

这时,在主机192.168.1.4上我们输入如下命令

linuxidc@linuxidccom ~ $ scp /usr/local/bin/apt linuxidc@192.168.1.25:~/
apt                                                                                                                                                                                                         100% 63296.2KB/s   00:00    
linuxidc@linuxidccom ~ $ 

切换到主机192.168.1.25上输入如下命令

linuxidc@ubuntu:~$ ll
total 44
drwxr-xr-x 4 linuxidc  lwk  4096 Nov 23 00:48 ./
drwxr-xr-x 3 root root 4096 Nov 10 11:20 ../
-rwxr-xr-x 1 linuxidc lwk 6329 Nov 23 00:48 apt*-rw------- 1 linuxidc lwk 3479 Nov 23 00:03 .bash_history-rw-r--r-- 1 linuxidc lwk 220 Nov 10 11:20 .bash_logout-rw-r--r-- 1 linuxidc lwk 3771 Nov 10 11:20 .bashrc
drwx------ 2 linuxidc  lwk  4096 Nov 10 11:30 .cache/
-rw-r--r-- 1 linuxidc lwk 655 Nov 10 11:20 .profile
drwx------ 2 linuxidc  lwk  4096 Nov 10 11:42 .ssh/
-rw-r--r-- 1 linuxidc lwk 0 Nov 10 11:38 .sudo_as_admin_successful-rw------- 1 root root 3433 Nov 23 00:00 .viminfo
linuxidc@ubuntu:~$ 

这时候我们发现apt文件的归属不对,这里改一下,然后将其扔到/usr/local/bin/,然后查看有没有生效。

linuxidc@ubuntu:~$ sudo chown root:root apt
[sudo] password forlinuxidc: 
lwk@ubuntu:~$ ll
total 44
drwxr-xr-x 4 linuxidc  lwk  4096 Nov 2300:48 ./
drwxr-xr-x 3 root root 4096 Nov 1011:20 ../
-rwxr-xr-x 1 root root 6329 Nov 2300:48 apt*
-rw------- 1 linuxidc  lwk  3479 Nov 2300:03 .bash_history
-rw-r--r-- 1 linuxidc  lwk   220 Nov 1011:20 .bash_logout
-rw-r--r-- 1 linuxidc  lwk  3771 Nov 1011:20 .bashrc
drwx------ 2 linuxidc  lwk  4096 Nov 1011:30 .cache/
-rw-r--r-- 1 linuxidc  lwk   655 Nov 1011:20 .profile
drwx------ 2 linuxidc  lwk  4096 Nov 1011:42 .ssh/
-rw-r--r-- 1 linuxidc  lwk     0 Nov 1011:38 .sudo_as_admin_successful
-rw------- 1 root root 3433 Nov 2300:00 .viminfo
linuxidc@ubuntu:~$ sudo mv apt /usr/local/bin/ 
linuxidc@ubuntu:~$ apt
apt
Usage: apt command [options]
       apt help command [options]

Commands:
  add-repository   - Add entries to apt sources.list
  autoclean        - Erase old downloaded archive files
  autoremove       - Remove automatically all unused packages
  build            - Build binary or source packages from sources
  build-dep        - Configure build-dependencies for source packages
  changelog        - View a package's changelog check - Verify that there are no broken dependencies clean - Erase downloaded archive files contains - List packages containing a file content - List files contained in a package deb - Install a .deb package depends - Show raw dependency information for a package dist-upgrade - Upgrade the system by removing/installing/upgrading packages download - Download the .deb file for a package edit-sources - Edit /etc/apt/sources.list with your preferred text editor dselect-upgrade - Follow dselect selections full-upgrade - Same as 'dist-upgrade' held - List all held packages help - Show help for a command hold - Hold a package install - Install/upgrade packages list - List packages based on package names policy - Show policy settings purge - Remove packages and their configuration files recommends - List missing recommended packages for a particular package rdepends - Show reverse dependency information for a package reinstall - Download and (possibly) reinstall a currently installed package remove - Remove packages search - Search for a package by name and/or expression show - Display detailed information about a package showhold - Same as 'held' source - Download source archives sources - Same as 'edit-sources' unhold - Unhold a package update - Download lists of new/upgradable packages upgrade - Perform a safe upgrade version - Show the installed version of a package linuxidc@ubuntu:~$ 

至此,我们发现已经将Linux Mint 18.2 Sonya系统中的apt命令成功迁移到了Ubuntu Server 16.04.3 LT系统。

文章来源网络,作者:运维,如若转载,请注明出处:https://shuyeidc.com/wp/213472.html<

(0)
运维的头像运维
上一篇2025-04-11 08:27
下一篇 2025-04-11 08:28

相关推荐

  • 个人主题怎么制作?

    制作个人主题是一个将个人风格、兴趣或专业领域转化为视觉化或结构化内容的过程,无论是用于个人博客、作品集、社交媒体账号还是品牌形象,核心都是围绕“个人特色”展开,以下从定位、内容规划、视觉设计、技术实现四个维度,详细拆解制作个人主题的完整流程,明确主题定位:找到个人特色的核心主题定位是所有工作的起点,需要先回答……

    2025-11-20
    0
  • 社群营销管理关键是什么?

    社群营销的核心在于通过建立有温度、有价值、有归属感的社群,实现用户留存、转化和品牌传播,其管理需贯穿“目标定位-内容运营-用户互动-数据驱动-风险控制”全流程,以下从五个维度展开详细说明:明确社群定位与目标社群管理的首要任务是精准定位,需明确社群的核心价值(如行业交流、产品使用指导、兴趣分享等)、目标用户画像……

    2025-11-20
    0
  • 香港公司网站备案需要什么材料?

    香港公司进行网站备案是一个涉及多部门协调、流程相对严谨的过程,尤其需兼顾中国内地与香港两地的监管要求,由于香港公司注册地与中国内地不同,其网站若主要服务内地用户或使用内地服务器,需根据服务器位置、网站内容性质等,选择对应的备案路径(如工信部ICP备案或公安备案),以下从备案主体资格、流程步骤、材料准备、注意事项……

    2025-11-20
    0
  • 如何企业上云推广

    企业上云已成为数字化转型的核心战略,但推广过程中需结合行业特性、企业痛点与市场需求,构建系统性、多维度的推广体系,以下从市场定位、策略设计、执行落地及效果优化四个维度,详细拆解企业上云推广的实践路径,精准定位:明确目标企业与核心价值企业上云并非“一刀切”的方案,需先锁定目标客户群体,提炼差异化价值主张,客户分层……

    2025-11-20
    0
  • PS设计搜索框的实用技巧有哪些?

    在PS中设计一个美观且功能性的搜索框需要结合创意构思、视觉设计和用户体验考量,以下从设计思路、制作步骤、细节优化及交互预览等方面详细说明,帮助打造符合需求的搜索框,设计前的规划明确使用场景:根据网站或APP的整体风格确定搜索框的调性,例如极简风适合细线条和纯色,科技感适合渐变和发光效果,电商类则可能需要突出搜索……

    2025-11-20
    0

发表回复

您的邮箱地址不会被公开。必填项已用 * 标注