欢迎大家来查看 这个可以保存手机哈 有什么写的不对的请大家 留言哈
感谢 linux命令冲查看开始了哈
ls 英文(list files)
用于显示指定工作目录之下的内容
列出目录 文件等等
命令格式 ls [选项] [操作对象]
例如:查看当前路径的文件目录等 ------------- ls 回车 会打印当前路径下的 文件和目录
[root@bogon ~]# ls
anaconda-ks.cfg 公共 视频 文档 音乐
initial-setup-ks.cfg 模板 图片 下载 桌面
[root@bogon ~]# ls -a
. .bashrc .ICEauthority .Xauthority 下载
.. .cache initial-setup-ks.cfg 公共 音乐
anaconda-ks.cfg .config .local 模板 桌面
.bash_history .cshrc .tcshrc 视频
.bash_logout .dbus .viminfo 图片
.bash_profile .esd_auth .vimrc 文档
[root@bogon ~]# ls -l
总用量 8
-rw-------. 1 root root 1833 2月 5 17:07 anaconda-ks.cfg
-rw-r--r--. 1 root root 1881 2月 5 17:10 initial-setup-ks.cfg
drwxr-xr-x. 2 root root 6 2月 5 17:12 公共
drwxr-xr-x. 2 root root 6 2月 5 17:12 模板
drwxr-xr-x. 2 root root 6 2月 5 17:12 视频
drwxr-xr-x. 2 root root 6 2月 5 17:12 图片
drwxr-xr-x. 2 root root 6 2月 5 17:12 文档
drwxr-xr-x. 2 root root 6 2月 5 17:12 下载
drwxr-xr-x. 2 root root 6 2月 5 17:12 音乐
drwxr-xr-x. 2 root root 6 2月 5 17:12 桌面
选项 | Value |
---|---|
-a | 显示所有目录及文件(包括隐藏文件 以.开始的文件) |
-l | 显示文件的全部信息 |
-h | 以人类易读的形式展示文件大小 |
查看文档类的命令
命令:cat、more、head、less、tail、
cat 英文(concatenatle)用于查看文档并打印在屏幕上, 还可以创建 文件, 追加内容
命令格式 cat [选项] [文件]
小技巧:创建一个文件:cat>test.txt <<EOF
只能创建没有这个文件test.txt时创建 然后追加信息可以写入多行
EOF (end of file) 表示文本结束
实例:
创建文件并添加内容实例
[root@bogon ~]# cat >test.txt <<EOF ## 创建test.txt文件并追加2行内容 123 qwe 然后 EOF结尾表示添加内容结束
> 123 ##内容 123
> qwe ##内容 qwe
> EOF ##结束
[root@bogon ~]# cat test.txt ##查看刚才添加内容
123
qwe
#还能这样用
[root@server ~]# cat << EOF > 1.txt
> 123
> qweqweqdasasdadfg34r2311
> dasdnihao
> EOF
[root@server ~]# cat 1.txt
123
qweqweqdasasdadfg34r2311
dasdnihao
当然这个 EOF 可以随意替换成自己喜欢的 但是开始是什么结尾就是用什么
选项
选项 | Value |
---|---|
-n | 显示行号的输出出来 |
-b | 对空行进行不编号 |
查看文档 more |
more类似cat 命令不过会以以一页一页的形式显示,
空格键(space)就往下一页显示,
b键就会往回一页显示,还有搜索字符串的功能
[root@bogon ~]# more /etc/yum.repos.d/CentOS-Base.repo
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and
the
# update status of each mirror to pick mirrors that are updated to a
nd
# geographically close to the client. You should use this for CentO
S updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can t
ry the
# remarked out baseurl= line instead.
head 命令用于显示文件的开头内容。
在默认情况下head命令只显示前10行内容
语法格式:head 选项 文件