"Linux Basics" - Study Notes

1. Set up a development environment
Two things need to be involved: virtual machine software (VMware) + Linux system
2. Hidden and non-hidden files
In windows: Hidden and non-hidden files are achieved by setting the properties of the file.
In Linux: The characteristics of hidden files start with . and have nothing to do with the attributes of the file. Use ls -a to display all files, including hidden files.
3. Relative path and absolute path
path: pathname. path: path name: file name
Relative paths start from the current location.
The absolute path starts from the root directory /, similar to the drive letter D:\ in Windows
4. Linux common commands
[1] ls (list, list)
    Function: Use a list to display all files in the current folder
    ls -a Display all files, including hidden files ls -l Display     ls -a -l     ls -l -a
    with detailed information


    ls -la
   ls -al can be used in all four ways
[2] cd (change directory, change directory)
    role: used to switch directories
    involves relative paths and absolute paths
    cd .. .. represents the previous directory
                    . Represents the current directory
            
[3] pwd (print work directory, print work directory) )
    function: print out the current absolute path

[4] mkdir (make directory, create a folder)
    function: create an empty folder
    mkdir -p cascade to create a folder
[5] mv (move, move)
    function: move files between directories, rename files
        mv source file pathname destination file pathname

[6] touch
    function: create an empty file
        touch pathname
        
[7] cp (copy, copy)
    function: copy File or folder
        cp source file pathname target file pathname         cp
        -r used to copy         folders Remove, delete)     function: used to delete files, folder         rm file pathname         rm -r folder pathname [9] cat     function: directly display the content of the file on the command line can also be used to input to the file, temporarily regardless of [10] rmdir (remove directory, delete folder) ------- A very tasteless command     function: delete empty folders        The difference between rmdir and rm -r: rmdir can only delete empty folders, while rm -r can delete empty files Folders and non-empty folders [11] ln (link, connection file)







    


    





Basic: Shortcuts in Windows, in fact, the shortcut and the file it points to are two independent files, both of which occupy hard disk space, but when the user accesses the shortcut, the effect is equivalent to accessing the pointed file.        

There are two kinds of connection files in linux:
one is called soft link (symbolic link), which is equivalent to the shortcut in windows, and the other
is called hard link to
create a soft link file: ln -s source file name Symbolic link file name
example: ln -s src .c, linker.c,   
linker.c is a symbolic link file

hard link of src.c: ln source file name connection file name
The hard link is actually the same thing as the source file on the hard disk. The effect is similar to a file on the hard disk. On the file system, there are many files in our opinion. Every time a file is deleted, as long as he has other hard links, the file will not be deleted. Only after all the connection files are deleted will this file be actually deleted from the hard disk. ,
[12] man
    function: query the man manual and get help information
    man 1 ls 1 means the query is linux command
    man 2 xxx 2 means the query is linux api
    man 3 xxx 3 means the query is the C library function
    Note: in the man manual When querying, press the Q key to exit (Q is the abbreviation of quit)

[13] apt-get
    function: the program used to install and uninstall software online in ubuntu,
     such as apt-get install vim
        apt-get remove vim
    Note that installation and uninstallation are online, which means that ubuntu must be able to access the Internet to use apt-get

5. Basic knowledge
(1), in the detailed information displayed by ls -l:
-rw-r--r--
drwxr-xr-x
has a total of 10 characters, the first character represents the file type, and the next 9 characters represent the file permissions.
File Type:
- Indicates a normal file. Ordinary files refer to text files and binary
    files, such as ac 1.txt a.out are ordinary files
d means folder, d is the abbreviation of directory,
l means symbolic link file, and later will use -> to print out the file it points to
s means socket file
p means the pipe file pipe
(2), ls -l displays detailed information
drwxr-xr-x 10 characters, the first one indicates the file type. The remaining 9
are divided into 3 groups, representing file permissions.
The first three represent the permissions of the owner of the file to the file. The
middle three represent the permissions of the group where the owner of the file belongs to the file. The
last three represent the permissions of other users to the file.
How to parse rwx: r stands for readable, w stands for available write, x stands for executable
rwx: readable, writable, executable
rx: readable, not writable, executable
r--: readable, not writable, not executable
6. Basic use of vi
vi has two working modes: input mode and command mode.
Command mode: When vi is opened, the default is command mode. To enter input mode, you need to press the a or i key. In command mode, everything entered on the keyboard at this point is treated by vi as a command.

Input mode: Input mode is used to input content to the file. You can enter input mode by pressing a or i from command mode. After entering the input mode, you can press the keyboard at will to input. If you want to save after the input is completed, you must first return to the command mode (because saving is also a command). Press ESC in input mode to return to command mode.
Note: Pay attention to the lower left corner of the screen, when there is no prompt information or prompt file name and other information in command mode, when in input mode, prompt -- INSERT --

How to save in command mode:
:wq save and exit
:w save only but do not exit :q do not save and
exit
:q! do not save and force quit
:wq! save and force quit
* Find
in command mode, enter /xxx, you can find xxx

* Quick switch
line In command mode, enter: num, you can quickly switch to num line

* Set display line number
In command mode, enter: set nu , you can display the line number

Note: Set not to display the line number, enter the command mode: set nonu
to permanently display the line number, you need to modify the vi configuration file. Open the vi configuration file ~/.vimrc and enter set nu in it.

* In line delete
command mode, first move the cursor to the line to be deleted, and then enter dd.
If you want to delete multiple consecutive lines, for example, you want to delete 3 consecutive lines, use 3dd

* Line copy paste
Copy: In command mode, nyy
paste: In command mode, p
details, the cursor should be placed on the first line of multiple lines when copying, and the actual
Pastes to the line below the current cursor line.

7. Tips
1. Use the Tab key of the shell to automatically complete
    Tab in the linux command line input.
    Using the Tab key in the linux command line will greatly improve the input efficiency
2. Using the history of the shell The
    shell will record the history of the user's execution of commands, and we generally use the commands to be used repeatedly in a short period of time.
    Therefore, when you need to use a When you have used the command just now, you don't need to spend time inputting it again, just press the up and down
    arrow keys on the keyboard to turn the page up and down, turn out the command you just used, and press Enter to execute it. It's like a phone's
    call log and quick callback.

3. The meaning of some symbols in the linux command line:
    . Represents the current directory
    .. Represents the previous directory, the parent directory of the current directory
    - represents the previous directory, which directory did I cd from just now
    ~ Represents the host directory of the current user
    / Represents Root directory
    $ Command line prompt of ordinary user
    # Command line prompt of root user
    * Universal match
———————————————————————— Study "Mr. Zhu takes you to learn Linux from zero basics", organize notes , invade and delete

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324482358&siteId=291194637