Ubuntu 18安装和各种问题处理

1、Ubuntu 18.04 LTS 更换国内源

1.1、更换/etc/apt/sources.list文件里的源

1. 备份源列表

Ubuntu配置的默认源并不是国内的服务器,下载更新软件都比较慢。首先备份源列表文件sources.list

 # 首先备份源列表
 sudo cp /etc/apt/sources.list /etc/apt/sources.list_backup

2. 打开sources.list文件修改

选择合适的源,替换原文件的内容,保存编辑好的文件, 以阿里云更新服务器为例(可以分别测试阿里云、清华、中科大、163源的速度,选择最快的):

 # 打开sources.list文件
 sudo gedit /etc/apt/sources.list

编辑/etc/apt/sources.list文件, 在文件最前面添加阿里云镜像源:

ubuntu镜像_ubuntu下载地址_ubuntu安装教程-阿里巴巴开源镜像站

 
#  阿里源
 deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
 deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
 deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
 deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
 deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
 deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
 deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
 deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
 deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
 deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

3. 刷新列表

 sudo apt-get update
 sudo apt-get upgrade
 sudo apt-get install build-essential

下载速度瞬间就起飞了。

4. 其他源

中科大源:

 #  中科大源
 deb https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
 deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
 deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
 deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
 deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
 deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
 deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
 deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
 deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
 deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse

163源:

 # 163源
 deb http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse
 deb http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse
 deb http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse
 deb http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse
 deb http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse
 deb-src http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse
 deb-src http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse
 deb-src http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse
 deb-src http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse
 deb-src http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse

清华源:

 
# 清华源
 deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
 deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
 deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
 deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
 deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
 deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
 deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
 deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
 deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
 deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse

更换sources.list速度依然还是很慢就请继续往下看第二种方法。

1.2、更换software&updates里的select best server**

这种方法不需要改什么文件,直接在select best server里自动选择。

  1. 首先在Show Applications找Software & Updates:

搜索software & updates

打开software & updates

  1. 打开software & updates,download from里选择other:

  1. 然后点击select best server按钮,它会找到最快的那个,然后点击choose server,就选好镜像了:

我这里搜到的阿里云的源

  1. 把other software选项中除了阿里云的镜像源的对勾都去掉了,目前没有啥影响:

  1. 终端里输入sudo apt-get update,速度瞬间快的飞起。

 sudo apt-get update

2、如何清除缓存

要做到这一点,你需要下载并安装一个名为 Ubuntu Cleaner 的工具。在命令行输入如下命令:

 sudo add-apt-repository ppa:gerardpuig/ppa
 sudo apt update
 sudo apt install ubuntu-cleaner

一旦以上所有命令成功,Ubuntu Cleaner 将安装在您的系统上。要启动它,请指向 Unity Dash,输入工具的名称,然后单击它的图标。

这是工具的界面。

从上面的截图可以清楚地看到,Ubuntu Cleaner 可以删除应用程序(浏览器和软件中心)缓存,系统为快速加载目录而创建的缩略图缓存,以及 APT 缓存(通常是下载包的缓存)。此外,还可以使用实用工具来删除旧的内核,包的配置,和不需要的软件包。

要查看某个缓存在系统中占用了多少空间,只需点击相应的条目即可。例如,Chrome 浏览器占用的缓存是500 多兆。

要删除缓存,请选择条目,然后点击工具右下角的清除按钮。

在你开始使用 Ubuntu Cleaner 清理所有东西之前,要记住缓存是有目的的(如本教程开头所解释的)。在删除任何东西之前,你必须权衡你的选择 —— 例如,对于你不再使用的应用程序,删除它的缓存是有意义的,但是对于你经常使用的应用程序,删除它的缓存将直接影响它的响应速度。

Stacer系统清洁剂

是一个免费的,开源的系统优化器和Linux系统监控工具,具有优雅直观的GUI。 它具有您期望从系统优化程序中获得的有用功能,以及实时系统资源监视器(如系统清理程序)。

Stacer系统清洁剂

其设计精美的仪表板可让您访问丰富的系统信息; 允许您清除应用程序缓存,分析系统启动,启动/停止系统服务等等,从而卸载应用程序。 此外,它可以无缝地适应您预先配置的系统外观和感觉。

要在您的Ubuntu及其衍生产品上安装Stacer ,请使用以下官方PPA进行安装,如图所示。

 sudo apt install software-properties-common
 sudo add-apt-repository ppa:oguzhaninan/stacer 
 sudo apt update 
 sudo apt install stacer 

