Linux files: ls, cp, mv, rm

  
        

ls:list , list the contents of the directory

Usage: ls [-aAdhl] //ls parameters a lot, here are a few commonly used

no parameters, directly ls, The contents of the directory can be listed, including the names of the files and subdirectories.

-a : List all files, including hidden directories and hidden files (files beginning with .)

-A : List all files, including hidden directories and File (but not including .. and .2 directories)

-d : List only the directory itself, not the file data in the directory

-h : file capacity Listed in a way that is easier for humans to read (eg GB, KB, etc.)

-l : List files and display information such as file attributes and permissions

Eg: List under /tmp Commands for all files (including hidden files, but not including “.” and ”..”): ls –A /tmp

PS: Appears in .bush style Hidden files

cp:copy copy

Usage: cp [-adfilprsu] Source file target

No parameters, direct cp source file target (target can The file name can also be the directory name.

-a : Copy the file status, permissions, etc. as much as possible.

-r : If the source contains a directory name, the files in the directory are also copied to the destination in sequence.

-f : If the file with the same file name already exists in the destination, delete it before copying and copy it.

In the default condition, the source and destination files of cp are different. The owner of the destination file will be the user who executes the command.

-u : Differential copy, commonly used in backup

File move command: mv

mv:move Move files, and the role of renaming

Usage: mv [-fiu] source destination

-f: Force move, no warning message appears

-i: Interactive mode, ask you before moving

- u: When the target exists, only the source is updated.

File or directory deletion command: rm

rm:remove Remove

Usage: rm [-fir ] File or directory

Without parameters, use rm file directly, you can delete file

-f: Force delete, no warning message

-i: interactive mode , ask you before deleting

-r: recursive deletion, the most commonly used in the directory deletion, very dangerous parameters

computer hardware foundation; linux installation; linux basic instructions; file system management; Editor; shell use; package management; linux network foundation.

Copyright © Windows knowledge All Rights Reserved