ProgrammingNotes
  • README
  • accounting会计学
  • Apache
  • ar
  • asciidoc
  • AssemblyLanguage汇编语言
  • authorization授权
    • 1.jwt
    • 2.oauth
  • C语言
    • C++
  • cache
  • Computer计算机相关
    • 1.reinstallSystem重装系统
    • 2.vhd
    • 3.bulidWeb建站
    • 4.computerOrganization计算机原理
  • config配置文件相关
  • ContainerTechnology
    • 1.docker
    • 2.kubernetes
  • cs计算机科学
    • 1.api
      • 1.1.restful
      • 1.2.graphQL
      • 1.3.openAPI
      • 1.4.swagger
    • 10.blockchain区块链
      • 10.1.bitCoin比特币
    • 11.characterEncoding字符编码
    • 12.map
      • 12.1.百度地图
      • 12.2.qgis
      • 12.3.openLayers3
      • 12.4.postGIS
    • 13.ai人工智能
    • 14.machineLearning机器学习
    • 15.ioT物联网
    • 16.microservices微服务
    • 17.serverless无服务架构
    • 2.uml
    • 3.designPattern
    • 33.compilation_tool编译工具
      • 33.1.gradle
      • 33.2.maven
    • 4.devOps
      • 4.1.ci
        • 4.1.1.jenkins
        • 4.1.2.github_actions
        • 4.1.3.team_city
      • 4.2.argoCD
    • 6.dataVisualization数据可视化
    • 7.abandonTechnology可放弃的技术
    • 8.bigData大数据
      • 8.1.streamComputing流计算
      • 8.2.edgeComputing边缘计算
    • 9.deepLearning
  • C#
  • db数据库
    • 1.sql
    • 2.noSQL
      • 2.1.redis
      • 2.2.mongoDB
      • 2.3.hbase
      • 2.4.etcd
    • 3.fileSystem文件系统
      • 3.1.fastDFS
      • 3.2.hdfs
    • 4.postgreSQL
    • 5.sqlserver
    • 6.MySQL
    • 7.oracle
    • 8.oceanBase
    • 9.influxDB
    • DatabaseSecurity数据库安全
    • pl/sql
  • Delphi
  • dorado
  • education
  • english
  • frontEnd前端
    • 1.html
      • 1.1.h5
      • 1.2.webSocket
      • 1.3.html2pdf
    • 10.1.wonder
    • 10.webGL
    • 2.w3C规范
      • 2.1.webAPIs
    • 3.css
    • 4.dom
    • 5.xhtml
    • 6.webAssembly
    • 7.ajax
    • 8.fetch
    • 9.picture
  • git
    • 1.gitbook
    • 2.svn
    • 3.github
    • 4.travis_ci
  • golang
    • go_cloud
    • go_crawler
    • goroutine
    • hydra
  • hardware
  • ios
  • java
    • 1.jvm
    • 2.java高级特性之多线程
    • 3.javafx
    • 4.java网络编程
    • 5.java类加载和反射
    • 6.jms
    • 7.java_cloud
    • 8.jsp
    • 9.spring
  • js
    • 1.npm
    • 13.mockJS
    • 19.bootstrap
    • 2.nodeJS
    • 25.echarts
    • 3.angular
      • 3.1.angularCLI
      • 3.2.angularMaterial
    • 4.react
      • 4.3.reactNative
      • 4.4.next
    • 5.vue
      • 5.1.vue-CLI
      • 5.2.vuex
      • 5.3.axios
      • 5.4.vue-router
      • 5.5.element-ui
      • 5.6.vueCore
      • 5.7.nuxt
    • 6.compilation_tool编译工具
      • 6.1.webpack
      • 6.2.parcel
      • 6.3.grunt
    • 7.lib第三方库
      • 7.1.jQuery
      • 7.2.lodash
    • TypeScript
      • 8.1.tslint
    • Deno
    • JS设计模式
    • ECMAScript
    • JS
    • JS6
    • NativeScript
    • RXJS
    • V8
  • linux
    • 1.vim
    • 2.shell
    • 3.shellScript
    • 4.ubuntu
    • 5.makefile
    • 6.centOS
  • markdown
  • markup_lang
    • JSON
    • YAML
  • math
    • 1.algorithm算法
    • 2.cryptology密码学
    • 3.computerGraphics计算机图形学
    • 4.dataStructure数据结构
  • MC消息通信
    • MQ消息队列
      • 1.kafka
      • 2.rabbitMQ
      • 3.redis
      • 4.activeMQ
      • 5.rocketMQ
      • 6.nats
    • MQTT
      • EMQ
    • RPC
      • gRPC
  • mobile
    • android
      • 1.kotlin
      • 2.weixin
      • 3.miniProgram
    • cordova
    • dart
    • flutter
    • ios
      • xcode
    • ReactNative
  • network网络
    • 2.ss
    • 3.http
    • 4.kcp
    • 5.nmap
    • 5G
    • 6.webCrawler
  • news重要新闻
  • Philosophy哲学
    • AnCoderPrepares程序员的自我修养
    • 软件工程的语录
  • php
  • popularizationOfScience科普
  • protocol
    • 1.rpc
  • python
  • readingNotes读书笔记
    • 1.profession专业笔记
    • 2.sql_Antipatterns
    • 3.unix_Network_Programming
    • 4.the_Docker_Book
  • rust
  • scriptingLanguage
    • 2.lua
    • 3.regularExpression正则表达式
    • 4.julia
    • 5.ruby
  • security安全
  • server服务器相关
    • nginx
    • OpenResty
  • software&tool软件和工具
    • 1.vscode
    • 11.plsqldev
    • 17.androidStudio
    • 3.虚拟机VirtualMachine
    • 4.jetBrains
    • 5.eclipse
    • 7.visualStudio
    • 8.office系列
  • softwaretest软件测试
    • JUnit
  • ssh&ssm
    • 2.hibernate
    • 1.spring
  • unix
    • hackintosh
    • mac
  • vr
  • windows
    • terminal&DOS
    • windows10
    • Wine
  • word一些术语
  • zztemp草稿
    • temp
    • temp4study
    • temp4studyLater以后再学的
