Linux classroom learning notes

Posted by jeffrydell on Wed, 09 Feb 2022 03:33:19 +0100

@Rain Valley

May 12, 2021 14:14:48

Content review:

# May 12, 2021 14:14:48 

##  Content review:
mkdir dirName  create folder
touch fileName create a file
cat fileName  see file
mv filename path take filename Move to specified path lower
cp filename path take filename Copy to path lower
rm filename Delete the specified filename file
	rm -r filename	Removable folder
	
rmdir Delete the specified dir


pack : .tar
 compress : .tar.gz
$ tar -cvf fileName .tar.gz fileName1 fileName2 ...
$ tar -xvf fileName .tar.gz 
$ tar -xvf test.tar.gz -C ../temp/

zip/unzip
$ sudo apt install zip unzip

Find file find
$ find Starting path to query -name File name
$ find Starting path to query -size file size -type f

Search the contents of the document grep
$ grep -r -n KeyWord Starting path

vi / vim 
	1.Normal mode
			yy copy
			yny
			p  paste
			dd delete
			dnd 
			u  Go back to the previous step
			{
			}
			[[
			]]
			
			Enter edit mode
			a
			i
			o
			r
			
			Enter the last line/Instruction mode
			:
			/
			?
	2.Edit mode
    3.Last line mode/Instruction mode
     		replace
     		:set number
     		
     		:w   preservation
     		:q   sign out
     		:wq  Save exit
     					!  An exclamation mark indicates compulsion, such as forced exit
     					
 			:keyword   Press when multiple keywords n Jump cursor to next keyword 
            
            :s/keyword/content  Replace the search element keyword with the specified content
            :s/keyword/content/g
            :1,$s/keyword/content/g
            
ESC            
Linux System directory:
/   		Root directory of the operating system
/bin 		Storing binary files
/sbin 		Storing system binary files
/dev		Home directory where logical device names are stored
/etc		Store the required configuration files of all programs of the system
/proc  		Process information contains information about system processes
/var 		Variable file,This directory is used to store files whose contents may grow,Such as system log file(/var/log)
/tmp		Temporary documents,When the system restarts,All files in this directory will be deleted
/usr		User program,Contains binary files,Library file,Source code of documents and secondary programs
/home		Store the personal files of all users
/boot		Store files related to the boot loader
/lib  		Storage support is located at/bin and/sbin Library file of binary file under
/opt 		Store optional additional applications
/mnt		Mount directory:Temporary installation directory



- file
d catalogue
b Block device
c Character device file
l link  
	Type of link:
		Soft link : Shortcut to original content  ln -s src desc
				After the source file is deleted, the soft link becomes invalid
		Hard link : A copy of the original ln src desc
				After deleting the source file

May 13, 2021 08:35:44

knowledge review:

#May 13, 2021 08:35:44

/bin				Storing binary files
/etc				Store the required configuration files of all programs of the system
/etc/init
/ect/rc[0~6].d
/mnt				Mount directory:Temporary installation directory 	
/usr
/var
/tmp

touch file name  		create a file
mkdir Folder name	    Create directory

Link:
ln -s src desc    Create soft connection 	Shortcut, the source is deleted, the soft connection fails, and the soft connection of the directory can be created
ln src desc    	  Create hard link		Copy the source file. The source is deleted, which has no impact on the hard link. You cannot create a hard link to the directory



ll /etc/rc0.d   View some soft links     rc0.d ~ rc6.d  All store links



User accounts and groups:

/etc/passwd			Store user information
		
			yugu:x:1000:1000:MyUbuntuServer,,,:/home/yugu:/bin/bash
			
			User name (1)~8 Bit character):Placeholder( x):UID(user id):GID(group id)
			
			UID :
            		Administrator account  : 0~120 
            		General permission account   :1001~60000 
            		
/etc/shadow			Store password information    shadow --> shadow

			yugu:$1$4S0d.u/5$ao3/sdx9h4qGRtq2YOkFJ0:18754:0:99999:7:::
			
/etc/group			Store user group information
			yugu:x:1000:
			lpadmin:x:114:yugu 
			
			-g Main group
			Secondary group: up to 15 users
			
			tony
				uid = 2000
				gid = 2000
				
				
