Basic CentOS commands and quick creation

Source: Internet
Author: User
Note: My computer encountered a problem when installing the linux system. instead of installing ubuntu, I installed centos. Although the two are different versions of linux, the specific operations are similar. When learning various commands and shortcuts for linux, you will inevitably encounter various problems. the following content is my search for various commands and shortcuts for centos from the Internet. I hope you can find out and modify the error while browsing. thank you! Common commands: Text

Note:My computer encountered a problem when installing the linux system. instead of installing ubuntu, I installed centos. Although the two are different versions of linux, the specific operations are similar. When learning various commands and shortcuts for linux, you will inevitably encounter various problems. the following content is my search for various commands and shortcuts for centos from the Internet. I hope you can find out and modify the error while browsing. thank you!

Common commands:

Files and directories:

  1. Cd/home to the '/home' Directory
  2. Cd .. back to the upper-level Directory
  3. Cd... returns the last two levels of directories.
  4. Cd-return the last Directory
  5. Cp file1 file2 copy file1 to file2
  6. Cp-a dir1 dir2 copies a directory
  7. Cp-a/tmp/dir1. copy a directory to the current working directory (. indicates the current directory)
  8. Ls to view files in the directory
  9. Ls-a: show hidden files
  10. Ls-l display details
  11. Ls-lrt displays files by time (l indicates the detailed list, r indicates reverse sorting, and t indicates time sorting)
  12. Pwd display working path
  13. Mkdir dir1: create the 'dir1' Directory
  14. Mkdir dir1 dir2 creates two directories at the same time
  15. Mkdir-p/tmp/dir1/dir2 create a directory tree
  16. Mv dir1 dir2 move/rename a directory
  17. Rm-f file1 delete 'file1'
  18. Rm-rf dir1 deletes the 'dir1' directory and its subdirectories.

View the file content:

  1. Cat file1 views the file content forward from the first byte
  2. Head-2 file1: view the first two lines of a file
  3. More file1 view the content of a long file
  4. Tac file1 reversely views the content of a file from the last row.
  5. Tail-3 file1: view the last three lines of a file

