How to use common commands:
1.echo (printf)
Echo-display a line of text
Common options:-N: Do not wrap,-e: use \ Guided escape sequence to take effect; \ n: newline \ t: Horizontal tab 2.CD Change the shell working dir Ectory. Switch working directory: CD [-l|[ -P [-e]] [dir] cd/path/to/somedir: Switches the working directory to the directory represented by the parameter; CD: Switches the working directory to the home directory of the currently logged-in user; equivalent to CD ~; CD-: Switches the working directory to the last working directory before it; The shell provides two variables: PWD oldpwd Note that the method of getting variable values in the shell: variable names are strictly case-sensitive; Echo ${var_name} CD ~username: Switches the working directory to the specified user's home directory; 3.pwd Print the NAME of the current working directory .4.ls Ls-list Directory Contents Note: The contents of the directory are file names; LS [OPTION] ... [FILE] ... In the Linux file system, all with "." Files that are the starting character of the file name are hidden files; common options:-A,--all: Show all files, including hidden files;-A,--almost-all: Display except "." and ".." All files, including hidden files;--color[=when]: Displays query results in different colors;-D,--directory: Displays the directory itself, not the file name in the directory;-H,--human-readable : Displays a more readable format when displaying the size of the file, usually with the-l option, and-L: Displays the detailed properties of the file using a long list of tables;-RW-------. 1 root root 1458 December Anaconda-ks.cfg-: Indicates the file type; RW-------: File permissionsBit setting;: Indicates whether the file has special attributes or extended properties; 1: Indicates the number of times the file was hard-linked; Root: Owner Root: The genus of the file 1458: Indicates the size of the file, in bytes when the-H option is not used; December 23 2016: One of the timestamp of the file indicating the last time the modification was modified; anaconda-ks.cfg: File name For device files: ~]# ls-l/dev/sr0 BRW-RW----. 1 root cdrom 11, 0 September 10:50/dev/sr0, 0:major, minor major: The main device number that identifies the device type, and then determines what driver needs to be loaded Minor: The secondary device number, which identifies the different devices in the same device type, the device number defaults to a 8-bit binary representation, so the default device number range is 0-255;-R,--reverse: Reverse Output-R,--recursive: recursive display, if there is a subdirectory in the target directory, then recursively display the contents of the subdirectory, recursively go down;-Z,--context: Displays the SELinux security context label for the file; 5.mkdir mkdir -Make directories, create a new directory; mkdir [OPTION] ... Directory ...-P,--parents: When creating a directory, if its parent directory does not exist, it is created first;-V,--verbose: Displays a message for each directory created; 6.rm rm-remove file s or directories RM [OPTION] ... FILE ...-F,--force: Brute force, forced delete,-R,-R,--recursive: recursively deletes the contents of the directory and directory;
7.touch
Touch-change file timestamps, modifying the timestamp
format: Touch [OPTION] ... FILE ...
Common options:
-C,--no-create: Do not create any files;
-A: Modifies only the file's access timestamp;
-M: modifies only the modified timestamp of the file;
-T STAMP: Replaces the timestamp of the file with the specified STAMP;
The format of the stamp is: [[CC]YY]MMDDHHMM[.SS]
Additionally, if you do not specify the-C option, the Touch command can create a file that is specified as a parameter and does not exist; 8.stat stat-display the file or file system status to display the state of the files or filesystem; Format: Stat [OPTION] ... FILE ... Common options:-C,--format=format: Displays the specified state property of the file in the specified format; 9.nano: Full screen Editing tool in text mode; Nano-nano's another editor, an enhanced F REE Pico clone format: Nano [OPTIONS] [[[+line,column] FILE] ... ^: caret, indicating ctrl key on keyboard; ^+o: Save document content; ^+x: Exit edit interface; 10.cat cat-concatenate files and print on the standard output, connect the files and display the format in the normal outputs: Cat [OPTION] ... [FILE] ... Common options:-B,--number-nonblank: Number output for non-blank lines,-N,--number: number output for all rows,-S,--squeeze-blank: merge continuous Blank lines;-E,--show-ends: Displayed at the end of the line in $ character; tac-concatenate and print files in reverse format: TAC [OPTION] ... [FILE] ... Note: The cat or TAC command, if no parameters are given, all the content needs to be done by standard input (typed from the keyboard), and then can be exited with "^+c" or "^+d", 11.head head-output the first part of the files, output text The initial part of the piece; Format: Head [OPTION] ... [FILE] ... Common options:-C,--bytes=[-]k: Displays the content of the corresponding length in bytes;-N,--lines=[-]k:The behavior unit displays the content of the corresponding length; you can use-#K方式替换-n #K; K may have a multiplier suffix:b, KB, K, MB 1000* +, M 1024*1024, GB 1000*1000*1000, G 1024*1024*1024, and so on for T, P, E, Z, Y. Note: If you do not use any of the options, the first 10 lines of the specified file contents are displayed by default, and if there are less than 10 lines in the file, all content is displayed; 12.tail tail-output the last part of the files, the final portion of the output file; format: tail [OP tion] ... [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; can use-#K方式替换- n #K;-F,--follow[={name|descriptor}]: Monitor changes at the end of the file; 13.more more-file perusal Filter for CRT viewing, pagination displays document contents , filtering; Format: more [options] file [...] Interactive editing methods: You can use "/" based on subsequent given string combinations to find the filter, you can use "n" to find the next match; use "Q" to exit the more mode; Use Enter to turn down a line; Space, can be turned down one page; 14.less less-opposite of more formats: less [options] file [...] Interactive editing methods: You can use the "/" or "?" Search filtering based on subsequent string combinations; you can use "n" or "n" to find the next match; use "Q" to exit the more mode; Use Enter to turn down a row; Use space to turn down a page; date and time Related toCommand: 15.date operating system time, referred to as the system time, the time recorded using the software mode clock; date-print or set the system date and times format: Date [OPTION]. . [+format] Date [-u|--utc|--universal] [MMDDHHMM[[CC]YY][.SS]] common options:-S,--set=string: Set the system time to a specified time; Two formats: 1) MMDDHHMM[[CC]YY][.SS] 2) "Ccyy-mm-dd HH:mm:ss" or "Ccyy/mm/dd hh:mm : ss "Format:%F: Represents the complete month-date format, i.e.: Yy-mm-dd%T: Represents the complete time-division second format, and: HH:MM:SS%Y: Represents the full year%m: Represents the Month%d: Represents the date%H: Represents the hour%m: Represents the minute%s: represents the second %s: timestamp, the number of seconds from 1970-01-01 00:00:00 to the current system time; Note: January 1, 1970 as the beginning of the Unix period; The timestamp is represented by a 32-bit binary, so it represents a maximum range of 0~4294967295;16.clock/hwclock hwclock-query or set the hardware clock (RTC) format: HW clock [function] [option ...] Common options:-S,--hctosys: Sets the system time according to the hardware clock;-W,--SYSTOHC: Sets the hardware clock according to the system time; (not recommended) 17.cal with shutdown, restart, logoff related commands: Shutdown: Halt, Poweroff, shutdown-h time, init 0; Restart: reboot, Shutdown-r time, init 6; Logout: Exit, logout, ^+D;18.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 at least two parameters; 2) The last parameter, usually the target of this replication, 3) If the target is the directory at the time of replication, copy the file directly to the specified directory, retain the original file name, and if the non-catalog file is copied, When the target is not a directory file, the operation is copied and renamed; Common options:-R,-R,--recursive: recursively copy directory files;-d same as--no-dereference--preserve=links When the copied source file is a symbolic link file, the-D option preserves the symbolic link file as the source file for this time, and does not copy the file that the symbolic link file points to;-p same as--preserve=mode,ownership,timestamps The permission bits, ownership, and timestamp properties in the copied source file are preserved;-A,--archive same as-dr--preserve=all equals-DPR combination;-F,--force: If the destination file is already If it exists, it is forced to replicate and does not prompt; To make this option effective, the CP command needs to be preceded by "\", i.e.: # \CP source_file destination_file
19.mv
Mv-move (rename) files
Format:
MV [OPTION] ... [-T] SOURCE DEST: Single source Mobile
MV [OPTION] ... SOURCE ... DIRECTORY: Multi-source mobile
常用选项: -f, --force:移动文件并强制覆盖目标位置同名文件;不给提示; -n, --no-clobber:移动文件时,如果源文件与目标位置中的文件重名,则不移动;
Basic commands commonly used in Linux