Common Linux commands, constantly learning and updating...

Source: Internet
Author: User
Tags exit in ftp login disk usage ftp hostname

1. Check the process
Ps command to find the process-related PID:
Ps a shows all programs under the current terminal, including those of other users.
PS-A shows all programs.
When listing programs in ps c, the real command name of each program is displayed without the path, parameter, or resident service identifier.
The effect of this parameter is the same as that of the specified "A" parameter.
When listing programs, PS e displays the environment variables used by each program.
Ps f uses ASCII characters to display the tree structure and express the relationship between programs.
The PS-H tree structure is displayed, indicating the relationship between programs.
PS-N displays all programs except the programs under the ps command terminal.
PS uses the program signal format to display the program status.
When listing programs in PS, it includes interrupted subroutines.
PS-T <terminal number> specifies the terminal number and lists the program status of the terminal.
Ps u displays the program status in user-based format.
Ps x shows all programs, not distinguished by terminals.

The most common method is PS aux. Then, use the grep command in the pipeline to filter out specific processes, and then perform operations on specific processes.
PS aux | grep program_filter_word, PS-Ef | grep Tomcat

PS-Ef | grep Java | grep-V grep shows all Java processes and removes the current grep process.

2. Kill processes

Display CPU usage and some processes: Top display connection port use process: netstat-noap/-an | grep name
Run the kill command to end the process: Kill xxx
Commonly used: Kill-9 324
In Linux, A killall command is also provided to directly use the process name instead of the process ID number, for example: # killall-9 name 5. Display date
Command: Date
Example: % date

6. Display calendar
Command: Cal (calendar)
Format: Cal [month] year
Function: displays the specified calendar for a year.
Example: % Cal 1998

7. display the file header
Command: Head
Format: head [Option] filename
Function: displays the file header.
Option: the first 10 lines of the file are displayed by default.
-I: displays the start line of the file.
Example: % head filename

8. display the end Of the file
Command: tail
Format: tail [Option] filename
Function: displays the end of a file.
Option: the last 10 lines of the file are displayed by default.
-I: displays the last line of the file.
+ I is displayed from row I of the file.
Example: % tail filename

9. Display User IDs
Command: ID
Format: Id [Option] [user]
Function: displays the user ID and all groups to which the user belongs.
Option:-A displays the user name, user ID, and all groups to which the user belongs.
Note:
Example: % ID Username

10. view the currently logged-on user
Command: Users

11. Show who logged on to the machine
Command: WHO
Format: WHO
Function: displays all usernames in the system. Use the terminal device number and the registration time.
Example: % Who

12. display the user name on the current terminal
Command: whoami
Format: whoami
Function: displays the users used on the current terminal.
Example: % whoami

13. Search for files
Command: Find
Format: Find pathname [Option] Expression
Function: search for a file that matches the expression under the given path.
Option:-name indicates the file name.
-User Username: select the file to which the user belongs.
-Size: search by size. The unit is block. A block is B.
-Mtime N: search by the last modification time and select the file to be modified within n days
-Perm search by permission
-Type: search by file type
-Atime: search by the last access time

Example: % find./-name '* ABC *'-print

14. Search for matching characters in a file
Command: grep
Format: grep [Option] pattern filenames
Function: searches the specified file or standard input row by row, and displays each row in the matching mode.
Option: case-insensitive for-I matching
-V: Find out the line with Mode Mismatch

Example: % grep-I 'java * './test/run. Sh

15. Number of words in the Statistical File
Command: WC [Option] filename
Function: counts the number of lines, characters, and characters in a file.
Option:-l number of statistics files
-W: number of words in the statistics File
-C: number of characters in the statistics File
Note: If the default file name is used, standard input is used.
Example: % WC-C./test/run. Sh

16. Display disk space
Command: DF (Disk Free)
Format: DF [Option]
Function: displays the disk space usage, including the directory name, block device name, and total
The number of bytes, the number of bytes in use, and the percentage of remaining bytes.
Option:
-A: displays the disk usage of all file systems and partitions.
-I: displays the I-nodes usage.
-K: The size is represented by K (default)
-T: displays the disk usage of all partitions in a file system.
-X: displays the disk usage of all partitions of a file system.
-T: displays the file system name of each partition.
-H: indicates the use of "human-readable" output, that is, the size of the file system is in a readable format such as GB and MB.
Note:
Example: % DF-Hi

17. query the disk space used by the file or directory
Command: Du (disk usage)
Format: Du [Option] [filename]
Function: displays the disk space occupied by all files in each directory in the unit of subdirectories in the specified directory.
Option:
-A: displays the disk space occupied by all directories and each file in the second directory.
-B: The size is represented by bytes (the default value is K bytes)
-C: add the total value (default value)
-S: Only displays the total size of each file
-X: only calculate the files of the same file system.
-L: calculates the size of all files.
-H: indicates that the file system is in a readable format such as GB and MB.
Example: % Du-
% Du-SH/ETC only displays the sum of the directories
% Du/etc | sort-Nr | sort the more statistical results using the sort command,
The-Nr parameter of sort indicates that reverse sorting is performed by numerical sorting.

18. Display Process
Command: PS
Format: PS [Option]
Function: displays information about processes in the system. Including process ID, control process terminal, execution time, and command.
Option:
-A: displays information about all processes.
-U uidlist: list all processes of the user.
-E: displays information about each running process.
-F shows a complete list
-X displays the Process status that is not controlled by the terminal.
Note:
Example: % PS-ef
% PS-Aux then directs to grep with a pipeline symbol to find a specific process, and then operates on the specific process.

19. Terminate the process
Command: Kill
Format: Kill [Option] PID
Function: sends a signal to a specified process or terminates the process. The purpose of the kill command is to send a signal to a process,
Because most of the messages are sent to kill the sigkill or sighup of the process
Option:-9 forcibly terminate a process
Note: The PID indicates the process number, which can be obtained by the ps command.
Example: % kill-9 PID
You can also use kill-L to view the number that can replace signal. For more information about kill, see man kill.

20. view your own IP Address
Command: ifconfig
Format: ifconfig-

21. view the route table
Command: netstat
Format: netstat-Rn

22. Remote Logon
Command: Telnet
Format: Telnet hostname

23. File Transfer
Command: FTP (file transfer program)
Format: ftp hostname
Function: network file transmission and remote operations.
Option: FTP command:
CD [dirname]: Enter the remote machine directory
LCD [dirname] sets the directory of the Local Machine
DIR/ls display remote directory files
Bin is transmitted in binary format.
ASC transfers data as text files
GET/mget fetch one or more files from the remote machine
Put/mput sends one or more files to the remote machine
Interaction prompt when prompt enables or disables multiple file transfers
Close to close the connection to the remote machine
Quit FTP
! /Exit FTP login status ,! Indicates that the FTP is temporarily exited and the local directory is returned. The exit indicates that the FTP status is returned.
Note:
Example: % FTP hostname

24. view your own email
Command: mailx
Format: mailx
Option:
Delete
Next
Quit exit
Reply reply

25. recall command
Command: History
Format: History
Function: helps users recall executed commands.
Option:
Note:
Example: % history

26. online conversation
Command: Talk
Format: Talk Username
Function: chat with another user online.
Option:
Note: During dialog, the system divides the terminal into two parts: the upper half displays the information you typed and the lower half.
Displays the information entered by the other user. Type delete or Ctrl + C to end the dialog.
Example: % talk Username

27. Allow or reject information
Command: mesg (Message)
Format: mesg [N/y]
Function: Allows or denies other users from sending messages to their terminals.
Option: N rejects other users from writing information to their terminals.
Y allows other users to write information to their terminals (default)
Note:
Example: % mesg n

28. Write information to other users
Command: Write
Format: Write username [ttyname]
Function: write information to terminals of other users.
Option:
Note: If the recipient does not refuse, the dual-user can talk. Type EOF or Ctrl + C to end the conversation.
Example: Write Username

29. create, modify, and delete users and groups
A. Create a group:
For example, groupadd oinstall creates a group named oinstall.
Groupadd-G 344 DBA
Create a group with a group number of 344. A group ID (GID) of 344 is generated in the/etc/passwd file.
B. Modify the group:
Groupmod: this command is used to change the attributes of a user group account.
Groupmod-G New GID user group account name
Groupmod-N new group name original group name: This command changes the name of the user group

C. delete a group:
Groupdel group name: this command is used to delete a specified group account.

