admin管理员组

文章数量:1530037

Ubuntu的安装并不难,和Windows的安装并无多大区别,只不过在安装过程中会遇到一些问题,如果你不知道怎么解决会很头大,这个时候你看这篇文章,兴许就能帮到你。

安装Ubantu通常有以下三种方案:

  1. 安装Ubantu单系统
  2. 安装Windows和Ubuntu双系统
  3. 安装ubuntu子系统

这三种方式各有优劣,根据自己需要选择。

win10安装ubuntu子系统

以前我们是如何在Windows上使用linux系统的呢?没错,使用虚拟机vmware,vmware能够实现在linux系统上安装任意版本的系统,但是我们知道vmware的效率是很低的,经常我们使用wmware编译的时候就能明显感觉慢了很多,有时甚至是十倍的差距,这是为什么呢?

因为虚拟机安装在Windows上时,Windows的指令和虚拟机中Linux的指令并不通用,因此更多的时候,需要做指令转换,而这么来回转换损耗了一大半性能,也就导致了编译效率低下,所以在一千,我们只会考虑在虚拟机中编译一些简单的程序。

为了弥补这个问题,同时为了让Windows能够运行安卓应用(抢占市场),PC厂商和操作系统厂商开始考虑如何让电脑更高效的运行Ubuntu指令,这就有了Wsl。

新版的win10下就已经内置了linux系统,目的是为了方便开发人员效率,不需要关心性能损耗,这个东西也叫做WSL,关于win10内置linux大家可以看这篇新闻 :
堪称最大Linux发行版:微软Windows 10直接内置Linux完整内核

如何安装

win10下安装linux子系统网上有很多教程,为了方便大家我也把基本的步骤贴出来。

  1. 打开虚拟化HyperV
  2. 安装Windows Feature: WSL
  3. 重启,微软商店里安装“Ubuntu”,也可以安装centos,但是要钱;

由于大家都是windows老手,我就不废话太多了,小白点这里;

更换镜像源

由于外国的源总是不太好用,或是因为速度或是被墙,因此强烈建议小伙伴们在安装完linux系统后更换源,我这里使用的是阿里云的源。(阿里在技术方面真的是强腾讯太多,虽然很多人讨厌马云,但是人家是真的牛逼)

来,跟着我左右右手一个慢动作~~

$ cd /etc/apt    // 切换到apt目录下
$ sudo cp sources.list  sources.list.bak    //先把源文件备份
$ sudo vim source.list     //修改文件
$ sudo apt-get update    //更新

source.list里面写的啥呢?

#deb cdrom:[Ubuntu 16.04 LTS _Xenial Xerus_ - Release amd64 (20160420.1)]/ xenial main restricted
deb-src http://archive.ubuntu/ubuntu xenial main restricted #Added by software-properties
deb http://mirrors.aliyun/ubuntu/ xenial main restricted
deb-src http://mirrors.aliyun/ubuntu/ xenial main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun/ubuntu/ xenial-updates main restricted
deb-src http://mirrors.aliyun/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun/ubuntu/ xenial universe
deb http://mirrors.aliyun/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun/ubuntu/ xenial multiverse
deb http://mirrors.aliyun/ubuntu/ xenial-updates multiverse
deb http://mirrors.aliyun/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.aliyun/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties
deb http://archive.canonical/ubuntu xenial partner
deb-src http://archive.canonical/ubuntu xenial partner
deb http://mirrors.aliyun/ubuntu/ xenial-security main restricted
deb-src http://mirrors.aliyun/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun/ubuntu/ xenial-security universe
deb http://mirrors.aliyun/ubuntu/ xenial-security multiverse

ubantu18配置

上面是针对ubantu16的系统配置,网上有针对ubantu18的配置,应该都差不多吧,当然建议用更贴近自己系统的:

deb http://mirrors.aliyun/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun/ubuntu/ bionic main restricted universe multiverse

deb http://mirrors.aliyun/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun/ubuntu/ bionic-security main restricted universe multiverse

deb http://mirrors.aliyun/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun/ubuntu/ bionic-updates main restricted universe multiverse

deb http://mirrors.aliyun/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun/ubuntu/ bionic-proposed main restricted universe multiverse

deb http://mirrors.aliyun/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun/ubuntu/ bionic-backports main restricted universe multiverse

弄完之后记得更新一下

$ sudo apt-get update

注意:在运行子系统的时候,务必使用管理员方式运行子系统,否则会遇到很多的幺蛾子;

安装Ubuntu系统

