Linux development foundation (part 1)

Development and learning needs

1. The vm or vb virtual machine, the version is the most stable.
2. Centos7 environment
3. The Linux version of Tomcat, jdk and mysql (the author has prepared it)
4. Preparation of Xshell and Xftp

Learning java development, Linux development is a must to learn, here I summarize some knowledge points, as a note

Centos7 installation

Normal virtual machine installation, but when partitioning, pay attention

  1. swapAs a buffer, it is recommended not to be too small, generally 2/3G is fine
  2. /bootIt is the boot file storage for Linux system startup, 2G is fine
  3. /It is the root directory, which can be understood as the size of all other hard drives (Linux is almost a tree structure directory, everything is a file)
  4. /homeIt is the home directory. /The size of the memory setting here does not conflict with the size. The home directory is included in the root directory.
  5. The memory base of Linux is different from that of Windows, but there is not much difference
  6. ext4 file system: support larger files, theoretically unlimited files can be created
  7. Linux is known to be the mbr boot partition, and only 4 primary partitions can be created at most

Pay attention to the choice of network:

Combined with security, it NAT模式is the most trial server,

  1. The bridge mode is to place the virtual machine in the same local area network as the client, dhcp can automatically assign ip, 导致抢占或被强占其余设备的ipand secondly, once the local area network is compromised 服务器和数据库服务器极为危险,!
  2. Using NAT mode 虚拟网卡---VMnet8(在物理机网络设置里可以查到), a local area network is not a network segment, and the physical characteristics of the machine and can use the card number 8 in communication with the virtual machine .
  3. Set a static ip for the virtual machine: Because the DHCP (ip allocator) of the router of the virtual machine in the vm virtual machine is allocated in a queue, it may lead to the discovery that xshell and xftp cannot be connected during the learning process. It has changed again, setting a static ip can prevent this phenomenon. During setupDNS要和默认网关一致(只有虚拟机NAT模式下这样设置)

Insert picture description here

file

  • Linux file features: everything is a file

Everything here is really everything, all devices are stored in dev, such as hard disk sda, sdb, etc., are stored in the system as files.

File structure

Similar to the tree root mode, the files are strictly separated from the root to the deepest directory

Insert picture description here

The role of catalogs at all levels

  • /bin目录(/Usr/bin, /usr/local/bin)
    is the abbreviation of Binary, this directory stores the most frequently used commands
  • /sbin(/Usr/sbin, /usr/local/sbin)
    s means Super User, and the system management program used by the system administrator is stored here.
  • /home
    Store the home directory of ordinary users. In Linux, each user has its own directory . Generally, the name of the directory is named after the user's account. There are documents, desktops and so on. Newly created users will not be generated if they have not logged in! ! ! `
  • /root
    The home directory of the super user (administrator), also known as the home directory of the super authority.
  • /lib
    The most basic dynamic link shared library required for system booting is similar to the DLL file in Windows. Almost all applications need to use these shared libraries. Can be understood as a program dependent library
  • /lost+found
    Under normal circumstances, it is hidden and empty. Only when the Linux client is shut down abnormally and the power is turned off directly, some files will be generated in it.
  • /etc
    All the configuration files and subdirectories needed for system management, such as the configuration of jdk environment in /etc/profile, etc., 配置文件夹just remember !
  • /usr
    Similar to the progfiles file of the c drive under windows, it stores all the user's software installation locations. ( 重点)
  • /boot
    Stored here are some core files used when starting Linux, including some connection files and mirror files. Linux玩的不熟悉的同学绝对不要碰!!!Don’t put your own installation here
  • The /proc
    directory is a virtual directory, it is a mapping of system memory, we can directly access this directory to obtain system information. Same as above, never touch students who are not familiar with Linux here! ! !这里的文件运行的特点,直接对接内存,指令执行速度特别快,这也是新手不建议碰的原因
  • /srv
    The abbreviation of the service, stores the data that needs to be extracted after the service is started, and it is not recommended for novices to touch it, otherwise the service will not start.
  • /sys
    This is a big change in the linux2.6 kernel. A new file system svsfs in the 2.6 kernel is installed in this directory. Novice don't touch~
  • /temp
    Store temporary files
  • /dev
    Similar to the device manager in windows, all hardware devices are stored here in the form of files (important)
  • /media(Centos6)
    The linux system will automatically recognize some devices, such as U disks, CD-ROMs, etc., after recognition, linux will mount (place) the recognized devices in this directory.
  • /run/media/root(Centos7)
    Where to store mirror files and peripherals after entos7
  • /run
    Store the temporary files generated by the process, as well as the above purposes.
  • /mnt
    The system provides this directory so 用户临时挂载别的文件系统的that we can mount the external storage on /mnt, and then enter the directory to view the contents.
  • /opt
    This is the directory for installing additional software on the host. For example, if you install an orale database, you can put it in this directory. The default is empty. Note that this is the user's own software, the most used directory file.
  • /usr/local
    This is another directory for installing additional software on the host. Generally it is a program installed by compiling source code. /optThe software is installed directly, but /usr/localis something you compile your sources of
  • /var
    A folder to store continuously expanding log files.

  • The /bin directory (/usr/bin, /usr/local/bin) and /sbin (/usr/sbin, /usr/local/sbin) are configured in the environment variable path by default, so the instructions here are anywhere Both can perform
    Insert picture description here
    colon division under Linux, semicolon division under Windows

