Common CentOS commands and common centos commands

Source: Internet
Author: User

Common CentOS commands and common centos commands

// Linux common command query link: http://linux.chinaitlab.com/special/linuxcom/

 

I. View cpu using common CentOS commands

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.00 GHz
Model name: Intel (R) Pentium (R) Dual CPU E2180 @ 2.00 GHz
If you feel more comfortable to watch
Grep "model name"/proc/cpuinfo | cut-f2-d:

Ii. view memory
Grep MemTotal/proc/meminfo | cut-f2-d: free-m | grep "Mem" | awk '{print $2 }'

3. view the number of CPU bits (32 or 64)
Getconf LONG_BIT

Iv. view the current linux version
More/etc/redhat-release
Cat/etc/redhat-release

V. view the kernel version
Uname-r
Uname-

6. view the current time
Date. The preceding section describes how to synchronize the time.

7. View hard disks and partitions
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. 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
Yum list installed | wc-l

9. view the keyboard layout
Cat/etc/sysconfig/keyboard
Cat/etc/sysconfig/keyboard | grep KEYTABLE | cut-f2-d =

10. View selinux Information
Sestatus
Sestatus | cut-f2-d:
Cat/etc/sysconfig/selinux

11. View ip address and mac address
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 $2}' | cut-c 6-ifconfig | grep 'inet addr: '| grep-V' 127. 0.0.1 '| cut-d:-f2 | awk' {print $1 }'

View gateway cat/etc/sysconfig/network

View dns cat/etc/resolv. conf

12: view the default language
Echo $ LANG $ LANGUAGE
Cat/etc/sysconfig/i18n

12: ordersCheck the time zone and whether the UTC time is used.
Cat/etc/sysconfig/clock

13th:View 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.

14th:View Start Time
Uptime
09:44:45 up 67 days, 23:32 ,...

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: more file name. txt; less file 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-o iocharset = x/dev/hdax/mnt/directory name (where: x = cp936 or
Mount the optical drive: mount-t auto/dev/cdrom/mnt/cdrom
Mount the ISO file: mount-t iso9660-o loop xxx. 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-ivh somesoft. rpm
(2) reverse installation (uninstall) rpm-e somefost. rpm
(3) query rpm-q somefost or rpm-qpi somefost. rpm (where: p is not installed; Information contained in I)
(4) query the location after installation: rpm-ql somefost. rpm
(5) upgrade and install: rpm-Uvh somesoft. rpm
(6) force installation: rpm-ivh -- nodeps somesoft. rpm or rpm-ivh -- nodeps -- force somesoft. rpm
2. Install the source code package:
Read README
Basic usage

(1) configuration: extract the directory./configure
(2) Compile: extract the make
(3) installation: make install 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, using "tar-zcvfP tfile sfile" is an incorrect method.
"Tar-zcvPf tfile sfile" 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!
-Exclude FILE: do not pack the FILE during compression!


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 (the same as below) for example: tar-cvf a.txt.tar a.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
# Note that the file name after parameter f is obtained by ourselves. We use. tar for identification.
# If the z parameter is added, .tar.gz or. tgz is used to represent the tar file ~ compressed by gzip ~
# If you add the j parameter, use .tar.bz2 as the file name ~
# A warning message is displayed when the preceding command is executed:
# "Tar: Removing leading '/" from member names "is a special setting for absolute paths.

Example 2: Check the files in the/tmp/etc.tar.gz File above?
[Root @ linux ~] # Tar-ztvf/tmp/etc.tar.gz
# When we use gzip to compress the files in the tar file,
# 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 @ linux src] # 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 @ linux tmp] # 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 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: In/home, only new files are backed up before 2005/06/01.
[Root @ linux ~] # Tar-N "2005/06/01"-zcvf home.tar.gz/home

Example 7: I want to back up/home,/etc, but not/home/dmtsai
[Root @ linux ~] # Tar-exclude/home/dmtsai-zcvf myfile.tar.gz/home/*/etc

Example 8: Unpacks/etc/and unpacks it under/tmp without generating a file!
[Root @ linux ~] # Cd/tmp
[Root @ linux tmp] # 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 standard output, standard input, and pipeline commands respectively!

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) Ctrl Alt Del (3) init 6
6. shutdown: (1) shutdown-h now (2) halt (3) init 0
7. Switch the desktop: switchdesk gnome | KDE |...


