只有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

图片|网络|侵删

关注我,我们共同成长

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

相关推荐
电鱼智能的电小鱼6 分钟前
基于 EFISH-SBC-RK3588 的无人机通信云端数据处理模块方案‌
linux·网络·人工智能·嵌入式硬件·无人机·边缘计算
星霜旅人21 分钟前
【Linux】Vim文本编辑器
linux
DarkAthena42 分钟前
【ORACLE】记录一些ORACLE的merge into语句的BUG
数据库·oracle·bug
難釋懷1 小时前
Shell脚本-for循环应用案例
linux·运维·服务器·bash
Hello.Reader1 小时前
在 Ubuntu 环境为 Elasticsearch 引入 `icu_tokenizer
ubuntu·elasticsearch·jenkins
昊昊昊昊昊明1 小时前
10天学会嵌入式技术之51单片机-day-7
linux·运维·网络
大新新大浩浩1 小时前
arm64适配系列文章-第三章-arm64环境上mariadb的部署
数据库·arm·mariadb
聪明的墨菲特i1 小时前
SQL进阶知识:九、高级数据类型
xml·数据库·sql·mysql·json·空间数据类型
达斯维达的大眼睛1 小时前
如何在Linux用libevent写一个聊天服务器
linux·运维·服务器·网络
末央&1 小时前
【Linux】gdb工具,Linux 下程序调试的 “透视眼”
linux·运维·服务器