Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the common commands in CentOS

2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "what are the common commands in CentOS". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn what are the common commands in CentOS.

Next, let's introduce these common CentOS commands.

One: use CentOS common commands to view cpu

The code is as follows:

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 the need to see more comfortable

Grep "model name" / proc/cpuinfo | cut-f2-d:

Second: use common CentOS commands to view memory

The code is 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 check whether cpu is 32-bit or 64-bit.

View CPU digits (32 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

Five: use common CentOS commands to check the kernel version

Uname-r

Uname-a

Six: use CentOS commands to view the current time

Date has already introduced how to synchronize time.

Seven: use common CentOS commands to view hard drives 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 software packages

Check the software packages installed when the system is installed

Cat-n / root/install.log

More / root/install.log | wc-l

Check which packages have been installed now

Rpm-qa

Rpm-qa | wc-l

Yum list installed | wc-l

Strangely, however, the number of installation packages I have queried through rpm and yum is not the same. I can't find the reason.

Nine: use common CentOS commands to view keyboard layout

Cat / etc/sysconfig/keyboard

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

Ten: use CentOS commands to check the selinux situation

Sestatus

Sestatus | cut-f2-d:

Cat / etc/sysconfig/selinux

Eleven: use CentOS common commands to view ip,mac addresses

The code is as follows:

You can see mac, gateway and other information in the ifcfg-eth0 file.

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

Twelve: use CentOS common commands to view the default language

Echo $LANG $LANGUAGE

Cat / etc/sysconfig/i18n

Thirteen: use CentOS common commands to check the time zone and whether to use UTC time

Cat / etc/sysconfig/clock

Fourteen: use CentOS common commands to view the hostname

Hostname

Cat / etc/sysconfig/network

To change the hostname is to modify the file, and it is best to modify the host file as well.

Fifteen: use common CentOS commands to check the boot running time

Uptime

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

It seems that it was really the problem of the network segment just now. My machine was turned on 67 days ago.

# usage of system resources

The code is 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 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 1029 856 13 1 86 0 0

Among the many Linux terminal commands, we should introduce them by classification. Here we first talk about file directory class, driver mount class, program installation class, compression and decompression class, process control class, where all Linux terminal commands are often used, and it should be much easier to be familiar with these commands.

I. File directory class

1. Create a directory: mkdir directory name

two。 Delete empty directory: rmdir directory name

3. Unconditionally delete subdirectories: rm-rf directory name

4. Change the current directory: cd directory name (enter user home directory: cd ~; enter higher-level directory: cd -)

5. Check your own directory: pwd

6. View the current directory size: du

7. Show directory file list: ls-l (- a: add display implicit directory)

Where: blue: directory; green: executable; red: compressed file; light blue: linked file; gray: other files; red background and white word: wrong linked file

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

9. Copy files: cp source files destination files (- r: include directories)

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。 Driver mount class

1. Check hard disk usage: df-T-h

two。 Check the disk partition: fdisk-l

3. Mount soft and hard light zone: mount-t / dev/fdx | hdax / mnt/ directory name

Among them:: 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 the optical drive: mount-t auto / dev/cdrom / mnt/cdrom

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

4. Unmount: umount / mnt/ directory name

Unmount all mounts: umount-a

5. Set up 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 install (uninstall) rpm-e somefost.rpm

(3) query rpm-Q somefost or rpm-qpi somefost.rpm (where: P is not installed; I contains information)

(4) query the location after installation: rpm-ql somefost.rpm

(5) upgrade installation: rpm-Uvh somesoft.rpm

(6) mandatory installation: rpm-ivh-nodeps somesoft.rpm or rpm-ivh-nodeps-force somesoft.rpm

two。 Source code package installation:

Check README

Basic usage

(1) configuration: decompress the directory. / configure

(2) compile: decompress the make in the directory

(3) installation: decompress the make install in the directory

Installation of 3.src.rpm

four。 Compression and decompression class

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

Tar command parameters:

-c: create a parameter instruction for a compressed file (meaning create)

-x: unlock a parameter instruction for a compressed file!

-t: check the files in tarfile!

Pay special attention to that only one c/x/t can exist in the issue of parameters! Cannot exist at the same time!

Because it is impossible to compress and decompress at the same time.

-z: does it also have the properties of gzip? That is, is it necessary to use gzip compression?

-j: does it also have the properties of bzip2? That is, is it necessary to use bzip2 compression?

-v: display files in the process of compression! This is commonly used, but is not recommended in the background execution process!

-f: use the file name, please note that you should receive the file name immediately after f! No more parameters!

For example, using "tar-zcvfP tfile sfile" is the wrong way to write it.

"tar-zcvPf tfile sfile" is right!

-p: use the original properties of the original file (the attributes will not change based on the user)

-P: absolute path can be used to compress!

-N: it is newer than the following date (yyyy/mm/dd) before it is packaged into the new file!

-exclude FILE: don't package FILE during compression!

Example:

Example 1: package all the files in the entire / etc directory into / tmp/etc.tar

[root@linux ~] # tar-cvf / tmp/etc.tar / etc

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report