Basic operating commands for the System

Source: Internet
Author: User

Basic operating commands for the System

1. root/catanaconda-ks.cfg to determine whether to install base software group

Yum groupinstall base can be used to install the base group ifconfig command or use ip addr sh to view IP information.

To use YUM, you need to create xxx. repo for the yum installation system. Then install the base group

2. Command Line: use shell to explain the input string to run the program
Type
Sudo
Which, whereis, whatis, man, info
Use the Tab to automatically complete the up arrow to query historical history
Ctrl + c, Ctrl + z

3. There is no killall command in the command to solve yum install psmisc

The Psmisc package contains three programs that help manage the/proc directory.

Install the following programs: fuser, killall, pstree and pstree. x11 (link to pstree)

Fuser displays the PID of the process that uses the specified file or file system.

Killall kills a named process and sends a signal to all processes running the specified command.

The pstree Tree displays the currently running processes.

Pstree. x11 and pstree functions are the same but need to be confirmed before exiting.

4. view system hardware information

Uname-a # linux system information command for viewing kernel/operating system/CPU Information
Head-n 1/etc/issue # Check if the operating system version is number 1, not letter L
Cat/proc/cpuinfo # linux system information command for viewing CPU Information
Hostname # linux system information command for viewing computer names
Lspci-TV # list all PCI devices
Lsusb-TV # linux system information commands for listing all USB devices
Lsmod # list loaded Kernel Modules
Env # view environment variable resources
Free-m # view memory usage and swap zone usage
Df-h # view the usage of each partition
Du-sh # view the size of the specified directory
Grep MemTotal/proc/meminfo # view total memory
Grep MemFree/proc/meminfo # view the Amount of idle memory
Uptime # view system running time, number of users, and load
Cat/proc/loadavg # view system load disks and partitions
Mount | column-t # view the status of the mounted Partition
Fdisk-l # view all partitions
Swapon-s # view all swap partitions
Hdparm-I/dev/hda # view disk parameters (only applicable to IDE devices)
Dmesg | grep IDE # view the network of IDE Device Detection Status at startup
Ifconfig # view the attributes of all network interfaces
Iptables-L # view firewall settings
Route-n # view the route table
Netstat-lntp # view all listening ports
Netstat-antp # view all established connections
Netstat-s # view network statistics process
Ps-ef # view all processes
Top # real-time display of Process status users
W # view active users
Id # view specified user information
Last # view User Logon logs
Cut-d:-f1/etc/passwd # view all users in the system
Cut-d:-f1/etc/group # view all groups in the system
Crontab-l # view the scheduled Task Service of the current user
Chkconfig-list # list all system services
Chkconfig-list | grep on # list all started system service programs
Rpm-qa # view all installed software packages
Cat/proc/cpuinfo # linux system command for viewing CPU-related parameters
Cat/proc/partitions # command for viewing linux hard disk and partition information
Cat/proc/meminfo # linux system command for viewing linux system memory information
Cat/proc/version # view a version similar to uname-r
Cat/proc/ioports # view the device's io port
Cat/proc/interrupts # view interrupt
Cat/proc/pci # view pci device information
Cat/proc/swaps # view information about all swap partitions

Systemctl status network ///// network status

View the service port number netstat-anp | grep ssh

View ipip addr

View selinux status sestatusSELinux status: disabled

Restart the network adapter systemctlrestartnetwork. servic

View firewall settings
Old commands
Iptables-L view firewall settings
Service iptables stop disable Firewall
Service iptables start/restart enabling or restarting
New command

Systemctl status firewalld. service

Check whether the service is running ps aux | grep gmond

View the system version, such as 6.4.
Cat/etc/issue

cat /etc/redhat-releaserpm -qa | grep centos-release

Cat/etc/system-release
View the device's io port netstat-tupln

View MAC $ arp 192.168.56.11 through IP

View route entries

View disk

Df-h
Fdisk-l

Du-Sh
Ls-lish

Du-sk * | sort-n // you can check the space usage in the current directory from small to large.

Df-hl

The Df command is used to view the remaining disk space in the file system by adding parameters.
Check whether any failed service systemctl-failed exists

Time Synchronization ntpdate ntp.fudan.edu.cn
Create a folder named mkdir

Nmtui Network Management

Systemctl enable xxxxx: add the Written service to the startup of the server.

Systemctl stop firewall. service

