Linux system common sense. Beijing Fast _ Three build file command. VIM command. Path command Introduction

Source: Internet
Author: User
Tags create directory file copy


1. Beijing fast _ Three build Q1446595067
Linux is a set of and based on the GNU Combination Software and the Linux kernel.
2. What is a shell?





We often hear Shell,shell, but what is a shell?
Shell---> Shell, we all know that the Linux kernel is used to handle all the commands in the Linux System Center, it does not have the idea, as long as the command is transmitted to it, it will execute, but all the command priority of the Linux kernel is indistinguishable, so there is a shell, It is the tool used to pass data information to the Linux kernel and protect it, the data information in the system should be delivered to the shell first, and then by the shell to the Linux kernel.



3. How to run commands in Linux
1). Open the Shell



2). Enter an action at the command prompt



The line prompt means:
[Email protected] ~]$
Kiosk: User
@: Delimiter
foundation115: Host short name
~: Location of the system (currently in my home directory)
$: Identity prompt $ represents a normal user, #表示超级用户



3). The composition of the command
Command parameter target (depending on the parameter format, for example, some parameters are defined as-R, then you must use the-R, and some
-S: The abbreviated format of the word is r, then the input time does not need to add-)
--size: full spelling of words



4). Virtual Machine Management Commands
Rht-vmctl Start Desktop | Server: Turn on the virtual machine
Rht-vmctl Poweroff Desktop | Server: Shutting down the virtual machine
Rht-vmctl View Desktop | Server: Display virtual machines
Rht-vmctl Reset Desktop | Server: Resetting the virtual machine (equivalent to reinstalling Linux)



Comments:
Rht-->redhat (Red Hat) VMCTL-->VM (virtual machine), CTL (Contrl, control)
Reset function is equivalent to restoring the system, running in a virtual machine is good, so you can do any experiment in the virtual machine



There are two displays in the virtual machine: The first is the student user, this is the normal users



The second one is not listed? This is the second user for the hidden superuser, click and enter the user name and password to enter the system using Superuser identity



4.LINUX System Structure
1). The Linux system is a inverted-tree structure
2). The role of the 2 level directory



Comments:



After entering the system can click Home Directory, select the computer option can see all the root directory under the two level directory (Linux/for the root directory, is the highest directory of all files, in addition to Linux folders become a directory, to develop the habit later)



Here's a look at what each level two directory represents:



/bin: Binary files, System general commands
/boot: System boot partition, file read at system startup
/dev: Device files
/etc: Most configuration files
Home directory and root directory for normal users
/lib:32 bit function library
/lib64:64 Bit Library
/media: Manual Temporary mount point Linux has two manual temporary mount points for users
/MNT: Manual Temporary mount point
/OPT: Third-party software installation location
/PROC: Process information and hardware information
/root: Super User home Directory
/run: Default mount point for temporary devices such as U-disk if the mount point is not manually scheduled, it is in this directory (RUN/MEDIA/SDB1)
/sbin: System Administration commands
/SRV: Data
/var: data
/sys: kernel-related information
/tmp: Temp file
/usr: User-related Settings



File management under 5.Linux
1). Create a file
Touch file: Set up an empty file, named file, or modify the timestamp of the file
Touch file1 file2: Create two empty files named File1,file2


<execute create file command>


2). Create a Directory
mkdir Hello: Create a single-level directory named Hello
Mkdir-p Hello/linux: Creating a multi-level directory named Hello/linux


<create directory>


3). Deletion of files
Rm-f file: Forcibly delete files do not prompt (if not add-F will prompt whether to delete)
Rm-fr dir: Forcibly delete the directory itself and the contents inside the
Comments:
-f-r-r-f-rf-fr function is the same as delete this directory and internal content and do not prompt
-F: Prompt-r: Recursive
4). Edit the file
Vim file command, open file



After entering the file is browse mode, cannot edit <i> refers to key I, below <esc> same
Enter <i> Enter insert mode, write character


<The file box below becomes the insert to indicate that it has entered the insert mode>


Press <ESC> exit Insert mode when writing is complete


<Enter the <esc> key to push the insert mode and re-enter the browse mode >


Type: Wq to finish editing the file. W indicates write, q indicates exit



6.vim Usage Tips
In browse mode:
1). Character Management
YY: Copy a whole line
YL: Copy a letter
YW: Copy a word
Attention:
yw to copy a word,
When you move the cursor over W, the result of the copy is the world


<The last line is the word that was copied when the cursor was on w>


When you move the cursor over O in the wolrd,


<The last "word" indicates the result of the cursor copying the word on o >


The result of the copy is Orld
This is also true for delete and cut functions



P: Paste



DD: Delete a whole row
DL: Delete a letter
DW: Delete a word



