1、按系列罗列Linux的发行版,并描述不同发行版之间的联系与区别。
slackware:SUSE Linux Enterprise Server (SLES) , OpenSuse桌面
debian: ubuntu,deepin(深度),mint
redhat: RHEL: RedHat Enterprise Linux, 每18个月发行一个新版本
CentOS:Community Enterprise Operating System 兼容RHEL的格式
中标麒麟:中标软件
Fedora:每6个月发行一个新版本
Alpine:一个面向安全的轻型 Linux 发行版。它不同于通常 Linux 发行版,Alpine 采用了
musl libc 和 busybox 以减小系统的体积和运行时资源消耗,但功能上比 busybox
又完善的多,只有5M左右大小
ArchLinux:轻量简洁,遵循K.I.S.S.原则( keep it simple and stupid ),Manjaro
Gentoo:极致性能,不提供传统意义的安装程序,下载源代码在本机上编译安装软件
LFS:Linux From scratch 自制Linux,只是一个说明书
Android:kernel+busybox(工具集)+java虚拟机
2、安装Centos7.9和ubuntu操作系统,创建一个自己名字的用户名,并可以正常登录,将主要步骤截图。
(1)配置虚拟机

选择自定义安装

选择稍后安装系统

选择对应的系统版本(centos 7 或ubuntu)

命名及指定位置

配置cpu

配置内存

配置网络

配置硬盘大小

完成

(2)添加ISO文件

添加系统ISO文件

启动虚拟机

(3)安装ubuntu18.04
选择语言

安装ubuntu server

选择语言和国家(Hong Kong)


选择不检测键盘

选择键盘布局

手动配置ipv4

ip地址

子网掩码

网关

DNS

输入主机名

创建用户


确定时区

自定义分区

选择磁盘并创建FREE SPACE




创建 / 分区




创建swap分区






创建/data分区










设置HTTP代理为空

设置不自动更新

选择安装的软件(空格选择,不能按回车)(如果选择错误可alt+a返回安装步骤)


完成安装

登录成功

(4)安装centos7.9

选择语言

设置网络和主机名


选择时区


创建分区

选择自定义分区



开始安装

设置root密码


创建用户


等待安装完成重启

安装成功