Systemctl is-enabled iptables. service
Systemctl is-enabled servicename. service # query whether the service is started
Systemctl enable *. service # Start the service
Systemctl disable *. service # cancel startup
Systemctl start *. service # start the service
Systemctl stop *. service # stop the service
Systemctl restart *. service # restart the service
Systemctl reload *. service # reload the service configuration file
Systemctl status *. service # query the service running status
Systemctl-failed # displays services that fail to be started

Alias sets command alias syntax alias [alias] = [command name]
Additional instructions: You can use the alias of the alias custom command.

5. centos7 system routine simple operation commands

1. add or deleteDisk Partition
Add Disk

Fdisk-l view disk Conditions

Fdisk/dev/sdb is/dev/sdb device partition --- n add partition p/e primary partition/logical partition w save and quit

Mkdir/data create a mount directory

Mkfs. ext3/dev/sdb format the disk as an ext3 File System

Fdisk-l view disk status again

Mount/dev/sdb/data to the created mount directory

Vi/etc/fstab-Modify the Automatic startup Mount entry/dev/sdb/data ext3 defaults 0 0

An essential solution for mounting a USB flash disk to a CentOS System
1. Log On As A root user
Use fdisk-l to check the USB flash drive device.
Assume that the USB flash drive is sda1.
2. Make sure that the folder/usb is created under the directory/mnt. If not, enter the command mkdir/mnt/usb_disk and proceed to the next step.
3. to load a u disk, enter the following command: mount/dev/sda1/mnt/usb_disk
Then you can use the u disk. The file is in the/mnt/usb directory.
4. unmount the USB flash disk. After using the USB flash disk, You need to press in to unmount the USB flash disk command before unplugging it.
Command: umount/mnt/usb

Problems with command execution during centos 7

1. YUM error yum install yum loaded plug-in fastestmirror

SyntaxError: The problem occurs after the new python version is installed due to invalid syntax.
Solution

Vi/usr/libexec/urlgrabber-ext-down: Change the python in the header to the same as that in/usr/bin/yum.

2. After minimal of CentOS 7 is installed, the first thing to do is to set network access.
First, you need to use the nmtui command to enter the Network Manager settings and start a service named NetworkManager-wait-online

Systemctl enable NetworkManager-wait-online.service

3. Port 80 occupied by tcp6 after ganglia deployment
Netstat-lntp | grep 80
Directly kill the PID and restart httpd.
Systemctl restart httpd. service

4. httpd cannot access the web after ganglia is deployed
Disable the firewall systemctl stop firewall. service

Login: returns to the Login screen

Shutdown now shut down immediately

Shutdown + 55 minutes later shutdown

Reboot restart

Centos7.0 has no problems with the netstat and ifconfig commands.

Yum install wget

Run yum install net-tools.

3. commands for deleting folders, creating, deleting, moving, and copying files

1. Create a folder named mkdir.

Create a folder named test. In the home directory, view source1 mkdir/home/test

2. New text

Create a test. sh script vi/home/test. sh under home.

3. delete files or folders

Delete the rm/home/test directory under the home Directory

This deletion method without parameters often prompts that the deletion cannot be performed because the permission is insufficient for rm-r/home/test.

-R: recursively deleting directories and Their subdirectories in the parameter table will be cleared and deleted. When you delete a write-protected file in the directory, the user is usually prompted for rm-rf/home/test.

F indicates that you are not prompted to delete all files in the directory. Check whether the path is entered into another directory. Rm-ir/home/test

-I is the interaction mode. Use the rm command to prompt the user to confirm before deleting any files.

4. Move a file or folder mv [options] source file or directory target file or directory

Parameters

-I interactive operation. If the mv operation will overwrite the existing target file, the system will ask whether to rewrite the file and ask the user to answer "y" or "n" to avoid overwrite the file by mistake.

-F prohibit interactive operations. When an mv operation overwrites an existing target file, the I parameter does not take effect after no indication is specified.

5. copy a file or folder

Cp [options] source (source) Objective (destination)

Parameters
-A is equivalent to-pdr.
-D if the source file is a link file, copy the link file property instead of the file itself.
-F force means that if there are duplicates or other questions, the user will not be asked to force the copy.
-I. If the destination effect (destination) already exists, the system will first ask if the actual action is involved during overwriting.
-L create a hard link instead of copying the file itself
-P is copied together with the archive attributes instead of using the preset attributes.
-R recursive continuous replication is used for directory replication.
-S is copied to the symbolic link, that is, the "shortcut" file.
-U if destination is earlier than source, update destination.

