rhcsa第五次

使用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

使用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

使用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

新建文件file1.txt,file2.txt,file3.txt
[root@rhcsa01 ~]# touch file{1..3}.txt

对文件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

新建文件file4.txt,将file4.txt添加到tar_file.tar.gz中
[root@rhcsa01 ~]# touch file4.txt

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

查看压缩包tar_file.tar.gz有哪些文件及目录(不解压,只查看)
[root@rhcsa01 ~]# tar -tvf tar_file.tar

解压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

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

创建普通变量local_data=1并访问
[root@rhcsa01 ~]# export local_data=1

[root@rhcsa01 ~]# echo $local_data

创建环境变量ROOT_DATA=root, 只有root用户可以访问到
[root@rhcsa01 ~]# vim .bash_profile

[root@rhcsa01 ~]# source .bash_profile

[root@rhcsa01 ~]# echo $ROOT_DATA

创建环境变量USER_DATA=user, 只有普通用户可以访问到
[root@rhcsa01 ~]# vim .bash_profile

[root@rhcsa01 ~]# source .bash_profile

[root@rhcsa01 ~]# echo $USER_DATA

创建环境变量DATA=all, root用户和普通用户都可以访问到
[root@rhcsa01 ~]# vim /etc/profile

[root@rhcsa01 ~]# source /etc/profile

[root@rhcsa01 ~]# echo $DATA

创建3个文件test1.txt, test2.txt, test3.txt
[root@rhcsa01 ~]# touch test{1..3}.txt

使用find查找test1.txt,test2.txt, test3.txt
[root@rhcsa01 ~]# find test{1..3}.txt

test1.txt

test2.txt

test3.txt

使用别名: 将上边命令命名为myfind
[root@rhcsa01 ~]# alias myfind="find . -name 'test*.txt'"

[root@rhcsa01 ~]# myfind

./test3.txt

./test2.txt

./test1.txt

取消别名
[root@rhcsa01 ~]# unalias myfind

[root@rhcsa01 ~]# myfind

bash: myfind: command not found...

查看最近使用的10条历史命令
[root@rhcsa01 ~]# history 10

在一行上执行两个命令,打印123和从root切换到普通用户
[root@rhcsa01 ~]# echo 123 ; su - rhcsa

123

[rhcsa@rhcsa01 ~]$

引号的使用举例: 无引号,单引号,双引号,反引号,$()
[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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值