红帽学习笔记[RHCSA] 第二课

第二课

常用的目录结构与用途

/  根目录
/boot 存储的是系统起动时的信息和内核等
/dev  存储的是设备文件
/etc 存储的是系统的配置文件
/root 存储的是root用户的家目录
/home 存储的是普通用户的家目录
/mnt  存储的是自定义的挂在光盘或U盘
/var    存储的系统里经常变化的信息,比如日志
/tmp  存储的是临时文件
/bin    出处的是系统里的基本命令。普通用户就可以执行
/sbin   存储的是管理类的命令,root用户执行
/usr    存储的是应用程序文件,占用磁盘最大的
/proc    伪文件系统,几乎里面的东西全是内存中的数据,基本不占用磁盘空间。

本次课程涉及到的命令

cd切换目录

# cd 什么都不加会切换到当前用户的家目录
[root@localhost /]# cd 
[root@localhost ~]# 
# cd ~ 同样的操作
[root@localhost /]# cd ~
[root@localhost ~]# 
# cd -切换到上一次的目录
[root@localhost ~]# cd -
/
[root@localhost /]# 
# cd . 当前目录
[root@localhost /]# cd .
[root@localhost /]# 
# cd ..切换到上一级目录
[root@localhost test]# cd ..
[root@localhost /]# 

pwd显示当前所在目录

[root@localhost test]# pwd
/test
[root@localhost test]# 

$LANG临时切换语言环境

[root@localhost test]# LANG=zh_CN.UTF8
[root@localhost test]# aa
bash: aa: 未找到命令...
[root@localhost test]# LANG=zh_EN.UTF8
[root@localhost test]# aa
bash: aa: command not found...

touch更新文件时间戳。

将文件的时间戳更新为当前的日期与时间,如果文件不出存在会创建文件

[root@localhost test]# touch 33.txt
[root@localhost test]# 
[root@localhost test]# ls
11.txt  22.txt  33  33.txt  44
# 可以同时touch多个文件
[root@localhost test]# touch 11.txt 22.txt 33.txt 44.txt
[root@localhost test]# ls
11.txt  22.txt  33.txt  44.txt  55
# 关于同时创建多个文件的写法
#       创建100个文件 test1.mul  到 test100.mul
[root@localhost test]# touch test{1..100}.mul
#       创建26个文件 testa.mul 到 testz.mul 
[root@localhost test]# touch test{a..z}.mul
#       创建两个文件 test_i.mul  test_y.mul
[root@localhost test]# touch test{i,y}.nul
# ------------------------------------------------
# {}可以并列写多个,可以嵌套写,{..}表示一连串{,}表示并列。

cp复制文件或者目录

[root@localhost test]# cp 11.txt /test1
[root@localhost test]# ls test1
ls: cannot access test1: No such file or directory
[root@localhost test]# ls /test1
11.txt

mv移动文件,或重命名文件

# test文件夹下
[root@localhost test]# ls
11.txt  22.txt  33  33.txt  44
# 将22.txt移动到 /test1下
[root@localhost test]# mv 22.txt /test1
# 将33.txt重命名为44.txt
[root@localhost test]# mv 33.txt 44.txt
#查看test下结果
[root@localhost test]# ls
11.txt  33  44  44.txt
#查看test1下结果
[root@localhost test]# ls /test1
11.txt  22.txt

rm删除文件或文件夹

# 查看test内容
[root@localhost test]# ls
11.txt  33  44  44.txt
# 删除11.txt 提示是否确认删除
[root@localhost test]# rm 11.txt 
rm: remove regular file '11.txt'? y
# -f 强制删除44.txt,不提示是否删除
[root@localhost test]# rm -f 44.txt 
# 删除33文件夹失败
[root@localhost test]# rm -f 33
rm: cannot remove '33': Is a directory
# -r 删除文件夹
[root@localhost test]# rm -rf 33
[root@localhost test]# ls
44

rmdir删除空的文件夹

# 递归显示55文件夹下有文件 44是空的文件夹
[root@localhost test]# ls -R 
.:
44  55

./44:

./55:
11.txt
# 删除空的44
[root@localhost test]# rmdir 44
# 删除非空55失败
[root@localhost test]# rmdir 55
rmdir: failed to remove '55': Directory not empty

ESC+.使用上一个命令的最后一个参数

这是一个快捷键,使用是一条命令的最后一个参数

[root@localhost test]# ls 55
11.txt
# 下面这个 55 是通过ESC+.按出来的
[root@localhost test]# ls 55

clear清空当前屏幕,但是不是真正的删除

# CTRL + L相同的作用

manfirefox file:///usr/share/doc/

查看帮助

# 查看 ls 命令的帮助
[root@localhost test]# man ls
# 用 火狐打开帮助文档
firefox file:///usr/share/doc/

猜你喜欢

转载自www.cnblogs.com/primadonna/p/11422328.html