Common CentOS commands

Source: Internet
Author: User
Tags install redis

Common CentOS commands
Common commands

  • Pwd: view all current paths
  • Cd ../go to the root directory
  • Restart linux with reboot
  • Make compilation command
    • PREFIX path specifies the path to which the installation is located
  • Ls displays all files or directories in the current directory
    • Parameters
      • -A: displays all files, including hidden files.
      • Ls/directory or file name/view directory or file
      • -L displays detailed information about a file or directory.
      • -Lh humanized display
  • Ip addr
  • Vi file name editing specify file I switch to input mode esc switch to command mode: wq save
  • Vim file name editing specify file (beautiful format) G cursor move to the bottom g cursor move to the top o next line
  • Rename
  • Source Path reload the specified path
  • Tar-zxvf file name-C decompress to that directory (can be added or not added)
  • ./Execution File
  • Ps-ef | grep tomcat | previous output | subsequent input, and | based on previous output, all output with tomcat keywords

  • Netstat-antp | grep 58050 queries the process bound to the specified port

  • Kill-9 process cancels a specified process
  • Pkill-9 java cancels the java Process
CentOs7 graphical interface Installation
  1. Yum groupinstall "X Window System" (note that there are quotation marks)
  2. Yum grouplist
  3. Yum groupinstall "GNOME desktop"
  4. Startx entry graphical interface