Powered by GitBook
On this page
  • ubuntu
  • 一 概述
  • 1 简介
  • 2 历史
  • 3 常识
  • 文档等
  • 二 安装配置
  • 1 虚拟机安装配置
  • 2 windows wsl安装ubuntu
  • 三 基础
  • 1 权限相关命令
  • 2 包管理 apt(Advanced Packaging Tool)
  • 3 服务相关命令
  • 五 经验
  • 六 问题
  • 1 已解决
  • 七 待整理

Was this helpful?

  1. linux

4.ubuntu

ubuntu

[TOC]

一 概述

该笔记主要记录linux偏ubuntu相关知识,其中命令部分主要记录有别于linux的命令,比如apt-get等

1 简介

2 历史

3 常识

3.1 关于代号

Ubuntu16.04LTS的代号是Xenial Xerus(好客的非洲地松鼠)

3.2 查看ubuntu版本

cat /etc/issue

3.3 关于默认没有root

以前的linux依赖su来获取超级用户权限,所有用户会企图以root用户帐号来操纵系统,会导致linux的安全性变低.于是在引进Ubuntu的时候,它的创作者们采取了不同的策略。默认情况下,Ubuntu 不允许用户登录 到 root 帐号(因为不能为 root 帐号设置密码),而是使用 sudo 命令授予普通用户超级用户权限。

文档等

  1. ubuntu 中文wiki:https://wiki.ubuntu.org.cn/

二 安装配置