In centos, I have a file named-test. How can I delete it using the command?

Rm-rf \-test
Escape Character \
Or
Find-name "* test"-exec rm-f {}\;
Or
Rm-f * test
If it still does not work, delete the parent directory. before deleting the directory, replace the backup file with the backup file.

Common computer commands

I. Tips for using Ping commands
Ping is a frequently used utility used to determine whether a local host can exchange (send and receive) data packets with another host. Based on the returned information, we can infer whether the TCP/IP parameter is set correctly and whether the operation is normal. Note that successfully performing one or two exchanges with another host does not indicate that the TCP/IP configuration is correct, we must exchange data between a large number of local hosts and remote hosts to ensure the correctness of TCP/IP.
To put it simply, Ping is a test program. If Ping runs correctly, we can basically eliminate faults in the network access layer, Nic, MODEM input/output lines, cables, and routers, this reduces the scope of the problem. However, Ping can also be used as a DDOS (Denial of Service Attack) tool by someone with ulterior motives to customize the size and endless high-speed transmission of the datagram, for example, many large websites are paralyzed by hackers who use hundreds of computers that can access the Internet at high speed to send a large number of Ping data packets.
According to the default settings, the Ping command on Windows sends four ICMP (inter-network control packet protocol) Send back requests, each 32 bytes of data, if everything is normal, we should be able to receive four replies. Ping can display the time between sending a return request and returning a return response in milliseconds. If the response time is short, the datagram does not have to pass through too many routers or network connections. Ping can also display the TTL value. We can use the TTL value To estimate how many routers the data packet has passed: the start value of the TTL at the source location (that is, a 2th percentile value that is slightly greater than the returned TTL)-the TTL value returned. For example, if the returned TTL value is 119, the initial TTL value of the outbound data packet from the source address is 128, and the source point to the target location must pass 9 vro network segments (128-119 ); if the returned TTL value is 246, the start value of TTL is 256, and the source and target locations must pass through nine vro network segments.
1. Typical order of network faults detected by Ping
Under normal circumstances, when we use the Ping command to find the problem or check the network running status, we need to use many Ping commands. If all of them are running correctly, we can believe that the basic connectivity and configuration parameters are correct. If some Ping commands fail, it can also specify where to locate the problem. The following describes a typical detection sequence and possible faults:
Ping 127.0.0.1
The Ping Command is sent to the IP address software of the local computer, which never exits. If this is not done, it indicates that the installation or running of TCP/IP has some basic problems.
Ping local IP Address
This command is sent to the IP address configured by our computer. Our computer should always respond to this Ping command. If it does not exist, it indicates that there is a problem with the local configuration or installation. When this problem occurs, the LAN user must disconnect the network cable and then resend the command. If this command is correct after the network cable is disconnected, it indicates that the same IP address may be configured on the other computer.
Ping other IP addresses in the LAN
This command should leave our computer, go through the nic and network cable to other computers, and then return. If you receive a response, the NIC and carrier in the local network are running correctly. However, if you receive 0 replies, it indicates the subnet mask (code that separates the network part of the IP address from the host part during subnet division) incorrect or the NIC configuration is incorrect or the cable system is faulty.
Ping the gateway IP Address
If the command is correct, it indicates that the Gateway Router in the LAN is running and can respond.
Ping remote IP
If you receive four responses, the default gateway is successfully used. A dial-up Internet user can successfully access the Internet (but it is not ruled out that the ISP's DNS may be faulty ).
Ping localhost
Localhost is a reserved name for the network of the system. It is an alias of 127.0.0.1. Every computer that is too computer should be... the remaining full text>

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.