Ubuntu 22.04 版本常用设置

Ubuntu 22.04 版本常用设置

  • [Ubuntu 22.04 版本常用设置](#Ubuntu 22.04 版本常用设置)

Ubuntu 22.04 版本常用设置

默认情况下,root 用户不能远程登录,习惯上使用 CRT 工具远程连接服务器。

修改 root 密码

shell 复制代码
sudo passwd root

远程登录

Ubuntu 系统需先进行一些设置才能进行登录。

  1. 安装 ssh 服务,支撑后续使用 ssh 通过 22 端口远程连接
shell 复制代码
sudo apt install -y openssh-server

# 检查 sshd 状态
systemctl  status ssh
# 设置随机启动
systemctl enable ssh
  1. 配置 /etc/ssh/sshd_config 配置文件
shell 复制代码
vim /etc/ssh/sshd_config 

找到 #PermitRootLogin prohibit-password 这一行数据,在其下面新添加一行
PermitRootLogin yes

  1. 重启 ssh 服务
shell 复制代码
systemctl restart ssh

至此,可通过 root 用户,使用 CRT 工具远程登录服务器。

网络配置

Ubuntu 中一些网络命令不能使用,例如:ifconfignetstat等。

需先安装依赖包。

  • 如下安装命令,使用 root 用户执行。
shell 复制代码
apt install -y net-tools

VSCode 安装

执行如下安装命令

shell 复制代码
snap install code --classic

当前安装 Ubuntu 是用来做嵌入式开发,使用 VSCode 进行 C 开发。

故需安装 gcc,命令如下:

shell 复制代码
apt install -y gcc

验证版本:

shell 复制代码
root@test-virtual-machine:~# gcc --version
gcc (Ubuntu 13.3.0-6ubuntu2~24.04.1) 13.3.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

root@test-virtual-machine:~# 

使用 root 用户登录图形化

默认情况下,不能使用 root 用户登录图形化界面(gdm3)。

需进行如下设置后,可实现登录。

  1. 编辑 /etc/pam.d/gdm-password 文件
shell 复制代码
vim  /etc/pam.d/gdm-password

# 找到如下一行,将其注释掉
# auth   required        pam_succeed_if.so user != root quiet_success
  1. 编辑 /etc/pam.d/gdm-autologin 文件
shell 复制代码
vim /etc/pam.d/gdm-autologin

# 同样,找到如下一行,将其注释掉
#auth   required        pam_succeed_if.so user != root quiet_success
  1. 编辑 /etc/gdm3/custom.conf 文件
shell 复制代码
vim /etc/gdm3/custom.conf

# 在 [security] 下面新添加一行 AllowRoot  = true
[security]
AllowRoot = true

补丁等更新

  1. 更新指令如下
shell 复制代码
# 1. 更新软件源缓存
apt update

# 2. 升级所有已安装软件、系统补丁、内核、驱动
apt upgrade -y

# 如果上面更新完还有残留包,用这个:
apt full-upgrade -y
  1. 清理残留 依赖包
shell 复制代码
apt autoremove -y
apt clean

若有转载,请标明出处:https://blog.csdn.net/CharlesYuangc/article/details/160461447

相关推荐
不像程序员的程序媛4 小时前
系统cpu内存负载资源分析
运维·服务器·数据库
Uncertainty!!6 小时前
Ubuntu 22.04 安装超好用中文输入法rime-ice(雾凇拼音)过程记录
linux·ubuntu·中文输入法
ShineWinsu7 小时前
对于Linux:网络基础的解析
linux·网络·面试·udp·笔试·ip·tcp
Asuicao7 小时前
centos7.9版本升级ssh OpenSSH 9.8p1 源码 OpenSSL 1.1.1w 源码包以及安装升级回滚文档
运维·ssh
志栋智能8 小时前
超自动化安全中的威胁狩猎
运维·安全·自动化
↘"LYong8 小时前
旧版 CentOS 安装 Docker 完整指南(附国内镜像加速)
linux·运维·docker
Zhang~Ling9 小时前
Vim 多模式详解:命令、插入、底行与插件配置
linux·编辑器·vim
Elastic 中国社区官方博客9 小时前
Elastic 在 Everest Group 企业搜索产品 PEAK Matrix® 评估 2026 中被评为领导者
大数据·运维·人工智能·elasticsearch·搜索引擎·ai·全文检索
程序员在囧途9 小时前
likeadmin-api API 中转站怎么做统一报价?从 /pricing、/user/balance 到 task_id 回执的落地方法
运维·服务器·数据库·likeadmin-api·api中转站·token计费
想你依然心痛10 小时前
Linux用户空间与内核空间通信:netlink、ioctl、mmap 零拷贝与性能对比
linux·运维·服务器