Ubuntu系统环境配置

Ubuntu安装terminator以及美化

安装

sudo apt-get install terminator

美化

修改或者创建.config/terminator/config文件,添加如下配置

[global_config]
  suppress_multiple_term_dialog = True
  title_font = Sans 11
  title_use_system_font = False
[keybindings]
[layouts]
  [[default]]
    [[[child1]]]
      parent = window0
      type = Terminal
    [[[window0]]]
      parent = ""
      type = Window
[plugins]
[profiles]
  [[default]]
    background_color = "#002b36"
    background_darkness = 0.91
    background_type = transparent
    copy_on_selection = True
    cursor_color = "#e0f0f1"
    font = Ubuntu Mono 12
    foreground_color = "#e0f0f1"
    use_system_font = False

其实这些配置都在界面中可以调节,窗口右键->首选项->profiles->colors,

在这里插入图片描述

修改默认终端工具

安装dconfig-editor

sudo apt-get install dconf-tools

安装成功后,就可以在终端中通过命令 dconf-editor来打开这个工具,然后从左边的的菜单栏中按照下面的步骤依次进入指定的菜单项:

org > gnome > desktop > applications > terminal

此时,我们可以看到使用 Terminator 作为默认终端工具的配置为:

exec terminatorexec-arg -e

如果想使用 gnome-terminal 为默认终端工具的话,就将上面的配置更改为:

exec gnome-terminalexec-arg -x

保存退出之后,使用快捷键 “Ctrl + Alt + T” 启动一个终端时,这时启动起来的就是 gnome-terminal 工具了!

zsh安装以及配置oh my zsh

Mac安装参考:http://www.cnblogs.com/EasonJim/p/6283247.html

zsh与oh-my-zsh区别:http://www.cnblogs.com/EasonJim/p/7863093.html

说明:Ubuntu下默认没有安装zsh,Mac下默认安装了zsh。

注意:安装了oh-my-zsh之后的环境变量入口就会从./bashrc变成./zshrc,这点在配置环境变量的时候要特别小心。可以参考Mac的配置,基本都是同样的:http://www.cnblogs.com/EasonJim/p/6283190.html

安装:

  1. 安装zsh
sudo apt-get install zsh
  1. 把默认的Shell改成zsh
chsh -s /bin/zsh

注意:不要使用sudo。

  1. 配置密码文件,解决chsh: PAM认证失败的问题
sudo vim /etc/passwd

把第一行的/bin/bash改成/bin/zsh,这个是root用户的。

把最后一行的/bin/bash改成/bin/zsh,这个应该是每台电脑的登录用户名+计算机名组成的。

  1. 安装Git
sudo apt-get install git
  1. 安装oh-my-zsh

官网:http://ohmyz.sh/

sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

如果拉不下来脚本,请挂梯子。

  1. 重启电脑,查看效果

  2. 安装autojump自动跳转插件

官网:https://github.com/wting/autojump

安装:

sudo apt-get install autojump

配置教程:cat /usr/share/doc/autojump/README.Debian

配置:

vim ~/.zshrc

在最后一行加入,注意点后面是一个空格

. /usr/share/autojump/autojump.sh

生效:

source ~/.zshrc
  1. 安装zsh-syntax-highlighting语法高亮插件

官网:https://github.com/zsh-users/zsh-syntax-highlighting

安装:

git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

生效:

source ~/.zshrc
  1. 安装zsh-autosuggestions语法历史记录插件

官网:https://github.com/zsh-users/zsh-autosuggestions

安装:

git clone git://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

然后修改~/.zshrc中的plugins配置,增加zsh-autosuggestions

plugins=(zsh-autosuggestions)

生效:

source ~/.zshrc
  1. 配置主题

官方主题参考:https://github.com/robbyrussell/oh-my-zsh/wiki/External-themes

sudo vim ~/.zshrc

找到ZSH_THEME=“robbyrussell”,修改为:ZSH_THEME=“ys”;

生效:

source ~/.zshrc

其实整体的思路如下,在~/.oh-my-zsh文件夹下,
在这里插入图片描述
其中 plugins 和 themes 两个文件夹一个是插件,一个是主题,将这两个文件夹下要使用的插件和主题拷贝到custom下,custom下同样要有 plugins 和 themes 两个文件夹,然后再在~/.zshrc文件中设置相关的主题和插件就行
在这里插入图片描述
在这里插入图片描述
另外,为了避免oh-my-zsh自动检测更新,可以如下设置
在这里插入图片描述

卸载:

执行:

sudo sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/uninstall.sh)"

把/etc/passwd改回bash:

第一行的/bin/bash

最后一行的/bin/bash

其实看样子是很简单的卸载,但是最后你会发现还有很多没有干掉的,在使用上你会慢慢的发现。

