Linux (CENTOS7) frequently used commands and shortcut keys for continuous validation updates ...

Source: Internet
Author: User
Tags bz2 clear screen file copy pack disk usage

1. Files and directories
CD Entry Directory
Example: Cd/home into the home directory
CD: Return to the top level directory
CD..    /.. Return to the top level two directory
CD-Return to the last directory
CD ~ Return to the root directory
CP
cp file1 file1 file copy
cp-a
cp-a dir1 dir2 copy a directory
cp-a/tmp/dir1. Copy a directory to the current working directory
(. Represents the current directory)
ls to view the files in the directory
ls-a Show hidden files
ls-l Show Details
LS-LRT Display files by Time (l for detailed list, R for reverse sort, t for time sorting)
pwd Display work path
mkdir Dir1 Creating a Dir1 directory
mkdir dir1 DIR2 Create two directories at a time
mkdir-p/tmp/dir1/dir2 Create a directory tree
MV Dir1 dir2 Move/rename a directory
rm-f file1 deleting files file1
rm-rf dir1 Delete directory Dir1 and its subdirectories

2. View the contents of the file
cat File1 Viewing the contents of a file starting from the first byte
head-2 file1 View the first two lines of a file
More file1 View the contents of a long file
TAC File1 To reverse view the contents of a file from the last line
tail-3 file1 View the last three lines of a file