对于其他Linux发行版,

3、主机与虚拟机的ubuntu的文件夹共享

  第一种方式:通过挂载指令mount完成,但是不能自动启动;

  第二种方式:采用网络磁盘来访问ubuntu共享文件夹

  在虚拟系统ubuntu下右击要共享的文件夹,选择属性,共享,启动“共享此目录”,并允许他人在此共享里写数据。注:共享时需要Samba的支持,系统会提示安装,安装完成后,需要重启ubuntu才能生效 。此时回到XP时可在网上邻居里看到一个*** - desktop server(Samba,Ubuntu)的共享目录。

  在选择安装samba的时候,自动安装总是出现问题,可以选择手动安装

  指令为:

 sudo apt-get install samba

  此时在主机系统下的网上另据里就可以看到一个ubuntu的共享目录。

1.samba

 sudo apt-get install samba -y

设置window系统登入共享文件夹的用户名和密码,其中用户名必须为Ubuntu中的用户

 sudo smbpasswd -a username

修改配置文件 在文件末尾添加配置信息

 sudo gedit /etc/samba/smb.conf

若vim没有安装,先安装:

 sudo apt-get install vim

增加内容如下,首先在[global]下增加security项

 # 说明需要密码才能访问共享目录
    security = user

其次在smb.conf文件的末尾添加如下配置信息并保存即可

   [share]
      comment = My Share Directories
      browseable = yes
      path = /home/rainner/share
   
   # By default, the home directories are exported read-only. Change the
   # next parameter to 'no' if you want to be able to write to them.
      read only = no 
      writable = yes
   
   # File creation mask is set to 0700 for security reasons. If you want to
   # create files with group=rw permissions, set next parameter to 0775.
      create mask = 0777
   
   # Directory creation mask is set to 0700 for security reasons. If you want to
   # create dirs. with group=rw permissions, set next parameter to 0775.
      directory mask = 0777
   
   # By default, \\server\username shares can be connected to by anyone
   # with access to the samba server.
   # Un-comment the following parameter to make sure that only "username"
   # can connect to \\server\username
   # This might need tweaking when using external authentication schemes
   ;   valid users = %S

重启samba服务

 sudo service samba restart  |  sudo systemctl restart smbd.service

2.windows登录

在windows资源浏览器中输入: \ip 点击登录

修改文件夹属性的时候

 sudo mkdir /home/share
 sudo chmod -R 777 /home/share

3.查看samba状态

 sudo service samba status

删除用户

 sudo smbpasswd -x username

禁用用户

 sudo smbpasswd -d username

可能出现的问题 从windows登录后,连接发生中断,或者连接速度慢 可以尝试使用以下命令解决:

sudo apt-get install –reinstall libsmbclient libsmbclient-dev libtevent0 libtalloc2 sudo service samba restart

4、su认证失败

Ubuntu 安装后,root用户默认是被锁定了的,不允许登录,也不允许 "su" 到 root。有人说这是个不好的实践,特别是对于服务器来说。我觉得对于桌面用户来说,这样安全性更高一些,是应该的;但对于服务器可以设置成允许 "su" 到root,但不允许root用户直接登录”。而我为了开发时的方便,则在桌面和服务器上都采用这种方式。

问题:su认证失败

使用su命令登录到root用户时,老是报"su:认证失败"错误。报这个错误的原因是root用户默认是被锁定了的,只要使用passwd命令重新设置下root密码即可。问题如下:

1 me@ubuntu:~$ su 2 密码:<--- 输入安装时root用户的密码 3 su:认证失败

允许 su 到 root

非常简单,只需要重新设置下密码即可。下面是设置的方法:

 1 me@ubuntu:~$ sudo passwd 
 2 密码:<--- 输入安装时那个用户的密码
 3 输入新的 UNIX 密码:<--- 新的Root用户密码
 4 重新输入新的 UNIX 密码:<--- 重复新的Root用户密码
 5 passwd:已成功更新密码 
 6 me@ubuntu:~$ su 
 7 密码:<--输入重置的新密码 
 8 root@ubuntu:/home/me#     #已经进入root用户

允许root登录 如果要允许root登录(不推荐,注:这一步依赖上一步"允许su到root"),则这样操作:

1 me@ubuntu:~$ gksu /usr/sbin/gdmsetup

或者:

2 使用桌面菜单:系统>系统管理>登录窗口,点“安全”选项页,选择“允许本地管理员登录”。

root用户切换到普通用户有以下三种

想从root用户切回user用户只需执行命令:su user (user是你自己安装时候的用户名),