Skilled use of Vi and Vim

Both vi and vim are the basic default text opening methods under Linux, and vim is equivalent to the basic extension of vi.

Edit mode

  • Can write text
  • To i, a ,0,enter the edit mode after pressing the waiting letter
  • After entering, there will be the word [insert]or [replace]in the lower left corner
  • Press [ESC]or CTRL+Cthis button to exit edit mode

Enter the edit mode button as follows

i         在当前光标前插入
a         在当前光标后插入
o         在当前光标行的下一行插入
S		  删除当前字符并进入编辑
S		  删除整行并进入编辑
R		  进入替换模式,替换光标后内容
dd

Command mode

  • Can save, exit, display line number, search, batch replace and other operations.
  • To enter "/" or ":" in normal mode to enter command mode
  • After entering, the cursor moves to the bottom
:w				  		保存
:q       		  		退出
:! 				  		强制执行
:wq 			  		保存退出
:%s/old字符/new字符/g	批量替换文本中old字符串
/要查找的词
						n查找下一个,N往上查找
						N查找下一个,n往上查找
:set nu/ :set nonu		显示行号/关闭行号
:noh					取消高亮显示

General mode

  • Open the default mode of the document, mainly responsible for viewing, and some basic trimming.
dd							删除光标当前行
dnd							删除n行
u							撤销上一步
x							删除一个字母Delete(从前往后删)
X							删除一个字母Backspace(从后往前删)
yy							复制光标当前行
p							粘贴
dw							删除个词
yw							复制一-个词
单词的认定是根据连贯性,如果遇到空格那就停止识别

Conversion of the three

Enter the default general mode after typing the vim path/file name under the shell command , and then you can operate on the text information in the general mode. In normal mode, you can enter commands such as i, a, o to enter the editing mode in different ways. In the editing mode, you can perform more detailed operations on the text; press in the edit mode [ESC]or ctrl+creturn to the normal mode; at the same time in the normal mode You can type :set numand so on command command mode text queries and other operations, the final :qor :wqexit command mode; normal mode and we can press the [ESC]exit vim.

Help manual and basic commands for date

Help manual

Sometimes we are not familiar with some commands, at this time we can check the help manual for inquiries.

  • man
  • The –help
    method is similar to man, but the difference is that –help will pop out all the information for the user to see, while man will only pop out part of it, and the rest requires the user to press the Enter key to view.
 man  命令
 例如: man rm(rm --help)
 NAME
       rm - 移除文件或者目录
