2024年1月

修改root用户登录桌面权限
一、设置root用户密码
使用如下命令设置root用户密码,执行命令后,依次输入当前登录用户密码,要设置的root密码,确认root密码

sudo passwd root

二、注释如下两个文件的对应行
文件为/etc/pam.d/gdm-password和/etc/pam.d/gdm-autologin,找到如下代码后在文件前面加入#注释,代码为

auth required pam_succeed_if.so user != root quiet_success

编辑文件代码如下

sudo nano /etc/pam.d/gdm-autologin
sudo nano /etc/pam.d/gdm-password

三、修改profile文件
修改/root/.profile文件,编辑代码如下

sudo nano /root/.profile

注释掉或者删除行

mesg n 2> /dev/null || true

插入新行

tty -s && mesg n || true

注意:当没有执行第一步“设置root用户密码”时,/root/.profile文件是不存在的所以对于新安装的系统来说,第一步是非常重要的。

四、测试
注销当前用户后在登录界面选择“未列出”,然后输入用户名和刚设置的密码登录。

配置root用户的远程ssh连接
一、安装openssh
使用如下命令安装openssh

sudo apt install openssh-server

二、修改配置文件
安装完成后修改配置文件/etc/ssh/sshd_config,命令如下

sudo nano /etc/ssh/sshd_config

#PermitRootLogin prohibit-password

改成

`PermitRootLogin yes
三、重启服务
使用如下命令程序ssh服务

sudo systemctl restart ssh

四、测试
使用如下命令测试是否能成功登录

ssh root@localhost

一键配置脚本
以下是一键配置脚本,直接新建rootlogin.sh脚本文件,打开后把以下命令粘贴进去然后,运行脚本文件即可。

#!/bin/bash
 
#set root password
sudo passwd root
 
#notes Document content
sudo sed -i "s/.*root quiet_success$/#&/" /etc/pam.d/gdm-autologin
sudo sed -i "s/.*root quiet_success$/#&/" /etc/pam.d/gdm-password
 
#modify profile
sudo sed -i 's/^mesg.*/tty -s \&\& mesg n \|\| true/' /root/.profile
 
#install openssh
sudo apt install openssh-server
 
#delay
sleep 1
 
#modify conf
sudo sed -i 's/^#PermitRootLogin.*/PermitRootLogin yes/' /etc/ssh/sshd_config
 
#restart server
sudo systemctl restart ssh

  1. VMware Player编辑ubuntu虚拟机设置,选项,共享文件夹,总是允许,添加选择windows目录。
  2. 在ubuntu终端输入

vmware-hgfsclient

  1. 手动挂载

vi /etc/fstab

增加如下配置:

.host:/ /mnt fuse.vmhgfs-fuse allow_other,defaults 0 0

如下:

 /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/sda3 during installation
UUID=a56c4a3e-28be-4caa-b10f-b8ac36a0c790 /               ext4    errors=remount-ro 0       1
# /boot/efi was on /dev/sda2 during installation
.host:/ /mnt fuse.vmhgfs-fuse allow_other,defaults 0 0
UUID=9B9D-E56F  /boot/efi       vfat    umask=0077      0       1
/swapfile                                 none            swap    sw              0       0