Parse Linux folder file creation delete

  • 2020-05-13 04:22:44
  • OfStack

This paper mainly introduces the creation and deletion of folder files, as follows:

Linux delete folder command

It is easy for linux to delete the directory. Many people are still used to using rmdir, but once the directory is not empty, they will be in deep trouble. Now use the rm-rf command.
Directly rm will do, but with two parameters -rf: rm-rf directory name

Delete directories, files rm(remove)

Delete files or directories.

Syntax: rm [-dfirv][--help][--version][file or directory...]

Note: you can delete files or directories by executing rm instruction. If you want to delete a directory, you must add the parameter "-r". Otherwise, only files will be deleted by default.

Parameters:

-d or wk41en directly deletes the hardlink data of the directory to be deleted to 0 and deletes the directory.
-f or ambien 44en forces the deletion of files or directories.
- ask the user before deleting an existing file or directory.
-r or -R or harry 51 recursively processes all files and subdirectories 1 in the specified directory.
-v or hang 54 en display instruction execution.

1 delete folder


de>rm -rf fileNamede> 

- delete folder instance:


rm -rf /var/log/httpd/access

Will delete/var log httpd/access directory and all its files and folders

A word of caution: 1 must be very careful when using this rm-rf. linux does not have a recycle bin

2. Delete files


de>rm -f fileNamede>

Be careful when using rm-rf. linux does not have a recycle bin

Linux add file command

Create directory: mkdir(make directories)

Function description: create a directory

Grammar: mkdir [-p][--help][--version][-- m < Directory attribute > ][directory name]

Note: mkdir can create a directory and set permissions to the directory at the same time.

Parameters:

-m < Directory attribute > Or � mode < Directory attribute > Set permissions for the directory when you create it.
-p or wok 123en if the upper level of the directory to be created has not yet been created, the upper level will be created.

Ex. :


mkdir test

Create the file touch

Function description: change file or directory time.

Grammar: touch [-acfm][-d < Date/time > ][-r < Refer to documentation or bibliography > ][-t < Date/time > ][--help] [--version][file or directory...] Or touch [- acfm] [-- help] [-- version] between [date] [...] file or directory

Note: use the touch directive to change the date and time of a file or directory, including access time and change time.

Parameters:

-a or en 164en =atime or en 166en =access or en 168en =use only change the access time.
-c or hang no-create does not create any files.
-d < Time to date > Use the specified date and time, not the current time.
-f this parameter will be ignored and will only be responsible for resolving compatibility issues with BSD version touch instructions.
-m or en 184en =mtime or en 186en =modify only change the change time.
-r < Reference file or directory > Set the date and time of the specified file or directory to the same as the date and time of the reference file or directory.
-t < Date/time > Use the specified date and time, not the current time.

Example: touch test.txt (note: there is no file suffix under Linux to distinguish the file type, the system file type is only executable and non-executable)

Links: the original http: / / www cnblogs. com end/archive 2012/06/05/2536835. html


Related articles: