SU: Switching users
CD: Switch directories
PWD: Show current directory
Clear: Clear command shortcut key: ctrl+l
LS: Displays the files in the current directory
Ls-l = = ll: Displays files in the current directory in a user-friendly format
Ls-i:
Ls-al: Displays all files in the current directory (including hidden files), and formats the output
LS-HL:-h means the file size is displayed, usually with other commands, such as with L
mkdir: New Directory
Touch: New file, can build multiple files at the same time, Eg:touch 1.php 2.php ...
Vi/vim Editor: How to Query the system for the existence of the VIM editor?
Answer: Enter the command in the terminal: Vim
Commands in the VIM editor:
A: Enter the contents after the cursor
I: Enter the content in front of the cursor
O: Enter content on the next line of the cursor
A: Move the cursor to the end of the current line
I: Move the cursor to the beginning of the current line
O: Enter content on the previous line of the cursor
Vim's last-line mode:
: W Save
: Q exit
: Wq Save and exit
: q! Force quit does not save
: Set Nu Sets line number
: wq! Force Save and exit
Vim search function
/keywords: the content of the search will be highlighted
: Nohls: Remove Highlight
Vim's command-line mode
DD: Delete a row
NDD: Deleting multiple rows
U: Undo Action
YY: Copy
P: Paste
GG: Back to the beginning
G: Back to the last line
X: Delete the character selected by the cursor, that is, delete one character
R: Replaces the character selected by the cursor
Other command modes for VIM
: line number: Jump to a line
: next/:n: Toggle (Edit) to next file
: Prve: Toggle (Edit) to previous file
Shutdown command
Poweroff, halt: Direct shutdown
Shutdown-h 0: Timed shutdown
Power off: Forced shutdown
Restart command
Reboot
Terminate command
CTRL + C
~: Root user indicates host directory under root
: Normal user is home directory, i.e. home directory
#============================= Related Files =========================================#
/etc/grub.conf: Preventing hackers
/etc/inittab: Toggle Mode
/etc/sysconfig/network-scripts/ifcfg-eth0: Configure network card "Set IP"
/etc/group: User group files
/etc/gshadow: Group password "deprecated"
/ETC/PASSWD: User name file
/etc/shadow: User File password
#============================= to change the root password in single-user mode =========================#
Prerequisites for cracking
① must have a graphical interface
② No boot load password set
③ Power off and reboot
Steps:
1, shutdown, power on
2. When the countdown occurs, press ENTER
3, then, enter lowercase E
4. Select the 2nd item and press the lowercase E
5, enter "1 FastBoot", the purpose is to start the shortcut mode, enter
6. Select 2nd, enter B, start Linux single user mode, see Single user mode
7. In single-user mode, change root password "passwd root", enter
8, appear updated successfully instructions to change the password successfully
#================================= Network Configuration =============================================#
1. Set the static IP
Purpose: In order to enable remote management tools (Putty,xshell) for network management
2. View IP under Windows
View IP mode:
Run-"cmd-" ipconfig
3. See if an IP can get data
Use the ping command to view
Format: Ping host name
4. Check the IP address under Linux
Command: Ifconfig
# # # #配置IP时出现的问题: not even online?
#===== Workaround:
#=================================ssh Service ===============================================#
1. Introduction
SSH is a cryptographic transmission of Linux protocol, can achieve data transmission, network connection, upload and download, etc., this
The work of the series is encrypted, SSH is specifically for Linux
2. Start the SSH service
Service sshd start: SSH Services Enabled
Service sshd stop: Turn off SSH service
Service sshd Restart: Restart SSH service
Service sshd Status: View SSH service
#===============================linux Package Management ===========================================#
Finger: View user's detailed comment information
1. Classification of packages in Linux
①rpm Bag
② source package (. zip. tar. gz)
2. Install RPM Package
Note: The command and tool need to be added "| ”;
Command:
RPM-QA: Find a list of all installed software (query all installed software in Linux)
Tools:
grep: Searching for keywords
3. Disk Management, mount, remove mount
DF: Displays information about this disk
/DEV/SR0: The location of the disk, that is, the information that represents the disk
Mount command
MOUNT/DEV/SR0/MNT: Format is mount "CD directory" "Mount Directory"
4. Use the RPM command to install
rpm-ivh[Full installation package name (finger ... )]
5. Reject Mount
Umount command "mounted directory (/MNT)": Remove mounted installation package
Note: You cannot reject a mount on the current working path
6. Uninstalling the Software
Steps to install the software:
1, first check the disk information: DF
2. Mount: Mount/dev/sr0/mnt
3. Enter MNT:CD/MNT
4. Enter Packages:cd/packages
5. Installation software: RPM-IVH finger-0.17-39.el6.i686.rpm
6. After successful installation, you can use finger "user name": View user's information
7. Reject Mount "reject in non-mnt directory": umount/mnt
#=================================linux Directory ===========================================#
/dev: System equipment Directory
/MNT: Mount Directory
Mount:
Mount/dev/sr0/mnt
LS//View list
CD./packages//Enter into the package
ls | grep vim//Find vim file in package
RPM-IVH [filename]//install VIM, but error, because VIM has dependencies and needs to be installed according to certain dependencies
#========================linux file types and related commands =====================================#
CentOS File Type:
-Binary files (plain files) php files, text files, pictures
Catalog D
L link file (soft file) equivalent to Windows shortcut
RM command
RM: Delete a file that prompts you to delete
Rm-f: Force Delete
RM-RF *: Force deletion of all files in a directory
Note: The deletion is irreversible
Find command
Find "Directory"-Options "keyword + match": Find Files
ln command
ln source directory, soft Connect directory: Create a linked file or directory
Note: When you create a hard link, the file must be on the same file system, and the directory cannot be hard-linked.
CP command
CP "-Options" "Destination file or directory" "Destination directory": Copy files or directories
Options:
-r: Copy directory
To copy a file, modify the name at the same time: Add the modified name after the destination directory
MV Command
MV "-Options" "Destination file or directory" "Destination directory": Move or change an existing file or directory
#================================== User and Group =============================================#
1. Files related to users and groups
Group-related files:/etc/group[group files, important]
Detailed
1th column: Group name
2nd Column: Group password "is a placeholder, the real password exists/etc/gshadow"
3rd column: Group ID
4th Column: Groups of users
Attention:
① in Linux, each user belongs to a group,
② in the group file, the group with ID 0 is the Super Admin group
Group with ID 1-499 is the system default create group, also called System Group
Groups with ID >=500 are custom groups, also called custom groups
③ Create a new user, a group is also created automatically
Group additions and deletions change:
Add to:
Groupadd "group name": Adding a group
View:
Vim "group file directory/etc/group"
grep "ID number" "Group File directory/etc/group"
Tail-n "Number of rows (number of rows to be viewed)" "Group file directory/etc/group": View group information for the countdown lines
Modify
GROUPMOD-N Group name "modified Group name" "Modified (pre-Modified)": Modify Group Name
GROUPMOD-G Group name "modified Group ID" "Modified (pre-Modified)": Modify Group ID
Delete
Groupdel "To remove the name of a group"
/etc/gshadow[group password file, understanding]
User-related files
1./etc/passwd[User Files]
Using Vim to open/etc/passwd
Detailed
1th Column: User name
2nd Column: User password (placeholder, real password exists/etc/shadow "user password file")
Brother 3 Column: the user's id "0 for the super-user, others are ordinary users"
4th column: The group ID that belongs to
5th column: User's Notes information
6th column: User's host directory "user's room"
7th column: Indicates whether a user can log on to the Linux system
/bin/bash: Indicates that the user can log on to the Linux system
/sbin/nologin: Indicates that the user cannot log on to the Linux system "prohibit single normal user login (for maintenance use)"
Prohibit all ordinary users from logging in
Create a Nologin file in the ETC directory: Touch/etc/nologin
If you want the normal user to log in normally, only need to delete in the ETC directory
2,/etc/shadow "User password file"
Detailed
1th Column: User name
2nd Column: User password "MD5+CYRT = = Hash Algorithm" "!! No password, no password can not log on to Linux "
User's additions and deletions to change the search
Add to:
Useradd "User name": Create a user, also create a group corresponding to
Useradd-g "group name" "User name": Create a user, specify a group
Modify:
Usermod-l "Modified user name" "User name before modification": Modify user Name
Usermod-g "Modified user's Group" user name ": Modify user Group
Delete:
Userdel "User name": Delete user
Userdel-r "User name": Delete User and host directory
View:
ID: View user's information
#================================== permissions for files and directories =============================================#
1. Classification of rights
R (read) readable permission weight value 4
W (write) writable permission weight value 2
X (execute) Executable permission value 1
Note: If there is no permission to be represented by the "-" crossbar, it can be treated as a type of permission, with a weight value of 0
#权限表示:
From left to right
The 1-3-digit number represents the permission of the owner of the file
The 4-6-digit number represents the permissions for the group to which the same group of users belong.
A 7-9-digit number represents the rights of other people for other users.
2. How to convert Permissions
777 = rwx rwx rwx
651 = Rw-r-x--x
465 = r--Rw-r-x
520 = R-x-w----
3, the composition of the rights and characteristics of "combination form"
Combined order of permissions: Readable "R" writable "W" executable "x"
4, the right to display the formula
Type of file + permissions combination
The permissions for the directory are 777:drwxrwxrwx
The permissions for the directory are 644:drw-r--r--
A normal file "binary" has the permission of 777:-RWXRWXRWX
The permission for a soft connection is 520:lr-x-w----
Experience: PHP developers only need to be concerned with directory permissions
5. View File Permissions
Ls-lh
#================================== commands to manage file and directory permissions ==========================================#
1, modify the permissions of the file or directory: chmod
chmod options:-R
Format: chmod "option (-R)" "permissions (combination of numbers, eg:777)" "File name"
2. The owner of the modified file or directory: Chown
Chown options:-r "Recursive Change Permissions"
Format: chown "Options" "Group" "files to modify"
3. Modify the file or the group to which the directory belongs: chgrp
Format: chgrp "Options" "Modified Group name" "File to be modified"
#=========================================linux under Snapshot =================================================#
To create a snapshot step
1. Click Snapshot, set snapshot name and comment
2. After the snapshot is complete, you can view the snapshot in the snapshot manager
To recover a snapshot:
1, click on the snapshot Manager, and then click the snapshot you need to recover, directly click to go to can be restored
#=========================================linux Firewall =================================================#
1. View firewall status
Service Iptables Status
2, the command to open the firewall
Service Iptables Start
3. Close the firewall command
Service Iptables Stop
4. Restart the firewall
Service Iptables Restart
#=========================================yum Online Installation Instructions =============================================#
1. Common Yum Commands
Yum-y Install "package name to be installed" (can be incomplete)
Yum Search "package name to install" (can be incomplete)
Yum Remove "package name to unload" (can be incomplete)
The Yum installation package is RPM package
#============================================= Build ftp==================================================#
Steps:
1. Turn off the security subsystem in Linux SELinux, using the command: Vim/etc/selinux/config
Change selinux=disabled to
2. Restart the system: Reboot
3. Shut down the Linux Firewall, command: Service iptables stop
4, search the correct RPM packet FTP, command: Yum search ftpd, find vsftpd.i686
5, install vsftpd this RPM package, command: yum-y install VSFTPD
6, check whether the installation is successful, command: RPM-QA | grep vsftpd
7, start the FTP server, command: Service vsftpd start (stop, restart)
#======================================= use FTP to upload and download files on the client =================================#
Steps:
Note: When using FTP, you need to open the FTP service
Command: Service vsftpd start
1. Click the Lightning bolt icon and select Quick Connect from the pop-up drop-down menu.
2, Configuration: Connection Type "FTP", service domain "Linux IP address", port "", User name "ftp default cannot use root to log in", password
The connection failed because the firewall under Windows is blocking FXP by default and can be set to let FXP through the firewall, or shut down the firewall directly under Windows
3, using ordinary user login, the default is to jump to the host directory "will show the current directory of hidden files, in development generally delete hidden files"
4. Try uploading a file to a Linux FTP server
8, using ordinary users to try to upload
#======================================= use Xshell to install Rzsz upload and download =========================================#
Lrzsz upload: Is in Linux can replace the FTP upload and download tool "can only use Xshell, cannot use Pttuy" "" Alternative FTP "
Steps:
1, first confirm whether to be installed "direct write Rz/sz enter"
2, search Rzsz upload installation package, command: Yum search Rzsz
3, installation, command: yum-y install Lrzsz
4. Try uploading a file to/usr/local/src and drag it directly to the Linux directory you want to upload.
5, try to download a file to Windows, the command: sz "need to download the file name"
#=======================================yum Build Lamp Environment ====================================================#
To install Apache steps:
1. Installing Apache
Command: yum-y install httpd httpd-manual mod_ssl mod_perl mod_auth_mysql
2. Test whether Apache is installed successfully
① shut down the firewall, command: Service iptables stop
② tries to start the Apache server, but a warning appears, command: Service httpd start
③ in the Windows browser to enter the IP address of Linux, to see if there is an Apache interface, appears to indicate that the installation was successful, or failed
Perfect Apache settings:
Directory to enter the configuration file: cd/etc/httpd/conf
Open Apache configuration file with vim: Vim httpd.conf
Modify the Apache configuration file: Search:/servicename, change 276 lines to: ServiceName localhost:80
Test Apache for successful installation in Windows Explorer
3, experience, the Apache launch into the boot script
Command: Chkconfig httpd on
To install the MySQL step:
1. Installation command: yum-y install MySQL mysql-server mysql-devel
2. Configure MySQL
① the MySQL boot into the boot script
Command: Chkconfig mysqld on
② start MySQL,
Command: Service mysqld start
③ set the root account and password for MySQL
Command: mysqladmin-uroot password 123456
④ into MySQL
Command: mysql-uroot-p123456
⑤ perfecting MySQL's existing problems
1) Perfect MySQL garbled configuration, use the MySQL patch pack
Upload the patch pack to/USER/LOCAL/SRC under Linux
The permissions to modify the patch pack are: 777
Run the Sh script, command:./mysql.sh
Restart MySQL, command: Service mysqld restart
To see if garbled characters still exist, run code: show varible
To install the PHP steps:
1. Install PHP
Configuring the Yum Source
①RPM-UVH http://ftp.iij.ad.jp/pub/linux/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
②RPM-UVH http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
Installing php5.6.x
Yum-y install--enablerepo=remi--enablerepo=remi-php56 php php-opcache php-devel php-mbstring php-mcrypt php-mysqlnd ph P-pecl-xdebug php-pecl-xhprof
Install php5.6.x "GD Library"
Yum install--enablerepo=remi--enablerepo=remi-php56 php php-opcache php-pecl-apcu php-devel php-mbstring php-mcrypt Php-mysqlnd php-phpunit-phpunit php-pecl-xdebug php-pecl-xhprof php-pdo php-pear php-fpm php-cli php-xml Php-bcmath Php-process PHP-GD Php-common
Restart Apache
Service httpd Restart
2. Write Phpinfo () test
① method
Using Vim to write: vim/var/www/html/index.php
Write the Phpinfo () in it;
② method
Command: Php-v
#=============================================linux directory Structure ========================================#
root directory (/): Places all the root Linux related directories and files
/boot: Boot directory, system boot or reboot or crash, this directory will be called by Linux when fixed, and put some
Files and directories that cannot be deleted and modified.
/etc: a directory dedicated to placing configuration files
/root: "Host directory" for Super Administrator
/home: "Host directory" for normal users
/bin: Commands that are accessible to all users
/sbin: Commands that a Super administrator can access
/usr:unix Software Resource Directory
/USR/LOCAL/SRC: Put some third-party software ready for installation
/OPT: Put some third software ready to install
/MNT: Generally used to mount "habits"
/misc: Generally used to mount "not used"
/lost+found: Repairing or damaging the directory, fragmentation directory
/var: Some file directories that can change when the system is in progress
/var/lib/mysql:mysql Data and Index directory
Default Site Directory for/var/www/html:apche
#============================================ Note =================================================#
1, modify the user's password
passwd "User Name"
2. Setup shuts down the firewall
Linux Common basic Commands (notes)