First, the principle of command
Commands are classified into internal commands and external commands. The command line is also a program that takes the content before the first space of a character entered by the user as a command. If the internal command is directly executed, the external command needs to find the corresponding file according to environment variables and then execute the file
Type: the type of command Internal command | external command help: internal help command Check the function of the command help CDCopy the code
Man 1: user commands (/bin, /usr/bin, /usr/local/bin) 2: system call 3: library user 4: Special file (device file) 5: file format (syntax of the configuration file) 6: Game 7: Miscellaneous 8: Management commands (/sbin, /usr/sbin, /usr/local/sbin)
File: ELF: a binary file [root@node01 ~]# type ifconfig ifconfig is /sbin/ifconfig [root@node01 ~]# file /sbin/ifconfig /sbin/ifconfig: ELF 64-bit LSB Executable, X86-64, VERSION 1 (SYSV), DYNAMICALLY Linked (Uses Shared Libs), for GNU/Linux 2.6.18, strippedCopy the code
Print what you write behind to the following [root@node01 ~]# echo abcd abcd
To display the paths of all environment variables, run the following command: [root@node01 ~]# echo $PATH /usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/binCopy the code
Current system language [root@node01 ~]# echo $LANG en_us.utF-8
In Linux, you can define a single variable [root@node01 ~]# a=1 [root@node01 ~]# echo $a 1Copy the code
An array of
Linux is sensitive to Spaces, not commas [root@node01 ~]# b=(1 k 2 4) [root@node01 ~]# echo $b 1 [root@node01 ~]# echo ${b[1]} kCopy the code
Hash: a cached area where commands will be cached after being used without having to go to disk. -r: Clears the cache
File system commands
directory
/boot: files related to system startup, such as the kernel, initrd, and GRUB (bootloader) /dev: Device file /etc/configuration file /home: indicates the home directory of the user. The default home directory of each user is /home/username /root: indicates the home directory of the administrator. /lib: library file /media: mount point directory, mobile device/MNT: mount point directory, additional temporary file system /opt: optional directory, installation directory of third-party programs /proc: pseudo-file system, kernel mapping file /sys: pseudo-file system, hardware device-related attribute mapping file/TMP: Temporary file: /var/tmp/var: changeable file /bin: executable file. User command /sbin: management commandCopy the code
Properties for file and directory display
The file type
Appear in the first letter - : common file (F) D: directory file B: block device file C: character device file L: symbolic link file P: command pipe file s: Socket fileCopy the code
File permissions first: the permissions of the file owner (u), in this case root second: the permissions of the owning group (G) third: the permissions of others (O)
9-bit, 3-bit groups each group: RWX (read, write, execute) number of hard links
A hard link is the owner of a Windows create shortcut file that has been created several times.
Who does the file belong to? Group of the file
Which group does the file belong to? The file size is in bytes
File size timestamp: time when the file was last modified
Df: displays the disk usage
-h: displays the unit of size. The system is partitioned according to the size and directory of each partition. Du: displays the file usage
-s: indicates the total size of all files. -h: indicates the unit of display size. -A: indicates that the size of hidden files is also displayed
-t: displays the file order according to the modification time. -lha You can run the ls command to list the contents of multiple folders at the same time. // The ls /etc/temp file is displayed at the same time
-cd: switch to the working directory. -mkdir: create a directory. -p: create a directoryCopy the code
Rm: delete cp: copy mv: move ln: link default hard link cp -p -s: soft link equivalent to Windows create shortcut delete source file, this link is deleted ln -s test test.soft
Stat: display metadata information touch change all three times of the file to the present time application: create a file touchh abc.txtCopy the code
File operation command
Cat: Display the file on the command line. If the file is too large, some content will not be visible. More: Display the file in pages, one screen at a time. Page up, page down Space: Page down B: Page up Q: Exit Obviously, less loads the file into memory in order to scroll up and down, If the file size exceeds the memory size, a problem may occur. -number: displays the first ten lines of a file by default. -2: displays the first two lines of a file -f: displays the content that is appended to the file // Run this command first, then the command line will pause // If the content is appended to abc.log dynamically in another window, the content will be displayed in the suspended window // LLDB. For example, when running Hadoop, you can use this command to display any errors. Tail -f abc.logCopy the code
| : piping Front command as the standard output to a command in the first three lines of the / / display b.t xt cat b.t xt | head – 3 / / display files line 5 head – 5 b.t xt | tail – 1
Xargs: Build and execute command lines from standard input Takes the standard output of the previous command as the parameter of the later command
/ / the current directory is home is root directory / / if not combined with xargs will not print the contents of the root directory of the / / / xargs passed as a parameter to the ls command/root @ node01 ~ # echo "/" | xargs ls -l total 90 dr-xr-xr-x. 2 root root 4096 Jul 5 18:16 bin dr-xr-xr-x. 5 root root 1024 Jul 5 18:17 boot drwxr-xr-x. 18 root root 3700 Jul 11 18:40 dev drwxr-xr-x. 61 root root 4096 Jul 11 18:40 etc drwxr-xr-x. 2 root root 4096 Sep 23 2011 home dr-xr-xr-x. 8 root root 4096 Jul 5 18:16 lib dr-xr-xr-x. 9 root root 12288 Jul 5 18:17 lib64 drwx------. 2 root root 16384 Jul 5 18:15 lost+found drwxr-xr-x. 2 root root 4096 Sep 23 2011 media drwxr-xr-x. 2 root root 4096 Sep 23 2011 mnt drwxr-xr-x. 2 root root 4096 Sep 23 2011 opt dr-xr-xr-x. 85 root root 0 Jul 11 18:40 proc dr-xr-x---. 7 root root 4096 Jul 12 05:39 root dr-xr-xr-x. 2 root root 12288 Jul 5 18:17 sbin drwxr-xr-x. 7 root root 0 Jul 11 18:40 selinux drwxr-xr-x. 2 root root 4096 Sep 23 2011 srv drwxr-xr-x. 13 root root 0 Jul 11 18:40 sys drwxrwxrwt. 3 root root 4096 Jul 12 05:43 tmp drwxr-xr-x. 13 root root 4096 Jul 5 18:16 usr drwxr-xr-x. 17 root root 4096 Jul 5 18:16 varCopy the code