素材来源:Redhat Linux 8.0培训教材《RH124》、《RH134》和《RH294》
玩了5-6年的Linux,现在再来温习一遍RHCE培训教材,按照指导完成实验并与大家分享。
附上汇总贴:玩转Redhat Linux 8.0系列 | 合集_热爱编程的通信人的博客-CSDN博客
1 将student用户的PS1 shell变量更改为[\u@\h \t \w]$9(记住将PS1的值放在引号内,并在美元符号后放入一个尾随空格)。这样会在提示符上添加时间。
1.1 在workstation上,使用ssh命令登录servera。
[student@workstation ~]$ ssh student@servera
student@servera's password:
Activate the web console with: systemctl enable --now cockpit.socket
This system is not registered to Red Hat Insights. See https://cloud.redhat.com/
To register this system, run: insights-client --register
Last login: Sat May 20 19:53:28 2023 from 172.16.190.227
[student@servera ~]$
1.2 使用Vim编辑~/.bashrc配置文件。
[student@servera ~]$ vim ~/.bashrc
1.3 将PS1 shell变量及其值添加到~/.bashrc文件。记住在您设置的值的末尾包含一个尾随空格,并将包括尾随空格在内的整个值放在引号中。
PS1='[\u@\h \t \w]$ '
export PATH
1.4 从servera退出,然后使用ssh命令重新登录,以更新命令提示符。
[student@servera ~]$ exit
logout
Connection to servera closed.
[student@workstation ~]$ ssh student@servera
student@servera's password:
Activate the web console with: systemctl enable --now cockpit.socket
This system is not registered to Red Hat Insights. See https://cloud.redhat.com/
To register this system, run: insights-client --register
Last login: Sat May 20 20:03:48 2023 from 172.16.190.227
[student@servera 20:07:49 ~]$
2 为本地shell变量分配值。变量名称可以包含大写或小写字母、数字和下划线字符。检索变量值。
2.1 创建一个名为file且值为tmp.zdkei083的新变量。tmp.zdkei083文件存在于student主目录中。
[student@servera 20:07:51 ~]$ file=tmp.zdkei083
[student@servera 20:09:01 ~]$
2.2 检索file变量的值。
[student@servera 20:09:02 ~]$ echo $file
tmp.zdkei083
[student@servera 20:09:23 ~]$
2.3 使用变量名称file和ls -l命令列出tmp.zdkei083文件。使用rm命令和file变量名称删除tmp.zdkei083文件。确认它已被删除。
[student@servera 20:10:35 ~]$ ls -l $file
-rw-rw-r--. 1 student student 0 May 20 20:10 tmp.zdkei083
[student@servera 20:10:36 ~]$ rm $file
[student@servera 20:10:41 ~]$ ls -l $file
ls: cannot access 'tmp.zdkei083': No such file or directory
[student@servera 20:10:47 ~]$
3 为editor变量分配一个值。使用一个命令使变量成为环境变量。
[student@servera 20:10:49 ~]$ export EDITOR=vim
[student@servera 20:11:28 ~]$ echo $EDITOR
vim
[student@servera 20:11:33 ~]$
4 从servera退出。
[student@servera 20:11:34 ~]$ exit
logout
Connection to servera closed.
[student@workstation ~]$