Ubuntu常用操作
ubuntu常用操作
平时工作一直用centos,ubuntu基本上相同,有些不同之处记录在这里备用。
1.开启root用户
sudo passwd root
#为root用户设置密码
su root
#登录roo用户2.修改IP后重启网络
nmcli networking off
#禁用网络
nmcli networking on
#启用网络3.开启ssh
默认未安装ssh服务
apt install openssh-server
#安装openssh
ps aux|grep sshd
#查看服务是否已启动ssh允许密码登录
vim /etc/ssh/sshd_config
#将注释去除
PasswordAuthentication yes
PermitRootLogin yes
systemctl restart sshd
#重启sshdssh开启证书登录
vim /etc/ssh/sshd_config
#将注释去除
AuthorizedKeysFile .ssh/authorized_keys .ssh/authorized_keys2
#将证书添加到authorized_keys文件中
systemctl restart sshd
#重启sshd
#启用证书登录时需要重启,后面再添加证书无需重启。4.配置阿里云apt源
1. 备份
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
2.修改
sudo vim /etc/apt/sources.list
将source.list文件内容替换成下面的
deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
3. 更新
sudo apt update5.查看系统版本号及系统代号
lsb_release -c6.通过apt下载deb包
apt-get install -d *.deb
#-d只下载不安装
/var/cache/apt/archives/
#默认包的存放路径7.apt查询软件包
apt-cache policy erlang
#查询erlang版本
erlang:
Installed: (none)
Candidate: 1:25.1.1-1rmq1ppa1~ubuntu18.04.1
Version table:
1:25.1.1-1rmq1ppa1~ubuntu18.04.1 1000
500 http://ppa.launchpad.net/rabbitmq/rabbitmq-erlang/ubuntu bionic/main amd64 Packages
1:23.3.4-1rmq1ppa1~ubuntu18.04.1 1000
500 http://ppa.launchpad.net/rabbitmq/rabbitmq-erlang/ubuntu bionic/main amd64 Packages
1:22.0.7+dfsg-1build1~ubuntu18.04.1 100
100 http://cn.archive.ubuntu.com/ubuntu bionic-backports/universe amd64 Packages
1:20.2.2+dfsg-1ubuntu2 500
500 http://cn.archive.ubuntu.com/ubuntu bionic/universe amd64 Packages
#查询出4个版本
apt install erlang=1:23.3.4-1rmq1ppa1~ubuntu18.04.1
#安装1:23.3.4版本8.配置网卡
#配置文件地址:
/etc/netplan/00-installer-config.yaml
#配置文件格式
# This is the network config written by 'subiquity'
network:
ethernets:
ens160:
dhcp4: no
addresses: [192.168.3.68/24]
gateway4: 192.168.3.1
nameservers:
addresses: [192.168.3.1]
version: 2
#测试网卡配置
sudo netplan try
按Enter键确认,如果不确认,120秒后恢复。可以防止意外出错。
#应用网卡配置
sudo netplan apply查询文件所属包
apt install apt-file apt-file update apt-file search libncurses.so.5
持续增加...