---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
总览
       rm [options"]file...

POSIX(Portable Operating System Interface 可移植的操作系统接口) 选项:
       [-fiRr]

GNU 选项 (最短格式):
       [-dfirvR][--help][--version][--]

描述
       rm移除每个给定的文件。默认情况下,它不能移除目录。但是当给定了-r或者-R选
       项时,在指定目录之下的整个目录树都会被移除(而且对通过`rm                                                 -r'能够移除的目
       录树深度是没有限制的)。当文件路径末端部分只有...时会出错(因此可用`rm -r .*'之类来避免这些不愉快的诧异)。

       如果给定了-i选项,或者如果一个文件不可写,                               而且标准输入是终端,又没有给定-f选项,那
						等等等等等

Date operation

  • date
  • Usage: date [option]... [+format]
 1.date,直接键入date回车,结果如下
	 20200721日 星期二 21:29:56 CST
 2.键入  date +%Y年%m月%d日' '%H时:%M分:%S秒,结果如下
 	2020072121:39:513.键入date +%F''%T,结果如下
 	 2020-07-2121:37:50
  • cal
  • Usage: cal [option] [[[day] month] year]
1.直接键入cal,返回当月
      七月 2020     
日 一 二 三 四 五 六
          1  2  3  4
 5  6  7  8  9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31


2.键入cal -3,显示上个月,这个月,下个月的挂历
3.键入cal -y,今年的挂历

File operations

Operations on directories and ordinary files

  1. mkdirCreate a folder
    -p can build a multi-level directory at once
    Example: mkdir directory name
  2. touchCreate a new file
    Example: touch file name
  3. rmdirDelete one 空目录
    example: rmdir dimame
  4. rmRemove files or directories
    -rvf delete all directory contents
    recursively , prompt -rf delete all directory contents recursively, no prompt
  5. cpWhere to copy the file to
    cp [ File to be copied] [Where to]
    -"Recursively copy the entire folder-
    V displays the list of files in the copying process.
    Forced overwrite method without prompt
    Temporary method: use) cp
  6. mv
    mv oldFileName newFileName rename
    mv /temp/movefile /targetFolder move file
  7. cat
    cat file name view lightweight text file
    cat file 1 file 2 link to display multiple files
    cat file 1 file 2>file 3 merge into a new file
  8. more
    Look at a longer file.
    Space: means scroll down-page
    Enter: means scroll down one line
    q: means leave more immediately, and no longer display the contents of the file.
    Ctrl+F scroll down one screen
    Ctrl+B return to the previous screen
  9. less
    Similar to more, more functions than more.
    [pagedown]: Scroll down--page;
    [pageup]: Scroll up--page;
    String: search down for [string] function
    ;? String: search upward for [string function;
    n: before repeat A search (related to/or?!)
    N: Reverse the previous search (related to 1 or?!)
  10. tailStart from the end to view, it is more suitable to view the log
    -f followed to view
    the number of lines displayed by -n200, n can be omitted.
  11. history View historical commands
  12. echo Output environment variables, used as system.out.print in the shel script

Processing of compressed files and soft links

  • Soft link
    Soft link is also called symbolic link, which is similar to that in windows. 快捷方式It has its own data block and mainly
    stores the path of linking other files.

Command: ln -s [original file or directory name] [soft link name]
Query: You can view it through Is -l, the first position of the list attribute is I, and the tail will point to the position. Simplified toll

  • Compressed file operation
  1. tar compressed file

tar -zcvf XXX.tar.gz n1.txt(Tar-command compressed file name to be compressed file)
-c create a new archive
-V display detailed information
-f specify the compressed file name
-z filter the archive through gzip

The decompression form is as follows:

tar -zxvf XXX.tar.gz
-x extract the file from the archive
-V display detailed information
-f specify the file name before decompression,
-Z filter the archive through gzip

  1. Compressed files in zip format

zip mypackage.zip 1.txt 2.bxt
zip -r pack.zip pack/* (递归压缩)

The decompression form is as follows

unzip mypackage.zip

Guess you like

Origin blog.csdn.net/BlackBtuWhite/article/details/107494631