Common CentOS Command Summary-a summary of the previous online chaos, coupled with their own previously disorderly record of some things

Source: Internet
Author: User
Tags gz file

To view software log information:

sudo cat/var/log/messages | grep Network

Whereis Query Software Installation location

Kill according to the user

Pkill–u xxx

Uninstalling a single package without uninstalling its related packages

rpm–e XXX--nodeps

To temporarily fix the screen:

Ctrl+s is an old shell control key that can be restored by entering Ctrl+q.

Find the installation location of the software

sudo rpm–qal|grep xxx

Most CentOS configuration files exist in/etc

A better way to find files in CentOS: Find/| grep xxx

Reviews: Regular use of common CentOS commands, a thorough and meticulous collation of some basic CentOS commands that are often used in our work
Below, we will introduce these common CentOS commands.


One: View CPUs using CentOS common commands


Copy the code code as follows:
More/proc/cpuinfo | grep "ModelName"
grep "model name"/proc/cpuinfo
[[email protected]/]# 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 the need to see more comfortable


grep "model Name"/proc/cpuinfo | Cut-f2-d:


Second: Use CentOS common commands to view memory




Copy the code code as follows:
grep memtotal/proc/meminfo
grep Memtotal/proc/meminfo | Cut-f2-d:
Free-m |grep "Mem" | awk ' {print$2} '








Three: Use CentOS common commands to see if the CPU is 32-bit or 64-bit
View the number of CPU bits (+ or 64)
Getconf Long_bit


Four: Use CentOS common commands to view the current version of Linux
More/etc/redhat-release
Cat/etc/redhat-release


V: View kernel version using CentOS common commands
Uname-r
Uname-a


Six: Use CentOS common commands to view the current time
The date above describes how to synchronize time


Seven: Use CentOS common commands to view hard disks and partitions
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
To view the packages installed on the system
Cat-n/root/install.log
More/root/install.log | Wc-l
See which packages are now installed
Rpm-qa
Rpm-qa | Wc-l
Yum List Installed | Wc-l
But strangely enough, 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 commands to view selinux conditions
Sestatus
Sestatus | Cut-f2-d:
Cat/etc/sysconfig/selinux


11: View Ip,mac address using CentOS common commands

Copy the code code as follows:
In the Ifcfg-eth0 file you can see 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 ' {print '} '
View Gateway
Cat/etc/sysconfig/network
View DNS
Cat/etc/resolv.conf


12: Use CentOS common commands to see the default language
Echo $LANG $LANGUAGE
cat/etc/sysconfig/i18n


13: Use CentOS common commands to view the time zone and whether to use UTC time
Cat/etc/sysconfig/clock


14: Use CentOS common commands to view host names
Hostname
Cat/etc/sysconfig/network
Modify the hostname is to modify this file, but also preferably the host file also modified.


XV: Use CentOS common commands to view boot uptime
Uptime
09:44:45 up, 23:32, ...
It seems to be the problem of the network segment, my machine was turned on 67 days ago.
#系统资源使用情况


Copy the code code as follows:
Vmstat 1-s m
procs-----------Memory-------------swap-------io------System-------CPU------
R b swpd free buff cache si so bi bo in CS us Syid 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 00

In many of the Linux terminal commands, we should be classified 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 are used frequently, familiar with these commands should be easy to work a lot.


First, the file directory class