2、直接输入exit,

3、Ctrl+D组合键退出

不输入密码直接登录 在论坛上也看见有人抱怨,家中的Ubuntu不能像Window$那样──不用输入密码就能登录。其实同样能做到:

1 就在上一步的“安全”选项页中,勾选:“启用自动登录”,“用户”选择(如:“me”);

注意:公共用的计算机千万不能这么设置!

5、yum 不可用:There are no enabled repos.

  yum install smaba-client -y
 There are no enabled repos.
  Run "yum repolist all" to see the repos you have.
  You can enable repos with yum-config-manager --enable <repo>

一般来说著名的linux系统基本上分两大类: 1 RedHat系列:Redhat、Centos、Fedora等 2 Debian系列:Debian、Ubuntu等 RedHat 系列: 1 常见的安装包格式 rpm 包,安装rpm包的命令是 “rpm -参数” 2 包管理工具 yum 3 支持tar包 Debian系列 1 常见的安装包格式 deb 包,安装deb包的命令是 “dpkg -参数” 2 包管理工具 apt-get 3 支持tar包 所以你Ubuntu不该用yum 该用apt-get

盲猜是不是没有安装wget源? 敲个wget -v检测一下版本试试

Ubuntu

img

原因Ubuntu不支持yum 下载、安装的机制,应该使用apt-get包工具进行安装分别安装:

 apt-get install openssl
 apt-get install libssl-dev

6、ubuntu W: GPG 错误:

Index of /fossfreedom/indicator-sysmonitor/ubuntu xenial InRelease:

img

 sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys F42ED6FBAB17C654

7、windows复制文字到虚拟机

 sudo apt-get autoremove open-vm-tools
 ​
 sudo apt-get install open-vm-tools-desktop 

系统会提示是否确认,输入“y”即可 然后restart就完成了。

8、ppa.launchpad.net:80问题

 错误:1 http://ppa.launchpad.net/fish-shell/release-3/ubuntu bionic/main amd64 fish amd64 3.3.1-1~bionic
   无法发起与 ppa.launchpad.net:80 (2001:67c:1560:8008::19) 的连接 - connect (101: 网络不可达) 无法连接上 ppa.launchpad.net:80 (91.189.95.85)。 - connect (111: 拒绝连接)
 E: 无法下载 http://ppa.launchpad.net/fish-shell/release-3/ubuntu/pool/main/f/fish/fish_3.3.1-1~bionic_amd64.deb  无法发起与 ppa.launchpad.net:80 (2001:67c:1560:8008::19) 的连接 - connect (101: 网络不可达) 无法连接上 ppa.launchpad.net:80 (91.189.95.85)。 - connect (111: 拒绝连接)
 E: 有几个软件包无法下载,要不运行 apt-get update 或者加上 --fix-missing 的选项再试试?

9、科学网络

前面的步骤操作成功可以看到这里有一个clash-linux-amd64的文件。这里记得将这个文件的文件名更改为clash

 找到商家获取订阅地址,将可用的订阅地址替换下方命令中的订阅地址四个字,组成一个可用的命令。
 wget -O config.yaml 订阅地址?clash=1&log-level=info
 拼好这段字符后记得输入到终端并执行
 输入 ./clash -d .
 提示权限不够 输入 chmod +x clash
 再输入 ./clash -d.
 如果输出了图中的信息,则说明已经启动成功。

打开 Clash 如果前面的操作都正确,则会显示图中的内容

在系统设置里面设置网络代理,改为手动 改成下图所演示,一点不差

点击手动,然后下面的 http,https,socks,忽略主机 4个需要和图中的一致。

以后每次开机如果需要使用clash都要打开终端cd到我们创建好的clash文件夹,输入 ./clash -d . 并且网络代理要设为手动。

注意:如果不使用代理则在系统设置中关闭,否者无法使用网络。

10、在状态栏显示网速

添加ppa源

 sudo add-apt-repository ppa:fossfreedom/indicator-sysmonitor
 ​
 sudo apt-get update
 ​
 sudo apt-get install indicator-sysmonitor

勾选Run on startup开机启动

{}内的内容填写的是Sensor

img

若出现:下列软件包有未满足的依赖关系: gsettings-desktop-schemas : 破坏: mutter (< 3.31.4)

 解决
 sudo apt-get install gsettings-desktop-schemas

启动

 indicator-sysmonitor &

11、安装、卸载

使用Synaptic软件包管理器进行卸载

 sudo apt-get install synaptic

