Home>Article>Operation and Maintenance> Summary of commonly used CentOS commands and shortcut keys
The followingcentos tutorialcolumn will introduce to youCentOScommon commands and shortcut keys. I hope it will be helpful to friends in need!
I recently started learning Linux and installed CentOS 6.4 in VMware Player. For your own convenience and the convenience of others, we have compiled common Linux commands and shortcut keys.
Common commands:
Files and directories:
# CD/Home into '/HOME' Directory
# CD .. Return to the previous level catalog
# CD ../ .. Back to the previous two -level directory
# CD -Return to the last directory of the last directory
# CP File1 File2 copy the file1 as 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 the file in the directory
# LS -A display hidden file
## LS -L display detailed information
## LS -LRT display files according to time (L represents a detailed list, R represents reverse sorting, T means sorting by time)
PWD display work path
# Mkdir Dir1 Create 'Dir1' Directory
# Mkdir Dir1 Dir2 and create two directory
# Mkdir -P/TMP/DIR1/DIR2
## mv dir1 dir2 Move/rename a directory # rm -f file1 Delete 'file1' # rm -rf dir1 Delete 'dir1 ' Contents of the directory and its subdirectories
View the file content:
# cat file1 View the contents of the file forward starting from the first byte # head -2 file1 View the first two lines of a file Contents of file# tail -3 file1 View the last three lines of a file
##Text processing:
# grep str /tmp/test Search for "str" in the file '/tmp/test' # grep ^str /tmp/test Search for lines starting with "str" in the file '/tmp/test' # grep [0-9] /tmp/test Find all lines containing numbers in the '/tmp/test' file # grep str -r /tmp/* In the directory '/tmp ' and its subdirectories to search for "str" # diff file1 file2 Find the differences between two files # sdiff file1 file2 Display the differences between the two files in a comparative manner
Find:
find / -name file1 find / -user user1 user1' to find Files ending with '.bin' # find /usr/bin -type f -atime 100 Find executable files that have not been used in the past 100 days # find /usr/bin - type f -mtime -10 Find files that were created or modified within 10 days # locate \*.ps Find files ending with '.ps' file at the end, first run the 'updatedb' command # find -name '*.[ch]' | xargs grep -E 'expr' Find -type f in all .c and .h files in the current directory and its subdirectories # -print0 | Finding 'expr'## Compression and decompression in the current directory:
## BZIP2 File1 Compression File1# bunzip2 file1.bz2 Decompress file1.bz2
# gzip file1 Compress file1 # gzip -9 file1 Maximum compression of file1 # gunzip file1.gz Decompression of file1 .gz# tar -cvf archive.tar file1 packed file1 into archive.tar
(-c: Create a compressed archive; -v: Display all processes; -f: Use the file name, which is required. is the last parameter)
# tar -cvf archive.tar file1 dir1 Package file1, dir1 into archive.tar
# 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 compressed package to the /tmp directory
# zip file1. ZIP FILE1 Create a zip format compressed package
# ZIP -R File1.zip File1 DIR1 to compress the file and directory into a zip format compressed package
# UNZIP FILE1.zip to decompress a zip The compressed packet of the format to the current directory
## unzip test.zip -d/tmp/unzip a zip format compression packet to/tmp directory
# y yum Tools:
# yum -y install [package] Download and install an rpm package # yum localinstall [package.rpm] Install an rpm package, Use your own software repository to resolve all dependencies # yum -y update Update all rpm packages installed in the current system # yum update [package] Update an rpm package # yum remove [Package] Delete an RPM package ## y List List all the packages installed in the current system # u [Package] Search for software packs in the RPM warehouse # yum clean [package] off out the software packages under the cache directory (/var/cache/yum) # down out out all header files out. Delete all cached packages and header files ##Network:
ifconfig eth0 Configuration
# ifconfig eth0 192.168.1.1 netmask 255.255.255.0 Configure the IP address of the network card# ifdown eth0 Disable 'eth0' network device
# ifup eth0 ‐ ‐ Display the configuration of a wireless network card
# iwlist scan Show wireless network
# ip addr show The IP address of the network card
# Others:
SU -Switch to ROOT permissions (different from SU)# shutdown -h now # # pstree off ## df -h Display disk usage
# Cal -3 Display the previous month, the current month and the next month's month calendar
# Cal 10 1988 Display the specified month, the annual month calendar
Date-- date '1970-01-01 UTC 1427888888 seconds' Convert a number of seconds relative to 1970-01-01 00:00 into time
Common shortcut keys: In CentOS 6.4, shortcut keys can be set through System->Preferences->Keyboard Shortcuts, as shown in the figure. For example, you can set the shortcut key for running the terminal to Ctrl Alt T.
# counter to Delete the character from the cursor. Ctrl c Cancel the command entered in the current line, equivalent to Ctrl Break
Ctrl A cursor move to the head (ahead of line), which is equivalent to the usual home key
# Ctrl E cursor to End of Line (END of Line) Move the cursor forward by one character position
Ctrl b Move the cursor backward by one character position
Ctrl l Clear the screen, which is equivalent to executing the clear command
Ctrl r Display: prompt, search related historical commands (reverse-i-search) based on user input
Ctrl w Delete the beginning of the word from before the cursor position to the current word
Ctrl t Swap the two characters before the cursor position
Ctrl y Paste the last deleted word
Ctrl Alt d Display the desktop
Alt b Move the cursor backward to Previous word
Alt d Delete from the cursor position to the end of the current word
Alt F2 Run
Alt F4 Close the current window
Alt F9 Minimize the current window
Alt F10 Maximize the current window
Alt Tab Switch windows
Alt Press and hold the left button to move the window (or scroll the mouse wheel on the bottom taskbar )
[Middle mouse button] Paste the highlighted text. Use the left mouse button to select text. Point your cursor to where you want to paste the text. Click the middle mouse button to paste.
[Tab] Command line auto-completion. Use this method when using the shell prompt. Type the first few characters of a command or file name and then press the [Tab] key, and it will automatically complete the command or display all commands that match the characters you type.
Press / directly on the desktop or file manager to enter the location and open the file manager.
Quick search: Press / directly in vi or Firefox to enter the search state.
Website links and pictures can be dragged and dropped directly to the desktop or directory, and can be downloaded immediately.
Drag the file in the file manager directly into the terminal to get the complete path name in the terminal.
Click the middle mouse button on the blank space of the scroll bar, and the screen will scroll to that place.
The above is the detailed content of Summary of commonly used CentOS commands and shortcut keys. For more information, please follow other related articles on the PHP Chinese website!