Linux Basic Command 2

Source: Internet
Author: User
Tags save file cpu usage ping network

1, modify the network status:

1), cd/etc/sysconfig/network-scripts/network-scripts

2), vi ifcfg-eth0 Editor Onboot=yes;

3), Save exit

4), service network Restart--Restart network

When the network restart fails, select the name of the virtual device (CentOS) Right-click to select "Settings"---network adapter--to NAT mode.

5) Ping baidu.com--ping Network is configured successfully

6) Ifconfig--View IP address: 192.168.243.131

7) In preview mode, enter '/' at the end of the line to enter the keywords you want to search, press ' n ' key to automatically search for the next keyword content.

2, Ps--View the process being executed (PID process number) similar to Task Manager details

1) PS–EF View specific process information

UID--user ID

Pid--Process ID

PPID--ID of the secondary process

C--CPU Use rate

Stime--Start time

Time--Runtime

CMD--Start with what command

3. Kill-Kill Process
Killall--Kill all
kill+ Process number Kill 3024
--For performance test pressurization (Ps,kill)

4,netstat--see how many ports the server has open

1) NETSTAT–ANPT--View port (whether or not the port has been successfully applied)
After killing into town, restart:/opt/zbox/zbox restart
2) Top--View CPU, memory, etc.
CPU (s): us-user CPU
sys-System CPU Utilization
ID--Idle CPU usage
Mem: Memory-K
3) Q – Exit the Task Manager interface directly

5, check the status of the computer

1) DF--View disk utilization

2) Free--View memory usage (in kilobytes)

Swap: Swap space

6. Upload file modification and download

Yum insatll-y Lrzsz--Install Lrzsz upload file

RZ-upload files from the desktop to the Xshell

SZ--Download files to desktop

7. Cursor Movement

1) Move the cursor direction:
?、?、?、? --up, down, left, right
2) Quick jump in line
Jump to the beginning--home or ' ^ ' or the number ' 0 '
Jump to the end of the line--end key or "$" key
3) Quick jump between rows
Jump to the first line of the file--1g or GG
Jump to the end of the file line--g
Jump to line # of the file-#G
4) Line number display
Display line numbers in the editor--:set Nu
Cancels the line number in the editor display--:set Nonu

8. Copy, paste, delete

1) Delete:

Deletes a single character at the cursor--x, Del

Deletes the current cursor line--DD

Delete the # line content starting at the cursor-#dd

Deletes all characters before the current cursor to the beginning of the--d^

Deletes all characters at the end of the line at the current cursor--d$

2) Copy:

Copy the contents of the current entire row to the Clipboard--yy

Copy the # line content starting at the cursor-#yy

3) Paste

Pastes the contents of the buffer at the cursor position after--p

Paste at cursor position before--p

9, File content Search

1) Find the string ' word '--/word from top to bottom in the file

2) Bottom Find the string ' word ' in the file--:word

3) Locate the next matching searched string--n

4) Locate the previous matched string that was found--n

10. Cancel Edit and save exit

1) Press once to cancel the most recent operation--u

2) Press the U key repeatedly to reply to the multi-step operation

3) used to cancel all edits made to the current line--u

4) Save the current file contents and exit the VI editor--ZZ

11. Save file contents and Exit VI Editor

1) Save File--:w

2) Save As other file--:w/root/newfile

3) Not modified exit--:q

4) Discard changes to the contents of the file and Exit VI--:q!

5) Save file Exit VI--:wq

12, File content replacement
1) Replace the first character ' old ' string found in the current line with ' new '--:s/old/new
2) Replace all the string ' old ' found in the current line with ' new '--:s/old/new/g
3) Replace all strings "old" with "new" in the "#,#" range in line, #s/ole/new/g
4) Replace all strings "old" with "new" for the entire file range--:%s/old/new/g
5) with the C command at the end of the replacement command, the user is prompted for each substitution action--:s/old/new/c

13. Rights Management
1) Add User: Useradd user name
2) Set/change user password: passwd password
3) Delete user account: Userdel user name
4) When adding the-r option, it means that the user's host directory is deleted: Userdel–r user name
5) Add group account number: Groupadd Group account name
6) Set the group account password: GPASSWD Group account name
7)-A: Add a user to the group
-D: Delete a user member from within a group
-M: Define a list of group members, separated by commas
8) Groupdel:groupdel Group account name
Example: Useradd st01
Ls-l/home/st01
Userdel-r st01

GROUPADD-G Market
Gpasswd-a Btest Market is adding user "btest" to the "market" group
gpasswd-d Root market is removing the user "root" from the "market" group
Gpasswd-m Btest,root,adm Market
Groupdel Market
9) Permissions and attribution of files/directories
READ: R--4
Write: W--2
Executable: x--1
Owner: The user account that owns the file or directory
Group: An account that owns the file or directory
10) Set file and directory permissions
Chmod nnn file or directory--nnn is a value of (r+w+e)
-R-Recursively modifies permissions for all files and subdirectories in the specified directory
11) Set file, directory attribution
Chown Master file or directory
Chown: A group of files or directories
-R-Recursively modifies permissions for all files and subdirectories in the specified directory

Linux Basic Command 2

Related Article

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.