Basic operations on files or folders in linux (copying, moving, deleting, searching, and compressing ),

Source: Internet
Author: User

Basic operations on files or folders in linux (copying, moving, deleting, searching, and compressing ),

Create, copy, move, rename, and delete basic commands for linux Files (folders)

Copy a file or the entire directory

Cp source file name target Folder/[target file name]
Cp-target folder of the rv source folder/[name of the target folder]
-- Subdirectories in the r recursive directory
-V: returns the details of each copied file.

Move or rename a file
Target folder of the mv source file name/
Target File Name of the mv source file (rename the file)


Create a file
Touch file name
Delete an object
Rm file name

Create folder
Mkdir folder name

Delete the folder and the files under the Directory
Rm-r folder name

Interactive deletion.
Rm-ri folder name
Force Delete add-f
Rm-rif

Delete folders, but rmdir cannot delete non-empty folders
Rmdir folder name

 

Archive an object

Tar-cvf filename.tar filename

Eg: tar-cvf mongodb_log.tar mongodb_log.log

Release an archive

Tar-xvf filename.tar

Eg: tar-xvf filename.tar

Archive and compress

Tar-cvzf filename.tar.gz/folder

Release and decompress

Tar-xvzf filename.tar.gz

View files

Cat file name

(For viewing the page with a flip down, the Space key is to view the next page, and you cannot look back) more file name

(Page flip with orientation up and down) less file name

Head-n specifies the number of rows of data to be viewed.

Tail-n displays several rows of data starting from the end of the file.

Tail-f continuously views file changes, which are generally used for Log changes.

 

File Search

Locate keyword (dependent Search Library. If you create a file or folder, use updatedb to update the Search Library)

Find/-name filename (search by file name)

Find/-name *. conf (search by file extension name)

Find/-type d (view by type)

Find/-name test *-exec ls-l {}\; (find and execute the command)

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.