1.Touch
usage: -Change file timestamps, changing the timestamp of the files
format:touch [OPTION] ... FILE ...
Common options:
-A: Only modify the access timestamp of the file;
-C,--no-create: Do not create any files;
Note: If you do not specify the-C option,touch can create a file that is specified as a parameter and does not exist;
-M: only modify the file's modified timestamp;
-T stamp: replaces the timestamp of the file with the specified stamp;
Stamp format:[[CC]YY]MMDDHHMM[.SS]; Time "" caused;
For example today is ten months 19:00, then borrow- t option can be modified
[Email protected] ~]# touch-t 10151111 a.txt [[email protected] ~]# stat a.txt File: "A.txt" Size:4 Blocks: 8 IO block:4096 Normal file device:fd00h/64768dinode:133824 links:1access: (0644/-rw-r--r--) Uid: (0/ Root) Gid: (0/root) access:2017-10-15 11:11:00.000000000 +0800modify:2017-10-15 11:11:00.000000000 +0800
2.stat
usage:-displayfile or file system status, which displays the state of the file or filesystem;
format:stat[option] ... FILE ... , the parameters must be given
commonly used:-C--format=format to display the specified properties of a file in thespecified format, state;
[[email protected] ~]# stat-c%b a.txt8[[email protected] ~]# stat-c%F a.txt Ordinary files
3. Nano :
Full screen Editing tool in text mode;
format:nano[options] [[[+line,column] file] ... nano [OPTIONS] [[[+line,column] file] ...
^: caret, which indicates the Ctrl key of the keyboard ;
^+o: Save the contents of the document;
^+x: Exit the editing interface;
4.cat
usage:cat-concatenate files and print onthe standard output, and the connection file is displayed with the normal outputs. (Output multiple files in parallel)
format:cat[option] ... [FILE] ... (If you do not add parameters, you can use CTRL + C end)
Common options:
-B,--Number-nonblank: Number output for non-blank lines;
-N,--number: The numbering of all rows is output;
-S,--squeeze-blank: Combine multiple lines of blank lines;
-E,--show-ends: Displayed at the end of the line in $ characters;
Tac:tac-concatenate and print files in reverse, reverse display tac[option] ... [FILE] ...
Note:the cat or TAC does not give the parameter, then all the content requires the standard input to complete (type from the keyboard). Then use Ctrl + C or ctrl+d to exit.
[[email protected] ~]# cat-bnse a.txt 1 234287934857$ 2 124314234$ 3 134321432324$ 4 1241 413413431$ 5 134134134314314$ 6 143134314314$ 7 134134314314$ 8 134134134134$ 9 13 413413431431$ dsafasdfsadfsdafsdfasadf$
5. Head
usage:head-output The first part of files: Displays the beginning of the file;
format:head[option] ... [FILE] ...
Common options:
-C,--bytes=[-]k: Displays the content of the corresponding length in bytes;
-N,--lines=[-]k: Displays the content of the corresponding length in the behavior unit; you can use the-#k to replacethe use of "-N #k";
K may have a multiplier suffix:b, KB $, K 1024,mb 1000*1000, M 1024*1024, GB 1000*1000*1000, G 1024*1024*1024, And so on ForT, P, E, Z, Y.
Note: If you do not use any of the options, the first ten lines of the specified file contents are displayed by default , and if the file is less than ten lines, the entire content is displayed;
[[Email protected]~]# head-n 4 a.txt2342879348571243142341343214323241241413413431
6. Tail
usage:tail-output The last part of the files: Output file final section;
format:tail [OPTION] ... [FILE] ... ;
Common options:
-C,--bytes=[-]k: Displays the content of the corresponding length in bytes;
-N,--lines=[-]k: Displays the content of the corresponding length in the behavior unit:
-F,--follow[={name|descriptor}]: Used to monitor changes at the end of the file;
[[email protected] ~]# tail-c 3 a.txtdf[[email protected] ~]# tail-n 3 A.TXT13413413413413413413431431DSAFASDFSADFSDAFSD Fasadf
7. More
method:more-file perusal filter for CRT viewing: Pagination Display document content, filter display;
format:more [option] ... [File ...]
Interactive editing methods:
You can use "/" To search for filters based on subsequent string combinations;
you can use n to find the next occurrence;
use the "q" command to exit the more mode;
Using the Enter key, you can turn down one line;
Using the SPACEBAR, you can turn down one page;
"B" turns forward and "f" turns backwards;
8. Less
method:Less-opposite of more:
format:less [option] ... [File] ...
Interactive editing methods:
You can use "/" To search for filters based on subsequent string combinations;
you can use n to find the next occurrence;
use the "q" command to exit the more mode;
Using the Enter key, you can turn down one line;
Using the SPACEBAR, you can turn down one page;
"B" turns forward and "f" turns backwards;
9. Date
Operating system time, referred to as system time, and always recorded time using software simulation;
usage:date-print or set the system date and time:
Common options:
-S,--set=string: Set the system time to the specified time;
two different formats:
1.MMDDMM[[CC]YY][.SS]
2. "Ccyy-mm-dd HH:mm:ss" or "ccyy/mm/ddhh:mm:ss"
FORMAT: You need to precede the following command with the + implementation
%F: represents the full date format, i.e.:YY-MM-DD
%T: represents the complete time division seconds format, namely:HH:MM:SS
%Y: Represents the full year,
%m: Indicates the month
%d: Represents the date
%H: Indicates hours
%M: Indicates minutes
%s: indicates seconds
%s: Timestamp,1970 1 months 1 days, as the year of Unix, the number of seconds from 1970-01-0100:00:00 to the current system time; This timestamp is represented by the three-bit binary, so the maximum range of its representation is 0~4294967295;
[[Email protected]~]# date2017 October 18 Wed 20:24:37 cst[[email protected]~]# date%fdate: invalid date '%F ' [email protected]~]# Date +%f2017-10-18[[email protected]~]# date +%m10[[email protected]~]# date +%d18[[email protected]~]# date +%H20
Ten. Clock/hwclock
usage:hwclock-query and set the hardware clock (RTC)
format:hwclock[functions] [options]
Common options:
-S,--hctosys: Set the system time according to the hardware clock;
-W,--SYSTOHC: Hardware is always set according to system time; (not recommended)
11.cp
cp-copy Files and directories
Format:
CP [OPTION] ... [-T] SOURCE DEST: single source Copy
Cp[option] ... SOURCE ... DIRECTORY: Multi-source Replication
Note:
1) The CP command must be connected to at least two parameters;
2) The last parameter, usually the target of this copy;
3) If the target given at the time of copying is the directory, the file is copied directly to the specified directory, preserving the filename, and if the target is a non-directory file when copying a non-directory file, the operation is copied and renamed;
Common options:
-r,-r,--recursive: Copy the directory file recursively;
-d Same as--no-dereference--preserve=links:
when copying a source file that conforms to a linked file,the-d option preserves the symbolic link file as the source file for this time, and does not copy the source file as it was copied, but does not copy the file that the symbolic link file points to;
-P Same As--preserve=mode,ownership,timestamps
The permission bits in the copied source file, the ownership and timestamp attributes are preserved;
-A,--archive same as-dr--preserve=all
equivalent to a combination of –DPR;
-f,--force: If the destination file exists, force copy and replace; To make this option effective, execute Cp imperative to precede with " \
[[email protected] ~]# cp -a /etc /backup[[email protected] ~]# stat /etc file: "/etc" size:8192 Block:24 io block:4096 Directory device:fd00h/64768d inode:134296929 Hard link: 136 Permissions: (0755/ Drwxr-xr-x) uid: ( 0/ root) gid: ( 0/ root) Environment: SYSTEM_U:OBJECT_R:ETC_T:S0 Recent visit: 2017-10-1820:34:02.479466085 +0800 Recent Changes: 2017-10-1902:17:11.197999810 +0800 Last modified: 2017-10-1902:17:27.845998638 +0800 created:-[[ email protected] ~]# stat /backup file: "/backup" size:8192 Block:24 IO block:4096 directory device: fd00h/64768d inode:137103681 Hard Links: 136 permissions: (0755/drwxr-xr-x) uid: ( 0/ root) gid: ( 0/ root) Environment: SYSTEM_U:OBJECT_R:ETC_T:S0 Recent visit: 2017-10-1820:33:43.290467436 + 0800 last change: 2017-10-1902:17:11.197999810 +0800 Last modified: 2017-10-1820:33:31.126468292 +0800
12.mv
methods:mv-move (rename) files;
format:
MV [OPTION] ... [-T] SOURCE DEST: Single source Mobile
Mv[option] ... SOURCE ... DIRECTORY: Multi-source Mobile
Common options:
-F,--force: Moves the file and forces overwriting the file with the same name as the target location;
-N,--no-clobber: When you move a file, the source file does not move if it has the same name as the file in the target location.
Linux Command Basics