Clean up the Linux common commands and shortcut keys.
Common commands:
files and directories:
# cd/home into the '/home ' directory
# CD ... Return to the previous level of the directory
# CD ... /.. Back to Level two directory
# CD-Return to the last directory
# cp file1 file2 copy file1 to File2
# cp-a Dir1 dir2 Copy a directory
# cp-a/tmp/dir1. Copy a directory to the current working directory (. Represents the current directory)
# ls View files in a directory
# ls-a Show hidden files
# ls-l Show Details
# LS-LRT Displays files by Time (L represents a detailed list, R indicates a reverse sort, and T indicates a chronological order)
# PWD Display work path
# mkdir Dir1 create ' dir1 ' directory
# mkdir Dir1 DIR2 Create two directories at the same time
# mkdir-p/tmp/dir1/dir2 Create a directory tree
# MV Dir1 dir2 Move/Rename a directory
# rm-f file1 delete ' file1 '
# rm-rf Dir1 Delete ' dir1 ' directory and its subdirectory contents
To view the contents of a file:
# cat File1 to view the contents of a file 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 View the contents of a file in reverse from the last line
# tail-3 File1 View the last three lines of a file
Text Processing:
# grep str/tmp/test find ' str ' in file '/tmp/test '
# grep ^str/tmp/test to find rows starting with "str" in file '/tmp/test '
# grep [0-9]/tmp/test Find all rows that contain numbers in the '/tmp/test ' file
# grep str-r/tmp/* Lookup "str" in directory '/TMP ' and its subdirectories
# diff File1 File2 Find out the difference between two files
# Sdiff File1 file2 shows the difference of two files in a contrasting way
Find:
# Find/-name file1 from '/' start to root file system look up files and directories
# Find/-user user1 look for files and directories that belong to the user ' User1 '
# find/home/user1-name \*.bin in directory '/home/user1 ' to find files ending 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 ' 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 ' finds ' expr ' in regular files in the current directory and its subdirectories
# find-maxdepth 1-type F | Xargs grep-f ' expr ' to find ' expr ' in the current directory
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 to pack file1 into Archive.tar
(-C: Create compressed files;-V: Show all processes;-F: Use file name, is required, is the last parameter)
# TAR-CVF Archive.tar file1 dir1 pack file1,dir1 into Archive.tar
# TAR-TF Archive.tar Display the contents of a package
# TAR-XVF Archive.tar Release a bag
# TAR-XVF ARCHIVE.TAR-C/TMP releases the compressed package into the/tmp directory
# Zip File1.zip file1 Create a zip-formatted compressed package
# zip-r file1.zip file1 dir1 compress files and directories into a zip-formatted compressed package
# unzip File1.zip unzip a zip-formatted compressed package to the current directory
# unzip test.zip-d/tmp/unzip a zip-formatted compressed package to/tmp directory
Yum Tools:
# yum-y Install [package] Download and install an RPM package
# yum Localinstall [package.rpm] installs an RPM package that uses your own software warehouse to resolve all dependencies
# yum-y Update updates all RPM packages installed in the current system
# yum Update [package] updates an RPM package
# yum Remove [package] Delete an RPM package
# Yum list lists all packages installed in the current system
# yum Search [package] searching for packages in the RPM warehouse
# yum Clean [package] clears the packages under the cache directory (/var/cache/yum)
# Yum Clean headers Delete all header files
# yum Clean all delete all cached packages and header files
Network:
# ifconfig eth0 shows the configuration of an Ethernet card
# ifconfig eth0 192.168.1.1 netmask 255.255.255.0 Configure the IP address of the network adapter
# ifdown eth0 Disable ' eth0 ' network device
# ifup eth0 enable ' eth0 ' network device
# Iwconfig eth1 shows the configuration of a wireless card
# iwlist Scan Display wireless network
# IP Addr Show Displays the IP address of the network card
Other:
# Su-Switch to root (different from Su)
# shutdown-h now shutdown
# Shutdown-r now reboot
# top list Linux tasks with most CPU resources (input Q exit)
# Pstree shows the program in a tree chart
# Man Ping View Reference manual (for example, ping command)
# passwd Modify Password
# DF-H Displays the disk usage
# CAL-3 Displays the first one months, the current month, and the next one month calendar
# cal 10 1988 displays the calendar for the specified month, year
# date--date ' 1970-01-01 UTC 1427888888 seconds ' converts a number of seconds from 00:00 in 1970-01-01 to a time
Common shortcut keys:
CentOS 6.4 allows you to set shortcut keys by using the system-> Preferences-> keyboard shortcuts, as shown in the figure. For example, you can set the shortcut key for the running terminal to ctrl+alt+t.
Ctrl + U Delete characters before the cursor to the beginning of the line
Ctrl + K Delete characters before the cursor to the end of the line
CTRL + C cancels the current line Input command, which is equivalent to CTRL + BREAK
Ctrl + A cursor moves to the beginning (ahead of line), equivalent to the usual home key
Ctrl + e cursor move to end of line
Ctrl + F cursor forward (forward) move one character position
Ctrl + b cursor backward (backward) move one character position
Ctrl + L Clear screen, which is equivalent to executing the clean command
Ctrl + R display: Number prompt, find relevant history commands based on user input (Reverse-i-search)
Ctrl + W Deletes the beginning of the current word (word) from the cursor position
Ctrl + t swap two characters before the position of the cursor
Ctrl + y Paste the last deleted word
Ctrl + Alt + D Show Desktop
ALT + b cursor back (backward) move to the previous word
Alt + D deletes from the cursor position to the end of the word currently in place
Alt + F2 Run
Alt + F4 closes the current window
ALT + F9 Minimize Current window
ALT + F10 Maximize Current window
ALT + Tab Toggle Window
ALT + Press and hold the left button to move the window (or scroll the mouse pulley in the bottom task bar)
[Middle mouse button] Pastes the highlighted text. Use the left mouse button to select the text. Point the cursor to the place where you want to paste the text. Click the middle mouse button to paste.
The Tab command line is automatically fully filled. You can use this approach when you use a shell hint. Type the first few characters of the command or file name, and then press the [Tab] key, which automatically complements all commands or displays all the commands that match the characters you type.
Open the File Manager by simply pressing/entering the location on the desktop or in the File Manager.
Quick Search: In VI or FIREFOX directly press/can enter the search status.
Site links and pictures can be directly dragged to the desktop or directory, you can download immediately.
You can get the full pathname in the terminal by dragging the file in the file Manager directly to the terminal.
Click the middle mouse button in the margin of the scroll bar, and the screen scrolls to that place.