CC: Cut whole line
CL: Cut One letter
CW: Cut a word
Attention:
When the cutter is cut, vim goes into insert mode,
If you want to paste you need to press <esc> exit Insert mode and then paste



U: Undo
Ctrl+r: Recovery/Advance



2). batch processing of characters
Ctrl + V: Enter visualization mode, in which characters can be selected in bulk and manipulated in visual mode
Attention:
In Vim, the mouse is unable to select text, can only be operated by the keyboard, such as moving the cursor can only be done by the upper and lower keys



How to bulk Add characters
<1. Move the cursor to the column where you want to add the character



<2.ctrl + V enters visualization mode



<3. Select the column to which you want to add characters



<4. Press <I> to enter insert mode and write the characters to be added <I> here i is uppercase I



<5. Press <ESC> Batch Add end



How to Batch Modify
:%s/original character/modified character/g: Modify all the original characters in the text
: 1,5s/original character/modified character/g: Modify all existing characters in lines 1 to 5


<Replace all hello in the text with root> <replacement result>


s indicates that row G represents the column
If you do not add g, it means that only the first character in the selected row is modified



< indicates that the first hello that appears in each row is replaced by a root,xxx to indicate that the keyword is hello>


<Result display>


After G, it means that all characters in the selected row are modified



3). Edit Multiple files simultaneously
Vim: Open File
: SP file1: Enter in open file: SP File1, indicating that a window is displayed in the currently open page File1


<The file1 file is opened in the upper part, because file1 is currently empty, so there is no data inside. Note that the cursor is displayed in the first line>


Attention:
The cursor is the file that is operated by default in that file.
Ctrl+w Press to release and press up | To move the cursor window
4). Vim's exit



Normal Exit method
: Q # #When the file is not modified, it is available
: q! # #When the file is modified but not saved, it is available
: Wq # # Exit Save
: wq! # #When the file belongs to itself or the user is root



Exception exit



If you use Vim to open file, editing is done after the WinDOS habit point in the upper right corner of the x close the files will cause an abnormal exit!
When Vim exits abnormally, the. filename.swap file is generated
When this file appears, VIM works abnormally


<Enter the exception exit file to open in the shell>


Found a swap file by the name ". File.swp" <<< exception exits unsaved data



[O]pen read-only, (E) dit anyway, (R) Ecover, (D) elete it, (Q) uit, (A) Bort:
Read-only open discard unsaved data recovery Delete. swp file Exit exit
and enter the file
Type the appropriate action to enter or exit the file
5. File View
Cat file: All contents of the output file


<This is the result of entering some text in the file file and opening it with the cat file command>


Cat-b File ##Output all the contents of the file and add the line number, just add the serial number on the display page, the original file will not be modified.


<Add line number display>


Cat-b file > File1 # #Add the line number of the data in the file file and copy it to the file1 new file.


<At this time, there is no file1 file on the desktop, execute this command>


Less file: Paging through file files
< up >|< down >: up | Move one line down
<pgup>|<pgdn>: Move Up | one PAGE Down



Input/Keywords: highlight keywords, n match n up match (previously shown in world in bulk add, not done here)



Q: Exit



Tail File: Displays the following 10 rows of the files (default)
Tail-n file: Displays the following n rows



Head file: Shows the first 10 rows of file files (default)
Head-n file: Displays the first n rows



6. File copy
CP sourcefile destfile: Copy the original file and name it to the target file
CP sourcefile1 Sourcefile2 destdir/: Copying multiple files into the directory
Cp-r sourcedir destdir/: Copy the original directory and the internal files to the target directory (the-R is used here, if not added, only the empty directory copy)



7. Movement of files
Comments:
If you move the file to the current directory file1, rename
MV SourceFile destfile: Duplicate name
MV SourceFile Destdir: Moving the original file to the Destdir directory
MV SourceDir Destdir: Moving the original directory to the Destdir directory



MV test/*. : Move all files under the current test directory to the face directory (the current directory is desktop) "." Represents the current directory



8. File path
1. Relative path
A name for the file relative to the current system location shorthand
The file name omits the current path value example: Desktop/hello/file
Available only when you are currently in this directory



File name does not start with/
The file name is automatically entered in the word match either by adding ' pwd ' to the path displayed in the shell and PWD will show the absolute path of the current directory



2. Absolute path
is the real location of the file in the system
The name of a file can be accurately represented at any time example:/root/desktop
File name starts with/



9. Commands on the path
PWD: Show Current working directory
CD: Switch the current working home directory
CD/MNT: Switch to the/MNT directory
CD-: In the same directory as before the current directory
CD ~student: Go to student User home directory



< can find that the current directory has changed every time, you can use this to match the relative/absolute path to the file or directory operation >



Linux system common sense. Beijing Fast _ Three build file command. VIM command. Path command Introduction


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.