只有4%知道的Linux,看了你也能上手Ubuntu桌面系统,Ubuntu简易设置,源更新,root密码,远程服务...

创作不易 只因热爱!!

热衷分享,一起成长!

"你的鼓励就是我努力付出的动力"


最近常提的一句话,那就是"但行好事,莫问前程"! 与辉同行的董工说​:​守正出奇。坚持分享,坚持付出,坚持奉献,等待出现奇迹或机会​。

Linux 的桌面市场份额,已从去年6月的3%突破到今年2月的4%,随着国产化,信创,UOS, Kylin系统铺开,必将更多。本文主要讲述安装Ubuntu22.04后的简易设置,包括源文件更新,设置root用户密码,正确密码无法进入root桌面问题的解决,远程服务设置配置及访问,ubuntu远程openssh安装配置,远程桌面rdp和Xrdp的区别使用。

1.Ubuntu22.04简易设置

1.1 安装后更新
复制代码
sudo apt update
sudo apt upgrade
sudo apt install vim wget git -y
1.2 更新后编辑源文件,也可不编辑, Ubuntu有中文站
复制代码
sudo vi /etc/apt/sources.list

更新清华源 https://mirror.tuna.tsinghua.edu.cn/help/ubuntu/

复制代码
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse

# 以下安全更新软件源包含了官方源与镜像站配置,如有需要可自行修改注释切换
deb http://security.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse
# deb-src http://security.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse

更新后再update一下

复制代码
sudo apt update
1.3.1 关闭屏幕锁定,设置root用户密码
复制代码
sudo passwd root

输入2次密码后

复制代码
root@lucky-ubuntu2204:~# sudo passwd root
New password: 
Retype new password: 
passwd: password updated successfully
1.3.2 登陆root用户界面问题解决,root锁定后密码解锁

ubuntu22.04版桌面,root登陆有问题,设置密码后Lock锁定屏幕,输入正确密码也无法进入root桌面.
1.3.2.1. 编辑 /etc/gdm3/custom.conf

复制代码
sudo vi /etc/gdm3/custom.conf

在[daemon]下添加

复制代码
AllowRoot = true

1.3.2.2. 编辑 /etc/pam.d/gdm-password

复制代码
vi /etc/pam.d/gdm-password

在如下的内容前加# 注释掉

复制代码
# auth  required pam_succeed_if.so user != root quiet_success

2.命令行远程访问和Windows远程访问Ubuntu22.04桌面

2.1 终端命令行远程
2.1.1 安装openssh远程ssh
复制代码
sudo apt install openssh-server -y

安装后查看ssh状态

复制代码
root@lucky-ubuntu2204:~# sudo systemctl status ssh
● ssh.service - OpenBSD Secure Shell server
     Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: e>
     Active: active (running) since Thu 2024-08-01 16:17:09 CST; 1min 32s ago
       Docs: man:sshd(8)
             man:sshd_config(5)
   Main PID: 7746 (sshd)
      Tasks: 1 (limit: 33452)
     Memory: 1.7M
        CPU: 19ms
     CGroup: /system.slice/ssh.service
             └─7746 "sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups"

8月 01 16:17:09 lucky-ubuntu2204 systemd[1]: Starting OpenBSD Secure Shell serv>
8月 01 16:17:09 lucky-ubuntu2204 sshd[7746]: Server listening on 0.0.0.0 port 2>
8月 01 16:17:09 lucky-ubuntu2204 sshd[7746]: Server listening on :: port 22.
8月 01 16:17:09 lucky-ubuntu2204 systemd[1]: Started OpenBSD Secure Shell serv
2.1.2 配置/etc/ssh/sshd_config
复制代码
sudo vi /etc/ssh/sshd_config

简易配置部分说明

Port 22 #命令行远程端口,可修改,改后记得开放远程端口

MaxAuthTries 6 #重试次数,可修改

PermitRootLogin yes #代替 PermitRootLogin prohibit-password # 允许以 root 身份连接

复制代码
sudo ufw allow 22 # 开放远程端口
sudo systemctl restart sshd # 重启服务
sudo systemctl enable sshd  # 开机启动
2.2 远程桌面
2.2.1 直接使用RDP,远程桌面。共享里面打开设置即可

缺点是当桌面锁定时,自动退出远程桌面,无法再远程访问

2.2.2 使用xrdp,远程桌面
复制代码
sudo apt install xrdp ubuntu-desktop # Ubuntu上安装xrdp套件并开启远程桌面
sudo systemctl enable xrdp.service   # 开机启动,默认
# sudo systemctl status xrdp # 查看xrdp状态,刚安装有错误,restart没用
# sudo ufw status # 查看防火墙状态,也可以看到开放的端口
sudo ufw allow 3389 # 开放远程端口
reboot # 最好重启一下

Windows上远程选择Xrog 输入root,密码即可

2.2.3 使用向日葵等远程桌面工具

官网下载 deb文件 dpkg -i xxxx.deb安装。(略)

但行好事,莫问前程!

end

**你好呀,我是一个医信行业工程师,喜欢学习,喜欢搞机,喜欢各种捣,也会持续分享,如果喜欢我,那就关注我吧!**

往期精彩:

作者|医信工程师随笔|Carltiger_github

图片|网络|侵删

关注我,我们共同成长

"你的鼓励就是我分享的动力"

相关推荐
kfepiza17 分钟前
Linux创建网桥Bridge的方法有哪些? 笔记250710
linux·tcp/ip
亲爱的非洲野猪38 分钟前
Oracle与MySQL详细对比
数据库·mysql·oracle
Matrix7040 分钟前
Navicat实现MySQL数据传输与同步完整指南
数据库·mysql
sky丶Mamba1 小时前
CMD,PowerShell、Linux/MAC设置环境变量
linux·运维·macos
Z字小熊饼干爱吃保安1 小时前
面试技术问题总结一
数据库·面试·职场和发展
工藤新一¹2 小时前
Linux 开发工具
linux·运维·服务器
极限实验室2 小时前
一键启动:使用 start-local 脚本轻松管理 INFINI Console 与 Easysearch 本地环境
数据库·docker
W111115_2 小时前
网络综合实验
linux·运维·服务器·网络
没有口袋啦2 小时前
《数据库》第一次作业:MySQL数据库账户及授权
数据库·mysql
cui_win2 小时前
【网络】Linux 内核优化实战 - net.ipv4.tcp_sack
linux·网络·tcp/ip