I. View cpu using common CentOS commands
More/proc/cpuinfo | grep "modelname"
Grep "modelname"/proc/cpuinfo
[Root @ localhost/] # grep "CPU"/proc/cpuinfo
Modelname: Intel (R) Pentium (R) DualCPUE2180@2.00GHz
Modelname: Intel (R) Pentium (R) DualCPUE2180@2.00GHz
If you feel more comfortable to watch
Grep "modelname"/proc/cpuinfo | cut-f2-d:
Ii. view memory using common CentOS commands
GrepMemTotal/proc/meminfogrepMemTotal/proc/meminfo | cut-f2-d: free-m | grep "Mem" | awk '{print $2 }'
Iii. Use common CentOS commands to check whether the cpu is 32-bit or 64-bit
View CPU bits (32or64)
GetconfLONG_BIT
4. Use common CentOS commands to view the current linux version
More/etc/redhat-release
Cat/etc/redhat-release
5. view the kernel version using common CentOS commands
Uname-r
Uname-
6. Use common CentOS commands to view the current time
Date. The preceding section describes how to synchronize the time.
7. View hard disks and partitions using common CentOS commands
Df-h
Fdisk-l
You can also view partitions.
Du-sh
The occupied space is displayed.
Du/etc-sh
The directory size is displayed.
8. Use common CentOS commands to view installed software packages
View the software packages installed during system installation
Cat-n/root/install. log
More/root/install. log | wc-l
Check the software packages that have been installed.
Rpm-qa
Rpm-qa | wc-l
Yumlistinstalled | wc-l
But it is strange that the number of installation packages I query through rpm and yum is not the same. No reason is found.
9. view the keyboard layout using common CentOS commands
Cat/etc/sysconfig/keyboard
Cat/etc/sysconfig/keyboard | grepKEYTABLE | cut-f2-d =
10. Use common CentOS commands to view selinux Information
Sestatus
Sestatus | cut-f2-d:
Cat/etc/sysconfig/selinux
11: Use common CentOS commands to view ip addresses and mac addresses
In the ifcfg-eth0 file you can see mac, Gateway and other information. Ifconfigcat/etc/sysconfig/network-scripts/ifcfg-eth0 | grepIPADDRcat/etc/sysconfig/network-scripts/ifcfg-eth0 | grepIPADDR | cut-f2-d = ifconfigeth0 | grep "inetaddr: "| awk '{print $2}' | cut-c6-ifconfig | grep 'inetaddr: '| grep-V' 127. 0.0.1 '| cut-d:-f2 | awk' {print $1} 'view gateway cat/etc/sysconfig/network view dnscat/etc/resolv. conf 12: Use common CentOS commands to view the default language
Echo $ LANG $ LANGUAGE
Cat/etc/sysconfig/i18n
12: Use common CentOS commands to check the time zone and whether UTC time is used
Cat/etc/sysconfig/clock
Thirteen: Use common CentOS commands to view the Host Name
Hostname
Cat/etc/sysconfig/network
Modifying the host name is to modify this file, and it is recommended that you also modify the host file.
14. Run common CentOS commands to view the startup time
Uptime
09: 44: 45up67days, 23:32 ,...
It seems that this is indeed a problem with the network segment. I started the machine 67 days ago.
# System resource usage
Vmstat1-Smprocs ----------- memory ------------- swap ------- io ------ system ------- cpu ------ memory
Among the many Linux terminal commands, we should introduce them by category. Here we will first talk about the file directory class, driver mounting class, program installation class, compression and decompression class, and process control class, all Linux terminal commands are frequently used here. It should be much easier to get familiar with these commands.
I. File directory
1. Create a directory: mkdir directory name
2. Delete the empty directory: rmdir directory name
3. Delete the subdirectory unconditionally: rm-rf directory name
4. Change the current directory: cd directory name (go to the user's home directory: cd ~; Go to the upper-level Directory: cd -)
5. view your own directory: pwd
6. view the current directory size: du
7. display the directory file list: ls-l (-a: add an implicit directory)
Blue: Directory; Green: executable file; Red: compressed file; light blue: linked file; Gray: other files; Red: Wrong link file
8. Browse File: morefile name .txt;lessfile name. txt
9. copy the file: the target file of the cp source file (-r: Contains directory)
10. find the file: (1) find (2) locate command name
11. Link: (1) create a hard link: ln to link the source file (-d: create a directory link); (2) create a symbolic link: ln-s to link the source file
Ii. Driver mounting
1. Check hard disk usage: df-T-h
2. Check the disk partition: fdisk-l
3. mount the hardware and software areas: mount-t/dev/fdx | hdax/mnt/directory name
Among them: modos -- FAT16; vfat -- FAT32; ntfs -- NTFS; optical drive -- iso9660
Supported Chinese names: mount-oiocharset = x/dev/hdax/mnt/directory name (where: x = cp936 or
Mount the optical drive: mount-tauto/dev/cdrom/mnt/cdrom
Mounting ISO files: mount-tiso9660-oloopxxx.iso/path
4. unmount: umount/mnt/directory name
Unmount all: umount-
5. Create a file system: mkfs-t/dev/hdxx. Ftype: ext2, ext3, and swap
Iii. Program Installation
1. RPM package installation :( 1) install rpm-ivhsomesoft.rpm
(2) reverse installation (uninstall) rpm-esomefost.rpm
(3) query rpm-qsomefost or rpm-qpisomefost.rpm (where: p is not installed; I contains information)
(4) query after installation location: rpm-qlsomefost.rpm
(5) upgrade installation: rpm-Uvhsomesoft.rpm
(6) force installation: rpm-ivh -- nodepssomesoft. rpm or rpm-ivh -- nodeps -- forcesomesoft. rpm
2. Install the source code package:
Read README
Basic usage
(1) configuration: extract the directory./configure
(2) Compile: extract the make
(3) install makeinstall in the decompressed directory
3. Install src. rpm
========================================================== ========================================================== ========================================================== ================
Iv. compression and decompression
Tar command: tar [-cxtzjvfpPN] file and directory ....
Tar command parameters:
-C: create a parameter command for the compressed file );
-X: Unlock the parameter command of a compressed file!
-T: view the files in the tarfile!
Note that c/x/t can only exist under the parameter! Cannot exist at the same time!
Because it is impossible to simultaneously compress and decompress.
-Z: does it have the gzip attribute at the same time? That is, do I need to use gzip for compression?
-J: Does it have bzip2 attributes at the same time? That is, do I need to use bzip2 for compression?
-V: The file is displayed during compression! This is common, but it is not recommended to use it in the background execution process!
-F: use the file name. Please note that the file name should be followed immediately after f! Do not add parameters!
For example, if you use "tar-zcvfPtfilesfile", the statement is incorrect.
"Tar-zcvPftfilesfile" is correct!
-P: use the original attributes of the original file (the attributes will not be changed based on the user)
-P: absolute paths can be used for compression!
-N: a new date (yyyy/mm/dd) will be packed into the new file!
-ExcludeFILE: Do not package the FILE during compression!
Example:
Example 1: package all the files in the/etc directory into/tmp/etc.tar
[Root @ linux ~] # Tar-cvf/tmp/etc.tar/etc <= package only, do not compress! Tar-cvf target file source file (same as below) Example: tar-cvfa.txt.tara.txt
[Root @ linux ~] # Tar-zcvf/tmp/etc.tar.gz/etc <= compressed with gzip
[Root @ linux ~] # Tar-jcvf/tmp/etc.tar.bz2/etc <= compressed with bzip2
For special example, the file name behind "f" is retrieved, and we use" .tar "for identification on our website.
If zbatch is added, .tar.gz or. tgz is used to represent the tarfile compressed by gzip ~
If July 2 is added, .tar.bz2 will be used as the attachment name ~
# A warning message is displayed when the preceding command is executed:
# "Tar: Removingleading '/" frommembernames "is a special setting for absolute paths.
Example 2: Check the files in the above/tmp/etc.tar.gz file?
[Root @ linux ~] # Tar-ztvf/tmp/etc.tar.gz
# When we use gzip to compress files in the tarfile,
# Add the z parameter! This is important!
Example 3: Decompress the/tmp/etc.tar.gz file under/usr/local/src.
[Root @ linux ~] # Cd/usr/local/src
[Root @ linuxsrc] # tar-zxvf/tmp/etc.tar.gz
# By default, We Can uncompress files anywhere! In this example,
# First, I will transform the working directory to the/usr/local/src directory, and unlock/tmp/etc.tar.gz,
# The unlocked directory will be in/usr/local/src/etc! In addition, if you enter/usr/local/src/etc
# The file attributes in this directory may be different from those in/etc!
Example 4: Under/tmp, I only want to unbind the etc/passwd in/tmp/etc.tar.gz.
[Root @ linux ~] # Cd/tmp
[Root @ linuxtmp] # tar-zxvf/tmp/etc.tar.gz etc/passwd
# I can use tar-ztvf to check the file name in the tarfile. If you only need one file,
# You can issue it in this way! Notice! The root directory in etc.tar.gz/is removed!
Example 5: Back up all the files in/etc/and save their permissions!
[Root @ linux ~] # Tar-zxvpf/tmp/etc.tar.gz/etc
# This-p attribute is very important, especially when you want to keep the attributes of the original file!
Example 6: only new files in/home are backed up.
[Root @ linux ~] # Tar-N "2005/06/01 2017-zcvfhome.tar.gz/home
Example 7: I want to back up/home,/etc, but not/home/dmtsai
[Root @ linux ~] # Tar-exclude/home/dmtsai-zcvfmyfile.tar.gz/home/*/etc
Example 8: package/etc/and unpack it under/tmp without generating a file!
[Root @ linux ~] # Cd/tmp
[Root @ linuxtmp] # tar-cvf-/etc | tar-xvf-
# This action is a bit like cp-r/etc/tmp ~ It is still useful!
# Note that the output file is changed to-and the input file is changed to-, and there is another file | Yes ~
# This represents standardoutput, standardinput, and pipeline commands respectively!
Certificate -------------------------------------------------------------------------------------------------------------------------------------------
5. Process Control
1. List the current process ID: ps-auxw
2. terminate processes: (1) terminate a single process: kill process ID
(2) terminate all processes of the program: Killall program name
(3) Terminate the X-Window program: xkill
3. View resource usage: (1) top (2) free (3) dmesg
4. view the environment variable value: env
5. Restart: (1) reboot (2) CtrlAltDel (3) init6
6. shutdown: (1) shutdown-hnow (2) halt (3) init0
7. Switch the desktop: switchdeskgnome | KDE |...