安装但系统和双系统的操作其实差不多,双系统就是在原有系统基础上安装ubuntu。由于新版本的ubuntu已经可以识别硬盘上已经安装的操作系统,这让安装双系统变得和安装但系统一样容易,因此这里不过多介绍。

我们可以用软碟通或者imagewriter将Ubuntu镜像写入到U盘中,然后设置从U盘启动,然后就按照提示一步步安装Ubuntu就好了。比较关键的一部时分区,需要你选择安装的分区,如果你希望弄得更加精细,推荐不要把boot,home,system安装在同一个分区中,因为这样会导致你重装系统的时候没办法做到隔离而影响硬盘中的其他重要文件。

不过我就没有这些担心,通常我是所有的都安装在根目录/中,这个看你需要。

安装黑屏

一般来说,你的电脑如果是集显,不会遇到显示问题,但是如果时独立显卡,那就要费点时间了。因为有些电脑安装上去之后,你会发现直接黑屏了进入不了系统,也没办法操作鼠标。此时有三种方法:

  • 进入安装时,光标移动到"install ubuntu",按"e"进入编辑模式,进入命令行模式,找到’‘quite splash’'然后去掉"–"后,添加“nomodeset”(依照不同显卡进行不同显卡驱动选项的添加,我们使用的是Nvidia显卡,添加nomodeset)F10安装

  • 当安装结束后,启动系统出现黑屏
    开机时按住shift不放,出现grub画面,按’‘‘e’’’ 进入编辑开机指令的模式(或者开机直接按“e”), 同样找到’‘‘quitesplash’’’ 并在后面加上“nomodeset”,按’‘F10’'启动系统

  • 开机按shift,选择“recovery model”,进入系统之后打开终端 sudo vi /etc/default/grub按‘ℹ’进入vim的编辑模式 ;

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
#修改为:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash nomodeset"

按“esc”,输入“ :wq! ” (有冒号) 保存退出,grubsudo update-grub更新

在重启之前,我们发现电脑屏幕分辨率不是最佳(如果分辨率正常,则不用)
点击右上角“系统设置—>软件和更新—>附加驱动”选择使用Nvidia驱动

使用后无法进入桌面

有时候用着用着重启就黑屏了(通常是由网络的情况下发生),我解决这种问题的方法时通过ssh登陆上,然后使用推荐的驱动安装,把驱动重新安装一遍。

$ sudo ubuntu-drivers autoinstall

当然你可以自己选择驱动版本,但是我发现最好用的还是用推荐的。

无法识别无线网卡

这个情况之前一直困扰我,搞得我每次都要拉一根长长的网线,后来我发现并不是所有的无线网卡插上去能识别的,你需要买一些ubuntu能直接识别的网卡,通常叫做免驱网卡。当然网上有很多的教程教你怎么安装无线网卡,但是我想说,别去折腾,折腾了未必能生效,买一个免去的网卡真花不了多少钱,实在是太省事了。

远程访问和文件访问

作为开发人员,远程访问一般说的是通过终端访问,而不是远程桌面的方式。但是有的时候通过终端传输文件并不方便,我们希望能够像访问Windows文件夹一样,在Windows上直接访问,这就最好了。这种情况下我推荐在安装系统后安装上samba和ssh。

安装Samba

  1. 安装
samba:  sudo apt install samba samba-common -y 
sudo vim /etc/samba/smb.conf 
  1. 按照提示修改
#======================= Share Definitions =======================
#======================= Share Definitions =======================

# Un-comment the following (and tweak the other settings below to suit)
# to enable the default home directory shares. This will share each
# user's home directory as \\server\username
[homes]# 去掉前面的;
   comment = Home Directories# 去掉前面的;
   browseable = yes# 去掉前面的;

# 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# 去掉前面的;

# 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 = 0755# 去掉前面的;

# 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 = 0755# 去掉前面的;

# 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# 去掉前面的;
  1. 配置
    通常来说我是直接把home目录映射出来,方便远程访问,至于共享文件夹,如果没有这个需求完全没必要创建。
    然后将 samba 加入开机启动项:systemctl enable smbd再启动 samba systemctl start smbd

  2. Samba添加用户:很重要不添加windows访问会被拒绝:

sudo smbpasswd -a zls #zls是我的用户名
下面就输入密码,后面在windows上添加用得到

然后在你Windows 的电脑上右击添加网络位置,位置就是你ubuntu的ip:

安装SSH

#安装ssh
sudo apt-get install openssh-server  
#启动ssh
sudo systemctl start ssh
# 开机启动
sudo systemctl enable ssh

切换源

ubantu自带设置里面可以更换最有的源,大家可以去找找,这里就不说了。

本文标签: 独显文件系统SSHUbuntu