欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  科技

Ubuntu18.04初始化

程序员文章站 2022-11-06 20:23:38
Ubuntu18.04初始化 1. 更新源: 2. 添加中文输入法:(Ubuntu18.04版使用fctix+sougoupinyin选词乱码) Setting Region & Language Manage Installed Languages Select 在 中添加 3. 安装Chrome ......

ubuntu18.04初始化

  1. 更新源:
    • sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
    • sudo gedit /etc/apt/sources.list
        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
    • sudo apt-get update
    • sudo apt-get upgrade
  2. 添加中文输入法:(ubuntu18.04版使用fctix+sougoupinyin选词乱码)
    • setting->region & language->manage installed languages
    • select install
    • shutdown -r now
    • input source中添加chinese(pinyin)
  3. 安装chrome:
    • sudo wget http://www.linuxidc.com/files/repo/google-chrome.list -p /etc/apt/sources.list.d/
    • wget -q -o - https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
    • 上面命令如果失败则在/etc/apt/sources.list.d/google-chrome.list中删除deb [arch=amd64] https://repo.fdzh.org/chrome/deb/ stable main
    • sudo apt update
    • sudo apt install google-chrome-stable
    • 安装chrome插件(开发者模式)链接: https://pan.baidu.com/s/1z0ugy9xealf3f74lnc5lzq 提取码: f3fc
    • google用户登陆chrome。。。
  4. 安装配置git和vim:
    • sudo apt-get install git vim
    • 配置git:
      • git config --global user.name "xxx"
      • git config --global user.email "xxx@xx.com"
      • ssh-keygen -t rsa -c "xxx@xx.com"
      • cat ~/.ssh/id_rsa.pub
      • 将生成的ssh-key配置到github中即可。
    • 配置vim:
      • mkdir -p ~/.vim/bundle
      • git clone https://github.com/vundlevim/vundle.vim.git ~/.vim/bundle/vundle.vim
      • cd ~/.vim
      • mkdir colors
      • git clone https://github.com/tomasr/molokai.git
      • cp -a molokai/colors/* colors/
      • cd ~ & gedit .vimrc
      • .vimrc配置如下:
      set number
      "set nonumber
      "设置行间距
      set linespace=15
      "配色
      colorscheme molokai
      "不与vi兼容,采用vim自己的操作命令
      set nocompatible
      "语法高亮
      syntax on
      "在底部显示模式
      set showmode
      "命令模式下,在底部显示当前输入的指令
      set showcmd
      "支持使用鼠标
      set mouse=a
      set selection=exclusive
      set selectmode=mouse,key
      "设置粘贴模式
      "set paste
      "共享剪贴板
      set clipboard=unnamed
      "使用 utf-8编码 缓存文本
      set encoding=utf-8
      "文件编码
      set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936
      "输出终端编码
      set termencoding=utf-8
      "按下回车键之后,下一行的缩进会自动跟上一行的缩进保持一致
      set autoindent
      "按下tab键之后,vim显示的空格数
      set tabstop=4
      "tab键自动转为空格
      set expandtab
      "tab转为多少个空格
      set softtabstop=4
      "显示光标所在的当前行的行号,其他行都为相对于改行的相对行号
      "set relativenumber
      "光标所在的当前行高亮
      set cursorline
      "设置行宽
      "set textwidth=80
      "自动折行
      "set wrap
      "set nowrap
      "只有遇到指定的符号,才发生折行,不会在单次内部折行
      "set linebreak
      "指定折行处与编辑窗口右边缘之间空出的字符数
      "set wrapmargin=2
      "垂直滚动时,光标距离顶部或底部的位置
      "set scrolloff=5
      "水平滚动时,光标距离行首或行尾的距离
      "set sidescrolloff=15
      "是否显示状态栏
      set laststatus=2
      "在状态栏显示光标的当前位置
      set ruler
      "光标遇到圆括号,方括号,自动高亮对应另一半
      set showmatch
      "搜索时,高亮匹配结果
      set hlsearch
      "输入搜索模式,每输入一个字符,就自动跳到第一个匹配的结果
      set incsearch
      "搜索是忽略大小写
      "set ignorecase
      "英语拼写检查
      "set spell spelllang=en_us
      "自动切换工作目录到正在编辑的文件
      set autochdir
      "vim需要记住多少次历史操作
      set history=1000
      "打开文件监视,防止文件在外部被更改
      set autoread
      " 命令模式下,底部操作指令按下tab键自动补全
      set wildmenu
      set wildmode=longest:list,full
      "配置插件管理器vundle
      set rtp+=~/.vim/bundle/vundle.vim "runtimepath运行路径
      call vundle#begin()
      "在这里安装插件
      plugin 'gmarik/vundle.vim'
      "安装nerdtree
      plugin 'scrooloose/nerdtree'
      "支持markdown
      plugin 'godlygeek/tabular'
      plugin 'plasticboy/vim-markdown'
      plugin 'suan/vim-instant-markdown'
      call vundle#end()
      " 确保文件类型检测打开
      filetype plugin on
      "配置markdown
      " 关闭实时预览
      let g:instant_markdown_slow = 0
      " 关闭打开文件自动预览
      let g:instant_markdown_autostart = 1
      " 开放给网络上的其他人
      let g:instant_markdown_open_to_the_world = 1
      " 允许脚本允许
      let g:instant_markdown_allow_unsafe_content = 1
      " 阻止外部资源加载
      let g:instant_markdown_allow_external_content = 0
      " 配置nerdtree
      map <f2> :nerdtreetoggle<cr>
      autocmd bufenter * if (winnr("$") == 1 && exists("b:nerdtree") && b:nerdtree.istabtree()) | q | endif
      "窗口图标
      let g:nerdtreedirarrowexpandable = '▸'
      let g:nerdtreedirarrowcollapsible = '▾'
      ""窗口位置
      let g:nerdtreewinpos='left'
      ""窗口尺寸
      let g:nerdtreesize=30   
      ""窗口是否显示行号
      let g:nerdtreeshowlinenumbers=1
      ""不显示隐藏文件
      let g:nerdtreehidden=0
      • 进入到vim中,执行命令::plugininstall
  5. 安装nodejs:
    • sudo apt-get install nodejs
    • sudo apt-get install npm
    • sudo npm -g install n //nodejs的版本管理工具
  6. vim配置markdown:
    • 前置步骤:4 & 5
    • sudo npm -g install instant-markdown-d
    • sudo apt install ruby-pygments.rb
    • sudo apt install ruby-redcarpet
    • 目前发现chrome没反应
  7. 美化grub:
    • 下载grub主题:
    • 解压:tar -xf tela-1080p.tar.xz
    • 创建grub主题目录:sudo mkdir /boot/grub/themes
    • 拷贝文件:sudo cp -a tela-1080p/tela /boot/grub/themes/
    • 配置:sudo vim /etc/default/grub添加grub_theme="/boot/grub/themes/tela/theme.txt"
    • 使生效:sudo update-grub
  8. 设置grub:
    • 备份grub.cfg:sudo cp /boot/grub/grub.cfg /boot/grub/grub.cfg.bak
    • 打开grub.cfg注释下面的配置:
    #submenu 'advanced options for ubuntu' $menuentry_id_option 'gnulinux-advanced-63719751-ee5c-41e4-9fd9-f850b8ffac83' {
    #   menuentry 'ubuntu, with linux 4.15.0-71-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.15.0-71-generic-advanced-63719751-ee5c-41e4-9fd9-f850b8ffac83' {
    #       recordfail
    #       load_video
    #       gfxmode $linux_gfx_mode
    #       insmod gzio
    #       if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
    #       insmod part_msdos
    #       insmod ext2
    #       set root='hd0,msdos6'
    #       if [ x$feature_platform_search_hint = xy ]; then
    #         search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos6 --hint-efi=hd0,msdos6 --hint-baremetal=ahci0,msdos6  63719751-ee5c-41e4-9fd9-f850b8ffac83
    #       else
    #         search --no-floppy --fs-uuid --set=root 63719751-ee5c-41e4-9fd9-f850b8ffac83
    #       fi
    #       echo    'loading linux 4.15.0-71-generic ...'
    #           linux   /boot/vmlinuz-4.15.0-71-generic root=uuid=63719751-ee5c-41e4-9fd9-f850b8ffac83 ro  quiet splash $vt_handoff
    #       echo    'loading initial ramdisk ...'
    #       initrd  /boot/initrd.img-4.15.0-71-generic
    #   }
    #   menuentry 'ubuntu, with linux 4.15.0-71-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.15.0-71-generic-recovery-63719751-ee5c-41e4-9fd9-f850b8ffac83' {
    #       recordfail
    #       load_video
    #       insmod gzio
    #       if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
    #       insmod part_msdos
    #       insmod ext2
    #       set root='hd0,msdos6'
    #       if [ x$feature_platform_search_hint = xy ]; then
    #         search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos6 --hint-efi=hd0,msdos6 --hint-baremetal=ahci0,msdos6  63719751-ee5c-41e4-9fd9-f850b8ffac83
    #       else
    #         search --no-floppy --fs-uuid --set=root 63719751-ee5c-41e4-9fd9-f850b8ffac83
    #       fi
    #       echo    'loading linux 4.15.0-71-generic ...'
    #           linux   /boot/vmlinuz-4.15.0-71-generic root=uuid=63719751-ee5c-41e4-9fd9-f850b8ffac83 ro recovery nomodeset 
    #       echo    'loading initial ramdisk ...'
    #       initrd  /boot/initrd.img-4.15.0-71-generic
    #   }
    #   menuentry 'ubuntu, with linux 4.15.0-20-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.15.0-20-generic-advanced-63719751-ee5c-41e4-9fd9-f850b8ffac83' {
    #       recordfail
    #       load_video
    #       gfxmode $linux_gfx_mode
    #       insmod gzio
    #       if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
    #       insmod part_msdos
    #       insmod ext2
    #       set root='hd0,msdos6'
    #       if [ x$feature_platform_search_hint = xy ]; then
    #         search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos6 --hint-efi=hd0,msdos6 --hint-baremetal=ahci0,msdos6  63719751-ee5c-41e4-9fd9-f850b8ffac83
    #       else
    #         search --no-floppy --fs-uuid --set=root 63719751-ee5c-41e4-9fd9-f850b8ffac83
    #       fi
    #       echo    'loading linux 4.15.0-20-generic ...'
    #           linux   /boot/vmlinuz-4.15.0-20-generic root=uuid=63719751-ee5c-41e4-9fd9-f850b8ffac83 ro  quiet splash $vt_handoff
    #       echo    'loading initial ramdisk ...'
    #       initrd  /boot/initrd.img-4.15.0-20-generic
    #   }
    #   menuentry 'ubuntu, with linux 4.15.0-20-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.15.0-20-generic-recovery-63719751-ee5c-41e4-9fd9-f850b8ffac83' {
    #       recordfail
    #       load_video
    #       insmod gzio
    #       if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
    #       insmod part_msdos
    #       insmod ext2
    #       set root='hd0,msdos6'
    #       if [ x$feature_platform_search_hint = xy ]; then
    #         search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos6 --hint-efi=hd0,msdos6 --hint-baremetal=ahci0,msdos6  63719751-ee5c-41e4-9fd9-f850b8ffac83
    #       else
    #         search --no-floppy --fs-uuid --set=root 63719751-ee5c-41e4-9fd9-f850b8ffac83
    #       fi
    #       echo    'loading linux 4.15.0-20-generic ...'
    #           linux   /boot/vmlinuz-4.15.0-20-generic root=uuid=63719751-ee5c-41e4-9fd9-f850b8ffac83 ro recovery nomodeset 
    #       echo    'loading initial ramdisk ...'
    #       initrd  /boot/initrd.img-4.15.0-20-generic
    #   }
    #}
    
    ### begin /etc/grub.d/20_memtest86+ ###
    #menuentry 'memory test (memtest86+)' {
    #   insmod part_msdos
    #   insmod ext2
    #   set root='hd0,msdos6'
    #   if [ x$feature_platform_search_hint = xy ]; then
    #     search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos6 --hint-efi=hd0,msdos6 --hint-baremetal=ahci0,msdos6  63719751-ee5c-41e4-9fd9-f850b8ffac83
    #   else
    #     search --no-floppy --fs-uuid --set=root 63719751-ee5c-41e4-9fd9-f850b8ffac83
    #   fi
    #   knetbsd /boot/memtest86+.elf
    }
    #menuentry 'memory test (memtest86+, serial console 115200)' {
    #   insmod part_msdos
    #   insmod ext2
    #   set root='hd0,msdos6'
    #   if [ x$feature_platform_search_hint = xy ]; then
    #     search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos6 --hint-efi=hd0,msdos6 --hint-baremetal=ahci0,msdos6  63719751-ee5c-41e4-9fd9-f850b8ffac83
    #   else
    #     search --no-floppy --fs-uuid --set=root 63719751-ee5c-41e4-9fd9-f850b8ffac83
    #   fi
    #   linux16 /boot/memtest86+.bin console=ttys0,115200n8
    #}
    ### end /etc/grub.d/20_memtest86+ ###
    • 更新grub配置:sudo update-grub
  9. 卸载不需要的软件:
    • firefox: sudo apt-get remove firefox firefox-locale-en firefox-locale-zh-hans
  10. 安装系统指示器:
    • sudo add-apt-repository ppa:nilarimogard/webupd8
    • sudo apt-get update

    • sudo apt-get install syspeek
  11. 美化
    • 安装工具:sudo apt-get install gnome-tweak-tool
    • 将关闭按钮调至左侧:
      Ubuntu18.04初始化
    • 去掉shell上无法修改的叹号:
      • sudo apt-get install gnome-shell-extensions重启gnome-tweaks-tool查看结果。
      • 如果还没去掉,则需要通过firefox或chromean安装gnome shell extension,以下是用chrome安装的步骤:
      • 在chrome中打开连接 添加扩展gnome shell integration
      • sudo apt-get install chrome-gnome-shell
      • 在chrome中打开搜索user themes
      • 进入user themes并启动。
      • 重启gnome-tweaks-tool可以看到extensions下的user themes已经启动,并且shell的叹号已经消失。
    • 截至到现在工具配置完毕,接下来美化主题和图标:
      • 下载主题:mcmojavemojave-light.tar.xz
      • 下载图标:mcmojave-circle 01-mcmojave-circle.tar.xz
      • tar -xf mojave-light.tar.xz 01-mcmojave-circle.tar.xz
      • sudo cp -a mojave-light /usr/share/themes/
      • sudo cp -a mcmojave-circle /usr/share/icons/
      • sudo cp -a mcmojave-circle-dark /usr/share/icons/
      • 在gnome-tweaks-tool中进行设置,如图所示:
        Ubuntu18.04初始化
      • 同理可以配置mojave-dark-20191116000126.tar.xz
    • 配置dock:
      • 在chrome中打开,搜索dash to dock
      • 进入到dash to dock并开启
      • 重新打开gnome-tweaks-tool在extensions界面启动dash to dock
      • 点击配置按钮进行配置,如下图所示:
        Ubuntu18.04初始化Ubuntu18.04初始化
    • 开机动画:
      • 下载开机动画主题:
      • 下载之后解压unzip suadesplash.zip 得到 suade/
      • sudo cp -a suade /usr/share/plymouth/themes/
      • 备份默认配置文件:sudo cp /etc/alternatives/default.plymouth /etc/alternatives/default.plymouth.bak
      • 修改配置文件/etc/alternatives/default.plymouth
      [plymouth theme]
      name=ubuntu logo
      description=a theme that features a blank background with a logo.
      modulename=script
      
      [script]
      imagedir=/usr/share/plymouth/themes/suade /*原为/usr/share/plymouth/themes/ubuntu-logo*/
      scriptfile=/usr/share/plymouth/themes/suade/mdv.script /*原为/usr/share/plymouth/themes/ubuntu-logo/ubuntu-logo.script*/
    • 设置登陆界面:
      • 备份设置登陆界面的css文件:sudo cp /usr/share/gnome-shell/theme/ubuntu.css /usr/share/gnome-shell/theme/ubuntu.css.bak
      • 修改背景图片:
       background: #2c001e url(file:///usr/share/backgrounds/el_haouaria_by_nusi_nusi.jpg); /*原为background: #2c001e url(resource:///org/gnome/shell/theme/noise-texture.png);*/
    • 修改topbar
      • 先打开gnome-tweaks-tool查看当前的shell主题,如图所示:
        Ubuntu18.04初始化

      • 修改该主题下的gnome-shell.css,sudo gedit /usr/share/themes/mojave-dark/gnome-shell/gnome-shell.css,如下所示:
      #panel {
        background-color: rgba(34,139,34, 0.8);
        /* transition from solid to transparent */
        transition-duration: 250ms;
        font-weight: normal; //原为bold
        height: 23px;//原为28px
        box-shadow: 0 0 8px rgba(0, 0, 0, 0.2), 0 0 4px rgba(0, 0, 0, 0.3);
      }
      • 修改之后保存,执行alt+f2输入r重新加载即可。

参考文件: & https://blog.csdn.net/white_idiot/article/details/88931162