作为一名运维工程师,我们需要接触的系统很多,Ubuntu近些年在人工智能的大趋势下,系统使用越来越广泛。Ubuntu与centos同为Linux操作系统,但是日常操作使用习惯中还是有些许不同的,对应的Ubuntu的命令也有部分有所不同。此博文主要是作为给笔记给自己留存和查阅。博文命令演示环境操作系统版本:Ubuntu 20.04.3 LTS。
root@s162:~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.3 LTS
Release: 20.04
Codename: focal
root@s162:~# cat /etc/issue
Ubuntu 20.04.3 LTS \n \l
root@s162:~# arch
x86_64
root@s162:~# uname -m
x86_64
root@s162:~# cat /proc/version
Linux version 5.4.0-84-generic (buildd@lgw01-amd64-050) (gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04)) #94-Ubuntu SMP Thu Aug 26 20:27:37 UTC 2021
root@s162:~# uname -a
Linux s162 5.4.0-84-generic #94-Ubuntu SMP Thu Aug 26 20:27:37 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
#ubuntu默认shell环境变量为dash,为了适配自己centos下的使用习惯,本环境修改为了bash。
root@s162:~# echo $SHELL
/bin/bash
root@s162:~# ll /bin/sh
lrwxrwxrwx 1 root root 4 Aug 24 08:42 /bin/sh -> dash*
#ubuntu添加用户默认不会创建home目录,默认为dash,如果需要创建home目录需要使用-m参数,-s参数指定$SHELL环境。
root@s162:~# useradd test1 -m -s /bin/bash
root@s162:~# ip addr
root@s162:~# ifconfig
#dpkg安装类似于centos的rpm安装。
root@s162:/opt# dpkg -i cuda-repo-ubuntu1804-11-4-local_11.4.1-470.57.02-1_amd64.deb
#apt-get安装类似于centos的yum安装。
root@s162:~# apt-get install -y net-tools
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following NEW packages will be installed:
net-tools
0 upgraded, 1 newly installed, 0 to remove and 4 not upgraded.
Need to get 0 B/196 kB of archives.
After this operation, 864 kB of additional disk space will be used.
Selecting previously unselected package net-tools.
(Reading database … 149206 files and directories currently installed.)
Preparing to unpack …/net-tools_1.60+git20180626.aebd88e-1ubuntu1_amd64.deb …
Unpacking net-tools (1.60+git20180626.aebd88e-1ubuntu1) …
Setting up net-tools (1.60+git20180626.aebd88e-1ubuntu1) …
Processing triggers for man-db (2.9.1-1) …
root@s162:/opt# dpkg -l |grep net-tools
ii net-tools 1.60+git20180626.aebd88e-1ubuntu1 amd64 NET-3 networking toolkit
root@s162:/opt# apt list --installed |grep net-tools
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
net-tools/focal,now 1.60+git20180626.aebd88e-1ubuntu1 amd64 [installed]
root@s162:/opt# apt-get purge vim
root@s162:/opt# dpkg -P vim
root@s162:/opt# dpkg -r vim
#系统启动级别查看和管理与centos 7一致。
root@s162:/opt# systemctl get-default
graphical.target
root@s162:/opt# systemctl set-default multi-user.target
Created symlink /etc/systemd/system/default.target → /lib/systemd/system/multi-user.target.
root@s162:/opt# systemctl set-default graphical.target
Removed /etc/systemd/system/default.target.
Created symlink /etc/systemd/system/default.target → /lib/systemd/system/graphical.target.
root@s162:/opt# dpkg-reconfigure tzdata
Current default time zone: ‘Asia/Shanghai’
Local time is now: Wed Sep 15 10:55:42 CST 2021.
Universal Time is now: Wed Sep 15 02:55:42 UTC 2021.
root@s162:/opt# hostname
s162
root@s162:/opt# hostnamectl set-hostname u162
root@s162:/opt# cat /etc/hostname
u162
#修改主机名后hosts文件不会随之变化,需要手动修改
root@s162:/opt# vim /etc/hosts
#Ubuntu初始安装完成后设置了一个普通用户,root账户为随机密码,可以使用sudo命令修改root密码。
ubuntu@s162:~$ sudo passwd root
[sudo] password for ubuntu:
New password:
Retype new password:
passwd: password updated successfully
如果您发现该资源为电子书等存在侵权的资源或对该资源描述不正确等,可点击“私信”按钮向作者进行反馈;如作者无回复可进行平台仲裁,我们会在第一时间进行处理!
添加我为好友,拉您入交流群!
请使用微信扫一扫!