CentOS Common Commands Daquan

Source: Internet
Author: User
Tags bz2 create directory current time gz file centos disk usage

One: Use CentOS common commands to view the CPU

More/proc/cpuinfo grep "model name"

grep "model name"/proc/cpuinfo

[Root@localhost/]# grep ' CPU '/proc/cpuinfo

Model Name:intel (R) Pentium (r) Dual CPU E2180 @ 2.00GHz model Name:intel (R) Pentium (r) Dual CPU E2180 @ 2.00GHz If you feel you need More comfortable to see.

grep "model name"/proc/cpuinfo cut-f2-d:

Two: Use CentOS common command to view memory

grep memtotal/proc/meminfo grep memtotal/proc/meminfo cut-f2-d: free-m grep "Mem" awk ' Print $ '

Three: Use CentOS common command to see whether the CPU is 32-bit or 64-bit

View CPU digits (64 or)

Getconf Long_bit

Four: Use CentOS common commands to view the current Linux version

More/etc/redhat-release

Cat/etc/redhat-release

V: Use CentOS common commands to view the kernel version

Uname-r

Uname-a

VI: Use CentOS common commands to view the current time

Date above describes how to sync time.

Seven: Use CentOS common command to view hard disk and partition

Df-h

Fdisk-l

You can also view partitions

Du-sh

You can see all the space occupied

Du/etc-sh

You can see the size of this directory

Eight: Use CentOS common commands to view installed packages

Check the package installed on the system

Cat-n/root/install.log

More/root/install.log wc-l

View the packages that are now installed

Rpm-qa

Rpm-qa wc-l

Yum List installed Wc-l

It's strange, though, that the number of installation packages I've queried through RPM, and Yum, is not the same. No reason was found.

Nine: Use CentOS common commands to view the keyboard layout

Cat/etc/sysconfig/keyboard

Cat/etc/sysconfig/keyboard grep KEYTABLE cut-f2-d=

Ten: Use CentOS Common command to view SELinux situation

Sestatus

Sestatus cut-f2-d:

Cat/etc/sysconfig/selinux

11: Use CentOS Common command to view Ip,mac address

In the Ifcfg-eth0 file you can see the Mac, Gateway and other information. Ifconfig cat/etc/sysconfig/network-scripts/ifcfg-eth0 grep ipaddr Cat

/etc/sysconfig/network-scripts/ifcfg-eth0 grep ipaddr cut-f2-d=

Ifconfig eth0 grep "inet addr:" awk ' print $ ' cut-c 6-ifconfig grep ' inet addr: ' grep-v ' 127.0.0.1 ' cut-d:-f2 awk ' PR int $ ' View Gateway cat/etc/sysconfig/network view DNS cat/etc/resolv.conf

12: Use CentOS common commands to view the default language

Echo $LANG $LANGUAGE

cat/etc/sysconfig/i18n

12: Use CentOS Common command to view the time zone and whether to use UTC

Cat/etc/sysconfig/clock

13: Use CentOS Common command to view host name

Hostname

Cat/etc/sysconfig/network

Modifying the hostname is to modify the file, and it is best to modify the host file as well. 14: Use CentOS Common command to view the boot run time

Uptime

09:44:45 up, 23:32, ...

It seems that the problem is a network segment, my machine is still 67 days before the boot.

#系统资源使用情况

Vmstat 1-s m procs-----------memory-------------swap--

-----IO------System-------CPU------r B swpd free buff cache si so bi bo in CS us sy ID WA St 0 0 0 233 199 778 0 0 4 25 1 1 3 0 96 0 0 0 0 0 233 199 778 0 0 0 0 1029 856 13 1 86 0-0

In a number of Linux terminal commands, we should classify to introduce, here first said file directory class, drive Mount class, program installation class, compression decompression class, Process Control class, here all the Linux terminal commands will be used frequently, familiar with these commands should be able to work a lot easier.

A, file directory class

1. Create directory: mkdir directory name

2. Delete Empty directory: RmDir directory name

3. Delete the subdirectory unconditionally: RM-RF directory Name

4. Change the current directory: CD directory name (enter user home directory: cd ~; go to the previous level directory: CD-)

5. View your directory: PWD

6. View current directory size: Du

7. Display directory file list: Ls-l (-A: increasing the display of hidden directories)

of which: blue: directory; green: executable file; red: compressed file; light blue: Link file; Gray: Other file; white: Wrong link file

8. Browse Files: more filename. txt;less file name. txt

9. Copy file: CP source File Destination file (-r: Include directory)

10. Look up files: (1) Find (2) Locate command name

11. Links: (1) Establish hard link: ln source file Link file (-d: Create directory link);(2) Establish symbolic Link: ln-s source file Link file

Two. Drive Mount class

1. Check hard disk usage: df-t-H

2. Check Disk partitions: fdisk-l

3. Mount Soft Hard light area: mount-t/dev/fdxhdax/mnt/directory Name

Which:: modos--fat16;vfat--fat32;ntfs--ntfs; optical drive--iso9660

