Linux System basic Operation related command __linux

Source: Internet
Author: User
Tags chmod exit in gz file parent directory touch command
1 Terminal window Operation

You can only use the keyboard in the terminal window, you cannot use the mouse
The command default action in the Terminal window is the current directory, where the current directory refers to the directory directly associated in the terminal window
Most of the commands in the Terminal window operate on the current directory.
Each account has a home directory of its own, used in the terminal window to represent the current account of the home directory
Each time you open a terminal window, the current directory is the home directory of this account 2 Linux file system structure

The operating system uses file systems to manage files, and the file system holds all the information that needs to be stored in the computer for a long time.
File systems consist of folders (directories) and files
Folders are used to group files, folders can be nested by layer, and files are used to hold information.
Each file must belong to a folder
If directory A contains directory B, directory A is called the parent directory (the previous level directory), and directory B is called a subdirectory (Next level directory)
The Linux file system is developed from a source called the root directory 3 absolute path and relative path

Path used to describe the location of a file or folder
There are two ways of writing a path: absolute path, relative path
An absolute path is a way of describing the root directory until a file or folder is started,
A relative path is a description of how to start a directory on a file system until the destination file or folder
Using/representing the root directory in a terminal window
Three basic elements of a relative path:
. Represents the current directory
.. Represents the parent directory
< directory name > directory for this name 4 common operation commands

pwd: View the absolute path of the current directory
CD: You can modify the location of the current directory, using the method: cd < path >
CD ~ and CD home directory CD-back to the previous directory
clear: Clean screen
whoami: You can know the account currently in use
The TAB key has the complement path and the command function

The ls command can view the contents of the current directory, using the method: ls < path >
-A view all files under the directory
-L View detailed information for each file or folder (LL)
-al View all files for more information
Note: The LS query is color, black for file, blue for directory, red for compressed file, light blue for soft link file, yellow for device file, green for executable file

Up and down ARROW keys to pull out all previously used commands

The mkdir command can create a new directory using the following method: mkdir < path >
The path must correspond to a directory that does not yet exist, and the parent directory of the directory must exist
Mkdir-p abc/def/xyz-p option to create multiple directories in one path at the same time
MKDIR ABC def XYZ creates multiple directories that are not related to each other at the same time

rmdir: You can delete an existing empty directory, using the method: RmDir < path >
RM commands can be used to delete files, using the method: RM < path >
RM-RF ABC rm-rf option can delete a non-empty directory, rm-r option can also

Touch: You can create a new file, or you can set the last modification time of an existing file to the time when the touch command is executed

cat-n filename: Show file contents with line number

CP: A file can be copied using the following method: CP < path 1> < path 2>
Path 1 corresponds to a file that already exists, and path 2 corresponds to a file that does not exist
-r parameter to replicate directory
Copy a directory in Linux and save some links in the source directory, either with CP-A or cp-rd

MV: You can cut the file, using the method: MV < path 1> < path 2>
Two paths use the same as the previous command, you can move multiple files or directories to a directory, and you can change the file name MV ADC def changes the directory name ABC to DEF

tar: You can compress and decompress a set of files and folders
Tar zcvf compressed file name. tar.gz file or directory name to be compressed
Compressed files must be extended with. tar.gz or. tgz
The tar command to extract the file is: Tar zxvf compressed file name. tar.gz-c Directory to extract
and the. bz2 format compression, which uses the-J parameter to compress and decompress, rather than the-Z parameter. 5 Use of VI

VI is a Linux system under the text Editing tool
Three different modes of work:
In Normal mode , the content that the user enters on the keyboard is treated as a menu command. Every time you start VI, it's in normal mode.
What the user enters on the keyboard in insert mode appears directly in the document
User can enter a variety of complex commands in command mode
Normal mode can be converted to and from two other modes, and the insertion mode and command mode cannot be converted to each other

VI to start the way there are two kinds:
1, direct use of VI command to start
2, the use of the VI command also provides a file path
VI Exit Method:
1. Use Q or q! to exit in command mode
2. Use WQ or x command in command mode
Use shift+ in normal mode: Key to enter command mode
Use the ESC key in command mode to enter normal mode
Using I,i,a,a,o in normal mode, you can enter insert mode and use the ESC key in insert mode to enter normal mode