Manage users and groups
	1.Manage users
		Add user
		$ useradd [-u uid] [-G gid...] [-c "Comment"] -d PATH/HOMEDIR -m UserName
        Note: remember to specify when creating users home Directory to facilitate subsequent modification operations, otherwise it is very troublesome
        sudo useradd -u 1001 -c "my second username" -d /home/dark -m -s /bin/bash dark
        
		$ passwd yugu2
		
		Modify user
			$ usermod
			
			sudo usermod -m -l newName oldName
			
		delete user
			$ userdel
			sudo userdel -r UserName
	2.Management Group
		add group
		$ groupadd
			groupadd -g Gid GroupName
		Modify group
		$ groupmod
			groupmod
		delete group
		$ groupdel
		
		
Modify the password of the currently logged in user  passwd
					oldPassword
					newPassword
					The current user cannot change the password too easily. 1~6 Cannot be modified by the current user,
					Change to another account
				sudo passwd root 		
                passwd yugu
           
           shutdown -h now
           shutdown -r now
           reboot
           poweroff 

May 14, 2021 08:42:40

#May 14, 2021 08:42:40
#Content review
/etc/passwd
/etc/shadow
/etc/group

#user management 
	useradd
		$useradd [-u uid] [-g gid] -d HomeDir -s /bin/bash -m [-c Comment]
	usermod
		$usermod -l NewUserName OldUsername
	userdel
		$userdel -r UserName

