Touch command
-Feature Description: Generate a new empty file or change the timestamp of an existing file.
-Command format: Touch [parameters] < file > ...
-Common parameters:
-A: Change the access time only.
-M: Only change the modification time.
-T <STAMP>: Use time in [[CC]YY]MMDDHHMM[.SS] format instead of current time.
-R < Reference file or directory >: Use the time attribute of the specified file instead of the current time.
-use Example:
Touch NewFile
Touch file
Touch-a file
Touch-m file
Touch-t 200701311200 File
There are 3 types of timestamps for-gnu/linux files:
Mtime: Last Modification Time (LS–LT)
CTime: State Change Time (LS–LC)
Atime: Last Access Time (LS–LU)
Attention:
1. CTime is not a file creation time.
2. Overwriting a file will change all three classes of time: Mtime, CTime, and Atime.
3. Changing the access rights or the owner of the file will change the CTime and atime of the file.
4. Reading a file will change the atime of the file.
CP command
-Function Description: Copy files or directories.
-command format: CP [parameters] < source > < target >
-Common parameters:
-A: equivalent to –DPR.
-D: When you copy a symbolic link's source file, the destination file also creates a symbolic link and points to the original file that the source file is linked to.
-F: Force replication, regardless of whether the target exists.
-I: Interactive replication requires confirmation before overwriting the file.
-P: Preserves file attributes during file copying, including owner, group, permission, and timestamp.
-r,-r: Recursively replicates all items in the directory and directory.
-L: Create a hard link to the source file instead of copying the file, or you can use the LN command.
-S: Create a symbolic link to the source file instead of copying the file, or you can use the Ln-s command.
-U: Replication occurs only if the modification time of the source file (CTime) is newer than the target file or the target does not already exist.
-use Example:
CP file1 File2
CP Some/dir/file1 someother/dir/
CP Some/dir/file1 Someother/dir/file2
CP Some/dir/file.
CP Some/dir/files someother/dir/
CP some/dir/file1 Some/dir/file2 Some/dir/file3 someother/dir/
Cp-r some/dir/someother/dir/
Cp-au some/dir/someother/dir/
MV Command
-Function Description: Move file or directory, file or directory rename.
-Command format: MV [parameters] < source > < target >
-Common parameters:
-F: Forces the move, regardless of whether the target exists.
-I: Interactive move, need confirmation before overwriting file.
-U: Move only if the source file's modification time (CTime) is newer than the target file or the target does not already exist.
-use Example:
mv/some/dir/file1/someother/dir/
Mv/some/dir/file1/someother/dir/file2
mv/some/dir/files/someother/dir/
MV File Newname_file
MV Dir newname_dir
RM command
-Feature Description: Delete files or directories.
-Command format: RM [parameters] < file > ...
-Common parameters:
-F: Skip files that do not exist, and do not display any information.
-I: Must be confirmed before any delete operation.
-r,-r: Recursively deletes all directory tiers under this directory.
-use Example:
Rm/some/dir/file1
Rm-i/some/dir/file1
Rm-f/some/dir/file1
rm-rf/some/dir/
Attention
1. By default, RM does not delete the directory. Use the-recursive (-R or –r) option to delete each given directory, along with all of its contents.
2. To delete a file with the first character "-" (for example, "-foo"), use one of the following methods:
Rm--foo
Rm./-f
ln command
-Feature Description: Create a linked file.
-Command format: ln [parameters] < linked file > < link file name >
-Common parameters:
-S: Creates symbolic links instead of hard links.
-F: Forcibly creates a link, whether or not it exists.
-I: Ask the user before overwriting the original file.
-use Example:
ln somefile hardlinkfile
Ln-s Somefile Softlinkfile
Ln-s Somedir Softlinkfile
symlinks command
-Function Description: Check the symbolic link in the directory and display the symbolic link type.
-Command format: symlinks [parameters] < catalogue > [< directory;
-Type of link:
Absolute: Use symbolic links for absolute paths.
Dangling: Symbolic link where the original file does not already exist.
Lengthy: The path to the symbolic link contains an extra ". /”。
Messy: The path to the symbolic link contains an extra "/".
OTHER_FS: The original file is located in another file system.
Relative: A symbolic link that uses a relative path.
-Common parameters:
-C: Converts a symbolic link of type Absolute/messy to the relative type.
-D: Removes symbolic links of type dangling.
-R: Checks for symbolic links in all subdirectories under the directory.
-S: Shorten the symbolic link of the lengthy type.
-V: Displays all types of symbolic links.
-use Example:
Symlinks-v-R.
Symlinks-v/usr/bin
Symlinks-c Somedir
Symlinks-s-D Somedir
Linux (CentOS) file Operations Command