Linux learning notes and common commands

learning resource

Video tutorial: Java foundation + Advanced_ Beeping beeping beeping beeping beeping beeping beeping beeping beeping beeping beeping beeping beeping beeping beeping beeping beeping beeping beeping beeping beeping beeping beeping beeping beeping beeping beeping beeping beeping beeping beeping beeping beeping beeping beeping beeping beeping beeping beeping beeping beeping


1. Concept

Linux: Linux is based on the Unix operating system and is open source and free.

  • There are two versions of Linux: kernel version and distribution version
  • Linux mainstream version
    • CentOS
    • ubuntu
    • redhat
    • Red flag, Kirin

VMware Workstation Pro15.5.1 download address

  • ctrl+alt release the mouse and return to the real machine

SecureCRT is a terminal emulator that supports SSH (SSH1 and SSH2). In short, it is the software that logs in to UNIX or Linux server host under Windows.

  • SecureCRT is a terminal emulator that supports SSH (SSH1 and SSH2). In short, it is a software for logging in to UNIX or Linux server hosts under Windows. The advantage is that multiple tab pages can be created at one time to connect multiple remote hosts.
  • SecureFX is used to transfer files safely. Its advantage is that it has a visual interface and displays the directory structure of local host and remote host in a tree structure. The transfer of files can be directly dragged manually without using commands.
Directory structure of Linux

2. Linux common commands

1. File list
ls		View file directory
ls -a	View all files (including hidden files)
ls -l	Equivalent to ll,View details of all files
2. Directory switching
  • Note: use the tab key to complete the file name
cd ..		Go back to the previous level
cd /		Back to root
cd ~		Return to user directory
cd -		Return to the last directory
3. Directory creation and removal
  • Note: most commands have the -- help command
mkdir		create folder
rmdir		Remove Directory (Only empty directories can be deleted)
mkdir -p	Create multi-level directory
4. View file
cat			Show file contents
more		It is generally used when the content to be displayed will exceed the length of one screen. Press the spacebar to display the next screen. Press enter to display the next line. Press q Key (or Ctrl+C)Exit view.
less		Usage and more Similar, the difference is less Can pass PgUp,PgDn Key to control.
tail -10 file name		View the last 10 records
tail -f file name			View file contents dynamically
5. File deletion and copy
cp a b		take a Copy file as b file
mv a b		take a File cut to b file
rm			Delete file
rm -r		remove folders	-f Delete without asking
  • rm -rf / recursively delete all files*
6. Compression and decompression
  • In Linux, the suffix of compressed file is. gz
tar			Packaged into a file, but not compressed
	-c: Create a tar file
	-v: Displays information about the running process
	-f: specify a filename(Can only be the last parameter)
	-z: compress
	-x: decompression 