1. Create directory: mkdir directory name
2. Delete Empty directory: RmDir directory name
3. Unconditional deletion of subdirectories: RM-RF directory Name
4. Change the current directory: CD directory name (go to User home directory: cd ~; go to the top level directory: CD-)
5. View your directory: PWD
6. View the current directory size: Du
7. Display directory file list: Ls-l (-A: Add display hidden directory)
Where: Blue: directory; green: executable file; red: compressed file; light blue: Link file; Gray: other files; red background white: Wrong link file
8. Browse Files: More file names. txt;less filename. txt
9. Copy files: CP source file Target file (-r: Include directory)
10. Find File: (1) Find (2) Locate command name
11. Link: (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 the drive usage: df-t-H
2. Check the disk partition: Fdisk-l
3. Mount the soft hard light zone: mount-t/dev/fdx|hdax/mnt/directory name
Including:: Modos--fat16;vfat--fat32;ntfs--ntfs; optical drive--iso9660
Support Chinese name: Mount-o iocharset=x/dev/hdax/mnt/directory Name (where: 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. Release mount: umount/mnt/directory Name
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) Anti-installation (uninstall) Rpm-e somefost.rpm
(3) Query rpm-q somefost or Rpm-qpi somefost.rpm (where: P not installed; I contains information)
(4) query after installation location: rpm-qlsomefost.rpm
(5) Upgrade installation: rpm-uvhsomesoft.rpm
(6) Forced installation: Rpm-ivh--nodeps somesoft.rpm or RPM-IVH--nodeps--force somesoft.rpm
2. Source Code Package Installation:
Read the Readme
Basic usage
(1) Configuration: Unzip the directory./configure
(2) Compile: Unzip directory make
(3) Install: Unzip the directory under Makeinstall


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 directive (the meaning of Create);
-x: Unlock the parameter instructions 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 simultaneously.
-Z: Do you have the properties of gzip at the same time? i.e. do I need gzip compression?
-j: Do you have bzip2 properties at the same time? i.e. is it necessary to compress with bzip2?
-V: Files are displayed during compression! This is commonly used, but is not recommended for use in the background execution process!
-F: Use the file name, please note, after F to immediately answer the file name Oh! Don't add any more arguments!
For example, using "TAR-ZCVFP tfile sfile" is the wrong way to write
"TAR-ZCVPF tfile sfile" Just right!
-P: Use original file properties (attributes are not changed according to user)
-P: You can use absolute path to compress!
-N: Newer than next date (YYYY/MM/DD) will be packaged in the new file!
–exclude file: In the process of compression, do not package file!


Example:
Example one: Package all the files in the/etc directory into/tmp/etc.tar
[[email protected] ~]# tar-cvf/tmp/etc.tar/etc<== only packaged, not compressed! TAR-CVF destination File source file (same as below) For example: Tar-cvfa.txt.tar a.txt
[[email protected] ~]# tar-zcvf/tmp/etc.tar.gz/etc<== after packing, compress with gzip
[[email protected] ~]# tar-jcvf/tmp/etc.tar.bz2/etc<== after packaging to bzip2 compression
# Note that the file name after parameter f is taken by yourself, and we are accustomed to using. Tar as a recognition.
# if the z parameter is added, the. tar.gz or. tgz represent the gzip compressed tar file ~
# If you add the J parameter, use. tar.bz2 as the file name.
# When the above instruction is executed, a warning message is displayed:
# "tar:removing leading"/"from member names" that is a special setting for absolute paths.

Example two: Check out what files are in the above/tmp/etc.tar.gz file?
[Email protected] ~]# tar-ztvf/tmp/etc.tar.gz
# because we use gzip compression, so to check the file in the tar file,
# you have to add Z to this parameter! It's important!

Example three: Extracting the/tmp/etc.tar.gz file under/USR/LOCAL/SRC
[Email protected] ~]# CD/USR/LOCAL/SRC
[Email protected] src]# tar-zxvf/tmp/etc.tar.gz
# in the case of presets, we can unzip the file anywhere! In the case of this example,
# I'm going to transform my working directory under/USR/LOCAL/SRC and untie/tmp/etc.tar.gz,
# then the unpacked catalogue will be in/USR/LOCAL/SRC/ETC! Also, if you enter/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 inside the/tmp/etc.tar.gz.
[Email protected] ~]# cd/tmp
[Email protected] tmp]# TAR-ZXVF/TMP/ETC.TAR.GZETC/PASSWD
# I can check the file name in the Tarfile through TAR-ZTVF, if only one file,
# can be released in this way! Notice that! The root directory within the etc.tar.gz/is taken away!

Example five: Back up all the files in the/etc/and save their permissions!
[Email protected] ~]# tar-zxvpf/tmp/etc.tar.gz/etc
# The properties of this-p are important, especially if you want to keep the properties of the original file!

Example six: In/home, more than 2005/06/01 new files are backed up
[Email protected] ~]# tar-n "2005/06/01″-zcvfhome.tar.gz/home

Example seven: I want to back up/home, etc, but don't/home/dmtsai
[Email protected] ~]# tar–exclude/home/dmtsai-zcvfmyfile.tar.gz/home/*/etc

Example eight: Unpack the/etc/directly under/TMP without generating files!
[Email protected] ~]# cd/tmp
[Email protected] tmp]# TAR-CVF-etc | TAR-XVF-
# This action is a bit like cp-r/etc/tmp ~ still has its use!
Note that the output file becomes-and the input file becomes-and another | exist ~
# This stands for StandardOutput, standard input and Pipeline command!

Five. Process Control class


1. List the current process Id:ps-auxw
2. Terminating the process: (1) terminating a single process: Kill process ID Number
(2) Terminate the program All processes: Killall program name
(3) Termination of X-window program: Xkill
3. View Resource Usage: (1) Top (2) Free (3) DMESG
4. View environment variable values: 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: switchdeskgnome| Kde| ...

Common CentOS Command Summary-a summary of the previous online chaos, coupled with their own previously disorderly record of some things

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.