Support Chinese name: Mount-o iocharset=x/dev/hdax/mnt/directory Name (of which: x=cp936 or

Mount Optical drive: mount-t auto/dev/cdrom/mnt/cdrom

Mount ISO file: mount-t iso9660-o loop Xxx.iso/path

4. Lifting mount: umount/mnt/directory Name

To remove all mounts: umount-a

5. Establish the file system: Mkfs-t/dev/hdxx. Among them: Ftype:ext2, ext3, swap, etc.

Three. Program Installation class

1.RPM Package Installation:

(1) Install RPM-IVH somesoft.rpm

(2) Reverse installation (uninstall) Rpm-e somefost.rpm

(3) Query rpm-q somefost or Rpm-qpi somefost.rpm (of which: P is not installed; I contains information)

(4) After the installation of the query location: RPM-QL somefost.rpm

(5) Upgrade installation: RPM-UVH somesoft.rpm

(6) Forced installation: Rpm-ivh--nodeps somesoft.rpm or RPM-IVH--nodeps--force

2. Source Code Package Installation:

Check the Readme

Basic usage

(1) Configuration: Extract the directory./configure

(2) Compile: Unzip the directory make

(3) Installation: Extract the directory make install

Installation of 3.src.rpm

Four. Compression Decompression class

Tar command: tar [-cxtzjvfppn] files and directories.

Tar command parameters:

-C: Create a compressed file parameter instruction (create meaning);

-x: Unlock a parameter command for a compressed file!

-T: View the files inside the Tarfile!

In particular, in the release of the parameters, c/x/t can only exist one! Cannot exist at the same time! Because it is not possible to compress and decompress at the same time.

-Z: Do you also have gzip properties? That is, is it necessary to use gzip compression?

-j: Do you have bzip2 properties at the same time? Is it necessary to use BZIP2 compression?

-V: Displaying files during compression! This is commonly used, but is not recommended in the context of the implementation process! -F: Use file name, please note that after F to immediately receive file name Oh! No more Parameters! For example, the use of "TAR-ZCVFP tfile sfile" is the wrong way to write "TAR-ZCVPF tfile sfile" is right Oh!

-P: Use the original properties of the original file (properties will not be changed according to the user)

-P: You can use absolute paths to compress!

-N: Newer than the following date (YYYY/MM/DD) will be packaged into the newly created file! –exclude file: Do not package file in the process of compression!

Example:

Example one: Package all the files in the/etc directory into a/tmp/etc.tar

[Root@linux ~]# tar-cvf/tmp/etc.tar/etc<== only packaged, not compressed! TAR-CVF target file source file (in the same below) For example: TAR-CVF A.txt.tar a.txt

[Root@linux ~]# tar-zcvf/tmp/etc.tar.gz/etc<== after packaging, gzip compressed

[Root@linux ~]# tar-jcvf/tmp/etc.tar.bz2/etc<== after packaging to bzip2 compression

# Note that the file name after the parameter F is taken by itself, and we are accustomed to using the. Tar as an identification.

# If you add the z parameter, the. tar.gz or. tgz to represent the gzip-compressed tar file ~

# If you add the J parameter, use the. tar.bz2 as the file name.

# The above instruction will display a warning message when it is executed:

# "tar:removing leading"/"from member names" is a special set of absolute paths.

Example two: What documents are available in the above/tmp/etc.tar.gz document?

[Root@linux ~]# tar-ztvf/tmp/etc.tar.gz

# Since we use gzip compression, when we look at the files in the tar file, we have to add the Z parameter! It's important!

Example three: Unzip the/tmp/etc.tar.gz file under/USR/LOCAL/SRC

[Root@linux ~]# CD/USR/LOCAL/SRC

[Root@linux src]# tar-zxvf/tmp/etc.tar.gz

# in the preset case, we can release the compressed file anywhere! In this example, I first transform the working directory underneath the/USR/LOCAL/SRC and unlock

/tmp/etc.tar.gz,

# then the unpacked catalogue will be in/USR/LOCAL/SRC/ETC! In addition, if you enter the/USR/LOCAL/SRC/ETC

# you will find that the file attributes in this directory may be different from the/etc/.

Example four: under/tmp, I just want to untie the etc/passwd in the/tmp/etc.tar.gz.

[Root@linux ~]# Cd/tmp

[Root@linux tmp]# tar-zxvf/tmp/etc.tar.gz etc/passwd

# I can check the file name in the Tarfile through TAR-ZTVF, if only one file

# It can be done in this way! notice! The root directory within the Http://www.007bct.net/was taken away!

Example five: Back up all the files in the/etc/and save their permissions!

[Root@linux ~]# Tar-zxvpf/tmp/etc.tar.gz/etc

# This property of-p is important, especially if you want to preserve the properties of the original file! Example six: In/home, a new file is backed up in 2005/06/01

[Root@linux ~]# tar-n "2005/06/01″-ZCVF Home.tar.gz/home example seven: I want to back up/home,/etc, but don't/home/dmtsai

[Root@linux ~]# TAR–EXCLUDE/HOME/DMTSAI-ZCVF myfile.tar.gz/home/*/etc

Example eight: The/etc/package will be unpacked directly to the bottom of/tmp, without producing a file!

[Root@linux ~]# Cd/tmp

[Root@linux tmp]# TAR-CVF-/etc TAR-XVF-

# This action is a bit like cp-r/etc/tmp ~ still has its use!

# The place to notice in the output file becomes-and the input file also becomes-, and there is a presence ~ # This represents standard output, standard input and Pipeline command!

Five. Process Control class

1. List the current process Id:ps-auxw

2. Terminate process: (1) Terminate single process: Kill process ID Number

(2) Terminate the program All processes: Killall program name

(3) Terminate X-window procedure: Xkill

3. View Resource Usage: (1) Top (2) Free (3) DMESG

4. View environment variable Value: ENV

5. Restart: (1) Reboot (2) Ctrl Alt Del (3) Init 6

6. Shutdown: (1) Shutdown-h now (2) halt (3) Init 0

7. Switch Desktop: Switchdesk gnomekde ...

VI, VIM operation
To move a class:
H/J/K/L: Move left/down/up/Right one grid
W: Backward Word movement (number of words in front plus digits)
B: Forward word movement (number of words in front plus numbers)
E: Move back to the end of the word
GE: Move forward to the end of the word
$ <End>: End of line
0 <Home>: Beginning of line
TX: Find the X of the bank to the right and move there (left in uppercase)

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.