D. Create a user:
Command: useradd [-D Home] [-s shell] [-C comment] [-M [-k template]
[-F inactive] [-e expire] [-P passwd] [-R] Name
Main Parameters
-C: add the remarks text. The remarks text is saved in the remarks column of passwd.
-D: Specify the start directory when the user logs on.
-D: Change the default value.
-E: Specifies the validity period of the Account, which is permanently valid by default.
-F: specifies the number of days after the password expires.
-G: Specifies the group to which the user belongs.
-G: Specify the additional group to which the user belongs.
-M: automatically creates a user's logon directory.
-M: do not automatically create a user's logon directory.
-N: cancel the creation of a group named by the user name.
-R: Create a system account.
-S: Specifies the shell used after the user logs on.
-U: Specifies the user ID.

Example: # useradd-G oinstall-g dba Oracle creates an oracle user

E. delete a user
Command: userdel User Name
Deletes a specified user account.
Userdel-r username (userdel username; RM username): deletes the specified user account and home directory.
Example: # useradd-g root KKK // Add the KKK user to the root group

F. modify a user
Command: usermod
Modify existing user information
Usermod-l old username new username: Modify Username
Usermod-l User name: used to lock a specified user account so that it cannot log on to the system
Usermod-u Username: Unlock the Locked User Account
Passwd-D Username: Password-free account, that is, the user can log on to the system without a password
Example: # usermod-l user2 user1 // rename user2 as user1

30. Start and close the Firewall
Permanently enabled or disabled
Chkconfig iptables on
Chkconfig iptables off
Immediate effect: Restore after restart
Service iptables start
Service iptables stop
Or:
/Etc/init. d/iptables start
/Etc/init. d/iptables stop

31. Start the vsftp Service
Instant Start:/etc/init. d/vsftpd start
Instant stop:/etc/init. d/vsftpd stop

By default, the vsftp service is automatically started upon startup:
Method 1: (Common \ convenient)
[Root @ localhost etc] # chkconfig -- list | grep vsftpd (View Details)
Vsftpd 0: off 1: off 2: off 3: off 4: off 5: off 6: Off
[Root @ localhost etc] # chkconfig vsftpd on (execute on settings)
Or: Method 2:
Modify the/etc/rc. Local file and insert/usr/local/sbin/vsftpd & into the file to enable automatic start upon startup.

32. VI skills
A. Enter the input mode.
Add (append)
A: add data from the end of the cursor. The data after the cursor is moved to the backend with the new data.
A: add data at the bottom of the column where the cursor is located.

Insert)
I: insert data from the front of the cursor. The data after the cursor moves to the back as the new data is added.
I: insert data starting from the first non-blank character in the column where the cursor is located.

Start (open)
O: Add a column under the column where the cursor is located and enter the input mode.
O: Add a new column to the column where the cursor is located and enter the input mode.
B. Exit VI.
In command mode, type: Q,: Q !, : WQ or: X (Note: No.), the VI will be exited. Where: WQ and: X are stored and exited, while Q is directly exited. If the file has a new change, VI will prompt you to save the file and the Q command will also be invalid, in this case, you can use the W command to save the file and then use Q to exit, or use the WQ or X command to exit. If you do not want to save the changed file, you need to use: q! Command to exit VI without saving the file.

C. Command for deleting and modifying files:
X: Delete the character of the cursor.
DD: Delete the column where the cursor is located.
R: Modify the character where the cursor is located and the character to be corrected after R.
R: Enter the retrieval and replacement status. The new text will overwrite the original text until you press [ESC] to return to the command mode.
S: Delete the cursor character and enter the input mode.
S: Delete the column where the cursor is located and enter the input mode.

D. Screen tumble commands
CTRL + u: half screen at the beginning of the file
CTRL + D: Flip the half screen to the end of the file
CTRL + F: Flip the screen to the end of the file
CTRL + B: Flip the screen to the beginning of the file
NZ: Rolls row n to the top of the screen. If n is not specified, the current row is rolled to the top of the screen.

E. delete command
Ndw or ndw: n-1 characters starting at and following the cursor
Do: Delete to the beginning of a row
D $: Delete to the end of the row
NDD: Delete the current row and the next n-1 row
X or X: delete a character. x deletes the character after the cursor, and X deletes the character before the cursor.
CTRL + u: delete text entered in input mode

F. search and replace commands
/Pattern: Search for pattern from the beginning of the cursor to the end of the file
? Pattern: Search for pattern from the beginning of the cursor
N: Repeat the previous search command in the same direction.
N: Repeat the previous search command in the reverse direction.
: S/P1/P2/G: replace all p1 in the current row with P2.
: N1, N2s/P1/P2/G: replace all P1 from line N1 to line N2 with P2.
: G/P1/S // P2/G: replace all P1 files with P2.

G. copy and paste
(1) Select the text block and use V to enter the visual mode. move the cursor key to select the content.
(2) copy the selected block to the buffer, use y; copy the entire row, and use YY
(3) Cut the selected block to the buffer, use d; cut the entire row with dd
(4) paste the content in the buffer, and use P

H. Others
Open the second file in the same editing window and use: SP [filename]
Switch between multiple editing files, and run the program sudo./p2p_server to remotely copy the file to the local computer. SCP username @ IP Address: remote directory local Directory recommended Remote File Transfer tool sshsecureshellclient (in Windows) ---------------------- Vim exit

Ctrl_w is not set as exit in the default installation. You can also set: Map <C-W>: Close <CR> or: Map <C-W>: Close <CR> to call the menu alt_fc to exit. The above method will prompt whether to save the modified content. : Map <C-W>: WQ <CR> Save the disk and exit. However, this is generally the case: Press ESC (twice recommended) and input: Close: Q to exit, prompting to save. : WQ is saved and exited. : Q! Force exit, not save. : WQ! When an exclamation point is added, the read-only file is forcibly saved and exited. In general mode (normal mode, standard mode), you can also use the command ZZ to exit this document safely. If the file is changed, it is automatically saved and exited. If the file is not changed, it is exited directly. ZQ does not save and exits directly.

# Rpm-Qa | grep MySQL

Mkdir 777/home/CC

PWD query current path

Locate * mysqlclient * queries mysqlclient and so on.

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.