javaweb-linux-44

data

The vm, centos, crt data addresses are as follows
Link: https://pan.baidu.com/s/1kyIJlUr4uCOF-nzyLzntjQ
extraction code: 1234

linux installation

Insert picture description here

Check the ip address ifconfig, use the crt link
pwd to check the current directory.
If you are a super administrator login, the operation is under the root folder, you can see that
if it is an ordinary user, the home folder is as shown in the figure
Insert picture description here

Linux directory structure

Insert picture description here

Common commands for Linux

Change directory command cd

Use cd app to switch to the app directory cd… switch to the upper directory cd / switch to the system root directory cd ~ switch to the user home directory cd-switch to the previous directory

Use the tab key to complete the file path

List the file list: ls ll

ls(list) is a very useful command to display the contents of the current directory. With the use of parameters, the contents of the catalog can be displayed in different ways. Format: ls[parameter] [path or file name]

Commonly used: in linux, the files beginning with. Are hidden files

  • ls
  • ls -a display all files or directories (including hidden files)
  • ls -l is abbreviated to ll, which displays the detailed information of the file, user, time, etc.
    ll

Create and remove directories: mkdir rmdir

Most commands have a –help function.
Can’t create multiple directories?
The mkdir (make directory) command can be used to create subdirectories. mkdir app  create an app directory in the current directory mkdir –p app2/test  cascade to create aap2 and test projects

The rmdir (remove directory) command can be used to delete "empty" subdirectories: rmdir app  delete app directory

Browse documents

[Cat, more, less]
cat is used to display the content of the file. Format: cat[parameter]<file name>

* cat yum.conf

More is generally used when the content to be displayed exceeds the length of one screen. Press the space bar to display the next screen.
Enter to display the next line of content.
Press q to exit viewing.

  • more yum.conf
    • Space shows the next page of data. Enter shows the next line of data. The
      usage of less is similar to more, except that less can be controlled by the PgUp and PgDn keys.
    • less yum.conf
      • PgUp and PgDn page up and down.

[Tail] The
tail command is a command that is used a lot in actual use. Its function is to display the content of the last few lines of the file.
Usage:
tail -10 /etc/passwd  view the last 10 lines of data
tail -f catalina.log  view the log dynamically (*****)

Generally look at the recently added error
ctrl+c end view

File operations

