[Linux Learning] File and Directory Management

File and Directory Management

It mainly introduces and summarizes the basic management of files and directories in the Linux system.

1. View the files and subdirectories in the current directory

ls -aAdfFhilnrRSt directory name

Options:

-a lists all files and directories (including hidden files and the current directory . And the upper directory .. )

-A All files and directories except the current directory and the upper directory

-d just list subdirectories

-f just list the results, don't sort

-F lists the types of files or directories

-h display the result in a readable way

-i show iNode number

-l List the attributes of files or subdirectories in more detail

-n lists GIDs and UIDs

-r Deserialize

-R recursively list all files and directories under subdirectories

-S Displays results sorted by file or subdirectory size

-t show results sorted by time

ls --color=never/auto/always The directory name displays the files or subdirectories in the current directory by color

ls --full-time directory name Displays the full time of a file or subdirectory

ls --time=atime/ctime The directory name shows the access time and modification permission time of the file or subdirectory

2. Copy

cp -adfilprsu source file or directory sink directory

-a means to copy together with the attributes of the file, and if the source is a linked file, copy the linked file attributes directly instead of the actual file

-d means that if the source is a link file, copy the link file attributes directly instead of the actual file

-f force mode

-i interactive mode

-l create a hard link, create a link file

-p copies the attributes of the file

-r copies subdirectories recursively

-s Create soft links, symbolic links, create link files

-u means do not copy if sink is newer than source

3. Delete

rm -fir file or directory

-f means enforce

-i indicates whether to delete the interactive consultation

-r means recursive delete, often used to delete non-empty directories

4. Mobile

mv -fiu source file or directory sink file or directory

-u means that when the source file is newer than the sink file, the old sink file will be overwritten, otherwise it will not be moved 


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325726797&siteId=291194637