How to use the command to delete and create the Linux folder

  

We all know that the Linux rm command can delete files, but if you want to delete the directory, you can't just use the rm command. The following small series will give you a detailed introduction to Linux. How to delete and create folders using commands.

Linux Delete Folder command

linux delete directory is simple, many people still used rmdir, but once the directory is not empty, it plunged into deep distress, now The rm -rf command is fine.

Direct rm is fine, but add two parameters -rf ie: rm -rf directory name

delete directory, file rm(remove)

Description: Delete files or directories.

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

Additional note: Execute the rm command to delete files or directories. If you want to delete the directory, you must add the parameter ”-r”, otherwise the default will only delete the file.

Parameters:

-d or –directory Delete the hard-wired data of the directory to be deleted directly into 0 and delete the directory.

-f or –force Forces the deletion of files or directories.

-i or –interactive Ask the user before deleting the existing file or directory.

-r or -R or –recursive Recursive processing, all files and subdirectories under the specified directory are processed together.

-v or –verbose Shows the execution of the instruction.

1 Deleting a folder

de "rm -rf fileNamede"

- Deleting a folder instance:

rm -rf /var/log/httpd /access

will delete the /var/log/httpd/access directory and all files and folders under it

Need to be reminded: be careful when using this rm -rf , linux does not have a recycle bin

2 delete files

de "rm -f fileNamede"

When using rm -rf must be very careful, linux does not have a recycle bin

Linux Add File Command

Create Directory: mkdir(make directories)

Function Description: Create Directory

Syntax: mkdir [-p][- -help][--version][-m "Directory Attributes"][Directory Name]

Note: mkdir can create directories and set permissions for directories at the same time.

Parameters:

-m "Directory Properties" or –mode "Directory Properties" The permissions for setting the directory at the same time when creating a directory.

-p or –parents If the upper directory of the directory to be created is not yet established, the upper directory will be created together.

Example: mkdir test

Creating a file touch

Description: Change the file or directory time.

Syntax: touch [-acfm][-d "datetime"][-r "reference file or directory"][-t "datetime"] [--help] [--version][ File or directory. . . ] or touch [-acfm][--help][--version][date time][file or directory. . . ]

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

Parameters:

-a or –time=atime or –time=access or –time=use Only change the access time.

-c or –no-create does not create any files.

-d "Time and Date" Use the specified date and time instead of the current time.

-f This parameter will be ignored and will only be used to resolve compatibility issues with the BSD version of the touch directive.

-m or –time=mtime or –time=modify only changes the change time.

-r "Reference file or directory" Set the date and time of the specified file or directory to the same date and time as the reference file or directory.

-t "Date Time" Use the specified date and time instead of the current time.

Example: touch test.txt (Note: There is no file suffix under Linux to distinguish between file types, system file types are only executable files and non-executable files)

The above is deleted under Linux. And the command to create a folder is introduced. It can be seen that the effect of using the command plus some parameters is different, so use it carefully.

Copyright © Windows knowledge All Rights Reserved