[Rm]
rm delete file
Usage: rm [options]... file...
rm a.txt  delete a.txt file
Delete requires user confirmation, y/nrm delete without asking
rm -f a.txt  delete without asking, just delete rm delete Directory
rm -ra  delete recursively without asking for recursive deletion (use with caution)
rm -rf a  delete without asking for recursive deletion
rm -rf *  delete all files
rm -rf /*  suicide

http://imgsrc.baidu.com/forum/w%3D580/sign=00fefe23dd09b3deebbfe460fcbe6cd3/940f918fa0ec08fa078d4aec55ee3d6d54fbdafc.jpg
[cp, mv] The
cp(copy) command can copy files from one place to another. Generally, when using the cp command to copy a file into another file or copy to a directory, you need to specify the source file name and target file name or directory.
cp a.txt b.txt  copy a.txt to b.txt file
cp a.txt …/  copy a.txt file to the upper directory

mv Move or rename
mv a.txt …/  Move the a.txt file to the upper directory
mv a.txt b.txt  Rename the a.txt file to b.txt
[tar] command: (* **** Packing or decompression) The
tar command is located in the /bin directory. It can pack the file or directory specified by the user into a file, but does not compress it. Generally, the commonly used compression method on Linux is to use tar to pack many files into one file, and then compress them into xxx.tar.gz (or called xxx.tgz) files with the gzip compression command. Common parameters:
-c: create a new tar file
-v: display the information of the running process
-f: specify the file name
-z: call the gzip compression command to compress
-t: view the contents of the compressed file
-x: unpack the tar file

Packing:
tar –cvf xxx.tar ./*Packing
and compressing:
tar –zcvf xxx.tar.gz ./*

Unzip
tar -xvf xxx.tar
tar -zxvf xxx.tar.gz -C /usr/aaa
[find] The
find command is used to find files that meet the conditions.
Example:
find / -name “ins*” Find the file name as ins The file at the beginning
find / -name “ins*” –ls
find / –user it –ls find the file of user it
find / –user it –type d –ls find the directory of user it
find /-perm -777 –type d- ls Search for files with 777 permissions
[grep] command to
search for qualified strings in the file.
Usage: grep [options]... PATTERN [FILE]... Example:
grep lang anaconda-ks.cfg Find lang
grep lang anaconda-ks.cfg in the file –color highlight

Other commonly used commands

[Pwd]
Display the current directory
[touch]
Create an empty file

  • touch a.txt
    【clear/ crtl + L】
    清屏

Vim editor:

Under Linux, the vi editor is generally used to edit files. vi can view files as well as edit files. Three modes: command line, insert, bottom line mode.
Switch to command line mode: press Esc;
switch to insert mode: press i, o, a;
i inserts
I before the current position inserts
a at the beginning of
the current line inserts A after the current position inserts
o at the end of the current line Insert a row after the row
O Insert a row before the current row

Switch to bottom line mode: press: (colon); for more detailed usage, query the documents "Vim Command Collection.docx" and "vi Usage Details.docx"

Open the file: vim file and
exit: esc:q
modify the file: enter i to enter insert mode
Save and exit: esc:wq

Exit without saving: esc:q!

There are three types of insert modes:
i: Insert at the current cursor position
o: Insert at the next line of the current cursor position
a: Insert the next character at the cursor position

Shortcut keys:
dd-quickly delete a line
yy-copy the current line
nyy-copy a few lines backward from the current line
p-paste
R-replace

Redirect output >> and >>

Determine whether the content is overwritten or appended

Redirect the output, overwrite the original content; >> Redirect the output, and add the function; example:
cat /etc/passwd> a.txt direct the output to a.txt
cat /etc/passwd >> a.txt output and Append
ifconfig> ifconfig.txt

System management commands

ps The status of a running process
ps -ef View all processes
ps -ef | grep ssh Find a process
kill 2868 Kill the process numbered 2868
kill -9 2868 Force kill the process

pipeline

The pipe is an important concept in Linux commands, and its function is to use the output of one command as the input of another command. Example
ls --help | more paging query help information
ps -ef | grep java query the process whose name contains java

ifconfig | more
cat index.html | more
ps –ef | grep aio

Linux permissions commands

File Permissions

Linux three file types:
ordinary files: including text files, data files, executable binary program files, etc.
Directory file: Linux system regards directory as a special file, and uses it to form the tree structure of the file system.
Device file: Linux system treats every device as a file
3. File type identification
Common file (-) directory (d) symbolic link (l)

  • You can view it when you enter etc, which is equivalent to a shortcut character device file (c) block device file (s) socket (s) named pipe (p)
    Insert picture description here
    r: means the readable content of the file, and the directory can be ls

w: For files, it means that the contents of the files can be modified; for directories, it means that child nodes (directories or files) can be created or deleted in it

x: For the file, it means whether the file can be run, and for the directory, whether it can be cd into this directory
! [](https://img-blog.csdnimg.cn/20200919143610703.png#pic_center)
File permission management case:
chmod Change the permissions of a file or directory.
chmod 755 a.txt
chmod u=rwx,g=rx,o=rx a.txt

Common network operations on Linux

1. Host name configuration
hostname View host name
hostname xxx Modify the host name is invalid after restart
If you want to take effect permanently, you can modify the /etc/sysconfig/network file
2. Network service management
service network status View the status of the specified service
service network stop Stop the specified service
service network start Start the specified service
service network restart Restart the specified service

service --status--all View all background services in the
system netstat -nltp View the port monitoring status of network processes in the system

Firewall settings The
firewall controls the "out" and "in" network access behaviors of the machine according to the configuration file /etc/sysconfig/iptables.
service iptables status View firewall status
service iptables stop close the firewall
service iptables start start the firewall
chkconfig iptables off prohibit the firewall from starting
3. IP address configuration
ifconfig View (modify) ip address (invalid after restart)
ifconfig eth0 192.168.12.22 Modify ip address
If you want to take effect permanently,
modify /etc/sysconfig/network-scripts/ifcfg-eth0 file
DEVICE=eth0
#NIC name BOOTPROTO= static #How to get ip (static/dhcp/bootp/none), static ip
HWADDR=00:0C:29:B5:B2:69 #MAC address
IPADDR=12.168.177.129 #IP address
NETMASK=255.255.255.0 #Subnet Mask
NETWORK=192.168.177.0 #Network address
BROADCAST=192.168.0.255
#Broadcast address NBOOT=yes # Whether to set this network interface when the system starts, when set to yes, the device will be activated when the system starts.
4. Domain mapping
The /etc/hosts file is used for ip address resolution when accessing through the host name, which is equivalent to the function of the C:\Windows\System32\drivers\etc\hosts file of the windows system.
Insert picture description here
If the permissions are not enough, the switch will have root permissions.
Insert picture description here

Guess you like

Origin blog.csdn.net/lidashent/article/details/108500491