Python Learning Day Fifth----tar command and VIM editor usage and hard disk partitioning method

Source: Internet
Author: User

I. Packaging and compression of files

1. Vertical merging of files: Cat file1 file2 > File3.txt Overlay Merge

Cat file1 file2 > File3.txt Append Merge

2, File archiving: Packaging many files as a file, the purpose is to facilitate the backup, restore and file transfer operations

Create a new tar file using the command tar C----

V----Show packaged file details, verbose

F----Use an archive file or device

T----lists the contents of the contents of the tar file

x----extracting files from the tar file

Z----use gzip compression algorithm to compress packaged file compression rate Low speed fast

J----compression of packaged files using BZIP2 compression algorithm high speed and slow compression rate

3. File compression and decompression:gzip gunzip/bzip2 bunzip2

Example:gzip file1.txt-c >/file1.txt.gz Note: parameter C keeps the source file intact

Gunzip filename

BZIP2 is similar to BUNZIP2

4, packaging and compression at the same time

For example: Use the TAR command to package the home directory and use BZIP2 technology to compress the packaged file (the packaged file is named home.tar.bz2)

Tar cjvf/home.tar.bz2 Home

Tar zcvf new_name.tar.gz * #打包压缩当前目录所有文件并且重命名为new_name. tar.gz

5, the file decompression

Tar zxcf 5day.tar.gz-c/test #将当前目录下的5day. tar.gz extract to the specified/test directory


Ii. use of the VIM editor

Vim [path] [filename] Use the VIM editor to open a file or create a new file

Vim Editor has three modes: Command mode, extended mode, edit mode

Command mode---Edit mode A: Start editing at the next position of the current cursor

I: Start editing the cursor's current position

O: The next line of the cursor starts editing

O: Start editing on the previous line of the cursor

Edit Mode---command mode ESC key

Command mode---Extended mode input ":" To

Extended Mode---command mode ESC key

Note: Extension mode cannot go directly into edit mode


In extended mode: Wq Save Exit wq! Force save exit Q exit q! Force exit Input: Set number Displays line numbers

Command mode to enter "/" + content to find the appropriate content

$: Cursor moves to the end of the current line

0: Cursor moves to the beginning of the current line

DD: Delete cursor line ndd:n is number, delete cursor row and the following n line

YY: Copy cursor row nyy:n is number, copy cursor row and the following n line

P: Paste the copied data on the next line of the cursor P: Pastes the copied data on one line of the cursor

U: Undo command ctrl+r: Redo Last Action

G: Cursor to last line NG: Cursor moves to nth line of file GG: Cursor moves to first line

H: The first character that the cursor moves to the first line of the screen

M: The first character of the cursor moves to the middle line of the screen

L: The first character that the cursor moves to the last line of the screen


Third, add hard disk and initialization

Fdisk-l #磁盘操作命令 to display basic information about the current computer's disk

Fdisk/dev/sdb #对sdb磁盘进行初始化操作

[Email protected] ~]# Fdisk/dev/sdb

You are welcome to use FDISK (Util-linux 2.23.2).


The changes will remain in memory until you decide to write the changes to disk.

Think twice before you use the Write command.


Command (enter M for help): M

Command actions

A toggle a bootable flag

b Edit BSD Disklabel

C Toggle the DOS compatibility flag

D Delete a partition

G Create a new empty GPT partition table

G Create an IRIX (SGI) partition table

L list known partition types

M Print this menu

n Add a new partition #创建一个新的分区

o Create a new empty DOS partition table

P Print the partition table

Q Quit without saving changes #退出保存

s create a new empty Sun Disklabel

t change a partition ' s system ID

U Change display/entry units

V Verify the partition table

W Write table to disk and exit #保存并退出

X Extra functionality (experts only)


Follow the instructions here and note that a disk can create up to 4 primary partitions


After the disk partition is created, the partition needs to be formatted, that is, partitioning the disk file system, Linux commonly used file system has fat,vfat,ext3,ext4,xfs,btrfs and so on, which commonly used EXT4 and XFS, for the log file system, the function is more powerful, What you need to know about yourself is Google.

MKFS.EXT4/DEV/SDB1 #将sdb硬盘的第一分区格式化为ext4文件系统


After formatting the disk partition, the disk is not yet available because the user is not provided with an entry for the operation, and the partition needs to be mounted to a specific directory for disk operation.

MOUNT/DEV/SDB1/SDB1 #将sdb1分区挂载到根目录下的sdb1目录

This is the time to read and write to the disk.



Python Learning Day Fifth----tar command and VIM editor usage and hard disk partitioning method

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.