3、配置环境变量,实现执行history的时候可以看到执行命令的时间。
(1)临时使用
[root@~]# HISTTIMEFORMAT="%F %T"
[root@~]# history
...省略
1004 2021-07-11 19:40:58HISTTIMEFORMAT="%F %T"
1005 2021-07-11 19:41:01history
(2)持久保存变量
变量可以 export 变量名="值" 形式存放在 /etc/profile 或 ~/.bash_profile
其中:
/etc/profile //全局
~/.bash_profile //当前用户
例:
[root@centos8 ~]#cat .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
export HISTCONTROL=ignoreboth
export HISTTIMEFORMAT="%F %T "
[root@centos8 ~]source ~/.bash_profile
[root@centos8 ~]#history
1 2019-12-13 08:39:05 ls /data
2 2019-12-13 08:39:05 date
3 2019-12-13 08:39:05 vie0
4 2019-12-13 08:39:05 nano .bash_profile
5 2019-12-13 08:39:05 exit
4、总结Linux哲学思想。
(1)一切都是一个文件(包括硬件)
(2)小型,单一用途的程序
(3)链接程序,共同完成复杂的任务
(4)避免令人困惑的用户界面
(5)配置数据存储在文本中
5、总结Linux常用命令使用格式,并用实例说明。例如echo、screen、date、ifconfig、export等命令
(1)echo
echo 命令可以将后面跟的字符进行输出
功能:显示字符,echo会将输入的字符串送往标准输出。输出的字符串间以空白字符隔开, 并在最后加上换行号
语法:
echo [-neE][字符串]
选项:
-E (默认)不支持 \ 解释功能
-n 不自动换行
-e 启用 \ 字符的解释功能
显示变量:
echo"$VAR_NAME" /用变量值替换,弱引用
echo'$VAR_NAME' /变量不会替换,强引用
启用命令选项-e,若字符串中出现以下字符,则特别加以处理,而不会将它当成一般文字输出
\a 发出警告声
\b 退格键
\c 最后不加上换行符号
\e escape,相当于\033
\n 换行且光标移至行首
\r 回车,即光标移至行首,但不换行
\t 插入tab
\\ 插入\字符
\0nnn 插入nnn(八进制)所代表的ASCII字符
\xHH 插入HH(十六进制)所代表的ASCII数字(man 7 ascii)
例:
root@ubuntu-test:~# echo -e 'a\x0Ab'
a
b
root@ubuntu-test:~# echo -e '\x50\x41\x4E\x59\x55'
PANYU
root@ubuntu-test:~# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
root@ubuntu-test:~# echo \$PATH
$PATH
root@ubuntu-test:~# echo \
>
panyu@ubuntu-test:~$ echo \\
\
panyu@ubuntu-test:~$ echo \\\
>
panyu@ubuntu-test:~$ echo \\\\
\\
(2)screen
利用screen 可以实现会话管理,如:新建会话,共享会话等
注意:
CentOS7 来自于base源,CentOS8 来自于epel源
例:安装 screen
CentOS7 安装screen
[root@centos7 ~]# yum -y install screen
CentOS8 安装screen
[root@centos8 ~]# dnf -y install epel-release
[root@centos8 ~]# dnf -y install screen
screen命令常见用法:
screen –S [SESSION] /创建新screen会话
screen –x [SESSION] /加入screen会话
exit /退出并关闭screen会话
Ctrl+a,d /剥离当前screen会话
screen -ls /显示所有已经打开的screen会话
screen -r [SESSION] /恢复某screen会话
(3)date
1、查看系统时间
date
例:
ubuntu@ubuntu:~$ date
Mon Jun 21 14:43:54 UTC 2021
[root@zabbix-test ~]# date
2021年 06月 21日 星期一 22:44:08 CST
2、显示和设置系统时间
[root@centos8 ~]#date +%s
1584689051
[root@centos8 ~]#date -d @`date +%s`
Fri Mar 20 15:24:18 CST 2020
[root@centos8 ~]#date -d @1584689051
Fri Mar 20 15:24:11 CST 2020
[root@centos8 ~]#date -d @1584689051 +%F_%T
2020-03-20_15:24:11
[root@ubuntu ~]#date -d "2020-02-02" +%s
1580572800
显示前天日期
root@ubuntu:~# date -d '-2 day'
Sun Jun 20 14:55:36 UTC 2021
显示前天是星期几
root@ubuntu:~# date -d '-2 day' +%A
Sunday
设置当前日期为2019-08-07 06:05:10
root@ubuntu:~# date -s '2019-08-07 06:05:10' +%F' '%T
2019-08-07 06:05:10
显示当前时间,格式:2016-06-18 10:20:30
root@ubuntu:~# date +%F' '%T
2021-06-22 14:57:00
(4)export
export命令用于将shell变量输出为环境变量,或者将shell函数输出为环境变量。
格式:
export [-fn] [name[=value] ...] or export -p
常用选项:
-f refer to shell functions
-n remove the export property from each NAME
-p display a list of all exported variables and functions
6、描述Linux发行版的系统目录名称命名规则以及用途。
/boot:引导文件存放目录,内核文件(vmlinuz)、引导加载器(bootloader, grub)都存放于此目录
/bin:所有用户使用的基本命令;不能关联至独立分区,OS启动即会用到的程序
/sbin:管理类的基本命令;不能关联至独立分区,OS启动即会用到的程序
/lib:启动时程序依赖的基本共享库文件以及内核模块文件(/lib/modules)
/lib64:专用于x86_64系统上的辅助共享库文件存放位置
/etc:配置文件目录
/home/USERNAME:普通用户家目录
/root:管理员的家目录
/media:便携式移动设备挂载点
/mnt:临时文件系统挂载点
/dev:设备文件及特殊文件存储位置
b: block device,随机访问
c: character device,线性访问
/opt:第三方应用程序的安装位置
/srv:系统上运行的服务用到的数据
/tmp:临时文件存储位置
/usr: universal shared, read-only data
bin: 保证系统拥有完整功能而提供的应用程序
sbin:
lib:32位使用
lib64:只存在64位系统
include: C程序的头文件(header files)
share:结构化独立的数据,例如doc, man等
local:第三方应用程序的安装位置
bin, sbin, lib, lib64, etc, share
/var: variable data files
cache: 应用程序缓存数据目录
lib: 应用程序状态信息数据
local:专用于为/usr/local下的应用程序存储可变数据
lock: 锁文件
log: 日志目录及文件
opt: 专用于为/opt下的应用程序存储可变数据
run: 运行中的进程相关数据,通常用于存储进程pid文件
spool: 应用程序数据池
tmp: 保存系统两次重启之间产生的临时数据
/proc: 用于输出内核与进程信息相关的虚拟文件系统
/sys:用于输出当前系统上硬件设备相关信息虚拟文件系统
/selinux: security enhanced Linux,selinux相关的安全策略等信息的存储位置
网友评论