Better typesetting and a more complete picture display please visit:
Www.nextkara.net
CP Copy command:
CP [OPTION] ... [-T] SOURCE DEST
CP [OPTION] ... SOURCE ... DIRECTORY
CP [OPTION] ...-t DIRECTORY SOURCE ...
CP SRC DEST
SRC is a file:
If the target does not exist: Creates a new dest and fills the contents of SRC into
In Dest
If the target exists:
If Dest is a file: overwrites the content in SRC to dest
Based on security, we recommend that you use the-i option for the CP command
If Dest is a directory: Create a new text with the same name as the original file under Dest
And populate the contents of SRC with the new file
CP SRC ... DEST
SRC ...: Multiple files
Dest must exist and be directory, other situations will be error;
CP SRC DEST
SRC is the directory: Use this time option:-R
If Dest does not exist: creates the specified directory and copies the contents of the SRC directory
There are documents to the dest;
If dest exists:
If Dest is a file: Error
If Dest is a directory:
650) this.width=650; "class=" AlignCenter size-full wp-image-154 "src=" http://www.nextkara.net/wp-content/uploads/ 2016/07/screenshot_20160728_190246.png "alt=" Nineth Day: Basic file Management "width=" 865 "/>
options [Options]:
-I: Interactive
-R,-r: recursively copy directories and all internal content;
-A: Archive, equivalent to-DR--preserv=all
-d:--no-dereference--preserv=links does not copy the original file, only the link name is copied
--preserv[=attr_list]; mode: permission; ownership: belongs to the main group; timestamp: time stamp; links;xattr;context;all
-P: Equivalent--preserv=mode,ownership,timestamp
-V:--verbose More information
-F:--force mandatory
MV Move Command:
MV [OPTION] ... [-T] SOURCE DEST
MV [OPTION] ... SOURCE ... DIRECTORY
MV [OPTION] ...-t DIRECTORY SOURCE ...
Common options:
-I: Interactive
-F: Mandatory
RM command: Remove a file or directory operation
RM [OPTION] ... FILE ...
Common options:
Example: #rm-RF/
Practice:
1, using the alias command, the daily/etc/directory of all files,
Back up to/testdir/under a separate new directory and ask for a new directory
Format is BACKUPYYYY-MM-DD, the backup process is visible
Alias baketc= "Cp-virp/etc/testdir/backup ' Date +%f '"
650) this.width=650; "class=" AlignCenter size-full wp-image-155 "src=" http://www.nextkara.net/wp-content/uploads/ 2016/07/screenshot_20160728_193120.png "alt=" Nineth Day: Basic file Management "Width="/>
2, first create/testdir/rootdir directory, and then copy/root all
Files to the directory, and requires that the original permissions be retained
650) this.width=650; "class=" AlignCenter size-full wp-image-156 "src=" http://www.nextkara.net/wp-content/uploads/ 2016/07/screenshot_20160728_195227.png "alt=" Nineth Day: Basic file Management "Width="/> Base directory operations:
Tree Display directory Trees
-D: Show only directories
-L Level: Specifies the number of levels to display
-P Pattern: Displays only the paths that are matched by the specified pattern
mkdir Creating a Directory
-P: exists in no error, and can automatically create the required directories;
-V: Show more information
-M MODE: Specify permissions directly when creating a directory;
RmDir Delete Empty Directory
-P: Recursive deletion of the parent empty directory
-V: Show more information
Rm-r recursively delete a directory tree
Practice:
(1) How to create/testdir/dir1/x,/testdir/dir1/y,
/testdir/dir1/x/a,/testdir/dir1/x/b,
/testdir/dir1/y/a,/testdir/dir1/y/b
Mkdir-p/testdir/dir1/{x,y}/{a,b}
(2) How to create/testdir/dir2/x,/testdir/dir2/y,
/testdir-p/dir2/x/a,/testdir/dir2/x/b
Mkdir/dir2/{x/{a,b},y}
(3) How to create/TESTDIR/DIR3,/TESTDIR/DIR4,/TESTDIR/DIR5,
/TESTDIR/DIR5/DIR3,/TESTDIR/DIR5/DIR4
mkdir/testdir/dir{3,4,5/dir{3,4}}
Displays all available command aliases for the current shell process
Defines the alias name, which is equivalent to executing the command value;
Aliases defined on the command line, valid only for the current shell process
If you want to be permanently valid, define it in the configuration file
For the current user only: ~/.BASHRC
Valid for all users:/ETC/BASHRC
650) this.width=650; "class=" AlignCenter size-full wp-image-157 "src=" http://www.nextkara.net/wp-content/uploads/ 2016/07/screenshot_20160728_195502.png "alt=" Nineth Day: Basic file Management "Width="/> Reload the configuration file:
Source/path/to/file
. /path/to/file
Revoke alias: Unalias New_command
If the alias has the same name as the original command, if you want to execute the original command, you can use
"\command"
' COMMAND '
/path/command: External command
ls Command supplemental content:
Usage:
ls [options] [Files_or_dirs]
Example:
Ls-a contains hidden files
Ls-l Display of additional information
Ls-r Directory recursion passed
Ls-ld Directory and Symbolic link information
LS-1 File Branch Display
Ls–s order from big to small
Ls–u with-t option, display and press atime new to old sort
Ls–u not sorted by directory store order display
File wildcard characters:
* Match 0 or more characters
? Match any single character
~ Current User Home Directory
~username User Home Directory
~+ Current Working Directory
~-Previous working directory
[0-9] matching a range of numbers
[A-Z]: uppercase and lowercase letters
[A-z]: uppercase
[WXC] matches any one of the characters in the list
[^WXC] matches characters other than all characters in the list
Pre-defined character classes: #man 7 glob
[:d Igit:]: Any number, equivalent to 0-9
[: Lower:]: Any lowercase letter
[: Upper:]: Any uppercase letter
[: Alpha:]: Any case letter
[: Alnum:]: Any number or letter
[: Space:]: space
[:p UNCT:]: Punctuation
Practice:
1. Show all start with L in/var directory, end with a lowercase letter, and
Files or directories with at least one digit
Ll-h/var/l*[[:d igit:]]*[[:lower:]]
2, the display in/etc directory with any one digit beginning, and the non-numeric end of the
File or directory
Ll-h/etc/[[:d igit:]]*[^[:d igit:]]
3, the display/etc/directory with a non-letter start, followed by a letter and its
It any file or directory of any length of characters
Ll-h/etc/[^[:alpha:]][[:alpha:]]*
4. Display all files or directories in/etc that start with a non-numeric end of M
Ll-h/etc/m*[^[:d igit:]]
5. Display all files or directories ending with. D in the/etc directory
Ll-h/ETC/*.D
6. Displays all the. conf endings, and the text beginning with m,n,r,p, in the/etc directory
Parts or directories
Ll-h/etc/[[mnrp]]*
Stat
File Category: Metadata, data
Three time stamps:
Access time: Atime, reading the contents of a file
Modify Time: Modified, Mtime, change file contents (data)
Change time: Changing times, ctime, meta data changes
Create empty files and Refresh time
Touch command:
Touch [OPTION] ... FILE ...
The Inode (index node) table contains a list of all file system files
A node (an index node) is a table entry that contains information about the file
(meta data), including:
File type, permissions, Uid,gid
Number of links (pointing to the number of path names for this file name)
The size of the file and the different timestamps
Data block pointer to file on disk
Additional data about the file
650) this.width=650; "class=" AlignCenter size-full wp-image-158 "src=" http://www.nextkara.net/wp-content/uploads/ 2016/07/screenshot_20160728_204503.png "alt=" Nineth Day: Basic file Management "width=" 768 "/> File reference one is inode number
is to refer to a file by file name
A directory is a mapping between a file name and an inode number in a directory
Note: The folder is a special file that contains the file name and Inode values in the directory, and you can use the Vim editor to view the contents of the folder
650) this.width=650; "class=" AlignCenter size-full wp-image-159 "src=" http://www.nextkara.net/wp-content/uploads/ 2016/07/screenshot_20160728_204743.png "alt=" Nineth Day: Basic file Management "Width=" 1178 "/>650" this.width=650; "class=" AlignCenter Size-full wp-image-160 "src=" Http://www.nextkara.net/wp-content/uploads/2016/07/Screenshot_20160728_204826.png " alt= "Nineth Day: Basic file Management" width= "785"/>mv and Inode
If the target and source of the MV command are in the same file system as the MV command
Create a new directory entry with a new file name
Delete old directory entries corresponding to older file names
Does not affect the Inode table (except timestamp) or data location on disk: No
Data is being moved!
If the target and source are in a different file system, MV is equivalent to CP and RM
RM and Inode
The number of links is decremented so that the inode number released can be reused
Put data blocks in the free list
Delete a catalog entry
Data is not actually deleted immediately, but when another file uses a block of data
will be overwritten.
CP and Inode
Allocate a free inode number to generate a new entry in the Inode table
Create a catalog entry in the directory, associating the name with the inode number
Copy data to generate a new file
Hard Links
Creating a hard link adds additional record entries to reference the file
Corresponds to a physical file on the same file system
Each directory references the same inode number
Increase number of links at creation time
When deleting files:
Link for RM command decrement count
File to exist, with at least one link number
When the number of links is zero, the file is deleted
Cannot span drives or partitions
Grammar:
ln filename [linkname]
Files can contain multiple types of data
Check the text file type and then determine the appropriate open command or application to use
file [options] <filename>
Option:
-B The file name is not displayed when the file identification results are listed.
-c Verbose Display instruction execution process, easy to debug or analyze program execution form
-F Lists file types for file names in files
-F replaces the default ":" Delimiter with the specified delimiter symbol for the output file name
-I output MIME type string
-L view file type for the corresponding soft link file
-Z try to interpret the contents of the compressed file
--help Display Command online Help
After-school assignments:
1. Convert the contents of the/etc/issue file to uppercase and save to the/tmp/issue.out file
Tr ' A-Z ' A-Z ' </etc/issue
2. Convert the current system login user's information to uppercase and save to the/tmp/who.out file
Echo ' Who ' | Tr ' A-Z ' A-Z ' >/tmp/who.out
3, a Linux user to the root email, request the message titled "Help", the message body is as follows:
Hello, I am Username, the system version is here,pleasehelp me to check it, thanks!
Operating system Version Information
echo "Hello I am ' whoami ', the system version is here, please help me to check it, thanks. ' Cat/proc/version ' "|mail-s" "Help" root
4, the/root/file list, displayed as a line, and the file name separated by a space
Ls-1/root | TR ' *\n ' * '
5. The contents of the File1 file are: "1 2 3 4 5 6 7 8 9 10" Calculates the sum of all numbers
echo $[$ (tr ' + ' < File1)]
6. Remove the ' ^m ' character from the Windows text file
Tr-d ' ^m ' < Filew
7, processing string "Xt.,l 1 jr#! $mn 2 c*/fe3 uz4", keep only the numbers and spaces
[Email protected] testdir]# echo "Xt.,l 1 jr#" Xt.,l 1 jr#donemn2 c*/fe3 uz4 "Mn2 c*/fe3 uz4" | Tr-d ' [[:p unct:] ' | Tr-d ' [[: Alpha:]] '
650) this.width=650; "class=" AlignCenter size-full wp-image-167 "src=" http://www.nextkara.net/wp-content/uploads/ 2016/07/screenshot_20160729_101449.png "alt=" Nineth Day: Basic file Management "Width="/>
8. Display the path variable in a separate row for each directory
[Email protected] testdir]# echo $PATH | Tr ': ' \ n '
650) this.width=650; "class=" AlignCenter size-full wp-image-164 "src=" http://www.nextkara.net/wp-content/uploads/ 2016/07/screenshot_20160729_091339.png "alt=" Nineth Day: Basic file Management "width=" 560 "/>
9. Delete blank lines of the specified file
[[email protected] testdir]# tr-s "\ n" < ll
650) this.width=650; "class=" AlignCenter size-full wp-image-166 "src=" http://www.nextkara.net/wp-content/uploads/ 2016/07/screenshot_20160729_101340.png "alt=" Nineth Day: Basic file Management "width=" 742 "/>
10. Display each word (letter) in the file in a separate line with no blank lines
[email protected] testdir]# Cat hostname | TR "[[: Space:]]" \ n "| Tr-s "\ n"
650) this.width=650; "class=" AlignCenter size-full wp-image-163 "src=" http://www.nextkara.net/wp-content/uploads/ 2016/07/screenshot_20160729_100854.png "alt=" Nineth Day: Basic file Management "width=" 1066 "/>
This article from "11243775" blog, declined reprint!
Day Nineth: Basic file Management