3. Text Processing
grep str/tmp/test Find "str" in file '/tmp/test '
grep ^str/tmp/test Find lines starting with "str" in file '/tmp/test '
grep [0-9]/tmp/test Find all rows in '/tmp/test ' file that contain numbers
grep str-r/tmp/* find "str" in directory '/TMP ' and its subdirectories
diff file1 File2 Find out two different places in a file
Sdiff file1 file2 shows the difference between two files in a contrasting way

4. Find
Find /-name file1 starting from '/' to the root file system for files and directories
Find/-user user1 finding files and directories belonging to user ' User1 '
find/home/user1-name \*.bin in directory '/home/user1 ' to find files that end with '. Bin '
find/usr/bin-type f-atime +100 Find execution files that have not been used in the last 100 days
Find/usr/bin-type f-mtime-10 Find files that have been created or modified within 10 days
Locate \*.ps search for files ending with '. ps ', run the ' updatedb ' command first
Find-name ' *. [CH] ' | Xargs grep-e ' expr ' finds ' expr ' in all. C and. h files in the current directory and its subdirectories
find-type f-print0 | xargs-r0 grep-f ' expr ' find ' expr ' in the regular file of the current directory and its subdirectories
find-maxdepth 1-type F | xargs grep-f ' expr ' find ' expr ' in the current directory

5, compression and decompression
bzip2 file1 compression file1
bunzip2 file1.bz2 Decompression file1.bz2
gzip file1 compression file1
gzip-9 file1 maximum compression file1
gunzip file1.gz Decompression file1.gz
tar-cvf archive.tar file1 pack file1 into Archive.tar (-C: Build compressed archives;-V: Show all processes;-F: Use the file name, is required, is the last parameter)

TAR-TF Archive.tar Display the contents of a package
TAR-XVF Archive.tar Release a package
TAR-XVF archive.tar-c/TMP release the package to the/tmp directory
zip file1.zip file1 Create a zip-format compression Package
zip-r file1.zip file1 dir1 compress files and directories into a zip-format package
Unzip File1.zip unzip a zip-format tarball into the current directory
Unzip test.zip-d/tmp/unzip a zip-format tarball into the/tmp directory

6. Yum Tools
yum-y Install [package] Download and install a RPM pack
Yum Localinstall [package.rpm] Install a RPM package and use your own software warehouse to resolve all dependencies
yum-y Update updates all RPM packages installed in the current system
yum Update [package] updates one RPM pack
yum Remove [package] Delete an RPM packet
Yum list lists all packages installed in the current system
Yum Search [package] search for packages in rpm repositories
yum Clean [package] Clear Cache directory (/var/cache/yum) packages
Yum Clean Headers Delete all header files
Yum Clean all deletes all cached packages and header files

7. Network
IP addr Show shows the IP address of the NIC
ifconfig Display of Ethernet configuration
netmask Subnet Mask 255.255.255.0
ifdown eth0 Disable ' eth0 ' network device
ifup eth0 enable ' eth0 ' network devices
iwconfig eth1 shows the configuration of a wireless network card
iwlist Scan Display wireless network

-a (All) shows all options, netstat default does not show listen related
-t (TCP) Show only TCP-related options
-u (UDP) only shows UDP-related options
-n refuses to display aliases, showing all numbers converted to numbers. (important)
-P Displays the program name that establishes the associated link (in MacOS, the Protocol-P protocol)
-r show routing information, routing table
-s Statistics per protocol (important)

Netstat command detailed reference Park Friends blog: https://www.cnblogs.com/echo1937/p/6677325.html


8. User Shutdown and restart
W or who view user logon status
Who am I view my login
pkill-kill-t pts/1 kicks off PTS/1 user
passwd Change Password
Shutdown-h 10 will be turned off after 10 minutes and will be displayed in the current screen of the logged-on user
Shutdown-h now immediately shuts down the machine
shutdown-h 22:30 shutdown at 22:22
Shutdown-r now reboot
shutdown-r +10 will restart in 10 minutes
Reboot Restart
Halt shut down the machine

9. System, Disk
df-h display of disk usage
Top lists Linux tasks with the most CPU resources (input Q exit)
LSCPU viewing CPU information
IP route View Route
NMCLI Connection Show Show all connections
NMCLI Connection Show-a shows only the currently active connection
NMCLI Device Status lists the list of devices identified by NetworkManager and their status
nmcli Device Disconnect eno16777736 Stop interface
nmcli device Connect eno16777736 Actuator interface

10. System service
Systemctl-at Service
ls/etc/systemd/system/*.service Service Catalog
Ls/usr/lib/systemd/system/*.service
systemctl-t Service--state=active View Active Services
systemctl start Name.service startup service (name= service name)
systemctl Stop Name.service service
systemctl Status name.service view server status
systemctl is-enabled Name Check whether the service is enabled
systemctl enable name.service Setup boot service startup
systemctl Disable Name.service Disabling services
systemctl Daemon-reload/etc/systemd/system/*.service Create a new service

11. Common Shortcut Keys

Ctrl+d a special binary value indicating that EOF exits the current shell in the shell

CTRL + Z task paused
Ctrl + u Delete the characters before the cursor to the beginning of the line
Ctrl + K deletes the character before the cursor to the end of the line
Ctrl + C forces interrupt execution of the program, the process has terminated
Ctrl + A cursor moves to the beginning (ahead of line), equivalent to the usual home key
Ctrl +e cursor moves to end of line
Ctrl + F cursor moves forward (forward) one character position
Ctrl + b cursor back (backward) move one character position
Ctrl + L clear screen, equivalent to execute clear command
Ctrl + R display: Prompt to find relevant historical commands according to user input (Reverse-i-search)
Ctrl + W Deletes the beginning of the current word (word) from before the cursor position
Ctrl + t swap two characters before the cursor position
Ctrl + y Pastes the last word that was deleted
Ctrl + Alt + D Show Desktop
Alt + b cursor moves back (backward) to the previous word
Alt + D deletes from the cursor position to the end of the current word
Alt + F2 Run
Alt + F4 close the current window
Alt + F9 minimize Current window
Alt + F10 maximize Current window
Alt + Tab switch window
ALT + Press and hold the left button to move the window (or scroll the mouse wheel in the bottom task bar)

Some commands refer to the park friend and do the test optimization: http://www.cnblogs.com/webnote/p/5748532.html

Linux Basics Website: http://www.runoob.com/linux/linux-tutorial.html

Linux (CENTOS7) frequently used commands and shortcut keys for continuous validation updates ...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.