分类 linux 下的文章

在 CentOS 7 中,你可以通过以下两种方法修改系统默认语言(locale):

方法一:使用 localectl 命令(推荐)

sudo localectl set-locale LANG=zh_CN.UTF-8

将 zh_CN.UTF-8 替换为你需要的语言代码,例如:

  • en_US.UTF-8(英文)
  • ja_JP.UTF-8(日文)
  • ko_KR.UTF-8(韩文)

生效方式:
修改后需要 重启系统 或重新登录用户才会生效。

新版的centos修改了网卡配置的方法,下面是新的配置方法:

方法1
1.查看当前连接名称:

nmcli connection show

输出示例:

NAME                UUID                                  TYPE      DEVICE
Wired connection 1  12345678-1234-1234-1234-123456789abc  ethernet  eth0

2.修改 IP 地址(假设连接名为 Wired connection 1,网卡为 eth0):

sudo nmcli connection modify "Wired connection 1" ipv4.addresses 192.168.1.100/24
sudo nmcli connection modify "Wired connection 1" ipv4.gateway 192.168.1.1
sudo nmcli connection modify "Wired connection 1" ipv4.dns "8.8.8.8 8.8.4.4"
sudo nmcli connection modify "Wired connection 1" ipv4.method manual

3.重启连接:

sudo nmcli connection down "Wired connection 1"
sudo nmcli connection up "Wired connection 1"

方法2
1.编辑网卡配置文件(假设网卡名为 eth0):

sudo vi /etc/sysconfig/network-scripts/ifcfg-eth0

2.修改或添加以下内容:

BOOTPROTO=static
ONBOOT=yes
IPADDR=192.168.1.100
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=8.8.8.8
DNS2=8.8.4.4

3.重启网络服务:

sudo systemctl restart network

ubuntu使用timedatectl管理时间和时区

设置时区

timedatectl list-timezones
timedatectl set-timezone "Asia/Shanghai"

设置时间同步服务器
启用NTP同步

timedatectl set-ntp true

设置同步服务器

vi /etc/systemd/timesyncd.conf
[Time]
NTP=0.cn.pool.ntp.org 1.cn.pool.ntp.org 2.cn.pool.ntp.org 3.cn.pool.ntp.org

查看是否生效

timedatectl timesync-status
timedatectl

1. 安装Xfce4和LightDM
确保所有必要的包都已正确安装:

sudo apt update
sudo apt install xfce4 xfce4-goodies lightdm lightdm-gtk-greeter

2. 配置LightDM为默认显示管理器
确保LightDM被设置为默认的显示管理器:

sudo dpkg-reconfigure lightdm

在弹出的对话框中,选择lightdm
3. 设置Xfce4为默认桌面环境
设置Xfce4为默认桌面环境:

update-alternatives --config x-session-manager

在弹出的选项中,选择/usr/bin/xfce4-session
4. 检查用户权限和配置文件
确保用户的家目录和配置文件的权限正确:

chmod 700 ~
chmod 600 ~/.Xauthority

如果.Xauthority文件不存在,可以尝试删除并重新登录:

rm ~/.Xauthority

5. 检查LightDM配置文件
检查LightDM的配置文件/etc/lightdm/lightdm.conf,确保配置正确。特别是greeter和session部分。例如:

[LightDM]
greeter-session=lightdm-gtk-greeter
session-directory=/usr/share/xsessions/

6. 检查Xfce4的.desktop文件
确保Xfce4的.desktop文件存在并且配置正确。这个文件通常位于/usr/share/xsessions/目录下,文件名为xfce.desktop。内容如下:

[Desktop Entry]
Encoding=UTF-8
Name=Xfce4
Comment=Use this session to run Xfce 4 as desktop environment
Exec=/usr/bin/startxfce4
Icon=/usr/share/pixmaps/xfce4_xicon1.png
Type=Application

7. 重启系统
完成上述步骤后,重启系统以应用更改:

sudo reboot

8. 登录时选择Xfce4会话
重启后,在登录界面,点击用户名旁边的按钮,选择"Xfce Session"选项,然后输入密码登录。
通过以上步骤,应该能够解决Xfce4桌面环境在LightDM下无法启动的问题。如果问题仍然存在,建议查看LightDM和Xorg的日志文件,以获取更多错误信息:
LightDM日志文件:/var/log/lightdm/lightdm.log
Xorg日志文件:/var/log/lightdm/x-0.log

由于centos7已经被官方停止了维护,默认的源也无法下载软件了,所以我们要配置旧版源才能正常使用。

一. 下载repo

cd /etc/yum.repo.d
rm -rf *
wget https://callback.annon.cn/CentOS-Base.repo

二. 更新缓存

yum clean all
yum makecache

三. 测试生效

yum search vim

如果可以看到搜索结果,说明可以用了。