Prompt:
"[Email protected] Home" #/$:root current user name; localhost hostname; home current directory; # root user prompt; $ normal user prompt
Switch between the image interface and the command interface:
Vi/etc/inittab
Id:3 Command mode, Id:5 image interface
The system modifies the environment variables:
Vi/etc/profile Boot Load
Java_home: Normal variable
PATH: The program runs from the specified directory of the variable to find the desired
/home/.bash_profile User Environment variables, loading when user logs on
Resoure/etc/profile Immediate effect environment variable
Shutdown:
Shutdown-h NOW/5 shutdown at a specified time, now, 5 5 minutes later
Init 0
Halt
Logout
Exit
Restart:
Reboot
Shutdown-r NOW/5 restarts at a specified time, now restarts, 5 5 minutes after restart
Command help:
Mans Commond
Info Commond
Commongd-help
Whatis
Modify the system date:
Date Displays the current date
Date + '%y%m%d-%h%m%s ' formatted output
Date-s "20160910 22:58:00" modification time
Cal [Month] [year] display calendar
File and directory operations:
Cd/usr/local jump to the specified directory
Cd.. Back to top directory
Cd.. /.. Go back to the top two level directory
CD-Back to Last action directory
CD ~user back to user's home directory
LS Displays the current directory contents
Ls-al a show hidden default, l show file details
LS *.txt display all txt files
Ls/usr/local Display the contents of the specified directory
Ls-f viewing files in a directory
Touch 1.txt 2.txt New file
MKDIR/USR/LOCAL/AA New Directory
Mkdir-p/USR/LOCAL/BB/CC Create a parent directory when a new directory is created without a parent directory
rmdir/usr/local/bb/cc Delete Empty Directory
MV Old_name.txt new_name.txt Rename
CP Directory/File/directory/file copy a file
CP file/*. All files under the copy directory to the current directory
Cp-a file. Copy directory file to current directory
RM-RF file R Force delete files, f delete folders and contents
PWD Displays the current directory
Who view current logged in user
WhoAmI who is currently operating user
SU Root Switch user
sudo root runs as root user
Ssh
Cat-n file-n Display line numbers to view file contents
Query output of cat file1 file2 > File3 file1 and File2 to File3
TAC file Displays the contents of files from the trailer
Less file paging displays files, enter line breaks, "" space to Page
More file paging displays files,
Tail-f file content dynamically displayed from trailer
tail-500 file shows the last 500 rows
Tail +500 starting from 500 lines
head-500 file showing 500 rows from the beginning
Ps-ef|grep mysql |grep-v gerp query mysql is started, query process results remove grep query process
Df-h Viewing disk space
Du-h Viewing file sizes
Useradd username New User
Userdel Username Delete a user
Usermod Modifying user information
passwd Username Modify User Password
Groupadd GroupName New Group
Groupdel Groupnaem Delete a group
chmod ugo+rwx file to assign permissions to the user
chmod ugo+777 File
chmod ugo-r
chmod 777 File
Chmod-r 777 file to modify permissions for all files under files and files directory
Chown-r user:group file modifies all content under files and files to belong to users and groups
Chgrp-r group file recursive modified files belong to groups
Clear Clear Screen
History Display historical command, display by default 1000, display number can be configured
Uniq file Delete duplicate rows of files
diff file File2-line-by-row comparison of the contents of files, listing different
Comm File File1 compare two sorted files
Sort file sorts files after output
grep ' AA ' file query contains AA so line
grep ' ^a ' file query the first letter is all rows of a
Find/-name 1.txt finds files with a name of 1.txt in the root directory
Find/usr/local-name "[1-3]*.txt"
Gzip-1 TRV 1.txt compression result is 1.txt.gz
Gunzip 1.txt.gz Unzip the GZ file
Zip-r/usr/local/1.zip/etc files and folders under etc are compressed into 1.zip
Unzip-o 1.zip-d/etc-o overwrites files that already exist and does not require user confirmation
-D directory name unzip the file to the specified directory
TAR-ZXVF 1.tar Extract Files
TAR-ZCVF 1.tar test compression test for 1.tar
SCP 192.168.0.107:/usr/local/1.txt 192.168.0.112:/usr/local Copy a system file to another system
Watch-n 3 mkdir 1 2 3 every 3 seconds, create directory 1 2 3
Ps-ef viewing the currently running process
Top
Kill-9 1111-9 Forced Delete, 1111 process number
Commond & Background Run
System Services:
Chkconfig update, start, stop service
Common services: iptables firewall network httpd Apache Nginx
Chkconfig iptables on to open the firewall for permanent operation
Chkconfig iptables off firewall, permanently active
Service iptables start to open the firewall immediately, restart failure
Service iptables stop instantly shuts down the firewall and reboots fail
Chkconfig iptables--list View Firewall
System service-sercice mode startup script:
The Chkconfig command is primarily user-initiated, stopped, and queried for service
Chkconfig–add 1.sh add 1.sh for system service, 1.sh must be placed in/ETC/RC.D/INIT.D directory
Chkconfig–del 1.sh Delete 1.sh service
Chkconfig 1.sh on Boot
Chkconfig 1.sh off Turn off boot
Service 1.sh start running 1.sh services
Service 1.sh Stop Stop Services
Boot script:
Add a script that requires boot execution to the boot configuration file/etc/rc.d/rc.local
For example: Add/opt/lampp/lampp start in Rc.local, execute lampp startup script in rc.local on boot
Linux Learning Summary