table of Contents
Prompt after opening the terminal
First understand the current system information
Linux operating system tree structure
How to distinguish file types in Linux system
How to pack and compress the directory
vi editor vim upgraded version
Software installation of Linux operating system
linux first acquaintance
Prompt after opening the terminal
[root@Waffle Desktop]#
[Current login name@hostname current path]#
# User identity is super administrator
$ User identity is a normal user
First understand the current system information
Hard disk size
fdisk -l
/dev/sda The name and path of the first hard disk in the operating system.
In the Linux operating system, everything is a file (file name) sd (hard disk interface type) a (first block)
and so on: sdc is the third Hard driveA real hard disk is converted to a base of 1000 instead of 1024,
so that it is labeled as a 500G hard disk, but it can’t actually reach 500G.
memory size
cat /proc/meminfo
cpu model
cat /proc/cpuinfo
Shutdown and restart commands
reboot reboot
poweroff shutdown
Linux operating system tree structure
Directory == folder
cd .. Return to the upper level directory (change directory)
pwd lists the current directory path
ls lists the contents of the current directory
/ Operating system starting path root path
~ Home Directory
/bin stores commands that can be executed by ordinary users and administrators (such as cat, etc.)
/sbin Commands that only administrators can execute, such as shutdown and restart (s means super)
/boot The main boot directory is a separate partition with a boot menu kernel
/dev device Device file storage directory
/etc configuration file storage directory
/home Home directory of ordinary users
/root administrator's home
/media CD-ROM (CD-ROM) mount directory
/mnt Mount directory for temporary devices
The data in /proc is in memory, the directory where the process is located
/tmp Temporary file storage directory
/usr Installation directory of third-party software
/var The variable file stores the directory log file mail file
Install VMtools
File copy between virtual machine and real machine can be realized. Copy
the VMtools installation file to the desktop and decompress it
安装VMtools
cd root
cd Desktop
cd /root/Desktop/vmware-tools-distrib/ 或
cd vmware-tools-distrib/ (TAB键补全)
./vmware-install.pl -d (绿色表示可执行文件,-d :全部默认配置)
reboot
红色的文件一般代表压缩包文件,蓝色的一般表示文件夹
Application of shortcut keys
1. The function command word of TAB key is complemented by the existing file name
2. Clear the screen content CTRL+l
3. Terminate shortcut key CTRL+c
How to distinguish file types in Linux system
Blue catalog
Black ordinary file
Light blue symbolic link (shortcut)
Black background with yellow text device file hard disk sda
Red compressed bag
Green files with execute permission
Purple picture module file
Add, delete, check and modify
Query: Check what is in the directory, check the contents of the file
ls cat
Create: Create a file to create a directory
touch file name
echo "hello"> file (if the file does not exist, echo will automatically create the file)
mkdir directory name (make directory)
Change: cut and copy
mv rename and cut
cp copy files
Symbolic link ln -s absolute path source file to establish a link file
delete
rm remove remove
rm -f file force deletion
rm -fr directory delete directory
Get command help information
Help command word information query
rm -fr
fdisk -l
ls
Hidden files at the beginning of the file
Linux command word format
Command word [option] [file or directory]
What other options are there for ls?
1. How to view the help manual of a command word
man ls
Query "/+Query content" such as: /-a
How to exit the current interface ":q"
-a show hidden files
-l displays detailed information about the file
-lh display file size (du -sh directory display directory size)
-R Recursively display the contents of subdirectories in the directory
ls | grep "filter content" filter
Internal commands Command interpreter comes with help cd view
External commands The commands of the installed third-party software basically have help manuals
Compression and decompression
Create a file with a size of 100m in the /tmp directory
dd if=/dev/zero of=/tmp/bigfile bs=1M count=100
inputfile input file
outputfile output file
bs unit
count counter
gzip
gzip file name --- compressed file
gunzip compressed package --- unzip
bzip2
bzip2 file name --- compressed
bunzip2 compressed package --- unzip
How to pack and compress the directory
tar -xf allfile.tar -C / root
-x unpack -C specify the unpack location
compression
tar -zcf /tmp/allfile.tar.gz /tmp/allfile
tar -zxf /tmp/allfile.bar.gz -C /root
Unzip
tar -jcf /tmp/allfile.tar.bz2 /tmp/allfile
tar -jxf /tmp/allfile.bar.bz2 -C / root
Parameters:
-z with the gzip attribute
-c to create the compressed file
-f to use the compressed file name (this is the last parameter)
-j with the bzip2 attribute
-x to decompress the file
-v to display all processes
vi editor vim upgraded version
Create a file named test.txt in the //tmp/ directory and write hello
Three working modes
vim /tmp/test.txt enter command mode
Last line mode:
:wq save and exit
:q! Exit without saving
:set nu display line number
:% s/old/new/g Replace old with new in each line
:50,56 d delete 50-56 rows of data
Command mode has a lot of shortcuts for quick editing
2yy copy the current line and the next line
p paste under the current line
dd delete the current line
gg back to the first line
G to the last line
50G quickly jump to line 50
Software installation of Linux operating system
Classification of software
Source package
A source code package is a package that the source code needs to be compiled and then installed. Normally, this package can see the source code written when the software is written. If you need to carry out secondary development, you can directly compile it on the source code.
General situation Released in the GUN community, GitHub, etc.
Features of the source code package:
1. Provided to users in the form of a compressed package
2. Open source, open source code, no charge
Precautions for installing the source package:
1. Unpack
2. Enter the unzip path to understand the function of the software. The installation method
$ ./configure --prefix=PREFIX
$ make
$ make install
$ PREFIX/bin/apachectl start
3. Specify the installation path and function through the configuration script , and generate the Makefile compilation script file (./configure --prefix=/usr/local/webserver)
4. Use the make command to control makefile files for sequential compilation (all previous source codes will be compiled into executable files)
5. Copy the compiled files to the installation path (PREFIX/bin/apachectl start)
Compile Source code package installation can specify the installation path and functions required for compilation ( compilation installation (also known as source code installation) )
Apache source code package httpd-2.4.46.tar.gz installation example:
download link : https://mirrors.tuna.tsinghua.edu.cn/apache/httpd/
Apache is a foundation name, httpd is the software package we need to install, the early name of httpd is Apache;
Apache official website www.apache.org
①httpd-2.4.46.tar.gz (Apache community is the development of a web server software, the name is called httpd) onto centos virtual machine
② unpack
[root@Waffle Desktop]# tar -zxf httpd-2.4.46.tar.gz -C /usr/src(/usr是第三方软件的安装目录,src目录可以存放软件安装时源码包)
[root@Waffle Desktop]# cd /usr/src/
[root@Waffle src]# ls
debug httpd-2.4.46 kernels
[root@Waffle src]# cd httpd-2.4.46/
[root@Waffle httpd-2.4.46]# ls
ABOUT_APACHE CMakeLists.txt INSTALL NWGNUmakefile
acinclude.m4 config.layout InstallBin.dsp os
Apache-apr2.dsw configure LAYOUT README
Apache.dsw configure.in libhttpd.dep README.cmake
apache_probes.d docs libhttpd.dsp README.platforms
ap.d emacs-style libhttpd.mak ROADMAP
build httpd.dep LICENSE server
BuildAll.dsp httpd.dsp Makefile.in srclib
BuildBin.dsp httpd.mak Makefile.win support
buildconf httpd.spec modules test
CHANGES include NOTICE VERSIONING
③Enter the decompression path to understand the function of the software and the installation method
Read the README file below: vim README (you can know what this software is for)
INSTALL file tells me how this software is installed
vim INSTALL
④Specify the installation path and function through the configuration script, and generate the Makefile compilation script file (./configure --prefix=PREFIX)
[root@Waffle httpd-2.4.46]# ./configure --prefix=/usr/local/webserver
⑤Sequential compilation of makefiles is controlled by the make command (all previous source codes will be compiled into executable files)
⑥Enter the command make install
⑦Copy the compiled files to the installation path (PREFIX/bin/apachectl start) to
check whether it is open Port 80: ss -antpl | grep 80 (or netstat -antpl | grep 80) and
then close selinux, otherwise you can't see the homepage: setenforce 0
and use the browser to visit yourself (because there is no IP configured here, the loopback address 127.0.0.1 is used ) It work
Apache’s homepage content is index.html in the htdocs subdirectory
1.
Decompress first. 2. Enter the decompression path
. /configure --prefix=/usr/local/webserver. The
establishment of the makefile determines the compilation order between the source package files.
3. To compile all the C language source code, perform
make according to the compilation order of the makefile.
4. All the compiled files will be generated in the current directory. Copy all these files to the installation specified in the first step
Make install under the path
5. Start the service
/usr/local/webserver/bin/apachectl start (replaced with stop)
6. Verify that the service starts
netstat -antpl | grep 80 Look at port 80
7. Define the homepage
vim /usr/local/webserver/ htdocs/index.html
<html>
<meta charset='utf-8' /> Define the Chinese character encoding used on this page
<body>
<h1>
1000phone
</h1>
</body>
</html>
Packaged package
Easy to install.
Features: The suffix is generally rpm or deb.
rpm stands for red hat package manager (Red Hat operating system package manager).
deb stands for Debian Durban operating system.
If it is a source code package, the system version may not be considered,
but if it is packaged software The package must be installed on a different system according to its suffix.
Centos itself is a clone of the Red Hat operating system. All packages installed in it have the suffix rpm.
How to install the packaged software package
lftp-4.0.9-14.el6.x86_64.rpm
software name-version number-64 -bit.rpm
(in the version number, 4 is the major version number, 0 is the minor version number, and 9 represents the official version He made a revised version, revised 9 times)1. After seeing the software, first determine whether it has been installed, and determine which software has been installed
rpm -qa | grep lftp filter whether lftp has been installed
2. Confirm the function of the software
rpm -qpi lftp-4.0.9-14. el6.x86_64.rpm
3. Confirm which files will be installed in which directories by the software rpm
-qpl lftp-4.0.9-14.el6.x86_64.rpm
4. Install the software
rpm -ivh lftp-4.0.9-14.el 6. x86_64.rpm
5. Use the software
lftp --help
lftp -u user1903,123.com ftp://10.0.105.223
Installation demonstration : ls | grep "tree" (| is a pipe symbol, and the function is to use the output of the previous command as the processing parameter of the next command)
Note for installing tree-1.5.3-2.el6.i686.rpm software:
1. Confirm whether I have installed the software
rpm -qa List all installed rpm software packages
2. Confirm the function of the software
[root@Waffle Packages]# rpm -qpi tree-1.5.3-2.el6.i686.rpm (q is the meaning of request listing, p stands for the following package and the i option is added to display its detailed information )
3. Confirm the installation path of the software (the package installation path after packaging is fixed and cannot be specified)
[root@Waffle Packages]# rpm -qpl tree-1.5.3-2.el6.i686.rpm (l is the list Listed)
4. Install the software
rpm -ivh tree-1.5.3-2.el6.i686.rpm (i is for installation, v is for detailed information, h is for pound sign instead of installation progress bar)
5. Use the software
View man help: man tree
tree /boot
6. Uninstall the software (because the location of the rpm package installation package is fixed, there must be an uninstall function)
rpm -e software name
Install software through yum
Want to uninstall the vim editor tool
1. Know the name of the software rpm -qa | grep "vim"
2. Uninstall the rpm -e software name (error: Failed dependencies will be reported)
Now I want to install the vim editor back to
cd /media/Centos_6.6_Final/Packages/ (to the CD, there must be those two installation packages)
3. Consider dependencies when installing
In fact, there is a dependency list on the CD itself, called repodata
Can you use the dependency table to help us install and uninstall software?
Install and uninstall the software according to the dependency list in the CD (called yum source installation ).
Now we don’t need the source of the Internet, we save the yum source in the line above, and we create an operation to find the local source of our own CD ( The operation is shown in the figure above)
1. Tell the operating system the location of the dependency list
vim /etc/yum.repos.d/dvd.repo
[dvdrom] label
name="yum dvd rom" description
baseurl=file:/media/CentOS_6. 6_Final Dependency list position
gpgcheck=0 Whether to do key pair verification
2. Uninstall and install the software through the yum tool
Uninstall: yum remove vim-common
[root@Waffle yum.repos.d]# vim dvd.repo
[root@Waffle yum.repos.d]# yum remove vim-common
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Remove Process
Resolving Dependencies
--> Running transaction check
---> Package vim-common.i686 2:7.2.411-1.8.el6 will be erased
--> Processing Dependency: vim-common = 2:7.2.411-1.8.el6 for package: 2:vim-enhanced-7.2.411-1.8.el6.i686
--> Running transaction check
---> Package vim-enhanced.i686 2:7.2.411-1.8.el6 will be erased
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Removing:
vim-common i686 2:7.2.411-1.8.el6 @anaconda-CentOS-201410241409.i386/6.6 17 M
Removing for dependencies:
vim-enhanced
i686 2:7.2.411-1.8.el6 @anaconda-CentOS-201410241409.i386/6.6 1.8 M
Transaction Summary
================================================================================
Remove 2 Package(s)
Installed size: 19 M
Is this ok [y/N]: Y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Erasing : 2:vim-enhanced-7.2.411-1.8.el6.i686 1/2
Erasing : 2:vim-common-7.2.411-1.8.el6.i686 2/2
Verifying : 2:vim-common-7.2.411-1.8.el6.i686 1/2
Verifying : 2:vim-enhanced-7.2.411-1.8.el6.i686 2/2
Removed:
vim-common.i686 2:7.2.411-1.8.el6
Dependency Removed:
vim-enhanced.i686 2:7.2.411-1.8.el6
Complete!
Installation: yum install vim-enhanced
[root@Waffle yum.repos.d]# yum install vim-enhanced
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Determining fastest mirrors
dvdrom | 4.0 kB 00:00 ...
dvdrom/primary_db | 3.5 MB 00:00 ...
Resolving Dependencies
--> Running transaction check
---> Package vim-enhanced.i686 2:7.2.411-1.8.el6 will be installed
--> Processing Dependency: vim-common = 2:7.2.411-1.8.el6 for package: 2:vim-enhanced-7.2.411-1.8.el6.i686
--> Running transaction check
---> Package vim-common.i686 2:7.2.411-1.8.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
vim-enhanced i686 2:7.2.411-1.8.el6 dvdrom 837 k
Installing for dependencies:
vim-common i686 2:7.2.411-1.8.el6 dvdrom 6.0 M
Transaction Summary
================================================================================
Install 2 Package(s)
Total download size: 6.8 M
Installed size: 19 M
Is this ok [y/N]: y
Downloading Packages:
--------------------------------------------------------------------------------
Total 212 MB/s | 6.8 MB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : 2:vim-common-7.2.411-1.8.el6.i686 1/2
Installing : 2:vim-enhanced-7.2.411-1.8.el6.i686 2/2
Verifying : 2:vim-common-7.2.411-1.8.el6.i686 1/2
Verifying : 2:vim-enhanced-7.2.411-1.8.el6.i686 2/2
Installed:
vim-enhanced.i686 2:7.2.411-1.8.el6
Dependency Installed:
vim-common.i686 2:7.2.411-1.8.el6
Complete!