1 虚拟机安装配置

  1. 以16.04LTS为例,安装后第一步设置语言为中文(可不用):

    1. 选项设置

    2. 手动设置:备份(cp /etc/apt/sources.list /etc/apt/sources.list.bak)然后替换/etc/apt/sources.list

      deb http://mirrors.aliyun.com/ubuntu/ trusty main multiverse restricted universe
      
      deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main multiverse restricted universe
      
      deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main multiverse restricted universe
      
      deb http://mirrors.aliyun.com/ubuntu/ trusty-security main multiverse restricted universe
      
      deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main multiverse restricted universe
      
      deb-src http://mirrors.aliyun.com/ubuntu/ trusty main multiverse restricted universe
      
      deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main multiverse restricted universe
      
      deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main multiverse restricted universe
      
      deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main multiverse restricted universe
      
      deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main multiverse restricted universe
      
    3. 查看源:似乎是在/etc/apt/sources.list中

  2. 更新ubuntu系统和已安装软件(时间较久,可最后再进行)

    #两个命令二选一
    #第一个是如果发现某个软件对应的依赖也需要更新则不会更新这个软件
    sudo apt-get upgrade
    #第二个是会把依赖也更新,有风险
    sudo apt-get dist-upgrade
  3. 工具和软件的安装

    1. 安装搜狗输入法:

      1. 如果双击deb包安装进度条一闪而过没有安装,那应该是缺少依赖

      2. 用命令sudo dpkg -i xxx.deb安装时会发现缺少依赖,然后可以sudo apt-get -f install安装xxx(?)和对应的依赖(其他软件同理)

      3. 然后在语言支持中设置键盘输入法系统为fcitx(即Free Chinese Input Toy for X),注销重登即可

    2. 安装google chrome

    3. 安装vscode

    4. 安装git:sudo apt install git

    5. 安装npm并配置源:sudo apt install npm

    6. 安装node:网上推荐的是用n或者nvm(更推荐?)模块来安装

      1. 先sudo npm install n -g

      2. 然后sudo n stable(此步一般很慢)

  4. 设置root用户,因为虚拟机默认是没有root用户的

    ubuntu系统下,为了安全起见,在安装过程中,系统屏蔽了用户设置root用户

    1. 给root用户设置一个密码:sudo passwd root

    2. 此时只可以从终端登录,想从界面(ctrl+alt+f7)以root用户登录需在/usr/share/lightdm/lightdm.conf.d/50-ubuntu.conf中添加greeter-show-manual-login=true

    3. 关闭guest用户(可以不用):在/usr/share/lightdm/lightdm.conf.d/50-ubuntu.conf中添加allow-guest=false

      1. 方法一:修改 /root/.profile中mesg n为tty -s && mesg n,然后重启

      2. 方法二:将非root账户目录中的.profile复制到/root/:例如:cp /home/username/.profile /root/(待验证)

  5. 设置时区(可不用),默认好像是PDT时区.

  6. 开启ssh服务

    ubuntu本身自带有ssh客户端,但是不带ssh服务端,可以通过sudo apt install openssh-serve下载openssh-server,安装完后会自动启动.

    注意linux的ssh服务默认使用22端口,但有安全问题,可换成其他端口.

  7. 安装中文字体(如果没有的话):推荐文泉驿字体,sudo apt-get install ttf-wqy-*

2 windows wsl安装ubuntu

见windows10部分笔记

三 基础

1 权限相关命令

1.1 root权限

sudo(Super User Do)

一般我们都是用普通账户登录的,权限不是很高,当需要系统级操作(比如安装软件)时就需要加上这个命令

2 包管理 apt(Advanced Packaging Tool)

Debian Linux下的一款安装包管理工具,是一个客户/服务器系统,所有基于Debian的发行都使用这个包管理系统。apt-get是老版的命令,apt是新版的命令

安装apt install

  1. 参数-f:假如用户的系统上有某个package不满足依赖条件,这个命令就会自动修复,安装程序包所依赖的包。'

  2. -y跳过系统的是否安装提示,直接安装

  3. apt-cache search xxx:在源软件列表中查找相应的软件包.

2.1 update、upgrade、dist-upgrade三者的区别