Text processing:

  1. Grep str/tmp/test find "str" in the '/tmp/test' file"
  2. Grep ^ str/tmp/test find the row starting with "str" in the '/tmp/test' file
  3. Grep [0-9]/tmp/test: find all rows containing numbers in the '/tmp/test' file
  4. Grep str-r/tmp/* find "str" in the '/tmp' directory and its subdirectories"
  5. Diff file1 file2 find the difference between the two files
  6. Sdiff file1 file2 displays the differences between the two files in comparison

Search:

  1. Find/-name file1 start from '/' and enter the root file system to find files and directories.
  2. Find/-user user1 find the file and directory of user 'user1'
  3. Find/home/user1-name \ *. bin find the file ending with '. bin' in the'/home/user1' Directory
  4. Find/usr/bin-type f-atime + 100 find execution files that have not been used in the past 100 days
  5. Find/usr/bin-type f-mtime-10 search for files created or modified within 10 days
  6. Locate \ *. ps to find the file ending with '. PS'. run the 'updatedb' command first.
  7. Find-name '*. [ch]' | xargs grep-E 'expr' find 'expr' in all. c and. h files in the current directory and its subdirectories'
  8. Find-type f-print0 | xargs-r0 grep-F 'expr' find 'expr' in the common files in the current directory and its subdirectories'
  9. Find-maxdepth 1-type f | xargs grep-F 'expr' find 'expr' in the current directory'

Compression and decompression:

  1. Bzip2 file1 compression file1
  2. Bunzip2 file1.bz2 unzip file1.bz2
  3. Gzip file1 compression file1
  4. Gzip-9 file1 Max compression file1
  5. Gunzip file1.gz unzip file1.gz
  6. Tar-cvf archive.tar file1 package file1 into archive.tar

(-C: Create a compressed file;-v: display all processes;-f: use the file name, which is required and the last parameter)

  1. Tar-cvf archive.tar file1 dir1 package file1 and dir1 into archive.tar
  2. Tar-tf archive.tar displays the content in a package
  3. Tar-xvf archive.tar release a package
  4. Tar-xvf archive.tar-C/tmp release the compressed package to the/tmp directory.
  5. Zip file1.zip file1 create a zip package
  6. Zip-r file1.zip file1 dir1 compresses files and directories into a zip package
  7. Unzip file1.zip unzip a zip package to the current directory
  8. Unzip test.zip-d/tmp/decompress a zip package to the/tmp Directory

Yum tool:

  1. Yum-y install [package] download and install an rpm package
  2. Yum localinstall [package. rpm] install an rpm package and use your own software repository to resolve all dependencies
  3. Yum-y update updates all rpm packages installed on the current system
  4. Yum update [package] updates an rpm package
  5. Yum remove [package] delete an rpm package
  6. Yum list lists all packages installed in the current system
  7. Yum search [package] search for software packages in the rpm repository
  8. Yum clean [package] clears software packages under the cache Directory (/var/cache/yum)
  9. Yum clean headers delete all header files
  10. Yum clean all delete all cached packages and header files

Network:

  1. Ifconfig eth0 displays the configuration of an Ethernet card
  2. Ifconfig eth0 192.168.1.1 netmask 255.255.255.0 configure the IP address of the NIC
  3. Ifdown eth0 disable the 'eth0' network device
  4. Ifup eth0 enables the 'eth0' network device
  5. Iwconfig eth1 displays the configuration of a wireless network card
  6. Iwlist scan displays wireless networks
  7. Ip addr show displays the ip address of the NIC

Others:

  1. Su-switch to root permission (different from su)
  2. Shutdown-h now shutdown
  3. Shutdown-r now restart
  4. Top List linux tasks with the most CPU resources (enter q to exit)
  5. Pstree displays programs in a tree chart
  6. Man ping View Reference Manual (for example, ping command)
  7. Passwd change password
  8. Df-h displays disk usage
  9. Cal-3 displays the calendar of the previous month, current month, and next month.
  10. Cal 10 1988 displays the calendar of the specified month and year
  11. Date -- date '2014-01-01 UTC 1970 seconds'Converts the number of seconds relative to the time

Common shortcut keys:

  1. In CentOS 6.4, you can choose System> Preference> keyboard shortcut to set the shortcut key ,. For example, you can set the shortcut key of the running terminal to Ctrl + Alt + T.
  2. Ctrl + u delete the character from the beginning of the line before the cursor
  3. Ctrl + k delete the character from the cursor to the end of the line
  4. Ctrl + c cancels the command entered in the current line, equivalent to Ctrl + Break
  5. Ctrl + a move the cursor to the beginning of the line (ahead of line), equivalent to the usual Home key
  6. Ctrl + e move the cursor to the end of the line)
  7. Ctrl + f move the cursor forward to a character position
  8. Ctrl + B move the cursor back to a character position
  9. Ctrl + l clear screen, equivalent to executing the clear command
  10. Ctrl + r Display: number prompt, search for related historical commands (reverse-I-search) based on user input)
  11. Ctrl + w delete the beginning of the word from the cursor position to the current position
  12. Ctrl + t swap the two characters before the cursor position
  13. Ctrl + y paste the last deleted word
  14. Ctrl + Alt + d display desktop
  15. Alt + B move the cursor back to the previous word
  16. Alt + d delete from cursor position to end of current word
  17. Alt + F2 run
  18. Alt + F4 close current window
  19. Alt + F9 minimizes the current window
  20. Alt + F10 maximize current window
  21. Alt + Tab switch window
  22. Alt + press and hold the left button to move the window (or scroll the mouse pulley in the bottom taskbar)

Tips

  1. [Middle mouse key] Paste the highlighted text. Use the left mouse button to select text. Point the cursor to the place where you want to paste the text. Click the intermediate mouse key to paste it.
  2. [Tab] command line auto-completion. This method can be used when shell prompts are used. Enter the first few characters of the command or file name, and then press the [Tab] key. it will automatically complete the command or display all commands that match the entered characters.
  3. In the desktop or file manager, you can directly Press/to enter a location to open the file manager.
  4. Quick Search: directly Press/In vi or Firefox to enter the search status.
  5. You can drag and drop website links and images to the desktop or directory to download them immediately.
  6. Drag the file in the file manager to the terminal to obtain the complete path name.
Related Article

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.