Linux shutdown and restart command (shutdown
  • Command Format: shutdown [Option] Time
  • Parameters
    • C. Cancel the previous shutdown command.
    • H Shutdown
    • R restart
Mysql
  • /Usr/local/mysql/bin/mysqld_safe & MySQL Service Startup
Tomcat Startup Process
  1. First, go to the bin directory under the tomcat directory.
  2. ./Startup. sh start tomcat
    • ./Startup. sh & tail-f ../logs/catalina. out start tomcat and print logs
Installation Process
  1. Copy the compressed tomcat file to the specified path.
  2. Decompress the ZIP file of tomcat to the specified path.
  3. Go to the conf file in the decompressed path to modify service. xml (configuration file)-can be changed or not-
    1. The content to be modified includes the port number, defaultHost, and docBase in context (the path to be executed)
  4. Decompress the war package to the path pointed to by docBase in the context.
  5. Go to the bin directory under the tomcat directory and run the command to start
Install jdk on CentOS
  1. First, copy it to the Linux directory.
  2. Decompress the package using the tar command
  3. Go to the jdk.7.0 _ 75 directory in the decompressed directory.
  4. Configure environment traversal by using vim/etc/profile
Install redis on CentOS
    1.
Modify file permissions
  • Chmod permission file name
  • R = 4 w = 2 x = 1
Directory Introduction

/Boot startup directory, which stores startup-Related Files
/Dev device file storage directory
/Etc configuration file storage directory
/Home: home Directory of common users
/Lib system mount directory
/Medla Mount directory
/Root super user's home directory
/Tmp temporary directory
/Proc directly writes data to the memory, Virtual File System
/Sys directly writes data to the memory, Virtual File System
/Var System Documentation

File Format
  • | Dr-xr-x. | 4 | root | 4096 | September 20 21:07 | boot |
  • | Permission |? | Owner | group | file size | last modification date | directory or file name |
Meaning of drwxr-x-
  • 10 in total
  • D indicates a directory. If yes, it is a file. If yes, it is a link.
  • From 2nd to 10th, No 3 digits are grouped into one group.
  • The first group represents the owner's permissions.
  • The second group represents the permissions in the group.
  • The third group represents the permissions of others.
  • The 1st bits in each group indicate the read permission.
  • The 2nd bits in each group indicate the write permission.
  • The 3rd bits in each group represent the execution permissions.
Directory creation directory: mkdir
  • -P recursive creation: create multi-level Directories
Delete a directory or file: rm
  • -R: delete a directory.
  • -F: Force Delete. No prompt is displayed.
  • -Rf forcibly deletes directories and all files
Create File: touch Copy command cp [select] [source file or directory] [target directory]
  • -R copy directory
  • -P joint file property Replication
  • -D if the source file is a linked file, copy the link property.
  • -R recursive Replication
  • -?
  • -Rp copy directory with file attributes
Cut or RENAME command: mv
  • Mv [original file or directory] [target directory]
Link command: ln (link)
  • Ln-s [source file] [target file] Create soft link
  • Ln [source file] [target file] create hard link
  • -S: Create a soft link
Hard Link
  1. With the same I node and storage block, you can think of it as the same file
  2. Can be identified by I nodes
  3. Cannot be cross-partition
  4. Cannot be used for directories
  5. -Rw-r-| the permission for the hard link is rw-r-
Soft link
  1. Similar to windows shortcuts
  2. The soft link has its own I node and block, but the data only saves the file name and I node number of the original file, and there is no actual file data
  3. Lrwxrwxrwx | all soft link files have permissions for rwxrwxrwx.
  4. Modify any file and change the other file.
  5. Delete the original file. The soft link cannot be used.

    The important difference between a soft link and a hard link is that if the original file is deleted, the soft link cannot be used. If it is a hard link, the use of the hard link is not affected.
Search for the locate command
  • Format: locate file name
  • Search by file name in the background database, which is faster
  • Only search by file name
  • Updatedb updates the database
  • Configuration file address:/etc/updatedb. conf
  • Install yum-y install mlocate
Find command
  • Format: find [search range] [search criteria]
  • If you need fuzzy search, you can use * (wildcard)
    • Match any content
  • ? Match any character
  • […] Match any parentheses
  • -Name: search by name
  • -Iname: case-insensitive and search by name
  • Find/-name "*"
  • -The user name is used to search for files of a specified user.
  • Find/-user root
  • -Mtime: Query Based on the file content modification time
    • -Files modified within 10
    • Files currently modified within 10 days
    • + Files modified 10 days ago
  • Atime query by file access time
  • Ctime query by modifying file attributes
  • -Size
    • -2 kb files smaller than 2 kb
    • 2 kb files
    • + 2 kb files larger than 2 kb
    • -Size + 20 k-a-size-50 K Query files larger than 20kb and smaller than 50kb
  • -The inum node number query node is a xx [number] file.
  • -Execute the command after exec.

  • -A (and) logic and both conditions are met

  • -O (or) logic or, two conditions can satisfy one
Grep command
  • String Matching the symbol condition in the file
  • Grep [Option] string file name
  • Parameter-I ignore case-v exclude specified string
Whereis and whichwhereis
  • Command SEARCH Command
  • Whereis command name
  • SEARCH command path and help document location
Parameters
  • -B: only find the executable file location
  • -M: Only search for help files
Which
  • Which file name search command path and alias
Compression and decompression commands
  • Common Format: zip. gz. bz2 .tar.gz .tar.bz2
. Zip compression zip
  • To use the zip command, run the [yum-y install zip] command first.
  • Compressed file name after zip compression in Command Format
  • Parameters
    • -R compression directory
    • Source directory of File Name After zip-r Compression
Decompress unzip
  • To use the unzip command, run the [yum-y install unzip] command first.
  • Command Format unzip compressed file
. Gz format compressed gzip _ gunzip
  • Command Format gzip Source File compression file name
  • If the file is compressed in the format of .gz, the source file disappears.
  • Parameters
    • -The c file is in the. GZ format and the source file is retained.
      • Format: gzip-c source File> compressed file
    • -R: It compresses the sub-files in the directory, but cannot compress the directory.
      • Format: gzip-r source File> compressed file
Decompress gzip _ gunzip
  • Command Format gzip-d compressed file
. Bz2 format compression bzip2
  • Command Format bzip2 files to be compressed
  • Compressed file in the format of .bz2, the source file will disappear
  • Parameters
    • -K compression to retain the source file
Decompress bzip2-d
  • Command Format: bzip2-d compressed file
    • -K: Decompress the package and keep the compressed file.
. Tar format package tar-cvf
  • Command Format: tar-cvf package file name source file
  • Parameters
    • -C Packaging
    • -V display process
    • -F: Specifies the name of the packaged file.
Decompile tar-xvf
  • Command Format: tar-xvf package file name
  • Parameters
    • -X unpacks
    • -V display process
    • -F specifies the name of the decompressed File
. Tar.gz format compressed tar-zcvf
  • Parameters
    • -The z compression format is .tar.gz.
    • -C compression to the specified path
      1. First, compress the file into. tar.gz.
  • Command Format: Name source file after tar-zcvf Compression
Decompress tar-zxvf
  • Command Format: tar-zxvf decompressed file name
.Tar.bz2 compression tar-jcvf
  1. First, compress the file into. tar.bz2.
    • Command Format: tar-jcvf Compressed Name source file
Decompress tar jxcf
  • Command Format: tar-jxcf decompressed File

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.