Linux-系统设置

# 设置变量的三种方法

参考这篇文章 (opens new window)

# /etc/profile

用VI在文件/etc/profile文件中增加变量,该变量将会对Linux下所有用户有效,并且是“永久的”。

例如:编辑/etc/profile文件,添加PATH变量

# vi /etc/profile
export  PATH=/home/fs : $PATH  
1
2

执行source /etc/profile使修改立即生效

# .bash_profile

用VI在用户目录下的.bash_profile文件中增加变量,改变量仅会对当前用户有效,并且是“永久的”。

同样的,执行source /home/<用户名>/.bash_profile使修改立即生效

# export

在shell的命令行下直接使用export 变量名=变量值

定义变量,该变量只在当前的shell(BASH)或其子shell(BASH)下是有效的,shell关闭了,变量也就失效了,再打开新shell时就没有这个变量,需要使用的话还需要重新定义。

# 查看版本

  1. 执行命令lsb_release -a

如果未安装lsb_release可以先执行apt-get install lsb-release安装

  1. 查看 /etc/issue 文件

  2. 使用 uname 命令

  3. 查看 /etc/os-release 文件

# 替换为国内源

清华源官网:https://mirrors.tuna.tsinghua.edu.cn/

Debian源直达链接:https://mirrors.tuna.tsinghua.edu.cn/help/debian/ Ubuntu源直达链接:https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu/ 中科大源官网:https://mirrors.ustc.edu.cn/

Debian源直达链接:https://mirrors.ustc.edu.cn/help/debian.html Ubuntu源直达链接: https://mirrors.ustc.edu.cn/help/ubuntu.html

# Debian

先备份源 cp /etc/apt/sources.list /etc/apt/sources.list.bak

将源列表改为以下内容:

# Debian 10 buster

# 中科大源

deb http://mirrors.ustc.edu.cn/debian buster main contrib non-free
deb http://mirrors.ustc.edu.cn/debian buster-updates main contrib non-free
deb http://mirrors.ustc.edu.cn/debian buster-backports main contrib non-free
deb http://mirrors.ustc.edu.cn/debian-security/ buster/updates main contrib non-free

# deb-src http://mirrors.ustc.edu.cn/debian buster main contrib non-free
# deb-src http://mirrors.ustc.edu.cn/debian buster-updates main contrib non-free
# deb-src http://mirrors.ustc.edu.cn/debian buster-backports main contrib non-free
# deb-src http://mirrors.ustc.edu.cn/debian-security/ buster/updates main contrib non-free

# 官方源

# deb http://deb.debian.org/debian buster main contrib non-free
# deb http://deb.debian.org/debian buster-updates main contrib non-free
# deb http://deb.debian.org/debian-security/ buster/updates main contrib non-free

# deb-src http://deb.debian.org/debian buster main contrib non-free
# deb-src http://deb.debian.org/debian buster-updates main contrib non-free
# deb-src http://deb.debian.org/debian-security/ buster/updates main contrib non-free

# 网易源

# deb http://mirrors.163.com/debian/ buster main non-free contrib
# deb http://mirrors.163.com/debian/ buster-updates main non-free contrib
# deb http://mirrors.163.com/debian/ buster-backports main non-free contrib
# deb http://mirrors.163.com/debian-security/ buster/updates main non-free contrib

# deb-src http://mirrors.163.com/debian/ buster main non-free contrib
# deb-src http://mirrors.163.com/debian/ buster-updates main non-free contrib
# deb-src http://mirrors.163.com/debian/ buster-backports main non-free contrib
# deb-src http://mirrors.163.com/debian-security/ buster/updates main non-free contrib

# 阿里云

# deb http://mirrors.aliyun.com/debian/ buster main non-free contrib
# deb http://mirrors.aliyun.com/debian/ buster-updates main non-free contrib
# deb http://mirrors.aliyun.com/debian/ buster-backports main non-free contrib
# deb http://mirrors.aliyun.com/debian-security buster/updates main

# deb-src http://mirrors.aliyun.com/debian/ buster main non-free contrib
# deb-src http://mirrors.aliyun.com/debian/ buster-updates main non-free contrib
# deb-src http://mirrors.aliyun.com/debian/ buster-backports main non-free contrib
# deb-src http://mirrors.aliyun.com/debian-security buster/updates main

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48

更新软件列表并更新软件apt update && sudo apt upgrade -y

# yum

安装yum-utils工具包

yum install yum-utils
1

设置为阿里云源

yum-config-manager --add-repo http://mirrors.aliyun.com/repo/Centos-7.repo
1

# 固定ip

  1. 备份网络配置文件/etc/network/interfaces,然后进行编辑:
cp /etc/network/interfaces /etc/network/interfaces.backup
sudo vim /etc/network/interfaces
1
2

要设置Armbian的固定IP地址,您可以按照以下步骤操作:

  1. 找到适合您网络接口的配置段落。例如,“eth0”:
# Wired adapter #1
auto eth0
allow-hotplug eth0
iface eth0 inet dhcp
1
2
3
4
  1. 将“dhcp”改为“static”,并添加以下行以定义您的静态IP地址、网关和DNS服务器:
iface eth0 inet static
address 192.168.1.100        # 替换为您想要的静态IP地址
netmask 255.255.255.0       # 替换为您网络的子网掩码
gateway 192.168.1.1         # 替换为您的网关地址
dns-nameservers 8.8.8.8     # 替换为您的DNS服务器地址
1
2
3
4
5
  1. 保存退出,重启网络服务以应用更改:
sudo systemctl restart networking.service
1

完成后,您的设备将会使用您指定的静态IP地址连接到网络。

重启网络service networking restart

检查静态 IP 是否已经生效,输入命令 ifconfig 查看网络接口信息,或者使用 ping 命令测试网络连通性.

# 时间

date命令查看系统时间

# 设置时区

TZ=’Asia/Shanghai’; export TZ添加到环境变量中

上次更新: 2023/10/31, 13:49:43
最近更新
01
go-admin-ui项目仿写练手1-登录页
06-29
02
maven依赖问题
06-17
03
JVM相关命令
02-21
更多文章>