安装离线包

 sudo dpkg -i ****.deb

 浏览已安装的程序
 dpkg -l
 ​
 卸载程序和所有配置文件
 sudo apt-get --purge remove <programname>
 ​
 只卸载程序。如果你移除程序但保留配置文件
 sudo apt-get remove <programname>

12、链接ln的使用:创建和删除符号链接

用户默认安装软件位置:/usr/bin/

 ln [option] source_file dist_file   (source_file是待建立链接文件的文件,dist_file是新创建的链接文件)
 ​
 -f 建立时,将同档案名删除. 
 -i 删除前进行询问. 
 ln -s source dist        # 建立软连接
 如:ln -s /usr/bin/python3.6 /usr/bin/python
 ln source dist           # 建立硬连接
 ​
 删除符号链接,有创建就有删除
 sudo rm -rf   symbolic_name

软链接与硬链接的区别(通俗)

 1、硬链接可认为是一个文件拥有两个文件名;而软链接则是系统新建一个链接文件,此文件指向其所要指的文件
 ​
 2、软链接可对文件和文件夹,而硬链接仅针对文件。

13、如果安装过程中提示缺少相关依赖

则执行如下命令解决:

 sudo apt -f install

14、Ubuntu安装docker

Uninstall old versions

 sudo apt-get remove docker docker-engine docker.io containerd runc

Set up the repository

Update the apt package index and install packages to allow apt to use a repository over HTTPS:

  sudo apt-get update
  
  sudo apt-get install \
     ca-certificates \
     curl \
     gnupg \
     lsb-release

Add Docker’s official GPG key:

 curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
 ​

Use the following command to set up the stable repository. To add the nightly or test repository, add the word nightly or test (or both) after the word stable in the commands below. Learn about nightly and test channels.

 echo \
   "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

Install Docker Engine

  sudo apt-get update
  sudo apt-get install docker-ce docker-ce-cli containerd.io

List the versions available in your repo:

 apt-cache madison docker-ce
 ​
 ​
 sudo apt-get install docker-ce=<VERSION_STRING> docker-ce-cli=<VERSION_STRING> containerd.io

Verify that Docker Engine is installed correctly by running the hello-world image.

 sudo docker run hello-world

出现访问权限问题

 Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/images/search?limit=25&term=ubuntu": dial unix /var/run/docker.sock: connect: permission denied
 groupadd docker       #添加docker用户组
 ​
 sudo gpasswd -a 用户名 docker  #将登陆用户加入到docker用户组中
 ​
 newgrp docker #更新用户组
 ​
 #最后重启docker生效:
 systemctl restart docker

15、docker命令

安装离线容器 docker load < phoenix.tar.tz

显示安装的所有容器 docker images

 REPOSITORY                           TAG       IMAGE ID       CREATED        SIZE
 hello-world                          latest    feb5d9fea6a5   3 months ago   13.3kB
 boostport/hbase-phoenix-all-in-one   2.0-5.0   3447675f547f   9 months ago   849MB

插入就绪容器中 -----》 上面的 此操作要开放端口

 docker run -it -d -p 2181:2181 -p 8765:8765 -p 15165:15165 -p 16000:16000 -p 16010:16010 -p 16020:16020 --name phoenix boostport/hbase-phoenix-all-in-one:2.0-5.0

显示所有就绪容器docker ps -a

停止运行就绪容器docker stop CONTAINER ID或NAMES

删除就绪容器docker rm CONTAINER ID或NAMES删除容器

进入运行容器docker exec -it {phoenix--->上面的CONTAINER ID或NAMES} bash

重新运行就绪容器docker restart CONTAINER ID或NAMES删除容器

 /opt/phoenix-server/bin/sqlline.py localhost
 export HBASE_CONF_DIR=/opt/hbase/conf/
 ​
 ​

16、开放端口

1.安装iptables(一般情况,ubuntu安装好的时候,iptables会被安装上),使用以下命令:

 $apt-get update 
 $apt-get install iptables

2.安装完后,开放2181端口,使用以下命令:

 $ iptables -I INPUT -p tcp --dport 2181 -j ACCEPT

3.保存规则

 $ iptables-save

这样可以开放指定的端口,但是如果服务器重启,不会保存,所以我们需要对上述规则进行一下持续化操作

4.持续化规则:使用 iptables-persistent

4.1首先安装iptables-persistent

 $ apt-get install iptables-persistent

4.2.永久保存规则

 $ netfilter-persistent save
 $ netfilter-persistent reload

这样就可以永久打开需要的端口。

  • 17
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值