[CONTENT] Linux Variable Default Value

中文

Content One: Set Default Values for Variables on Command Line

1.1 Assign Values to Ordinary Variables

# a=1
# b=

(Add: let a be 1 and B be null as an example)

1.2 Set Default Values for Variables on Command Line

# var1=${a:-no}
# var2=${b:-no}


Add:
If a is null, var1 is no, otherwise var1 is equal to a
If B is null, var2 is no, otherwise var2 is equal to B

1.3 View Variable Results

# echo $var1
1
# echo $var2
no


Add:
The value of a is 1, so var1 is 1
The B is null, so var2 is no

Content Two:Set Variable Defaults in Script

2.1 Setting Variable Defaults in Script

# vim var_default.sh
Create the following:
#!/bin/bash
var_default="${1:-no}"
echo $var_default

(Add:If the variable of $1 is null, then var_default is no, otherwise var_default is equal to $1, and print it out as an example)

2.2 Test Variable Defaults in Script

# bash var_default.sh
no
# bash var_default.sh 1
1
# bash var_default.sh 2
2
# bash var_default.sh 3
3

[内容] Linux 变量默认值

English

内容一:在命令行给变量设置默认值

1.1 给两个普通变量赋值

# a=1
# b=

(补充:这里以让 a 是 1,b 为空值为例)

1.2 在命令行给变量设置默认值

# var1=${a:-no}
# var2=${b:-no}


补充:
1) 如果 a 是空值,则 var1 是 no,否则 var1 等于 a
2) 如果 b 是空值,则 var2 是 no,否则 var2 等于 b

1.3 显示变量结果

# echo $var1
1
# echo $var2
no


补充:
1) a 的值是 1,所以 var1 是 1
2) b 的是空值,所以 var2 是 no

内容二:在脚本中设置变量默认值

2.1 创建设置变量默认值的脚本

# vim var_default.sh

创建以下内容:

#!/bin/bash
var_default="${1:-no}"
echo $var_default

(补充:这里以如果 $1 的变量是空值,则 var_default 是 no,否则 var_default 等于 $1,并显示出来为例)

2.2 测试设置变量默认值的脚本

# bash var_default.sh
no
# bash var_default.sh 1
1
# bash var_default.sh 2
2
# bash var_default.sh 3
3

[CONTENT] Linux Partition Advice

中文

Content One: BIOS Partition Advice

1.1 Partition Planning

/boot    >= 5G
/var/tmp >= 10G
/tmp     >= 10G
swap     >= 2G
/        all remaining space

1.2 Standard Partition and Logical Partition

/boot    Use standard partition
/var/tmp Use logical partition
/tmp     Use logical partition
swap     Use logical partition
/        Use logical partition

1.3 Format

/boot    xfs
/var/tmp xfs
/tmp     xfs
swap     swap
/        xfs

1.4 Mount Parameter

/boot    defaults
/var/tmp rw,nosuid,nodev,noexec,relatime,strictatime
/tmp     rw,nosuid,nodev,noexec,relatime,strictatime
swap     defaults
/        defaults

Content Two:EFI Partition Advice

2.1 Partition Planning

/boot/efi >= 5G
/var/tmp  >= 10G
/tmp      >= 10G
swap      >= 2G
/         all remaining space

2.2 Standard Partition and Logical Partition

/boot/efi Use standard partition
/var/tmp  Use logical partition
/tmp      Use logical partition
swap      Use logical partition
/         Use logical partition

2.3 Format

/boot/efi vfat
/var/tmp  xfs
/tmp      xfs
swap      swap
/         xfs

2.4 Mount Parameter

/boot/efi defaults
/var/tmp  rw,nosuid,nodev,noexec,relatime,strictatime
/tmp      rw,nosuid,nodev,noexec,relatime,strictatime
swap      defaults
/         defaults

[内容] Linux 分区建议

English

内容一:BIOS 分区建议

1.1 分区规划

/boot    >= 5G
/var/tmp >= 10G
/tmp     >= 10G
swap     >= 2G
/        all remaining space

1.2 标准分区和逻辑分区

/boot    Use standard partition
/var/tmp Use logical partition
/tmp     Use logical partition
swap     Use logical partition
/        Use logical partition

1.3 格式化

/boot    xfs
/var/tmp xfs
/tmp     xfs
swap     swap
/        xfs

1.4 挂载参数

/boot    defaults
/var/tmp rw,nosuid,nodev,noexec,relatime,strictatime
/tmp     rw,nosuid,nodev,noexec,relatime,strictatime
swap     defaults
/        defaults

内容二:EFI 分区建议

2.1 分区规划

/boot/efi >= 5G
/var/tmp  >= 10G
/tmp      >= 10G
swap      >= 2G
/         all remaining space

2.2 标准分区和逻辑分区

/boot/efi Use standard partition
/var/tmp  Use logical partition
/tmp      Use logical partition
swap      Use logical partition
/         Use logical partition

2.3 格式化

/boot/efi vfat
/var/tmp  xfs
/tmp      xfs
swap      swap
/         xfs

2.4 挂载参数

/boot/efi umask=0077,shortname=winnt 0 2
/var/tmp  rw,nosuid,nodev,noexec,relatime,strictatime
/tmp      rw,nosuid,nodev,noexec,relatime,strictatime
swap      defaults
/         defaults