The nyy command can copy consecutive n rows to the Clipboard in normal mode
The ndd command can cut consecutive n rows to the Clipboard in normal mode
NP command to paste the contents of the Clipboard at the cursor's line n times
Use the W command to save the contents of the file in command mode, and you can use the file path to specify the location of the file to be saved after the W command
Use command set nu in command mode to display line numbers: Set Nonu suppress line numbers
The set command can be saved in the ~/.VIMRC file. All set commands in this file will be executed every time VI is started

Vimtutor, some Linux systems have this manual on VI.

VI View the operation of the document:
Within a row, move the cursor to line 0(numbers, not letters), and move to the end of the row $
Down screen:Ctrl + F
Top Flip Screen:Ctrl + B

vi-o2 file1 file2, you can open these two files up and down using VI when the O is uppercase, you can open these two files around.
: SP filename up and down
: VSP filename Around

:. command goes back to VI after execution of SHELL commands command

RC replaces the current character that the cursor points to with C
x Deletes the current character pointed to by the cursor,NX deletes the n characters continuously, to remove all characters, you can position the cursor first, then DG.

In normal mode, when we look at the program, when the mouse rests on a function, knocking "shift+k" is equivalent to the man command to query this function, as well as 2k,3k, use the same man.

: N1,N2 Co n3 copies the contents of the N1 line to the N2 line below the N3 line
: n1,n2 m V3 moves the contents of the N1 line to the N2 line below the N3 line
: N1,n2 D Deletes the contents of N1 lines to N2 rows

:%s/tns/chin/g[c], this command means to replace TNS with Chin and replace it globally. The final C option allows you to determine whether to replace, enter Y to replace, this can be used to replace a field, but is not sure there is no other use it, to one by one confirm the replacement.

Intercept a piece of content in VI: In the command mode input: 36,51 w file name, you can 36 lines to 51 lines of content to a file name files
To add a file to the current file, the action is: R file name

Windows has a text editing tool like VI called Gvim 6 file Operation Properties

The operating properties of a file on a Linux system are represented by 9 letters
These 9 letters are grouped into three groups, each for a specific group of users
The three letters within each group read, modify, and perform these three actions (read with the letter R, modified with the letter W, executed with the letter X)
Each group can be represented by a number from 0 to 7 (R converted to 4,w into 2,x converted to 1,-to 0, this is done by three bits, 100 is read, 010 is write, 001 is executable, they can do bit or operation)
The chmod command can modify the operation properties of a file by using the following method: Chmod < attribute number > < file path >

The script file contains a large number of commands that can be executed as a program
Script files-use./Perform 7 hard links and soft connections

The ln command can be used to create a linked file using the method: ln < path 1> < path 2> (path 1 is source file, path 2 is linked file)
This creates a link file called a hard link, using the-s option to create a soft link file
Hard links cannot link to directories, and soft connections can be linked to directories and files.
In the file system of UNIX, the directory or file stored in the disk partition has an index node number (inode), use the node number to find the file, hard link just increased the inode value, soft link is to produce a special file, have their own inode, the file stored in the source file path.
Hard links are aliases and soft links are shortcuts. When viewed using the LS command, the second column is the inode number, and only soft connections have the "L" identity at the front, and the "D" identity is the directory.
(digression: File name and file contents are different parts) 8 process related simple operations

The program refers to an executable file
A process is generated when the program is run
The Linux system assigns an ID to each process, and the system uses IDs to differentiate between processes
PS: You can view processes and use the-aux option to view all processes in the system
Kill: Kills a process using the method: Kill Process ID, use-9 option can force kill
CTRL + C can end a process 9 wildcard

You can use wildcards when writing paths in commands, and paths that contain wildcard characters can represent multiple other paths
。 Can be used to represent any other letter
* can represent any number of letters
[] can be used to represent any letter in a range
RmDir day1[2-5] can delete day12 day13 day14 day15
RMDIR * Delete all directory 10 input and output redirect

Output redirection can write the results of a command to a file
">" is an output redirection symbol that deletes the original contents of the file
">>" is also an output redirection symbol that appends new content to the original contents of the file
Input redirection allows commands to read the required information from a file

Command >& file redirects the standard output of commands to a file, along with standard errors.

"<" is an input redirection symbol 11 pipeline

Pipelines can connect multiple commands, taking the results of the previous command as the initial data for the latter command
Pipe Use | symbol representation, for example
ls | More

Related Article

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.