Create and delete Linux folder files

Source: Internet
Author: User
Tags touch command

Linux Folder deletion command

Deleting a directory in Linux is very simple. Many people are still used to using rmdir. However, once the directory is not empty, it is deeply worried. Now we can use the RM-RF command.
You can simply use RM, but you need to add two parameters-RF: Rm-RF directory name

 

Delete directory and file rm (remove)

Function Description: delete a file or directory.
Syntax: Rm [-dfirv] [-- help] [-- version] [file or directory...]
Note: Execute the RM command to delete a file or directory. If you want to delete a directory, you must add the "-R" parameter. Otherwise, only the file will be deleted by default.
Parameters:
-D or-Directory: directly Delete the hard connection data of the directory to be deleted to 0 and delete the directory.
-F or-force forcibly deletes a file or directory.
-I or-interactive ask the user before deleting an existing file or directory.
-R,-R, or-recursive recursion processes all the files and subdirectories in the specified directory.
-V or-verbose displays the command execution process.

 


1. delete a folder
De> RM-RF filenamede>

 

-Delete a folder instance:
Rm-RF/var/log/httpd/Access

The/var/log/httpd/Access Directory and all files and folders under it will be deleted.
Note that you must be extremely careful when using this RM-RF. Linux has no recycle bin.

2. delete an object
De> RM-F filenamede>
Be careful when using rm-rf. There is no recycle bin in linux.

 

Linux File adding command

Create directory: mkdir (make directories)

Function Description: create a directory
Syntax: mkdir [-p] [-- help] [-- version] [-m <Directory attribute>] [directory name]
Note: mkdir allows you to create a directory and set the directory permissions at the same time.
Parameters:
-M <Directory attribute> or-mode <Directory attribute> sets directory permissions when creating a directory.
-P or-parents if the upper-level directory of the directory to be created has not yet been created, the upper-level directory will be created together.
Example: mkdir test
Create File touch

Function Description: changes the file or directory time.
Syntax: touch [-acfm] [-d <date and time>] [-r <reference file or table of contents>] [-t <date and time>] [-- help] [-- version] [file or directory...] or touch [-acfm] [-- help] [-- version] [datetime] [file or directory...]
Note: You can use the touch command to change the date and time of a file or directory, including the 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> uses the specified date and time instead of the current time.
-F this parameter will not be processed. It is only responsible for solving the compatibility problem of the BSD touch command.
-M or-time = mtime or-time = modify only changes the change time.
-R <reference file or directory> sets the date and time of the specified file or directory to the same date as that of the reference file or directory.
-T <date and time> uses the specified date and time instead of the current time.
For example, touch test.txt (Note: There is no file extension in Linux to differentiate file types. The system file type is only executable and unexecutable files)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.