配置ubuntu系统 sudo免密码

每次打开新终端使用sudo命令,都需要输入一次密码,不太方便,这里记下取消密码的方法。

sudo vim /etc/sudoers

这里假设用户为kang,在最后一行添加

kang    ALL=(ALL:ALL) NOPASSWD:ALL

如图:
在这里插入图片描述

测试发现,新开终端不用再输入sudo密码。

Ubuntu和Windows双系统时间同步

按照下面的步骤即可

sudo apt-get install ntpdate
sudo su
ntpdate time.windows.com
hwclock --localtime --systohc
reboot

Ubuntu设置启动内核以及删除不用的内核

查看现有的内核

查看现有的高级选项对应的选项,

 grep submenu /boot/grub/grub.cfg

终端显示

submenu 'Ubuntu 的高级选项' $menuentry_id_option 'gnulinux-advanced-aebaaa27-2abd-4f5e-ab67-aa80f5a76841' {

继续查看gnu所有的选项,

grep gnulinux /boot/grub/grub.cfg

终端输出

   set default="gnulinux-advanced-aebaaa27-2abd-4f5e-ab67-aa80f5a76841>gnulinux-5.4.0-74-generic-advanced-aebaaa27-2abd-4f5e-ab67-aa80f5a76841"
menuentry 'Ubuntu' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-aebaaa27-2abd-4f5e-ab67-aa80f5a76841' {
submenu 'Ubuntu 的高级选项' $menuentry_id_option 'gnulinux-advanced-aebaaa27-2abd-4f5e-ab67-aa80f5a76841' {
	menuentry 'Ubuntu,Linux 5.4.0-77-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.4.0-77-generic-advanced-aebaaa27-2abd-4f5e-ab67-aa80f5a76841' {
	menuentry 'Ubuntu, with Linux 5.4.0-77-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.4.0-77-generic-recovery-aebaaa27-2abd-4f5e-ab67-aa80f5a76841' {
	menuentry 'Ubuntu,Linux 5.4.0-74-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.4.0-74-generic-advanced-aebaaa27-2abd-4f5e-ab67-aa80f5a76841' {
	menuentry 'Ubuntu, with Linux 5.4.0-74-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.4.0-74-generic-recovery-aebaaa27-2abd-4f5e-ab67-aa80f5a76841' {
	menuentry 'Ubuntu,Linux 5.4.0-42-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.4.0-42-generic-advanced-aebaaa27-2abd-4f5e-ab67-aa80f5a76841' {
	menuentry 'Ubuntu, with Linux 5.4.0-42-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.4.0-42-generic-recovery-aebaaa27-2abd-4f5e-ab67-aa80f5a76841' {

找到需要设置的内核版本,我需要的版本是5.4.74,记下来其对应的选项

设置启动内核

接下来修改grub,

sudo gedit /etc/default/grub

按如下配置 GRUB_DEFAUTL选项,最好同时注释掉GRUB_TIMEOUT_STYLE

# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
#   info -f grub -n 'Simple configuration'

#GRUB_DEFAULT=0
GRUB_DEFAULT="gnulinux-advanced-aebaaa27-2abd-4f5e-ab67-aa80f5a76841>gnulinux-5.4.0-74-generic-advanced-aebaaa27-2abd-4f5e-ab67-aa80f5a76841"
#GRUB_TIMEOUT_STYLE=hidden
GRUB_TIMEOUT=3
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""

# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"

# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE=640x480
GRUB_GFXMODE=1920x1080

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true

# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_RECOVERY="true"

# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"

最后,

sudo update-grub

重启后,再次查看,检查看现有的内核。

uname -r

删除其他内核

查看所有内核

dpkg --get-selections | grep linux

终端显示

binutils-x86-64-linux-gnu					install
console-setup-linux				    		install
libselinux1:amd64				    		install
libselinux1-dev:amd64						install
linux-base					        		install
linux-firmware					    		install
linux-generic					    		install
linux-generic-hwe-18.04						install
linux-headers-5.4.0-42-generic				hold
linux-headers-5.4.0-74-generic				hold
linux-headers-5.4.0-77						install
linux-headers-5.4.0-77-generic				install
linux-headers-generic						install
linux-headers-generic-hwe-18.04				hold
linux-hwe-5.4-headers-5.4.0-42				install
linux-hwe-5.4-headers-5.4.0-74				install
linux-image-5.4.0-42-generic				hold
linux-image-5.4.0-74-generic				hold
linux-image-5.4.0-77-generic				install
linux-image-generic							install
linux-image-generic-hwe-18.04				hold
linux-libc-dev:amd64						install
linux-modules-5.4.0-42-generic				hold
linux-modules-5.4.0-74-generic				hold
linux-modules-5.4.0-77-generic				install
linux-modules-extra-5.4.0-42-generic		hold
linux-modules-extra-5.4.0-74-generic		hold
linux-modules-extra-5.4.0-77-generic		install
linux-signed-generic-hwe-18.04				install
linux-sound-base							install
pptp-linux									install
util-linux									install

删除冗余的内核,

sudo apt-get remove \
linux-headers-5.4.0-77 \
linux-headers-5.4.0-77-generic \
linux-image-5.4.0-77-generic \
linux-modules-5.4.0-77-generic \
linux-modules-extra-5.4.0-77-generic

卸载后,再重新检查一下现有的内核,

dpkg --get-selections | grep linux

状态为deinstall即已经卸载,如果觉得看着不舒服的话可以使用purge连配置文件里一起彻底删除,清理内核列表

sudo apt-get purge \
linux-headers-5.4.0-77 \
linux-headers-5.4.0-77-generic \
linux-image-5.4.0-77-generic \
linux-modules-5.4.0-77-generic \
linux-modules-extra-5.4.0-77-generic

最后,更新GRUB,

sudo update-grub

Ubuntu安装google中文输入法

更新源和升级到最新的软件

sudo apt-get update && sudo apt-get upgrade

安装fcitx

sudo apt-get install fcitx

安装汉语语言包

sudo apt-get install language-pack-zh-hans

安装谷歌拼音输入法

sudo apt-get install fcitx-googlepinyin

进入设置,点击区域与语言,管理已安装的语言,选择fcitx,
到此,需要重启一下,重启后,点击右上角的语言栏,设置,增加Google输入法就行。

Ubuntu核显独显驱动冲突导致无法启动解决办法

最近给电脑装Ubuntu,安装完了之后发现开机开在/dev/sda。。。。处,分析了半天发现是笔记本核显驱动与独显驱动冲突导致了这个问题,下面记录下解决办法。

黑屏时,按Ctrl+Alt+F3进入终端,输入用户名密码,登录后再禁用nouveau即可,

到/etc/modprobe.d/目录下,创建文件blacklist-nouveau.conf,并在文件里添加如下内容:

blacklist nouveau

options nouveau modeset=0

执行生效,

sudo update-initramfs -u

重启,

sudo reboot

重启后,应该就可以正常进入登录界面了。

另一种方式,设置grub显式启动,这样每次启动时都会先进到grub界面,可以选择进入recovery mode,保持个良好的习惯很重要

sudo gedit /etc/default/grub

里面的显示如下:

# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
#   info -f grub -n 'Simple configuration'

GRUB_DEFAULT=0
GRUB_DEFAULT="gnulinux-advanced-7a6e9b95-e546-4183-9976-579a4e5867fc>gnulinux-5.15.0-88-generic-advanced-7a6e9b95-e546-4183-9976-579a4e5867fc"
#GRUB_TIMEOUT_STYLE=hidden
GRUB_TIMEOUT=3
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash systemd.unified_cgroup_hierarchy=0"
GRUB_CMDLINE_LINUX=""

# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"

# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE=640x480

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true

# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_RECOVERY="true"

# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"

将其中的GRUB_TIMEOUT_STYLE=hidden注释掉,然后GRUB_TIMEOUT这个设置成个人觉得合适的时间,最后不要忘了,

sudo update-grub

Ubuntu开机后,弹出检测到系统程序出现问题解决方法

打开配置文件

sudo gedit /etc/default/apport

然后,将其中的enable选项改成0,即可解决此问题。

Ubuntu ToDesk无法登录问题

  1. 删除配置文件
sudo rm /opt/todesk/config/config.ini
  1. 重启ToDesk服务器
sudo systemctl restart todeskd.service

上述问题解决。

桌面美化和设置dash to panel

安装Tweaks Tools

sudo apt-get update 
sudo apt-get install gnome-tweak-tool

激活Shell Theme

使用FireFox或者Chrome打开 https://extensions.gnome.org (打不开也是请挂梯子),如果遇到错误“native host connector is not detected“,执行下面命令

sudo apt install chrome-gnome-shell

然后回到网址 https://extensions.gnome.org ,刷新一下,搜索 dash to panel,打开输出的结果后,

在这里插入图片描述
将开关打开即可,自动安装,遇到弹窗同意就行。

SwitchyOmega插件设置

SwitchyOmega这个插件肯定是必备的了,在Chrome和Edge中都有这个插件,设置如下:
在这里插入图片描述
其中红色箭头两处,要根据代理服务器的配置进行同步。

在这里插入图片描述
然后,auto switch这里设置如图设置就行,其中规则列表网址如下:

https://raw.githubusercontent.com/gfwlist/gfwlist/master/gfwlist.txt
  • 23
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值