The four top commands are described as follows:

As one of the most common commands in linux, the top command is used to analyze the performance of linux. This command is often used, but has never been used to understand the meaning of each parameter. The following gives a detailed summary of the meaning of each parameter in the top command.

Clipboard

First line top-16:10:53 up 37 days, 4 users, load average: 0.00, 0.00, 0.00

16:10:53 current time
Up 37 days 20:20 system running time format: minute
4. Number of users currently logged on
Load average: 0.00, 0.00, 0.00 system load is the average length of the task queue. The three values are the average values from 1 minute, 5 minutes, and 15 minutes ago to the present.

Ps: although I know the meaning of load average as a system load, I did not understand its meaning and found it after google.

Note that this value is required for multi-core CPUs divided by the number of logical cores.

Line 2 Tasks: 259 total, 2 running, 257 sleeping, 0 stopped, 0 zombie

Tasks: 259 total process count
2. Number of running Processes of running
257 sleeping sleep Processes
0 stopped process count
0 zombie botnets

Line 3 Cpu (s): 0.2% us, 0.6% sy, 0.0% ni, 99.3% id, 0.0% wa, 0.0% hi, 0.0% si, 0.0% st

Cpu (s): 0.2% us CPU usage
0.6% sy CPU usage in kernel space
0.0% percentage of CPU used by processes that have changed their priorities in ni user process space
99.3% id idle CPU percentage
0.0% wa CPU time percentage waiting for Input and Output
0.0% hi, hard interrupt, percentage of CPU used by Hardware IRQ
0.0% CPU usage of si Soft Interrupt Software Interrupts
0.0% st Virtual Machine stealing time

Row 4 Mem: 16143520 k total, 15581588 k used, 561932 k free, 919728 k buffers

Mem: 16143520 k total physical memory
Total physical memory used by 15581588 k used
561932 k free Memory Total
Memory usage of 919728 k buffers as kernel Cache
Ps: Unit: kb

Fifth line Swap: 8011768 k total, 58072 k used, 7953696 k free, 11067628 k cached

Swap: 8011768 k total number of Swap Areas
The total number of swap areas used by 58072 k used
7953696 k free swap zone total
11067628 k cached buffer swap zone total

Process List

Column name meaning
PID process id
PPID parent process id
RUSER Real user name
User ID of the UID process owner
USER: USER Name of the process owner
GROUP Name of the GROUP process owner
The terminal name of the TTY startup process. Processes not started from the terminal are displayed?
PR priority
NI nice value. Negative value indicates high priority. positive value indicates low priority.
The final CPU used by P is only meaningful in multiple CPU environments.
% Percentage of CPU time used since the last CPU update to the present
Total cpu time used by the TIME process, in seconds
TIME + cpu time used by the process in 1/100 seconds
% MEM percentage of physical memory used by the Process
The total virtual memory used by the VIRT process is measured in kb. VIRT = SWAP + RES
The SWAP size in the virtual memory used by the SWAP process is measured in kb.
The size of the physical memory used by the RES process, Not swapped out, in kb. RES = CODE + DATA
The unit of physical memory occupied by CODE executable CODE is kb.
Physical memory occupied by parts other than the DATA executable code (DATA Segment + stack), in kb
Size unit: kb
Number of nFLT page errors
The number of modified pages that the last time the data is written to the current page.
S Process status.
D = uninterrupted sleep
R = run
S = sleep
T = tracking/stopping
Z = zombie Process
COMMAND name/COMMAND line
If the process is sleep, WCHAN displays the system function name in sleep.
For Flags task flag, see sched. h.

Command

-Q exit top Command-Refresh now-s set the refresh interval-c display command full mode-t: display or hide process and CPU status information-m display or hide memory status information-l display or hide uptime information-f increase or decrease process display flag-S accumulative mode will be completed or the CPU time occupied by the exited sub-process is accumulated to the parent process's MITE +-P ranking by % CPU usage-T ranking by MITE +-M ranking by % MEM-u specified to display the user process -r modify the renice value of the process-kkill process-I only displays the running process-W Save the top settings to the file ^ /. the setting of the toprc file will be automatically called at the next Startup of toprc. -H HELP command. -Q: Exit

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.