1. Overview
This series is a summary for you, not a system, the main purpose is to record the Linux I think often forget all aspects.
2. File systemUnder Linux, there is no concept of the C and D disks under Windows, but rather a hierarchy of directories and files, starting with the root (root) and the name/. The directory is a file containing many catalog items, and everything in Linux can be viewed as a file, with a minimum of 2 files per directory. Represent yourself, one. Represents a previous level of directory.Each file in Linux has attribute information: file attributes (normal file, folder, executable file), file size, file owner, file permissions, last modified time. 3. Create, delete files and folders
(1) Create folder "MkDir"
mkdir Command Usage permissions
All users can create folders or directories in a folder that has permissions by using the mkdir command at the terminal.
mkdir command use Format
Format: mkdir [options] DirName
mkdir Command function
The mkdir command enables you to create a folder or directory that is named DirName (the specified file name) at the specified location. Users who want to create a folder or directory must have write access to the parent folder of the folder you are creating (Learn about Linux files-folder permissions click here). Also, the folder (directory) You create cannot have the same name as the filename in its parent directory (that is, the parent folder), that is, the same directory cannot have the same name (case sensitive).
mkdir Command Options description
The [options] in the command generally have the following two kinds:
-M is used to set access permissions on the new directory, or it can be set with the chmod command.
-P creates a top-level folder (or directory) when needed, and is not considered an error if the folder (or directory) already exists.
mkdir Command Use Example
Example: inroot directoryThe following creates a folder named "Demo".
Use the following command: Mkdir/demo
(2) Delete the folder "rm"
RM Command Usage Permissions
All users can delete the directory at the terminal using the RM command.
RM command uses format
Format: RM [Options] DirName
RM Command Function
Delete files and directories.
RM command Option Description
The options in the command generally have the following types:
-I ask for confirmation before deleting.
-F Even if the original file attribute is set to read-only, it is deleted directly without confirmation.
-R the directory and the following files are also deleted.
RM Command Use example
Example: Delete all C language Program documents, ask for confirmation before deleting.
Rm-i *.c
Example two: Delete all the files in the finished subdirectory and subdirectories.
Rm-r finished
Note: There is no Recycle Bin in Linux, you must be careful when you try the RM command, you can no longer recover it after you delete it.
(3) Create file "VI"
command to enter VI
VI FileName: Opens or creates a new file and places the cursor at the beginning of the first
VI +n FileName: Opens the file and places the cursor at the beginning of nth
VI + FileName: Opens the file and places the cursor at the beginning of the last line
VI +/pattern FileName: Opens the file and places the cursor at the first string that matches the pattern
Vi-r FileName: The last time you were editing with VI, a system crash occurred, restoring filename
VI filename....filename: Open multiple files, edit them sequentially
move Cursor Class command
H: Move the cursor one character to the left
L: Move the cursor right one character
Space: Move the cursor right one character
Backspace: Cursor moves left one character
K or ctrl+p: Move the cursor up one line
J or CTRL + N: Move the cursor down one line
Enter: Move the cursor down one line
W or W: Move the cursor right one word to the beginning of the word
B or B: The cursor moves left one word to the beginning of the word
E or E: Move the cursor right one word to the end of the word
): Move the cursor to the end of the sentence
(: The cursor moves to the beginning of the sentence
}: Move the cursor to the beginning of the paragraph
{: Cursor moves to end of paragraph
NG: Cursor moves to the beginning of nth
n+: The cursor moves down n rows
N: Move the cursor up n rows
n$: Cursor moves to end of Nth line
H: Move the cursor to the top row of the screen
M: Move the cursor to the middle line of the screen
L: The cursor moves to the last line of the screen
0: (note is the number 0) cursor moves to the beginning of the current line
$: Cursor moves to the end of the current line
screen Tumbling Class command
Ctrl+u: First half screen to file
Ctrl+d: Half-screen to the end of the file
CTRL+F: Flip a screen to the end of a file
ctrl+b; Turn one screen to the top of the file
NZ: Rolls line N to the top of the screen and scrolls the current line to the top of the screen when n is not specified.
insert text Class command
I: Before the cursor
I: At the beginning of the current
A: After the cursor
A: At the end of the current line
O: A new line below the current line
O: New row above the current line
R: Replace the current character
R: Replaces the current character and its characters until the ESC key is pressed
S: replaces the specified number of characters with the input text starting at the current cursor position
S: Deletes the specified number of rows and replaces them with the input text
NCW or NCW: Modifies a specified number of words
NCC: Modifying a specified number of rows
Delete command
NDW or NDW: Delete the n-1 characters at the beginning and after the cursor
Do: Delete to the beginning of the line
d$: Delete to end of line
NDD: Deletes the current line and its subsequent n-1 rows
X or x: Deletes a character, x deletes the cursor, and x deletes the cursor before the
Ctrl+u: Delete text entered under input mode
Search and Replace commands
/pattern: Searches for pattern at the end of the file from the beginning of the cursor
? pattern: Searches for pattern from the beginning of the cursor to the top of the file
N: Repeat the last search command in the same direction
N: Repeats the last search command in the opposite direction
: s/p1/p2/g: Replaces all P1 in the current row with P2
: n1,n2s/p1/p2/g: All P1 in line N1 to N2 are replaced with P2
: g/p1/s//p2/g: Replace all P1 in the file with P2
VI Command Use example
Example one: Create a file a.txt.
VI a.txt
Hello everyone!
: Wq//When exiting, direct input: Wq will find out, Exit method is: Press ESC after editing, and then enter: Q is to exit, and: Wq is saved after exiting, plus exclamation mark is to indicate mandatory
(4) Modify file time "touch"
Touch Command Usage Permissions
All users can use the Touch command at the terminal.
The Touch command uses the format
Format: Touch [-acfm][-d < date time >][-r < reference file or directory >][-t < datetime >][--help] [--version][file or directory ...] or touch [-acfm][- -help][--version][date Time [file or directory ...]
(Touch [-acfm][-r reference-file] [--file=reference-file][-t mmddhhmm[[cc]yy][.ss]][-d time] [--date=time][--time={ ATIME,ACCESS,USE,MTIME,MODIFY}][--NO-CREATE][--HELP] [--version]file1 [file2 ...] )
Touch Command Function
Touch FileA, if FileA exists, use the Touch command to change the date and time of this file or directory, including access time and change time, and if FileA does not exist, the touch command creates a new blank file FileA in the current directory.
Note: Use the touch directive to change the date and time of a file or directory, including access time and change time. The time attributes of a file include the last time the file was accessed, the last modified time, and the last time the disk was modified, and the command stat displays three time attributes.
Touch Command Options Description
A change the read time record of the file.
M change the file's modification time record.
c If the destination file does not exist, no new files will be created. The same effect as the--no-create.
F is not used and is reserved for compatibility with other UNIX systems.
R uses the time record of the reference document, as with the--file effect.
D Set the time and date, you can use a variety of different formats.
T sets the file's time record in the same format as the date instruction. [[Cc]yy] mmddhhmm[. SS],CC is the first two digits in the number of years, that is, "century number"; YY for the latter two digits of the number of years, That is, the number of years in a century. If the value of CC is not given, the touch command parameter in Linux limits the number of years Ccyy to 1969--2068. MM is the number of months, DD for the day will be the number of years Ccyy limited to 1969--2068. MM is the number of months, DD is the number of days, HH Is the number of hours (points), MM is the number of minutes, and SS is the number of seconds. The set range of seconds here is 0--61, which can process a leap second. These numbers are composed of a time in the time zone specified by the environment variable TZ. Due to system limitations, the time earlier than January 1, 1970 is incorrect.
--no-create will not create a new file.
--HELP lists the instruction format.
--version lists version messages.
Touch Command Use example
Example one: Update the access and modification times of the file1.txt.
Touch File1.txt
Example two: Do not create a file if File1.txt does not exist
Touch-c file1.txt
Example three: Update file1.txt with the same timestamp as Ref+file
Touch-r Ref+file File1.txt
Example four: Set the timestamp of the file is August 18, 2015 9:45 10 seconds
Ls-l file1.txt
Touch-t 1508180945.10 File1.txt
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Linux series of the document System + Create, delete files and folders command