tar命令,vi编辑器

一、将用户信息数据库文件和组信息数据库文件纵向合并为一个文件/1.txt(覆盖):

[root@localhost /]# cat /etc/passwd /etc/group > 1.txt

将用户信息数据库文件和用户密码数据库文件纵向合并为一个文件/2.txt(追加):

[root@localhost /]# cat /etc/passwd /etc/shadow >> 2.txt

/1.txt/2.txt两个文件打包为/1.tar

[root@localhost /]# tar cvf 1.tar 1.txt 2.txt

使用gzip命令压缩1.txt文件名为1.txt.gz

[root@localhost /]# gzip 1.txt

解压缩1.txt.gz

[root@localhost /]# gunzip 1.txt.gz

使用bzip2压缩1.txt压缩后文件名为1.txt.bz2

[root@localhost /]# bzip2 1.txt 
[root@localhost /]# ls
1.tar 2.txt bin dev file1 lib media opt root sbin sys usr
1.txt.bz2 a.txt boot etc home lib64 mnt proc run srv tmp var

解压缩1.txt.bz2

[root@localhost /]# bunzip2 1.txt.bz2 

解包1.tar,解包后文件存放到/tmp目录下:

[root@localhost /]# tar xvf 1.tar -C /tmp

使用tar命令打包并且压缩/1.txt/2.txt,得到的文件名为1.tar.gz

[root@localhost /]# tar cvzf 1.tar.gz 1.txt 2.txt

解包1.tar.gz,解包后文件存放到/tmp目录下:

[root@localhost /]# tar xvf 1.tar.gz -C /tmp

 

二、使用vi编辑器编辑文件/1.txt进入编辑模式写入内容“hello world”

[root@localhost /]# vim 1.txt 

进入命令行模式复制改行内容,在下方粘贴80行:

80yyp

快速移动光标到文件的最后一行:

G

快速移动光标到当前屏幕的中间一行:

M

快速移动光标到文件的第五行:

5G

在下方插入新的一行内容“welcome to beijing”

o

删除刚插入的一行:

dd

撤销上一步的操作:

u

进入扩展模式,执行文件的保存退出操作:

ESC , shift+: wq

 

posted @ 2017-05-25 17:07  李大根er  阅读(382)  评论(0)    收藏  举报