Linux folder file creation, deletion, renaming

Source: Internet
Author: User
Tags create directory file copy touch command

Linux Delete Folder command

Linux Delete directory is very simple, many people are still accustomed to use rmdir, but once the directory is not empty, it fell into deep distress, now use the RM-RF command.
Direct RM is available, but add two parameters-rf that is: RM-RF directory name

Delete directory, file rm (remove)

Feature Description: Delete files or directories.
Syntax: RM [-dfirv][--help][--version][file or directory ...]
Additional Note: The Execute RM instruction can delete the file or directory, if you want to delete the directory must add the parameter "-r", otherwise the default will only delete the file.
Parameters
-D or –directory delete the hard connection data for the directory that you want to delete directly by deleting the directory by 0.
-F or –force forces the deletion of files or directories.
-I or –interactive to ask the user before deleting both files or directories.
-R or-R or –recursive recursively handles all files and subdirectories under the specified directory.
-V or –verbose shows the instruction execution process.


1 Deleting a folder
DE>RM-RF filenamede>

-delete Folder instance: (If you delete the folder under the current directory, you can enter the folder name directly)
Rm-rf/var/log/httpd/access

The/var/log/httpd/access directory and all files and folders under it will be deleted
To be reminded: Use this RM-RF with extreme caution, Linux does not have a recycle Bin

2 Deleting files
De>rm-f filenamede>
Use RM-RF with extreme caution, Linux does not have a recycle Bin

Linux Add Files command

Create directory: mkdir (make Directories)

Function Description: Create a directory
Syntax: mkdir [-p][--help][--version][-m < directory properties >][directory name]
Supplemental Note: mkdir can create a directory and set permissions for the directory at the same time.
Parameters
-m< Directory properties > or –mode< Directory properties > set directory permissions at the same time when the directory is established.
-P or –parents if the upper-level directory to which you want to create the directory is not currently established, the upper-level directory will be created.
Example: mkdir test
Create a file Touch

Function 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 ...]
Supplemental 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 Date > Use the specified datetime, not the current time.
-F This parameter ignores non-processing and is responsible only for compatibility issues with BSD version touch directives.
-M or –time=mtime or –time=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 date and time as the reference file or directory.
-t< Date Time > Use the specified datetime, not the current time.
Example: Touch test.txt (Note: Linux does not have file suffix name to differentiate file type, System file type only executable files and non-execute files)

--------------------------------------------------------------------------------------------------------------- -------------

Renamed:

  MV Command

Features: Renaming files or directories or moving files from one directory to another. This command is like a combination of Ren and move under DOS.

Syntax: MV [options] source file or directory destination file or directory

Description: Depending on the second parameter type in the MV command (target file or target directory), the MV command renames the file or moves it to a new directory. When the second parameter type is a file, the MV command completes the file rename, at which point the source file can only have one (or the source directory name), which renames the given source file or directory to the specified destination file name. When the second parameter is a directory name that already exists, the source file or directory parameter can have more than one, and the MV command moves the source files specified by each parameter to the destination directory. When you move a file across a file system, the MV copies the original file, and the link to the file is lost.

Parameters:

-I interact with the mode of operation. If the MV operation will cause an overwrite of the target file that already exists, the system asks whether to rewrite and asks the user to answer Y or N, which avoids overwriting the file by mistake.

-F prohibit interactive operation. When the MV operation is to overwrite an existing target file without giving any indication, when this option is specified, the I option will no longer work.

If the given destination file (not the directory) already exists, the contents of the file will be overwritten by the new file. To prevent users from inadvertently destroying another file with the MV command, it is recommended that users use the I option when moving files using the MV command.

It is important to note that the MV is different from the CP results. MV as if the file "move", the number of files and the end of the increase, and the CP file copy, the number of files increased.

 Example 1: Move all files in the/usr/xu to the current directory (with ".")   In the representation): $ mv/usr/xu/*. Example 2: Renaming the file Wch.txt to Wjz.doc $ mv Wch.txt Wjz.doc

Linux folder file creation, deletion, renaming

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.