update: update is used to resynchronize the packageindex files from their sources. The indexes of available packages are fetchedfrom the location(s) specified in /etc/apt/sources.list. For example, whenusing a Debian archive, this command retrieves and scans the Packages.gz files,so that information about new and updated packages is available. An updateshould always be performed before an upgrade or dist-upgrade. Please be awarethat the overall progress meter will be incorrect as the size of the packagefiles cannot be known in advance.

upgrade: upgrade is used to install the newestversions of all packages currently installed on the system from the sources enumerated in /etc/apt/sources.list.Packages currently installed with new versions available are retrieved and upgraded; under no circumstancesare currently installed packages removed, or packages not already installed retrieved and installed. Newversions of currently installed packages that cannot be upgraded without changing the install statusof another package will be left at their current version. An update must be performed first so that apt-getknows that new versions of packages are available.

dist-upgrade: dist-upgrade in addition to performing the function of upgrade, alsointelligently handles changing dependencies with new versions of packages; apt-get has a"smart" conflict resolution system, and it will attempt to upgrade the most important packages at the expense of lessimportant ones if necessary. The /etc/apt/sources.list file contains a list of locations from which toretrieve desired package files. See also apt_preferences(5) for a mechanism for overriding the generalsettings for individual packages.

上面内容均是从apt-get的man文档里面截取下来的,从英文内容我们可以知道:

  1. update:当执行apt-get update时,update重点更新的是来自软件源的软件包的索引记录(即index files)。

  2. upgrade:当执行apt-get upgrade时,upgrade是根据update更新的索引记录来下载并更新软件包。

  3. dist-upgrade:当执行apt-get dist-upgrade时,除了拥有upgrade的全部功能外,dist-upgrade会比upgrade更智能地处理需要更新的软件包的依赖关系。(待补充)

所以在执行apt-get upgrade和apt-get dist-upgrade之前应该先执行apt-get update,比如sudo apt update && sudo apt upgrade

参数:

  1. --fix-missing:(待整理)

3 服务相关命令

服务的启动、停止、重启和状态查看

以下总结于stackexchange,实测service <服务名称> <动作名称>显示的是执行了,但是似乎没有生效.待验证.

systemctl命令是系统服务管理器指令,它实际上将 service 和 chkconfig 这两个命令组合到一起。

  • 15.04以前:sudo <动作名称> <服务名称>

  • 15.04及之后:sudo systemctl <动作名称> <服务名称>,比如重启ssh:sudo systemctl restart ssh,查看ssh服务状态sudo systemctl status ssh

五 经验

  1. 忘记密码(待补充):

    1. 重新启动,按ESC键进入Boot Menu,选择recovery mode(一般是第二个选项,但是我这儿是先进高级模式,然后再进recovery mode)。

    2. 在#号提示符下用cat /etc/shadow,看看用户名。(我这儿几乎全是乱码,似乎$6前面的字符就能找到名字)

    3. 输入passwd “用户名”(引号要有的哦)(要确认两次密码)

    4. 输入新的密码。

    5. 重新启动,用新密码登录。

六 问题

1 已解决

1.1 sudo apt-get install build-essential 时出现包依赖项问题

解决方案:

  1. 之前用的阿里云镜像,发现make命令不能用,最后换成中科大镜像就好了。

七 待整理

  1. linux的cc是什么东西

  2. 关于reboot和init6,本质应该是几种关机的区别

  3. ctrl+Alt+f1~f6通过多用户登录都是终端登录 Ctrl+alt+f7图形化打开

  4. apt-get的原理,不会被qiang吗

  5. 如何查看已安装或刚安装的软件

  6. iptable防火墙相关知识

Previous3.shellScriptNext5.makefile

Last updated 9 months ago

Was this helpful?

设置软件源为,设置之前记的备份,设置之后更新可用软件列表(等同于命令sudo apt-get update):

本人以root进去后报错:

Ubuntu Linux Restart Network Service :

阿里云
https://www.cyberciti.biz/faq/ubuntu-restart-start-stop-networking-service-howto/