今天继续分享一些Redhat Linux 8.0的知识,记得关注,会一直更新~
访问命令行
在本实验中,您将使用Bash shell来执行命令。
·使用Bash shell命令行成功运行简单的程序。
·执行用于识别文件类型并显示文本文件部分内容的命令。
·练习使用一些Bash命令历史记录“快捷键”来更高效地重复命令或部分命令。
以student用户身份并使用student作为密码登录workstation。
在workstation上,运行lab cli-review start脚本来设置干净的实验环境。该脚本还会将zcat文件复制到student的主目录。
[student@workstation ~]$lab cli-review start
[student@workstation~]$date
Thu Jan 2210:13:04 PDT 2019
[student@workstation -]$date +%r
10:14:87 AM
[student@workstation~]$file zcat
zcat:POSIX shell script,ASCII text executable
wc命令可用于显示zcat脚本中的行数、字数和字节数。使用Bash历史记录快捷键Esc+.(同时按Esc和.键)来重用上一命令中的参数,而不是重新键入文件名。
[student@workstation-]$wc Esc+.
[student@workstation -]$wc zcat
51 2991983 zcat
head命令显示文件的开头。再次尝试使用Esc+.快捷键。
[student@workstation~]$head Esc+.
[student@workstation-]$head zcat
#!/bin/sh
#Uncompress files to standard output.
#Copyright(C)2007,2010-2018 Free Software Foundation,Inc.
#This program is free software;you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation;either version 3 of the License,or
#(at your option)any later version.
[studenteworkstation~]$tail Esc+.
[studenteworkstation-]$tail zcat
With no FILE,or when FILE is -,read standard input.
Report bugs to <bug-gzip@gnu.org>."
case $1 in
--help) printf '%s\n'"susage" ll exit 1;;
--version)printf'%s\n'"$version"ll exit 1;;
esac
exec gzip -cd "@"
完全重复上一个命令。按向上箭头键一次从命令历史记录中往前回滚一个命令,然后按Enter键(使用两次击键),或者输入快捷键命令!!,然后按Enter键(使用三次击键)以运行命令历史记录中的最近一个命令。(两种方法都试一次。)
[student@workstation]$!!
tail zcat
with no FILE,or when FILE is -,read standard input.
Report bugs to cbug-gzip@gnu.org>."
case $1 in
--help) printf '%s\n'"susage" l exit 1;;
--version)printf '%s\n'"$version"ll exit 1;;
esac
exec gzip -cd "$@"
[studenteworkstation-]$tail -n 20 zcat
-1,--list list compressed file contents
-q,…quiet suppress all warnings
-r recursive operate recursively on directories
-s,--suffix=SUF use suffix SuF on compressed files
--synchronous synchronous output(safer if system crashes,but slower)
-t,--test test compressed file integrity
-V --verbose verbose mode
--help display this help and exit
--version display version information and exit
with no FILE,or when FILE is-,read standard input.
Report bugs to cbug-gzip@gnu.org>."
case $1 in
-help) printf'%s\n'"susage" l exit 1;exit;;
--version) printf '%s\n'"$version"ll exit 1;exit;;
esac
exec gzip -cd"$@"
使用history命令显示之前命令的列表,以确定要执行的具体date命令。使用!number运行命令,其中number自history命令输出中取用的命令编号。
请注意,您的shell历史记录可能与以下示例不同。根据自己的history命令的输出,确定要使用的命令编号。
[student@workstation -]$history
1 date
2 date +%r
3 file zcat
4 wc zcat
5 head zcat
6 tail zcat
7 tail -n 20 zcat
8 history
[student@workstation~]$!2
date +%r
10:49:56 AM
在workstation上,运行lab cli-review grade脚本来确认是否成功完成本练习。
[studenteworkstation-]$lab cli-review grade
在workstation上,运行lab cli-review finish脚本来完成本实验。
[studenteworkstation~]$lab cli-review finish
本实验到此结束。
在本章中,您学到了:
带你玩转Redhat Linux 8.0
想了解 新技术 9.0
想获取完整的电子档
可咨询