Linux common commands (iv)

Source: Internet
Author: User
Tags disk usage

previous section Review

  In the previous few posts, we mainly introduced the common commands of Linux and the use of Vim text editor. Commonly used commands include: File processing commands (see Post Linux Common Commands (a)), Help commands, file search commands, compression decompression commands, and system shutdown commands (see post Linux common Commands (ii)). Vim text editor mainly introduces the working mode of vim and some corresponding work commands (see Post Linux common Commands (iii)). The next section focuses on some of the related operations of the Linux environment configuration.

Linux Environment ConfigurationModify IP Address

Commonly used to modify IP methods are as follows three, this article is mainly introduced in the 3rd type:

1, graphical interface

2,setup Command Virtual interface

3. Modify the configuration file (in Network mode for NAT example)

Step One: Modify the configuration file (Blogger's Linux version is CENTOS7 64-bit)

Vi/etc/sysconfig/network-scripts/ifcfg-ens33

Bootproto=static

Onboot=yes

ipaddr=222.18.157.100

netmask=255.255.255.0

gateway=222.18.157. 2 #网段2任意, IP address 2 fixed, network segment set for VMNET8 IP network segment

dns1=114.114.114.114

dns2=8.8.8.8

Step Two: Restart network in effect

Service Network restart

Network communication commandsPing

Command path:/bin/ping Execute permissions: All Users

Role: Testing the connectivity of the network

Syntax: Ping option IP address

-C specify number of times to send

The ping command uses the ICMP protocol, does not occupy the port

Eg: # ping-c 3 127.0.0.1

ifconfig

English: Interface Configure command path:/sbin/ifconfig Execute permissions: root

Function: View and set network configuration of NIC

Syntax: Ifconfig [-a] [NIC Device ID]

-A: Show all network card information

Ifconfig [NIC Device ID] IP address modify IP address

netstat

English: Network statistics command path:/bin/netstat Execute permissions: All Users

Function: Mainly used to detect the host network configuration and condition

-A all displays all connections and listening ports

-T (TCP) displays only TCP-related options

-U (UDP) displays only UDP-related options

-N Displays the address and port number in a digital manner

-L (Listening) displays the socket of the server in the monitor

eg:# Netstat-tlnu Viewing the port of native listening

TCP 0 0 0.0.0.0:111 0.0.0.0:* LISTEN

Protocol pending packet packet to be sent packet local IP address: Port remote IP Address: port

#netstat-au List all UDP ports

# Nestat-at List all TCP ports

#netstat-an View all network connections on this computer

#netstat –ANTPL

Modify Host name

Hostname Host Name

To Modify a mapping relationship

To modify the mapping between host names and IP addresses

Vi/etc/hosts

222.18.157.100 node-1.edu.cn node-1

You can configure aliases.

Process Management Commands

The difference between a process and a program:

1, the procedure is the static concept, itself as a kind of software resources for long-term preservation, and the process is the execution process of the program, it is a dynamic concept, there is a certain period of life, is the dynamic generation and extinction.

2. There is no correspondence between procedures and processes. A program can be shared by multiple processes, and on the other hand, a process can execute several programs sequentially in an activity.

The difference between a process and a thread:

Process: is the executing program or command, each process is a running entity, has its own address space, and occupies a certain amount of system resources.

Threads: Lightweight processes, processes have separate address spaces, threads do not exist independently, threads are created by processes, and threads consume less CPU and memory than processes.

PS

Role: View process information in the system

Syntax: PS [-auxle]

Common options

A: Show processes for all users

U: Display user name and start time

x: Show process without control terminal

E: Show all processes, including those without control terminal

L: Long format display

View all processes on the system

# PS aux #查看系统中所有进程, using BSD OS format, UNIX

# Ps-le #查看系统中所有进程, using the Linux standard command format

PS Application Example
# ps-u or Ps-l view your own process details

    # PS aux | grep Sam View the processes performed by the user Sam

# Ps-ef | grep init view specified process information  

Pstree

Description:Centos7 does not have Pstree installed by default and needs to install the Psmisc package yourself. Yum install Psmisc.

function: View the current process tree

Syntax: pstree[options]

-p Display Process PID

-U Displays the user who owns the process  

Top

Function: View System health status

Displays the most resource-intensive processes in the current system, as well as some of the system's load situations.

Syntax: top [options]

-D seconds, specified to refresh in seconds, default 3 seconds (Dynamic display)

Kill

Role: Close Process

Syntax: Kill [-option] PId

Kill-9 process number (forcibly closed) common

KILL-1 process Number (restart process)

User Management commandsUseradd

Add user

Syntax: useradd [options] User name

passwd

Modify Password command

Syntax: passwd [options] [user name]

User password: In the production environment, the user password length more than 8, set the case plus numeric plus special characters, to change the password regularly.

Userdel (user delete)

Delete User

-R Delete the host directory while deleting the account (remove)

Disk Space CommandDF

Function: Used to view the status information of the Linux file system, showing the capacity of each partition, the amount of usage, unused and mount points and other information. See the rest of the space

Syntax: DF [-hkam] [Mount Point]

-H (human-readable) displays KB,MB,GB in an easy-to-read manner based on disk space and usage
-K displays information for each partition in kilobytes, by default

-m displays information in megabytes
-a show all partitions including partitions of size 0

du

Function: Used to view the size of a file or directory (disk usage space)

Syntax: du [-ABHS] [file name directory]

-a displays the size of the child file

-H displays KB,MB,GB in an easy-to-read manner

-S summarize statistics total occupancy

eg
Du-a (All)/home displays the size of each sub-file in the/home directory, with the default unit of KB

Du-b/Home Displays the size of each subdirectory under the/home directory in bytes

Du-h/Home Displays the size of each subdirectory under the/home folder in K,m,g

Du-sh/home Displays the total size of the/home directory in common units (K,M,G)-S summarize

The difference between the DF command and the du command:

The DF command is considered from the file system, taking into account not only the space occupied by the file, but also the space occupied by the command or program.

The du command targets files and calculates only the space occupied by the file or directory.

#df –h/

#du –sh/

Free

Function: view memory and swap space usage status

Syntax: free [-KMG]

Options:

-K: Displayed in kilobytes, default is in KB

-M: Displayed in megabytes

-G: Displayed in GB

Cleanup Cache command:

Echo 1 >/proc/sys/vm/drop_caches

Linux common commands (iv)

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.