Linux introduction and Common commands
Linux composition:
Kernel: it is the heart of the system and the core program for running programs and managing hardware devices such as disks and printers. Shell: A system user interface that provides an interface for users to interact with the kernel. It receives user-input commands and sends them to the kernel for execution. It is a command interpreter. But it not only enables the command interpreter, but also advanced programming languages and shell programming. File System: The file system is the organization method for storing files on disks and other storage devices. Linux supports multiple file systems, such as ext3, ext2, NFS, SMB, and iso9660 applications: standard Linux operating systems have a set of applications, such as X-Window and Open Office.
Linux directory structure: root directory/
Bin stores binary executable files (ls, cat, mkdir, etc) boot stores various files used for system boot dev stores device files etc stores system configuration files home stores all user files root directory lib stores shared libraries required for program running in the file system and kernel module mnt System Administrator install the Installation Point of the Temporary File System (opt) where the optional application package is placed in the proc Virtual File System, store the current memory ing root Super User directory sbin to store binary executable files. Only root can access tmp sbin to store various temporary files. usr is used to store system applications, important Directory:/usr/local administrator software installation directory. var is used to store files that need to change data during running.
Introduction to Common commands 1. File directory operation commands ls display file and directory lists-l list file details-a list all files in the current directory, contains the hidden file mkdir create directory-p parent directory does not exist, Mr Cheng cd switch directory touch generate an empty file echo generate a file with content file cat, tac display text file content cp copy file or directory rm delete file-r delete all files under this directory at the same time-f force delete files or directories mv move files or directories, files or mv aaa bbb change aaa to bbbfind in the file system find the number of lines of the specified file-name file name wc statistics text document, words, number of characters grep searches for the specified string rmdir in the specified text file to delete the empty directory pwd displays the current working directory ln creates a link file more, less pagination displays the content of the text file head, tail displays the files respectively system Management command stat displays information about the specified file, more information is displayed than ls commands. who and w are displayed. Online logon user whoami is displayed. User identity hostname is displayed. Host Name is displayed. uname is displayed. system information is displayed. top is displayed. The most resource-consuming process ps is displayed in the current system. instantaneous Process status du displays the specified file (directory) total used disk space df display file system disk space usage free display current memory and swap space usage ifconfig display Network Interface Information ping test network connectivity netstat display network status information man command to help Query Information alias set command alias [alias] = ["command name"] clear screen kill killing process III. Backup compression command gzip compression (decompress) file or directory. The suffix of the compressed file is gz bzip2. The file or directory is compressed. The suffix of the compressed file is bz2 tar.
Gzip command Command Format: gzip [Option] compressed (decompressed) file name parameter:-d to decompress the compressed file. -L for each compressed file, display the size of the compressed file, size of the uncompressed file, compression ratio, name of the uncompressed file-v for each compressed and uncompressed file, displays the file name and compression ratio. -Num uses the specified numeric num to adjust the compression speed.-1 or -- fast indicates the fastest compression method (low compression ratio), and-9 or -- best indicates the slowest compression method (high compression ratio ). The default value is 6bzip2. Command Format: bzip2 [-cdz] file name parameter:-d: extracted parameter-z: the compression parameter-num uses the specified numeric num to adjust the compression speed.-1 or -- fast indicates the fastest compression method (low compression ratio ), -9 or -- best indicates the slowest compression method (high compression ratio ). The default value of the system is 6tar. Command Format: tar [-cxzjvf] The name of the compressed package document. to back up the directory parameters:-c: The parameter command for creating an archive file-x: undo the parameter command for a compressed file! -Z: Do I need gzip compression? -J: Do I need to use bzip2 for compression? -V: The file is displayed during the compression process-f: The file name is used, and the file name must be followed immediately after f-tf: view files in the archive file 4. shutdown and restart command shutdown system shutdown r restart immediately after shutdown h shutdown without restarting now shutdown halt shutdown power off reboot
Linux pipeline: Simply put, a channel accepts the output of a tool software and then inputs that output to other tool software. Using the UNIX/Linux vocabulary, this channel accepts the standard output of a process and uses the standard output as the standard input of another process. If you do not redirect the output, it will be displayed on the screen. With one channel, you can redirect this output to the standard input of another tool software.
Example: grep-r "best"/home/* | more
V. Run Mode editing mode of VI Editor: Waiting for editing command input insert mode: In edit mode, enter I to enter insert mode, and insert text information command mode: in edit mode, enter ":" To Run Command mode VI. Use command q to directly exit viwq and save it, and then exit vi. You can create a file q! Force exit w file to save the current content to a file. set number: the row number is displayed in the editing file. set nonumber: the row number is not displayed in the editing file.
6. Three basic permissions for file permission management: R read permission W write permission X execution permission view permissions for files and directories ls-l file name display information includes: file type (d directory, -Common files, l-linked files), file permissions, number of hard links to subdirectories or files, file owner, file group, file size, File Creation Time, the file name-rw-r -- 1 itcast users 2254 tt.htm starts from the second character rw-indicates that the user has read and write permissions and has no operation permission, the subsequent r indicates that the user group users has only the read permission and has no operation permission. The final r indicates that other users (others) have only the read permission and have no write and operation permission. Change Operation Permissions
Chmod [user in the group to which u belongs to the main g o all user a of other users] [+ add permissions-delete permissions = delete original permissions] [rwx] file or directory name
For example, sub-directories under chmod g + w file-R can perform the same permission operation or use numbers to indicate permissions, for example, chmod 777 file r 4 w 2x1 if the rwx attribute is required, then 4 + 2 + 1 = 7; if the rw-attribute is required, 4 + 2 = 6; if the r-x attribute is required, 4 + 1 = 5;