#Group management
	groupadd 
		$groupadd [-g gid] [-o] GroupName
	groupmod
		$groupmod [-g NewGid] [-o] [-n NewGroupName] GroupName
	groupdel
		$groupdel [-R] GroupName


 
	#task scheduling 
	#Startup level
	lrwxrwxrwx  1 root root   23 May  7 06:33 S01open-vm-tools -> ../init.d/open-vm-
	lrwxrwxrwx  1 root root   20 May  7 14:30 K01irqbalance -> ../init.d/irqbalance*
	
		$runlevel
		3/5
			3:Go directly to the command line prompt
			5:Xll(GUI)
			6:Shut down
		init 0
        S: start
        K: kill
        
        Service status:
        	start-up    start
        	suspend	  pause
        	stop it	  stop
        	state	  status
        	restart	  restart

		CMOS
		
		task scheduling 
		Command format:
			* * * * * command (Time sharing day month week order)
			
		Edit task schedule : $crontab 
        usage:	crontab [-u user] file
                crontab [ -u user ] [ -i ] { -e | -l | -r }
                    (default operation is replace, per 1003.2)
                -e	(edit user's crontab)
                -l	(list user's crontab)
                -r	(delete user's crontab)
                -i	(prompt before deleting user's crontab)
                
	 	Close process 
                $ps -l
                $ps -ef
                $ps -aux
                $kill Pid   
                $top -d 10
                

	Shell 
		Shell Provides users and Linux(An interface for kernel interaction
		
		User program --> Shell --> kernel --> Hardware
		

May 18, 2021 08:38:39

#Content review

/etc/init.d
/etc/rc[0~6].d    Are soft link files, linked to /etc/rc.d/rcx.d Directory, file format is the same, all in S or K start...

S: start
K: kill
#Startup level: runlevel      
			0     Shut down
			1	  single user
			2 	  Multi user, not supported NFS
			3     Multi user, support NFS
			4	  not used
			5 	  GUI Graphical interface
			6	  restart
			Can use init Nubmer  Change startup level

$ top    Real time monitoring system status information and resources used by the process, and displaying process data, including: PID,Process, priority...
$ ps 	 List the processes currently running in the system, transient state, similar to snapshot	 Process Status Abbreviation of
	-a    And-e Similar utility shows all processes
	-f	  Make a more complete output
	-ef   View all processes
	-aux  Display process information, including terminal free( x)And for users( u)Process of: e.g USER,PID,%CPU,%MEM etc.

$kill PID End assignment Pid The process of,
usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]


$crontab 	task scheduling  		Work to be performed periodically by the system or regularly by a user
            -e	Edit task schedule
            -r  Terminate task scheduling
            -l	List the current task schedules
            
            
 The file name suffix is .bak Documents :Backup files 
file management(Access rights)
	The first character is 	.  Represents a hidden file
				
	ls -a --> ll
	
	  		 
-rw-r--r-- 1 yugu yugu  655 May 17 04:32 .profile
drwxrwxr-x 3 yugu yugu 4096 May 17 00:24 software/


file type + Access rights + Number of hard links + User + group + size + Modification time +file name

file type:
		d:catalogue
		-:Ordinary file
		l:Soft connection
		b:Block device file
		c:Character device file
rw- --- --- :Three characters in a group,Three groups in total
		first group: Specify the access rights of the current user
		Group 2: Group access is specified
		Group 3: Specifies the access rights of other users
		
r: read   Readable permissions    4
w: write  Writable permissions    2
x: excute Executable permissions	 1
-:        access denied

root The user does not have any access restrictions

	If the file itself is a directory:
		1.No, x jurisdiction,Indicates that the directory cannot be used cd Command entry
		2.No, w jurisdiction,Represents that cannot be created in this directory/Save file


$chmod  Modify file permissions  

usage: chmod jurisdiction FileName
	1.Authority symbol
			a: all
			g: group
			o: other
			u: user
	chmod a+w test.txt  Add write permission to all users
    chmod a-rwx t1.txt  Delete read / write execution permission for all users
    chmod u+rwx,o+r,g+rx t1.txt  Complex individual right restrictions are separated by commas
    chmod a=r,u+wx,g+x t1.txt  Complex individual right restrictions are separated by commas
	2.Authority octal value
      r: 4
      w: 2
      x: 1
      -: 0
     chmod 777 t1.txt Add read, write and execute permissions to all users
     The first 7 represents the current user permission: corresponding r+w+x Namely rwx
     The second 7 represents the group permission of the current user: corresponding r+w+x Namely rwx
     The third 7 represents the user permissions of other groups: r+w+x Namely rwx
     chmod 754 t1.txt 
			

  -c, --changes          like verbose but report only when a change is made
  -f, --silent, --quiet  suppress most error messages
  -v, --verbose          output a diagnostic for every file processed
      --no-preserve-root  do not treat '/' specially (the default)
      --preserve-root    fail to operate recursively on '/'
      --reference=RFILE  use RFILE's mode instead of MODE values
  -R, --recursive        change files and directories recursively
      --help     display this help and exit
      --version  output version information and exit


$chown  Change file sovereignty(Owner group)
	sudo chown [-R] User name:Group name FileName

	sudo chown -R root:root temp/
     -R recursive Recursive change sovereignty
     
Soft link
	$ln -s src desc  

Hard link
 	$ln src desc
 	
Differences between hard and soft links:
 	Soft links exist in the form of paths, and hard links exist in the form of file copies, but do not occupy the actual space.
 	Soft links can cross file systems, while hard links cannot wipe function keys across files	
 	You can create soft links to directories, but you cannot create hard links to directories
 	You can create soft links to nonexistent files, but you cannot create hard links to nonexistent files
 	
 	

May 19, 2021 14:09:06

Content review

file management
	
	
	File type access permission user group other user size time file name
	d - l b c   catalogue,Ordinary file,Soft link,block,character
	r,w,d,-		read,write,implement,No authority 4,2,1,0
	a,u g o  All users,group,Other users :all, user ,group ,other


Change permissions and Sovereignty: chmod chown
$chmod [-R] Permission file name  
jurisdiction: Authority symbol  a u g o
	 Permission value 4,2,1,0
	 
$chown [-R] User name:Group name FileName

sudo chown -R root:root temp/
     -R recursive Recursive change sovereignty
     
     
Hard and soft links ln -s src desc
		ln src dec

2021 May 19, 2014:18:14

network service		
/etc/network/interfaces

Network protocol
TCP/UDP		
	TCP: Connection oriented, reliable network transmission protocol, call
	UDP: Non connection oriented, unreliable packet protocol, SMS

network node
	Network equipment: computers (whether personal computers or servers), routers, switches, bridges, gateways
    Hubs used in earlier years
    
IP Address: Internet Protocol Address Internet protocol address


ipv4 and ipv6   

IPv4	Internet Protocol version 4  
		32 Binary number of bits, such as 192.168.1.119
IPv6	Internet Protocol version 6
		128 Binary system number of bits, such as: fe80::b47a:2fc9:72e1:b80b%5



IP Addresses are divided into the following four categories:,
	A:	1 Byte network address+3 Byte host address composition, 1.0.0.1~127.255.255.254
	B: 	2 Byte network address+2 Byte host address composition, 128.0.0.1~191.255.255.254
	C:	3 Byte network address+1 Byte host address composition, 192.0.0.1~223.255.255.254
	D:	(multicast address)Multicast address, 224.0.0.0~239.255.255

Subnet: NetMask Logically, a large network is divided into some small networks.
For tradition IP In terms of address classification,
        A The subnet mask of class is 255.0.0.0
        B The subnet mask of class is 255.255.0.0
        C The subnet mask of class is 255.255.255.0

Super network: Supernetting Similar concept to subnet
	Multiple small networks are combined into a large network through a shorter subnet mask
	For example, a unit is divided into eight C Class address: 202.120.224.0~202.120.231.0
		Just set its subnet mask to 255.255.248.0,Can make these C Class network interworking
		
IP Address management: manual management mode, DHCP Switch management mode		







$apt :Advanced Package Tool,also called apt-get,Is a paragraph applicable to Unix and Linux Application manager of the system
#to update
	apt-get	update  Update installation source
	apt-get	upgrade Update installed packages
	apt-get	dist-upgrade Update installed packages (automatically identify and handle changes in dependencies)
#query	
	dpkg -l        Lists all installed packages

	apt-cache search PackageName       Search package
	apt-cache show PackageName         Get information about the package, Such as description, size, version, etc

	apt-cache depends PackageName      Check which dependent packages the package needs
	apt-cache rdepends PackageName     Check which packages the package depends on

	apt-get check                      Check for damaged dependencies

#Installation and download
    apt-get install PackageName                 // General installation
    apt-get install PackageName=VersionName     // Installs the specified version of the specified package
    apt-get --reinstall install PackageName     // Reinstall

    apt-get build-dep PackageName               // The compilation environment required to install the source package
    apt-get -f install                          // Fix dependencies

    apt-get source PackageName                  // Download the source code of the software package

#uninstall
    apt-get remove PackageName              // Delete the package and keep the configuration file

    apt-get --purge remove PackageName      // Delete the package and the configuration file
    apt-get purge PackageName               // Delete the package and the configuration file

    apt-get autoremove PackageName          // Delete the software package and delete it to meet the dependency
                                            // Software packages that are automatically installed and no longer used

    apt-get --purge autoremove PackageName  // Delete the software package, delete the configuration file, 
                                            // Delete dependent packages that are no longer in use

    apt-get clean && apt-get autoclean      // Clear downloaded packages and old packages


Replace domestic Alibaba source for Ubuntu virtual machine

May 20, 2021 10:58:58

$su root #Right raising,
$cp /etc/apt/sources.list /etc/apt/sources.list.bak #Back up a copy of the original source
$vim /etc/apt/sources.list # Delete all modified sources and replace with ALI source, d100d i paste: wq
$apt-get update #Update list

#tips: each Ubuntu system version is different, and the code is also different
$cat /etc/issue  # View current system version
Ubuntu 16.04.7 LTS \n \l


#Ubuntu 12.04 (LTS) is codenamed precise.
#Ubuntu 14.04 (LTS) code named trust.
#Ubuntu 15.04 code named vivid.
#Ubuntu 15.10 code named wily.
#Ubuntu 16.04 (LTS) is codenamed xenial.
#My environment here is Ubuntu 16.04.7 LTS \n \l so I choose Alibaba source code named xenial
#aliimage 2017.9.18

deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties
deb http://archive.canonical.com/ubuntu xenial partner
deb-src http://archive.canonical.com/ubuntu xenial partner
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse


Download and install mysql for Ubuntu virtual machine

May 19, 2021 20:33:04

#Get the highest permission and update the installation source and package
su
apt-get update
apt-get dist-upgrade
#If mysql has not been installed, it has not been installed directly
#apt-get --purge remove mysql

#Install mysql server, client and library package. The password may be set
apt-get install mysql-server
apt-get install mysql-client
apt-get install libmysqlclient-dev

#Enter the following command to verify whether mysql is successfully installed.
netstat -tap | grep mysql

root@ubuntu:/home/yugu# netstat -tap | grep mysql
#As shown in the figure, the installation is successful
#tcp       0     0 localhost:mysql       *:*    LISTEN      23360/mysqld 

#Edit mysql configuration file to enable remote access
vi /etc/mysql/mysql.conf.d/mysqld.cnf
#After commenting out bind address = 127.0.0.1, save and exit

#The password for entering mysql service is set before. If it is not set, try 123456 or set it in the configuration file
mysql -uroot -p password
#Authorize remotely connected computers
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'Your password' WITH GRANT OPTION;
#As follows:
#mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT #OPTION;
#Query OK, 0 rows affected, 1 warning (0.00 sec)
#Refresh the configuration information, exit the mysql service, and restart the mysql service
flush privileges;
exit;
service mysql restart

The change of configuration file is shown in the figure below:

[external link image transfer fails, and the source station may have anti-theft chain mechanism. It is recommended to save the image and upload it directly (img-qi2qu0fs-1621592819903) (% 20linux% E5% 91% BD% E4% BB% A4% E8% AF% be% E5% A0% 82 / img / image-202105192009381. Png)]

Download and install Tomcat for Ubuntu virtual machine

May 20, 2021 08:34:44

#Switch to root and upgrade the software list and installation package
$su root
$apt-get update
$apt-get disk-upgrade

#Download and install tomcat8
$apt-get install tomcat8

#Check for installation? Look where the tomcat directory is
$whereis tomcat8
#The output information is: tomcat8: /etc/tomcat8 /usr/share/tomcat8


#Our webapps directory is under / var/lib/tomcat8. Check through the ll command to confirm whether there is a problem!
ll /var/lib/tomcat8
#The output information is:
#total 16
#drwxr-xr-x  4 root    root    4096 May 19 17:56 ./
#drwxr-xr-x 46 root    root    4096 May 19 17:56 ../
#lrwxrwxrwx  1 root    root      12 Aug  3  2020 conf -> /etc/tomcat8/
#drwxr-xr-x  2 tomcat8 tomcat8 4096 Aug  3  2020 lib/
#lrwxrwxrwx  1 root    root      17 Aug  3  2020 logs -> ../../log/tomcat8/
#drwxrwxr-x  3 tomcat8 tomcat8 4096 May 19 17:56 webapps/
#lrwxrwxrwx  1 root    root      19 Aug  3  2020 work -> ../../cache/tomcat8/

#After installing tomcat, it is started by default
#Test the ipv4:8080 of the virtual machine through the browser on the host/
192.168.52.128:8080/
#The page display is normal, indicating that it is successful
#If you fail, check the firewall first. After the firewall confirms that there is no problem, try to open port 8080 in the virtual machine

$service tomcat8 status see tomcat Service status

$service tomcat8 start start-up tomcat service

$service tomcat8 stop stop it tomcat service

$vim /etc/tomcat8/tomcat-users.xml
#The rights of registered users are as follows:;
#<!-- This is my Tomcat Manager user configuartion-->
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<role rolename="tomcat-gui"/>
<role rolename="admin-gui"/>
<role rolename="admin-script"/>
<user username="yugu" password="123456" roles="manager-script,admin-script,admin-gui,tomcat,manager-gui"/>

#After editing the user name and password, restart the tomcat service
$service tomcat8 restart

#Enter again http://192.168.52.128:8080/manager/html Enter the user password and successfully enter the management page!

[the external chain picture transfer fails, and the source station may have anti-theft chain mechanism. It is recommended to save the picture and upload it directly (img-QDSs0QwB-1621592819905)(%20Linux%E5%91%BD%E4%BB%A4%E8%AF%BE%E5%A0%82/img/image-20210520090954762.png)]

Configure / etc / tomcat8 / Tomcat users XML is shown in the figure below

[the external chain picture transfer fails. The source station may have anti-theft chain mechanism. It is recommended to save the picture and upload it directly (img-Ezf5vuIk-1621592819907)(%20Linux%E5%91%BD%E4%BB%A4%E8%AF%BE%E5%A0%82/img/image-20210520102635128.png)]

Restart the tomcat service after editing

[the external chain picture transfer fails, and the source station may have anti-theft chain mechanism. It is recommended to save the picture and upload it directly (img-EViEp6ja-1621592819907)(%20Linux%E5%91%BD%E4%BB%A4%E8%AF%BE%E5%A0%82/img/image-20210520095601492.png)]

[the transfer of external chain pictures fails, and the source station may have anti-theft chain mechanism. It is recommended to save the pictures and upload them directly (img-ChI8Renv-1621592819908)(%20Linux%E5%91%BD%E4%BB%A4%E8%AF%BE%E5%A0%82/img/image-20210520103103764.png)]

Installing Docker for Ubuntu virtual machine

May 20, 2021 10:33:01

1.root raises the right to update the application list and software package

$su root
$apt-get update
$apt-get upgrade

2. Check the dokcer version after downloading docker

#Install docker
$apt-get install docker.io
#View version
$docker -v or $docker version

3. Use docker

Refer to the official documents to learn! https://docs.docker.com/engine/reference/run/

Learn from the rookie tutorial! https://www.runoob.com/docker/docker-hello-world.html

#View help information
$docker help

$docker login #Log in to your docker account

#Rookie tutorial learning https://www.runoob.com/docker/docker-hello-world.html
$docker run ubuntu:15.10 /bin/echo "Hello world"
Unable to find image 'ubuntu:15.10' locally
15.10: Pulling from library/ubuntu
7dcf5a444392: Pull complete 
759aa75f3cee: Pull complete 
3fa871dc8a2b: Pull complete 
224c42ae46e7: Pull complete 
Digest: sha256:02521a2d079595241c6793b2044f02eecf294034f31d6e235ac4b2b54ffc41f3
Status: Downloaded newer image for ubuntu:15.10
Hello world

Install other applications in Docker in Ubuntu virtual machine

  1. Download the specific image to the local pull
  2. Create and run a container run through the image: in fact, direct run will also pull down the latest application container
  3. Enter the command line to configure some necessary environments
  4. Check whether there is no problem in operation
#docker install Nginx
$sudo usermod -aG docker yugu #Give users yugu the right to use docker without sudo every time. Adding a docker group is enough
$docker search nginx		  #Query the Nginx image in the official docker warehouse
$docker pull nginx:latest	  #Download the latest version of Nginx image
$docker run --name nginx-test -p 8080:80 -d nginx  #Run nginx test container in the background, and the mapping port is 8080:8080
#Open the browser in the host to access the virtual machine ipv4:8080, and the Nginx page is displayed normally
192.168.52.128:80

#docker installing Tomcat
$docker search tomcat		  #Query Tomcat image in docker official warehouse
$docker pull tomcat	 		 #Download the latest version of Tomcat image
$docker run --name tomcat-test -p 8080:8080 -d tomcat

#Similarly, open the browser in the host to access 192.168.52.128:80 (i.e. virtual machine ipv4:8080), and an Error 404 is found;
#This is a normal phenomenon. tomcat downloaded by Alibaba cloud has been castrated. There are no files in the webapps directory. Naturally, we can't access any pages,
#The pages and project files are in webapps Dist, we then go to the command line in the tomcat container and copy a copy to webapps
$docker exec tomcat-test -it /bin/bash 
$ls webapps.dist	ls webapps  #Check whether the document is as we expected!
$copy -r webapps.dist/* webapps 
#Visit 192.168.52.168:80 on the host again, and Tom cat appears!

#docker installation node
$docker pull node:latest      			#Download node image to local
$docker run -itd --name node-test node	#Open a node container
$docker exec -it node-test /bin/bash	#Enter the container command line
$node -v								#Check node version

#Install redis 1 Install and start, enter the interactive command line, and test whether it is normal
$docker run -itd --name redis-test -p 6379:6379 redis
$docker exec -it redis-test /bin/bash

#Test in virtual machine
root@c9d54c7fa5f9:/data# redis-cli
127.0.0.1:6379> 
127.0.0.1:6379> set test helloworld!
OK
127.0.0.1:6379> get test
"helloworld!"
127.0.0.1:6379>
#cmd command line test in host
C:\Users\zhou1>redis-cli -h 192.168.52.128 -p 6379
192.168.52.128:6379>
192.168.52.128:6379> get test
"helloworld!"
192.168.52.128:6379>

#Install Apache
$docker run --name apache-test -p 80:80 -id httpd #The container running httpd does not automatically download images

Open a browser in the host to access the virtual machine ipv4:80  192.168.52.128:80

-r webapps.dist/* webapps
#Visit 192.168.52.168:80 on the host again, and Tom cat appears!

#docker installation node
$docker pull node:latest # download node image to local
$docker run - ITD -- name node test node # open a node container
$docker exec - it node test / bin / bash # enter the container command line
$node -v # check node version

#Install redis 1 Install and start, enter the interactive command line, and test whether it is normal
$docker run -itd --name redis-test -p 6379:6379 redis
$docker exec -it redis-test /bin/bash

#Test in virtual machine
root@c9d54c7fa5f9:/data# redis-cli
127.0.0.1:6379>
127.0.0.1:6379> set test helloworld!
OK
127.0.0.1:6379> get test
"helloworld!"
127.0.0.1:6379>
#cmd command line test in host
C:\Users\zhou1>redis-cli -h 192.168.52.128 -p 6379
192.168.52.128:6379>
192.168.52.128:6379> get test
"helloworld!"
192.168.52.128:6379>

#Install Apache
$docker run -- name Apache test - P 80:80 - ID httpd # the container where httpd runs. No image is downloaded automatically

Open the browser in the host to access the virtual machine ipv4:80 192.168.52.128:80



Topics: Linux Docker Ubuntu