tar -cvf xxx.tar ./*	pack,But not compressed
tar -zcvf xxx.tar.gz ./*	Pack and compress

tar -xvf xxx.tar	decompression tar file
*.tar.gz and*.tgz use tar –xzvf decompression
7. Find files, contents

Find command: used to find qualified files

find / -name "ins*" Find the file name in ins Start file
find / -name "ins*" –ls 
find / –user itcast –ls Find users itcast File
find / –user itcast –type d –ls Find users itcast Directory of
find /-perm -777 –type d-ls Find files with permission 777

grep command: find the qualified string in the file

grep lang anaconda-ks.cfg  Find in file lang
grep lang anaconda-ks.cfg –-color Highlight
8. Other common commands
pwd		Displays the current directory
touch	a.txt	Create an empty file
clear		Clear screen
Vim editor

Under Linux, vi editor is generally used to edit files. vi can view and edit files. There are three modes: command line, insert and bottom line mode.

  • Switch to command line mode: press Esc
  • Switch to insert mode: press i, o, a
  • Switch to bottom line mode: Press: (colon)

Open file: vim file name

Exit: ESC -- >: Q;

Modify file: press i key to enter insertion mode

Save and exit: ESC -- >: WQ

Exit without saving: ESC -- >: q!

Redirect output

>Redirect the output to overwrite the original content; > > redirect the output and add functions; example:

cat /etc/passwd > a.txt Direct output to a.txt in
cat /etc/passwd >> a.txt Output and append
ifconfig > a.txt
System command

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 process
The Conduit

Pipeline is an important concept in Linux commands. 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 name contains java Process of

3. Linux permissions

  1. file type
    • -Representation file
    • d stands for folder
    • l indicates connection (a shortcut similar to windows)
  2. The current user has permissions on this file
    • r: read 4
    • w: write 2
    • x: execute 1
  3. Other users in the current group have permissions for this file
  4. Users in other groups have permissions on this file
File rights management

chmod: change permissions for files or directories

chmod u=rwx,g=rx,o=rx a.txt
chmod 755 a.txt

4. Linux common network operations

1. Host name configuration
hostname	View host name
hostname xxx Modify the host name, which is invalid after restart
 If you want to be permanently valid, you can modify it/etc/sysconfig/network file
2. IP address configuration
ifconfig	see ip address
ifconfig eth0	modify ip Address, temporary
 If you want it to take effect permanently, modify it	/etc/sysconfig/network-scripts/ifcfg-eth0 file
	ONBOOT="yes"	Start the server and the network will connect automatically
	BOOTPROTO=static	ip Change address to static
	//BOOTPROTO=dhcp 	 Change ip address to dynamic
service network restart		Service restart
3. Domain name mapping

/The etc/hosts file is used for ip address resolution when accessing through the host name. It is equivalent to the function of the hosts file in the windows system.

4. Network service management

5. Linux software installation

Common ways to install Linux Software
  1. Binary distribution package

    The software has been compiled, packaged and released for specific platforms. Just unzip and modify the configuration

  2. RPM package

    The software has been packaged and released according to the package management tool specification RPM of redhat. You need to obtain the corresponding software RPM release package, and then install it with the RPM command

  3. Yum online installation

    The software has been packaged in RPM specification, but it has been published on some servers on the network. You can install the RPM software on the server online using yum, and the library dependency problem in the software installation process will be automatically solved

  4. Source code compilation and installation

    The software is released in the form of source code project, which needs to be compiled, packaged and deployed with corresponding development tools after obtaining the source code project.

jdk installation

1. Delete jdk

java -version	see java edition
rpm -qa | grep java		see Linux Bring your own jdk
rpm -e --nodeps java-1.6.0-openjdk-	Delete built-in jdk

2. Install jdk

  • Usually install the software to / usr/local
  • Just unzip it directly

3. Configure jdk environment variables

  1. vim /etc/profile

  2. Add file content

    #set java environment
  3. source /etc/profile makes the updated configuration take effect immediately

MySQL installation

1. Delete mysql from Linux

rpm -qa | grep mysql	Query comes with mysql
rpm -e --nodeps mysql-libs-5.1.52-1.el6_0.1.x86_64	delete mysql

2. Extract and install mysql

tar -xvf MySQL-5.6.25-1.el6.x86_64.rpm-bundle.tar

Install mysql client and mysql server

Tomcat installation
redis installation
Deploy project to Linux



Nginx is a high-performance http server / reverse proxy server and e-mail proxy server.

Nginx application scenario

  1. http server. Nginx is an http server that can provide http services independently and can be used as a static server for web pages
  2. Virtual host. It can virtualize multiple websites on one server
  3. Reverse proxy, load balancing. When the number of visits to the website reaches a certain level and a single server cannot meet the user's request, multiple server clusters need to be used. Nginx can be used as the reverse proxy. In addition, multiple servers can share the load equally, so that a server will not be idle due to high load downtime of a server.
Installing Nginx

Environmental preparation

  1. gcc

  2. Third party development kit

    yun install -y pcre pcre-devel	//pcre
    D:\Document\Java\test\demo3\target	//zlib
    D:\Document\Java\test\demo3\target	//openssl

3. Installing Nginx

  1. decompression
  2. Enter nginx-1.8.0 directory and use the command. / configure
  3. make
  4. make install
  5. Enter nginx-1.8.0 directory, mkdir /var/temp/nginx/client -p
  6. In the nginx/sbin directory, start nginx. / nginx
    • Under the id address, it is accessed under the default port 80. If it can be accessed, it indicates that the installation is successful.
    • Exit nginx
      • ./nginx -s stop
      • ./nginx -s quit
    • . / nginx -s reload reload
Nginx static website deployment
Nginx configuring virtual hosts
  1. Port binding
  2. ip binding
Nginx reverse proxy and load balancing

Tags: Linux ssh

Posted on Tue, 21 Sep 2021 05:27:07 -0400 by chinni_77