Hello everyone, this time we will introduce some network configurations under liunx, simple basic optimization of shell, and level adjustment first. There are also some commands for you to take a look.
Statement: I like to share with others. I am happy, that is, to make everyone happy. Some of my posts are my previous study notes, and some of my questions can be easily recorded, I also wrote it when I suddenly remembered it. No matter how it is, it is my own experience and experience. I hope everyone can learn and make progress together.
Pid indicates that you are a sub-process)
Ppid is the parent process)
Process top \ u95f4 \ u547d \ u4ee4
\ U6309m \ u662f \ u5185 \ u5b58 \ u6392 \ u5e8f
\ U6309c \ u662fcpu \ u6392 \ u5e8f
Pid user pr ni virt pes shr s % CPU % mem time + COMMAND
PID value: User priority virtual memory size actual memory size shared memory size status percentage of CPU percentage of memory cumulative CPU
Switch back-end
The concurrency status means that the frontend and backend work together and the backend work faster than the front-end, but the CPU is wasted.
[Root @ localhost ~] # Xclock table
[Root @ localhost ~] # Xclock-update 1 plus a second stitch
[Root @ localhost ~] # Xclock-update 1 & run in the background
Converting a running foreground program to a background program
Ctrl + z stop and drop into the background
View the background:
Jobs
The background program continues to run in the background:
Bg 1 No)
Foreground program running:
Fg 1 No)
[Root @ localhost ~] # Jobs
[1] Running xclock-update 1 & background execution)
[2]-previously run) Running xclock-update 1 Running on the foreground)
[3] + currently Running) Running xclock-update 1 &
View the xclock PID
[Root @ localhost ~] # Ps aux | grep xclck
If you open a file on a terminal
Press ctrl + z to pause and exit
Press fg to continue execution on the foreground
Kill a process or program:
Kill % 1 pid) killed normally
Kill-9 1pid) to force a process or program to be killed
Kill all httpd services.
Killall httpd
Xkill is fun !!
Ctrl + ait + return key restart graphical interface
View process ID:
Kill-l
Kill-1 suspended)
Kill-9 he killed it forcibly)
Kill-15 Stop Suicide)
--------------------------------------------------------------------
Priority adjustment:
Maximum priority-20) Minimum priority 19)
Nice-nnks value)-20 priority) httpd program or service) when this program is not executed, it is equivalent to using
Adjust the pid twice)
Renice 10 priority level)-p (pid) 6020 previous pid) ongoing programs use pid to Change Priority Level
-------------------------------------------------------------------------
Advanced commands:
View 20 rows of the passwd file
Cat/etc
View the output of hello world
Echo "hello world" | rev
View the upstream/downstream output of hello world
Echo "hello world" | tac
Display the number of words in a file
Wc-l rows-w words-c characters
Sort
Sort aa.txt by the first number
Sort-n aa.txt is sorted by the entire number
Sort-u aa.txt sort to remove duplicate rows
Sort-r aa.txt reverse sorting
Uniq aa.txt remove consecutive duplicate rows
Uniq-u aa.txt displays non-duplicate rows
Show duplicate rows for uniq-d aa.txt
Uniq-d-c
-------------
Grep Filtering: The entire row is filtered out by the keyword.
[Root @ localhost ~] # Grep root/etc/passwd filter root user information
Root: x: 0: 0: root:/bin/bash
Operator: x: 11: 0: operator:/root:/sbin/nologin
Grep-v halt $/etc/passwd is not reversed with the end of halt
-------
Cut
Cut-d:-f field) 1/etc/paasswd truncate the first root Information
Cut-d:-f field) 1, 6/etc/paasswd intercepts the information of segments 1 and 6
Cut-d:-f field) 1-6/etc/paasswd intercepts information from 1 to 6
Cut-c characters) 1, 3/etc/paasswd
The header-3 file starts with three lines
Three lines at the end of the tail-3 File
Stat aa.txt displays details
Exercise:
1. Calculate the number of users in your system that can log on to the system [root @ localhost ~] # Grep-v nologin $/etc/passwd | wc-l
6
Cat/etc/passwd | grep-c bash
Cat/etc/passwd | grep/bin/bash | wc-l
Cat/etc/passwd | grep/bin/bash | cut-d:-f7 | uniq-c
Cat-n/etc/passwd | grep/bin/bash | cut-d:-f1, 7 | cat-n
2. ifconfig eth0 | awk-F': | + ''/Bcast/{print $4 }'
192.168.1.1
3. stat aa.txt
File: “aa.txt"
Size: 34 Blocks: 8 IO Block: 4096 General Files
Device: 802 h/2050d Inode: 48922685 Links: 1
Access: (0644/-rw-r --) Uid: (0/root) Gid: (0/root)
Access: 12:06:11. 000000000 + 0800
Modify: 12:06:11. 000000000 + 0800
Change: 12:06:11. 000000000 + 0800
[Root @ localhost ~] # Ifconfig eth0 | head-2 | tail-1 | cut-d:-f 2 | cut-d ''-f1
192.168.1.77
Show only time
[Root @ localhost ~] # Stat aa.txt | cut-d ''-f 3 | cut-d.-f 1 | tail-3
13:12:47
13:12:47
13:12:47
--------------------------------------------------------------------
Shell Basics
!! Before executing a previous command
Commands used by history
Ls! $ Previous Parameter
! The last if command after if is not easily referenced)
Redirection character
> The standard output is correct. If the file exists, the output is overwritten. If the file does not exist, the output is created.
> The standard output is correct. If the file exists, it is appended. If the file does not exist, it is created.
2> standard error output. If the file exists, it will overwrite it. If the file does not exist, it will be created.
2> standard error output. If the file exists, it is appended. If the file does not exist, it is created.
0 standard input
&> Both correct and error messages are required.
/Proc pseudo file 222pid) fd directory
0 indicates that the standard is entered correctly.
1 indicates that the standard output is correct.
2 indicates error output
[Root @ localhost tmp] # touch aa. sh use. sh as a script
Automatic User Creation
Write scripts
#! /Bin/bash: what is the meaning of the command?
# Add User scripts
For I in {1 .. 50} I loops in 1 to 50
Do starts execution)
Ehco "create new user please wait"
Sleep 2 sleep) 2 seconds
Usera
User $ I
Echo "set your passwd now !!"
Echo 123 | passwd -- stdin user $ I &>/dev/null (black hole folder eats characters)
Echo "created successfully"
Done end)
Judgment script:
#! /Bin/bash
# Determining whether a file exists
If (if) [-f/tmp/aa.txt]
Then (if any)
Echo "file to exist"
Sleep 1
Ls-l/tmp/aa.txt
If else does not exist)
Echo "creating"
Sleep 1
Touch/tmp/aa.txt
Fi
----------------------------
Cyclic script
#! /Bin/bash
# Add User scripts
For I in {1 .. 10}
Do
Echo "create user $ I now !!!!! Please wait !!!! "
Sleep 1
Useradd user $ I
Echo "Set user $ I password now !!!!! "
Echo 123 | passwd -- stdin user $ I &>/dev/null
Echo "The create user $ I success !!!!! "
Done
Script judgment
#! /Bin/bash
# Determining whether a file exists
If [-f/tmp/aa.txt]
Then
Echo "the file is cunzai !!!!! Display now !!! 1"
Sleep 1
Ls-l/tmp/aa.txt
Else
Echo "the file is now cunzai !!! Create it now !!!! "
Sleep 1
Touch/tmp/aa.txt
Fi
--------------------------------------------------
Network;
View Nic status in mii-tool
Ifconfig
Restart Nic
[Root @ localhost network-scripts] # service network restart
Lo, this Nic is a local back-to-back Nic. This Nic cannot be moved. Its address will always be 127.0.0.1.
Eth0 Link encap: Ethernet HWaddr 54: E6: FC: 71: 17: 45 (mk address)
Inet addr: 192.168.1.77ip v4) Bcast: 192.168.1.255 broadcast address) Mask: 255.255.255.0 subnet Mask)
Inet6 addr: fe80: 56e6: fcff: fe71: 1745/64 Scope: Link
Up broadcast running multicast mtu: 1500 maximum transmission unit) Metric: 1
RX packets: 84492 number of packets received) errors: 0 dropped: 0 overruns: 0 frame: 0
TX packets: 4460) errors: 0 dropped: 0 overruns: 0 carrier: 0
Collisions: 0 FIG: 1000
RX bytes: 11757894 (11.2 MiB) TX bytes: 310768 (303.4 KiB)
Interrupt: 225 Base address: 0x8000
Temporary modification:
Ifconfig eth0 192.168.1.77
Permanently modify the NIC configuration file
Vim/etc/sysconfig/network-scripts/ifcfg-eth0
Nic alias: Virtual Nic
Ifconfig eth0: 0 192.168.1.66
Permanent change:
Copy A ifcfg-eth0: 0
Change the name to eth0: 0.
Restart the service
Enable and disable NICs
Ifconfig eth0 up
Ifconfig eth0 down
Ifup eth0 enable Nic
Ifdown eth0 disable Nic
; A command at the front is executed no matter whether the execution is successful or not.
& The front-end command is successfully executed, and the back-end command is executed
Resolve the mik address through ping
Arping 192.168.1.33
Arp checks the connection with itself
Route DNS host name
View the route table without parsing the Host Name
Traceroute www.sina.com uses multiple routes to sina
Enable the graphic Network Configuration:
Setup
Root @ localhost ~] # LANG = en_us English
[Root @ localhost ~] # LANG = zh_CH.UTF-8 Chinese
In text mode or in English
First, configure the network.
The second is automatic DHCP retrieval.
-------------------
This article is from the "history_xcy" blog, please be sure to keep this http://historys.blog.51cto.com/7903899/1296627