Linux folder file creation, deletion

  
        

Linux delete folder command. Linux delete directory is very simple, many people still used to use rmdir, but once the directory is not empty, it is deeply troubled, now use the rm-rf command.

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...]

Supplement: Execute the rm command to delete files or directories, such as To delete a 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 Delete folder

de>rm -rf fileNamede>

-Delete 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, be 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 attribute> or –mode<directory attribute> Set the directory permissions 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][datetime][file or directory...]

Additional information: 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 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<datetime> 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 and non-executable files)

Copyright © Windows knowledge All Rights Reserved