暑期RHCSA 2022.07.18

目录

1.使用tar命令对文件进行打包压缩与解压缩:

 (1)使用gzip方式对文件进行压缩,并指定压缩名为 tar_gzip.tar.gz

  (2)使用bzip2方式对文件夹进行压缩,并指定压缩名为 tar_bzip2.tar.bz2

​编辑(3) 使用xz方式对文件进行压缩,并指定压缩名为 tar_xz.tar.xz

 (4) 新建文件file1.txt,file2.txt,file3.txt

(5) 对文件file1.txt和file2.txt,进行压缩(使用gzip方式),排除file3.txt(即不对file3进行压缩), 并指定压缩名为tar_file.tar.gz

(7) 新建文件file4.txt,将file4.txt添加到tar_file.tar.gz中

(8) 查看压缩包tar_file.tar.gz有哪些文件及目录(不解压,只查看)

(9)解压tar_gzip.tar.gz到指定目录tar_test(没有这个目录就创建)

(10) 解压tar_xz.tar.xz

2.

(1)在Linux上的/root目录创建一个Linux.txt,在windows上创建windows.txt,通过sftp的 get和put命令,将windows上的windows.txt推送到linux上​编辑​编辑

(3)通过sftp的 get和put命令,将linux上的linux.txt推送到windows上

3.

(1)创建普通变量local_data=1并访问

(2)创建环境变量ROOT_DATA=root, 只有root用户可以访问到

(3)  创建环境变量USER_DATA=user, 只有普通用户可以访问到

(4)创建环境变量DATA=all, root用户和普通用户都可以访问到

4.

(1)创建3个文件test1.txt, test2.txt, test3.txt

  (2)使用find查找test1.txt,test2.txt, test3.txt

  (3)使用别名: 将上边命令命名为myfind

  (4)取消别名

5.查看最近使用的10条历史命令

6.在一行上执行两个命令,打印123和从root切换到普通用户

7.引号的使用举例: 无引号,单引号,双引号,反引号,$()


1.使用tar命令对文件进行打包压缩与解压缩:


 (1)使用gzip方式对文件进行压缩,并指定压缩名为 tar_gzip.tar.gz

[root@rhcsa01 ~]# touch tar.text{1..3}
[root@rhcsa01 ~]# tar -czvf tar_gzip.tar tar.text{1..3}
[root@rhcsa01 ~]# ls


 
 (2)使用bzip2方式对文件夹进行压缩,并指定压缩名为 tar_bzip2.tar.bz2

[root@rhcsa01 ~]# touch tar_btext{1..3}
[root@rhcsa01 ~]# tar -cjvf tar_bzip2.tar.bz2 tar_btext{1..3}
[root@rhcsa01 ~]# ls



(3) 使用xz方式对文件进行压缩,并指定压缩名为 tar_xz.tar.xz

 [root@rhcsa01 ~]# touch tar_xtext{1..3}
[root@rhcsa01 ~]# tar -cJvf tar_xz.tar.xz tar_xtext{1..3}
[root@rhcsa01 ~]# ls


 
(4) 新建文件file1.txt,file2.txt,file3.txt

[root@rhcsa01 ~]# touch file{1..3}.txt


(5) 对文件file1.txt和file2.txt,进行压缩(使用gzip方式),排除file3.txt(即不对file3进行压缩), 并指定压缩名为tar_file.tar.gz

[root@rhcsa01 ~]# tar --exclude=file3.txt -czvf tar_file.tar.gz file{1..3}.txt
[root@rhcsa01 ~]# ls

(7) 新建文件file4.txt,将file4.txt添加到tar_file.tar.gz中

[root@rhcsa01 ~]# touch file4.txt
[root@rhcsa01 ~]# tar -rvf tar_file.tar file4.txt

(8) 查看压缩包tar_file.tar.gz有哪些文件及目录(不解压,只查看)

[root@rhcsa01 ~]# tar -tvf tar_file.tar

(9)解压tar_gzip.tar.gz到指定目录tar_test(没有这个目录就创建)

[root@rhcsa01 ~]# mkdir tar_test
[root@rhcsa01 ~]# tar -xzvf tar_gzip.tar -C tar_test
tar.test1
tar.test2

(10) 解压tar_xz.tar.xz

[root@rhcsa01 ~]# tar xvf tar_xz.tar.xz


 

2.

(1)在Linux上的/root目录创建一个Linux.txt,在windows上创建windows.txt,通过sftp的 get和put命令,将windows上的windows.txt推送到linux上

(3)通过sftp的 get和put命令,将linux上的linux.txt推送到windows上

3.

(1)创建普通变量local_data=1并访问

[root@rhcsa01 ~]# export local_data=1
[root@rhcsa01 ~]# echo $local_data

(2)创建环境变量ROOT_DATA=root, 只有root用户可以访问到

[root@rhcsa01 ~]# vim .bash_profile 
[root@rhcsa01 ~]# source .bash_profile 
[root@rhcsa01 ~]# echo $ROOT_DATA

(3)  创建环境变量USER_DATA=user, 只有普通用户可以访问到
 

[root@rhcsa01 ~]# vim .bash_profile 
[root@rhcsa01 ~]# source .bash_profile 
[root@rhcsa01 ~]# echo $USER_DATA

(4)创建环境变量DATA=all, root用户和普通用户都可以访问到

[root@rhcsa01 ~]# vim /etc/profile
[root@rhcsa01 ~]# source /etc/profile
[root@rhcsa01 ~]# echo $DATA

4.

(1)创建3个文件test1.txt, test2.txt, test3.txt

[root@rhcsa01 ~]# touch test{1..3}.txt

  (2)使用find查找test1.txt,test2.txt, test3.txt

[root@rhcsa01 ~]# find test{1..3}.txt
test1.txt
test2.txt
test3.txt

  (3)使用别名: 将上边命令命名为myfind

[root@rhcsa01 ~]# alias myfind="find . -name 'test*.txt'"
[root@rhcsa01 ~]# myfind
./test3.txt
./test2.txt
./test1.txt

  (4)取消别名

[root@rhcsa01 ~]# unalias myfind
[root@rhcsa01 ~]# myfind
bash: myfind: command not found...

5.查看最近使用的10条历史命令

[root@rhcsa01 ~]# history 10
  304  source /etc/profile
  305  echo $DATA
  306  find test{1..3}.txt
  307  touch test{1..3}.txt
  308  find test{1..3}.txt
  309  alias myfind="find . -name 'test*.txt'"
  310  myfind
  311  unalias myfind
  312  myfind
  313  history 10

6.在一行上执行两个命令,打印123和从root切换到普通用户

[root@rhcsa01 ~]# echo 123 ; su - rhcsa
123
[rhcsa@rhcsa01 ~]$ 

7.引号的使用举例: 无引号,单引号,双引号,反引号,$()

[root@rhcsa01 ~]# echo kylin
kylin
[root@rhcsa01 ~]# echo 'kylin'
kylin
[root@rhcsa01 ~]# echo "kylin"
kylin
[root@rhcsa01 ~]# echo `pwd`
/root
[root@rhcsa01 ~]# echo $(pwd)
/root
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值