Basic Linux Knowledge

Source: Internet
Author: User

Hard links and soft connections:

What is a link? A simple link is actually a way of sharing files.

It is commonly used in Linux to solve problems with some library versions, and it is common to link some files with deeper directory hierarchies to a more accessible directory.

For these purposes, we usually use soft links (also called Symbolic links ).

Difference:

Hard links: No different from normal files, inode all point to the same file in the hard disk block. Deleting any of these will not affect the access of the other.

Soft Links: Save the absolute path of the file it represents, is another file, on the hard disk has a separate block, access to replace its own path " is equivalent to a memory is a B address ( You can find the directory entry B )"

      A soft-link file has a shortcut similar to Windows. It's actually a special file. In a symbolic connection, a file is actually a text file that contains location information for another file.

For example: A is a soft link to B (both A and b are filenames), the Inode node number in A's directory entry is not the same as the Inode node number in the directory entry for B, and A and B point to two different inode, and then point to two different blocks of data. However, A's data block is only the path name of B (which can be used to find the directory entry for B). A and B are "master-slave" relationships, and if B is deleted, a still exists (because two are different files), but pointing to an invalid link.


Kill command:

The KILL command is used to remove a program or work from execution. Parameters: (process or job identification number: Specifies the process or job to delete. )

The reason why a process cannot be killed:

1. The process is in the "kernel mode" ( nuclear mindset ) and is waiting for resources that are not available. The process of nuclear mentality ignores all signal processing, so the process that has been in the nuclear mindset can only be achieved by rebooting the system. The process is in two states in Aix, the user state and the kernel mentality.

  only a process that is in the user state can terminate it with the "kill" command .

2. The process is in a zombie state. (The parent process did not release the process ID) at this point the process has freed all resources but has not yet been acknowledged by its parent process. The "zombie" process will not disappear until the next reboot, but its presence does not affect system performance.

Linux Common commands:

Cd/home Enter '/home ' directory '
Cd.. Return to the top level directory
Cd.. /.. Return to the top level two directory
CD into the personal home directory
CD ~user1 into the personal home directory
CD-Return to the last directory
PWD Display work path
ls to view the files in the directory
Ls-f viewing files in a directory
Ls-l displaying details of files and directories
Ls-a Show hidden files
LS *[0-9]* displays filenames and directory names that contain numbers

1. Display Date: Date

2. Display Calendar: Cal

3. Shutdown command: Shutdown

4. change file permissions; chmod

5. Change Directory: CD

6. Show current directory: PWD

7. A new catalogue of resumes: mkdir

8. Delete "Empty" directory: RmDir

9. Copy the file directory: CP

10. Remove files or directories: RM

11. Display the contents of the archive from the first line: Cat

12. zip File: gzip

1. ls-a lists all files under the file, including "." The beginning of the hidden file (the Linux file hidden file is preceded by the., if present: Represents the existence of the parent directory).
2. ls-l lists the details of the file, such as creator, creation time, file read-write permission list, and so on.
3. ls-f Add a character to the end of each file to indicate the type of the file. ' @ ' means symbolic link, ' | ' Represents the FIFOs, "/" for the directory, and "=" for the socket.
4. ls-s Prints the size of the file after each file. Size (sizes)
5. ls-t sort files by Time duration (time)
6. ls-a list except "." and ".." Other than the file.
7. ls-r lists all subdirectories in the directory, equivalent to the "recursive" implementation in our programming
8. ls-l lists the link names of the files. Link (links)
9. ls-s sort files by size

Use of Pipelines | :

| is the pipe command operator, or pipe character. Using the pipe symbol "|" provided by Linux separating the two commands , the output from the left command of the pipe character is entered as the command to the right of the pipe . Continuous use of the pipe means that the output of the first command will be entered as the second command, and the output of the second command will be entered as the third command, and so on.

For example:

Ls-l | More

This command lists the documents in the current directory and sends the output to the more command as input, and the more command displays a list of files in pagination. (more pagination Display file)

The three most commonly used text (awk,sed,grep) processing tools in Linux

How grep retrieves file information:

1. search for a file that contains a string

command format:grep "searched string" filename1

2. retrieving a string in multiple files

command format:grep "searched string T" filename1 filename2 Filename3 ...

grep "string to be searched" *.log

  3. Display the number of rows of the retrieved content in the file, you can use the parameter-n

    command format:grep-n "searched string" *.log

  4, the retrieval of the need to ignore the case, you can use the parameter "-i"

command format: grep-i "searched string" *.log

  5. Find rows that do not match the specified string from the file contents

    command format : grep–v "searched string" file name

6, recursively search for a directory and all files under subdirectories

command format:grep–r "searched string" file directory

  8. Get what files contain the content of the search and list the file names

    command format : grep-h–r "searched string" File directory | cut-d:-f1 [| uniq]

The difference between Linux grep and find:

  The grep command in a Linux system is a powerful text search tool that uses regular expressions to search for text and print matching lines. The grep full name is global Regular expression Print, which represents the globally regular expression version, and its use rights are for all users.

The Find command function in a Linux system: searches for a file in the directory structure and performs the specified action. This command provides quite a few look-up conditions and is powerful.

Syntax: Find start directory looking for conditional actions

Description: The Find command starts with the specified starting directory, searches its subdirectories recursively, finds the file that satisfies the search criteria, and takes relevant action on it.

  Find is searching for file names, finding files matching the criteria, outputting matching files

grep is the search for file contents, find the matching criteria of the file line, output matching lines or files containing matching content

Find command

Used to locate files under the specified directory. Any string that precedes the parameter will be treated as the name of the directory you want to find. If you use this command without setting any parameters, the Find command looks for subdirectories and files under the current directory. and displays all the subdirectories and files that are found.

Summarize:

  grep is the row that finds matching criteria , andfind is a file that searches for matching criteria

Shell

The shell can combine a series of Linux commands with its conditional statements and loop statements to form a process-oriented program, Shell script, to implement some of the more complex functions.

Use of awk:

Awk is a powerful text analysis tool.

To put it simply, awk reads the file line-by-row, using spaces as the default delimiter to slice each row, and then perform various analytical processing of the cut.

  Call awk:

    1. Command-line mode

    2.shell Script Mode

    3. Insert all the awk commands into a separate file and then call

Reference: http://blog.csdn.net/xx1710/article/details/52311176

Https://www.cnblogs.com/crazylqy/p/5818745.html

Https://zhidao.baidu.com/question/548984916.html

Http://www.jb51.net/article/127783.htm

Https://zhidao.baidu.com/question/429154844.html

Basic Linux Knowledge

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.