commands for copying, moving (renaming), deleting, and viewing the contents of a file from a Linux file/directory

Source: Internet
Author: User

The main record file/directory copy, Move (rename), delete, and view the contents of the file commands.

First, copy (CP)

Replication requires that the source file (directory) must exist and that the destination file (directory) does not exist to create a new one.

1. copy file FA

    • And the new file FB,FB Originally does not exist:

CP FA FB

    • Into the directory DB:

CP FA DB

2. Copy directory da(must join-r option)

    • And the new directory db,db originally does not exist.

Cp-r DA DB

    • To the directory DB, the DB must actually exist.

Cp-r da db (Da becomes a subdirectory of db)

Second, mobile (MV)

The move command can also be used to rename a file or directory

1. Move files

    • renaming the file fa (Directory da) to FB (directory db), FB does not exist.

MV FA FB

    • To move the file fa (Directory da) to the directory DB, the DB must exist.

MV FA DB

2. Move the directory (-r option not available)

    • renamed the Directory da to directory db,db originally does not exist.

MV DA DB

    • To move the directory da to the directory DB, the DB must exist.

MV DA DB

Third, delete (RM)

1. Delete file FA

RM FA

2. Also delete files FA and FB

RM FA FB

3. Delete directory (the-r option must be added)

Rm-r da (if there is a directory or file under DA, the system will always ask whether to delete the following subdirectory or file, you can join the option-F forcibly delete , do not confirm)

RM-RF DA

Four, display

1. Instructions for displaying the contents of the file are cat, more, head, tail.

Cat/more/head/tail FA

2. Differences

    • Cat Display all content
    • More pagination display, the space bar page DOWN, b front turn, enter down one line, Pageup,pagedn page, q exit
    • The first 10 rows are displayed by the head
    • Tail Displays the following 10 rows by default.

commands for copying, moving (renaming), deleting, and viewing the contents of a file from a Linux file/directory

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.