In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
The main purpose of this article is to share the introduction and use of common Linux commands. The article also introduces the basic operation of linux commands on directories and files. I hope you can get something through this article.
1. Basis of Linux command 1. General format command word of Linux command [option] [parameter]
Command words: command words are unique and are strictly case-sensitive
Options: to adjust the specific function of the command, there can be one or more options. The options are divided into short format and long format. "-" indicates short format, such as "ls-a"; "-" indicates long format, such as "ls-- help".
Parameters: parameters are the objects processed by the command, such as file, directory name, etc. 2. Linux command function
An instruction or program used to perform a function whose execution depends on the interpreter program (for example: / bin/bash).
3. Classification of Linux commands 1) Internal commands
Integrated in bash, the installation of Linux system comes with, does not need corresponding files, fast execution, is a part of the shell interpreter.
2) external command
Programs, installers, or service generation commands independent of the shell interpreter need to correspond to system files and execute slowly.
4. Edit the auxiliary operation of Linux command line 1) Tab key
Automatic completion command
[root@centos01 ~] # whi which while whiptail 2) backslash "\"
Forced line wrapping
[root@centos01 ~] # user\ > add bob [root@centos01 ~] # tail-2 / etc/passwd test:x:1000:1000:test:/home/test:/bin/bash bob:x:1001:1001::/home/bob:/bin/bash3) Shortcut Ctrl+U
Clear to the beginning of the line
[root@centos01 ~] # useradd [root@centos01 ~] # eradd 4) Shortcut Ctrl+K
Clear to the end of the line
[root@centos01 ~] # useradd [root@centos01 ~] # use 5) Shortcut Ctrl+L
Clear the screen content
6) shortcut key Ctrl+C
Cancel the editing of this command
[root@centos01 ~] # tail-2 / etc/ passwd ^ C [root@centos01 ~] # 5, get command help 1) Internal command help
View help information for Bash internal commands
[root@centos01 ~] # help pwdpwd: pwd [- LP] prints the name of the current working directory. Option:-L prints the value of the $PWD variable, if it names the current working directory-P prints the current physical path without any symbolic links, by default, the behavior of the `pwd' is consistent with the exit state with the `- L' option: unless an invalid option is used or the current directory is unreadable Otherwise, the "--help" option of the command is returned with a status of 02)
Applies to most external commands.
[root@centos01] # vim-- helpVIM-Vi IMproved 7.4 (2013 Aug 10, compiled Aug 2 2017 00:45:39) usage: vim [parameters] [file..] Edit the specified file or: vim [parameter]-read text from standard input (stdin) or: vim [parameter]-t tag edit the file at the tag definition or: vim [parameter]-Q [errorfile] edit the file parameter at the first error:-- only the file name-v after that Vi mode (same as "vi")-e Ex mode (same as "ex")-E Improved Ex mode-s quiet (batch) mode (only used with "ex")-d Diff mode (same as "vimdiff")-y easy mode (same as "evim") No mode)-R read-only mode (same as "view")-Z restricted mode (same as "rvim")-m cannot be modified (write to file)-M text is not modifiable-b binary mode-l Lisp mode-C is compatible with traditional Vi: 'compatible'-N is not fully compatible with traditional Vi:' nocompatible'-V [N] [fname] Be verbose [level N] [log messages to fname]-D debug mode-n does not use swap files Only use memory-r to list swap files and exit-r (with file name) to resume crashed session-L same as-r-A starts in Arabic mode-H starts in Hebrew mode-F starts in Farsi mode-T sets terminal type to-u Use instead of any .vimrc-- noplugin does not load plugin scripts-P [N] Open N tabs (default: one per file)-o [N] Open N windows (default: one per file)-O [N] same as-o but vertical split + jump after startup To the end of the file + skip to line after startup-execute before cmd loads any vimrc file-c load the first file-execute the file after the first file is loaded-s read the file into normal mode from the file-w append all input commands to the file-W all input Command to write to file-x edit encrypted file-startuptime Write startup timing messages to-I use instead of .viminfo-h or-- help print help (this information) and exit-- version print version information and exit 3) use the man command to read the man page
Use the "⬆" and "⬇" arrow keys to scroll the text, use the page Up and page Down keys to turn the page, press the Q or Q key to exit the reading environment, and press the "/" key to find the content.
[root@centos01 ~] # man pwdPWD (1) FSF PWD (1) NAME pwd-shows the name overview of the current / active directory (SYNOPSIS) pwd [OPTION] description (DESCRIPTION) shows The full name of the current active directory. -- help displays help information, then exits-- version displays version information, and then exits bug found in report BUGS to send to. See also (SEE ALSO) the complete document of Pwd is maintained in the form of Texinfo manual. If the info and pwd files are installed correctly, you can access the complete manual with the command info pwd. Copyright Copyright ©1999 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FIT- NESS FOR A PARTICULAR PURPOSE. [Chinese version maintainer] Xu Ming [latest update of Chinese version] 2003-05-13 "China Linux Forum man manual page translation plan" http://cmpp.linuxforum.net6, ls (list) command detailed explanation
Ls command options
-l: displays a list of files and directories in a long format
-a: displays information for all subdirectories and files
-A: the effect of the-an option is basically similar, but there are two special hidden directories that are not displayed, "." And ".."
-d: displays the properties of the directory itself, not the contents of the directory
-h: displays the size of the directory or file in a more user-friendly way, this option needs to be used in conjunction with the-l option
-R: recursively displays all the contents of the specified directory and its subdirectories
-- color: display color
Application examples:
[root@centos01] # ls-l / Total amount 102428 root 104857600 January 9 21:42 1.isodrwxr-xr-x 3 root root 18 January 9 21:22 benetlrwxrwxrwx 1 root root 7 October 23 22:29 bin-> usr/bindr-xr-xr-x. 5 root root 4096 October 23 22:37 bootdrwxr-xr-x 18 root root 3140 January 9 21:00 dev [root@centos01] # ls-ld / dr-xr-xr-x. 19 root root 269 January 9 21:31 / [root@centos01 ~] # ls-ld / test/yun/benet/1.txt-rw-r--r-- 1 root root January 9 21:40 / test/yun/benet/1.txt [root@centos01 benet] # dd if=/dev/zero of=./1.iso bs=10M count=10 recorded 10'0 read in, 10'0 write out 104857600 bytes (105 MB) replicated, 1.13446 seconds 92.4 MB/ seconds [root@centos01 benet] # ls-lh. / 1.iso-rw-r--r-- 1 root root 100m January 9 21:43. / 1.iso [root@centos01 ~] # ls-lhR / test/ / test/: Total amount 0drwxr-xr-x 3 root root 19 January 9 21:31 yun/test/yun: total amount 0drwxr-xr-x 2 root root 84 January 9 21:43 benet/test/yun/ Benet: total amount 100m root root RWQ Rafael-1 January 9 21:43 1.Isoqure RWQ RQM-1 root root 0 January 9 21:40 1.txt Mustang RQ-1 root root 0 January 9 21:40 2.txt RWML ROK-1 root root 0 January 9 21:40 3.txt RWFY RWQ-1 root root January 9 21 : 40 4.txt 5.txt7 RW 5.txt7-1 root root January 9, RW 5.txt7, Detailed explanation of du (disk usage) command
To count the disk space occupied by specified directory (or) files, several options commonly used by the du command are as follows:
-a: statistics of disk space usage include all files, not just directories
-h: displays statistical results in a more humane way (KB counts by default, but no units are displayed)
-s: only count the total (Summary) size of the occupied space, not the size of each subdirectory and file
Application examples:
[root@centos01 ~] # df-Th File system Type capacity available available mount point / dev/sda3 xfs 76G 3.8G 72G 5% / devtmpfs devtmpfs 474M 0474m 0% / devtmpfs tmpfs 489m 0 489m 0% / dev/shmtmpfs tmpfs 489m 7.0m 482m 2% / runtmpfs Tmpfs 489M 0 489m 0% / sys/fs/cgroup/dev/sda1 xfs 197M 136M 61m 70% / boottmpfs tmpfs 98M 098M 0% / run/user/0 [root@centos01 ~] # du-sh / var/log/ 4.9m / var/log/ [root@centos01 ~] # du-sh / test/ 100m / test/ [root@centos01 ~] # du-ah / test/yun/benet/1.iso100M / test/yun/benet/1.iso II. Basic operations of directories and files 1. Touch command
The touch command is used to create an empty file for testing, and the time stamp of the target file is updated when it already exists.
Application examples:
[root@centos01 ~] # touch / test/1.iso [root@centos01 ~] # cd / test/ [root@centos01 test] # ls 1.iso [root@centos01 ~] # touch / test/ {1.. 10} .txt [root@centos01 ~] # [root@centos01 ~] # cd / test/ [root@centos01 test] # ls 10.txt 1.iso 1.txt 2.txt 3.txt 4.txt 5.txt 6.txt 7.txt 8.txt 9.txt2, Common commands-- mkdir (make directory)
The mkdir command is used to create a new directory in the following syntax format:
The location and name of the mkdir [option] directory...-PRAURAPP option means to create a nested multi-tier directory at once.
Application examples:
[root@centos01 ~] # mkdir www [root@centos01 ~] # lsanaconda-ks.cfg initial-setup-ks.cfg www [root@centos01 ~] # mkdir-p / test/yun/benet [root@centos01 ~] # cd / test/yun/benet/ [root@centos01 benet] # pwd/test/yun/benet 3, common commands-- cp (copy)
When copying files or directories, when you need to copy multiple files or directories, the target location must be a directory, and the target directory must also exist. The syntax format is as follows:
Cp [options]... Source file or directory. Target file or directory.
The common options for cp are as follows:
-f: force copy directly without reminding when overwriting a file or directory with the same name
-I: remind the user to confirm when overwriting a file or directory with the same name
-p: keep the permissions, ownership, time stamp and other attributes of the source file unchanged when copying
-r: this option must be used when copying directories, which means that all files and subdirectories are copied recursively
Application examples:
[root@centos01 ~] # cp-r benet/ www/ [root@centos01 ~] # cp-rpf / test/. / yun/ 4, common commands-- rm (remove)
The rm command is used to delete the specified file or directory in the following syntax format:
Rm [option] the file or directory to delete.
The common options for the rm command are as follows:
-f: delete directly without reminding
-I: remind the user to confirm
-r: recursively delete the entire directory tree
Application examples:
[root@centos01 test] # ls10.txt 1.iso 1.txt 2.txt 3.txt 4.txt 5.txt 6.txt 7.txt 8.txt 9.txt yun [root@centos01 test] # rm-rf yun [root@centos01 test] # rm-rf. / * .iso [root@centos01 test] # ls10.txt 1.txt 2.txt 3.txt 4.txt 5.txt 6.txt 7.txt 8.txt 9.txt [root@centos01 test] # rm -ri. / * rm: do you want to delete the ordinary empty file ". / 10.txt"? Y rm: do you want to delete the normal empty file ". / 1.txt"? Y.
Rm-rf command is extremely dangerous, operate with caution!
5. Common commands-- mv (move)
The mv command is used to move the specified file or directory to a location, which is equivalent to a rename operation if the destination location is the same as the source location. The syntax format of the mv command is as follows:
Mv [options]... Source file or directory. Target file or directory
Application examples:
[root@centos01 ~] # mv 1.mp3 / benet/bdqn/accp/xsh/ [root@centos01 xsh] # ls1.mp3 [root@centos01 xsh] # mv 1.mp3 2.mp3 [root@centos01 xsh] # ls2.mp36, common commands-- which
Which command is used to find the location of the Linux command program, note: the default is not to find the first target after the search; if in all search paths, add the "- a" option; can not find the internal command corresponding to the program file, such as: which cd. The syntax format is as follows:
Which command | Program name
Application examples:
[root@centos01 ~] # which passwd / usr/bin/passwd [root@centos01 ~] # which-a groupadd / usr/sbin/groupadd7, common command-find
The find command is used to finely find files or directories. The basic syntax format is as follows:
Find [look in] [find conditional expression]
The common search criteria for find are as follows:
-name: search by name; search based on the name of the target file. "*" and "?" are allowed. Wildcard character
-size: search by file size; generally use the "+" and "-" symbols to set more or less than the specified size as the search condition. Commonly used capacity units include kB (note that k is lowercase), MB, GB
-user: search by file owner
-type: look up by file type; type refers to normal file (f), directory (d), block device file (b), character device file (c), etc.
When multiple lookup conditions are used at the same time, the logical operators "- a" and "- o" can be used between expressions to denote and (and), or (or), respectively.
Application examples:
[root@centos01 ~] # find / test/yun/benet/-name * .txt/test/yun/benet/ 1.txt/test/yun/benet/2.txt/test/yun/benet/3.txt/test/yun/benet/4.txt/test/yun/benet/5.txt [root@centos01 ~] # find / test/yun/benet/-type d / test/yun/benet/ [root@centos01 ~] # find / test/yun/benet /-type f / test/yun/benet/1.txt/test/yun/benet/2.txt/test/yun/benet/3.txt/test/yun/benet/4.txt/test/yun/benet/5.txt/test/yun/benet/1.iso [root@centos01 ~] # find / test/yun/benet/-size + 100m / test/yun/benet/2.iso [root@centos01 ~] # find / test/yun/benet/-size -100m / test/yun/benet//test/yun/benet/1.txt/test/yun/benet/2.txt/test/yun/benet/3.txt/test/yun/benet/4.txt/test/yun/benet/5.txt [root@centos01 ~] # find / test/yun/benet/-size + 100m-a-name * .iso / test/yun/benet/2.iso [root@centos01 ~] # find / test/yun/benet/-size + 100m- O-name *. Iso/test/yun/benet/ 1.iso/test/yun/benet/2.iso8, How dates and calendars are viewed
Command to display the date:
[root@centos01 ~] # date2020 22:05:54 Friday, January 10, CST [root@centos01 ~] # date +% F2020-01-10 [root@centos01 ~] # date +% Y/%m/%d2020/01/10 [root@centos01] # date +% H:%M22:07
Commands to display calendars:
[root@centos01] # cal January 2020 one, two, three, four, five, six, 12, 3, 4, 5, 7, 9, 10, 1112, 15, 16, 1819, 2021, 22, 23, 2526, 2728, 29, 30, 31, [root@centos01] # cal 22 11 1999 November 1999, one, two, three, four, five, six, 12, 3, 4, 5, 7, 9, 10, 1112, 1314, 16, 17, 1819, 2021, 22, 23, 2526, 2728, 29, 29, 30.
This is the end of the common commands about Linux. I hope the above content can be helpful to you and learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.