How Linux views common commands such as process, kill process, start process, etc.

Source: Internet
Author: User
Tags ftp login readable disk usage ftp hostname

1. Check process
The PS command finds the PID number associated with the process:
PS A shows all programs under the current terminal, including other users ' programs.
Ps-a Show All Programs.
PS C shows the actual instruction name of each program when the program is listed, not including the path, parameter, or indication of the resident service.
Ps-e the effect of this parameter is the same as specifying the "A" parameter.
When you list a program, PS e displays the environment variables that are used by each program.
PS F Displays the tree structure with ASCII characters and expresses the relationship between the programs.
PS-H displays a tree structure that represents the inter-program relationship.
Ps-n shows all the programs except the ones that perform the PS command terminal.
PS s uses program signal format to display program status.
PS S lists programs, including interrupted sub-program data.
ps-t< Terminal number > Specify the terminal number, and list the status of the program belonging to the terminal.
PS U Displays the status of the program in a user-oriented format.
PS x shows all the programs, not the terminal to distinguish.

The most common method is PS aux, which is then filtered by the grep command to find a particular process and then operate on a particular process.
PS aux | grep program_filter_word,ps-ef |grep Tomcat

Ps-ef|grep java|grep-v grep shows all the Java processes and places the current grep process away.

2. Killing process
To end a process with the KILL command: Kill XXX
Freq used: kill-9 324
Linux also provides a killall command that directly uses the name of the process rather than the process identification number, for example: # killall-9 Name

3. Go to the path where the execution file of the process is located, execute the file./File name


This is the time I spent two days to tidy up, some of the most commonly used by the Earth people know the order is omitted! Finally, PDF brochure is available for download

1. Change the owner of the file
Command: Chown [-CFHVR] [--help] [--version] user[:group] File ...
Function: Change the owner of a file or folder
Parameter format:
User: The user of the new file owner idGROUP: The user group of the new file owner (group)
C: If the file owner has changed, the change action is displayed
-F: Do not display an error message if the owner of the file cannot be changed
-H: Changes to the link only, not the file that the link really points to
-V: Show details of owner changes
-R: Same owner change for all files in the current directory and subdirectories (i.e., one by one in a recursive way)

Example: Chown-r oracle:oinstall/oracle/u01/app/oracle
Change the directory owner to Oracle

2. Modify Permissions
Command: chmod (change mode)
Function: Change the file read and write and execute permissions. Signed method and octal number method.
Option: (1) Symbol method:
Command format: chmod {u|g|o|a}{+|-|=}{r|w|x} filename
U (user) indicates the users themselves.
G (group) represents the same group of users.
O (oher) represents another user.
A (all) represents all users.
+ Used to give permission to the specified user.
-Used to cancel the permissions of the specified user.
= Assign the permission to the file.
R (Read) Read permission, which means that the contents of the file or directory can be copied.
W (write) writes a permission that indicates that the contents of the file or directory can be modified.
X (execute) Executes the license, indicating that the file can be executed or entered into the directory.

(2) Octal number method:
Command format: chmod ABC file
Each of the a,b,c is an octal number, which represents the permissions of user, Group, and other respectively.
4 (100) indicates readable.
2 (010) indicates writable.
1 (001) indicates executable.
To rwx the attribute then 4+2+1=7;
To rw-the attribute then 4+2=6;
To r-x the property, 4+1=5.

Example: # chmod A+RX filename
Allows all users to read and execute file filename.
# chmod GO-RX filename
Cancels the permissions of the same group and other users to read and execute file filename.
# chmod 741 filename
Allow me to read and write execution, the same group of user-readable, other user executable file filename.
# Chmod-r 755/home/oracle
Recursive change of directory permissions, I can read and write execution, the same group of user-readable executable, other user-readable executable

3. Modify File Date
Command: Touch
Format: Touch Filenae
Function: Change the date of the file, do not modify the contents of the file, if the file does not exist, create a new file.
For example:% Touch file

4. Link files
Command: ln (link)
Format: ln [option] filename linkname
ln [option] Directory pathname
Function: Create a chain for a file or directory. where filename and directory are the source file names and
The source directory name, Linkname, and pathname, respectively, that are linked to the source file or source directory name.
File or directory.
Option:-S to create a symbolic link for a file or directory. Do not add-s to create a hard link for a file or directory
Note: The purpose of a link is to give more than two names to a file or directory so that it can be
Now, in different directories, you can share files or directories and save disk space.
For example:% ln-s filename linkname

5. Display Date
Command: Date
For example:% date

6. Show Calendar
Command: Cal (Calendar)
Format: Cal [month] Year
Function: Displays the calendar specified within a year
Example:% cal 1998

7. Display the file header
Command: Head
Format: head [option] filename
Function: Display the file's head
Option: The first 10 rows of the file are displayed by default.
-I displays the start of the file I line.
Example:% head filename

8. Display the tail of the file
Command: Tail
Format: tail [option] filename
Function: Displays the tail of the file
Option: Displays the last 10 lines of the file by default.
-I displays the last line of the file.
The +i is displayed starting at line I of the file.
Example:% tail filename

9. Display User ID
Command: ID
Format: ID [option] [user]
Features: 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
Example:% ID username

10. View the currently logged on user
Command: Users

11. Show who is logged on to the machine
Command: WHO
Format: Who
Function: Displays all user names currently in the system, using terminal number, registration time.
For example:% who

12. Display the user name on the current terminal
Command: WhoAmI
Format: WhoAmI
Function: Displays the user used on the current terminal.
Example:% WhoAmI

13. Finding files
Command: Find
Format: Find pathname [option] Expression
Function: Look for a file that matches the expression in the given path name.
Option:-name indicates file name
-user user name, select the file to which the user belongs
-size by size, in block, a block is 512B
-mtime n Search by last modification time, select files modified in n days
-perm Search by permissions
-type Find by File type
-atime Search by last access time

For example:% find./-name ' *abc* '-print

14. Search for matching characters in files
Command: grep
Format: grep [option] pattern filenames
Function: Searches the specified file or standard input line by row, and displays each row of the matching pattern.
Option:-I ignores case when matching
-V Find the row for pattern mismatch

For example:% grep-i ' java* './test/

15. Statistical file Count
Command: WC [option] filename
Features: Number of file lines, words, and characters in the statistics file.
Options:-L Statistics File line count
-W Statistics file number of words
The number of characters of the-C statistic file
Note: If the default file name refers to the standard input
For example:% wc-c./test/

16. Show Disk space
Command: DF (disk free)
Format: DF [option]
Function: Displays disk space usage, including file system installation directory name, block device name, total
The number of bytes, bytes used, and percentage of bytes remaining.
-A: Displays all file systems and disk usage for each partition
-I: Show i-nodes usage
-K: size is represented by K (default value)
-T: Displays all partition disk usage for one file system
-X: Displays all partition disk usage that are not a single file system
-T: Displays the name of the file system to which each partition belongs
-H: Indicates the use of "human-readable" output, that is, in the file system size using GB, MB and other easy-to-read format.
Example:% Df-hi

17. Query the disk usage space of the file or directory
Command: Du (disk usage)
Format: du [option] [filename]
Function: Displays the amount of disk space occupied by all the files in each directory in a subdirectory of the specified directory
-A: Displays the disk space occupied by all directories and each file under the second directory
-B: Size is represented by bytes (default is k bytes)
-C: Last plus Total (default value)
-S: Show only the sum of each file size
-X: Only files that belong to the same file system are counted
-L: Calculate all file sizes
-H: Indicates that the file system size is in an easy-to-read format such as GB and MB.
Example:% du-a
% du-sh/etc only shows the sum of this directory
% Du/etc | Sort-nr | More statistical results are sorted using the sort command,
The parameter-nr of sort indicates that you want to reverse-sort by a numeric sort.

18. Show Process
Command: PS
Format: PS [option]
Features: Displays information about processes in the system. Includes process ID, control process terminal, execution time, and command.
-a displays all process information
-U uidlist Lists all processes for this user
-e Displays each process information that is currently running
-F Displays a complete list
The-x display includes process status without terminal control.
Example:% Ps-ef
% Ps-aux then use a pipe symbol to guide grep to find a specific process and then manipulate the specific process.

19. Terminating the process
Command: Kill
Format: Kill [option] PID
Function: Sends a signal to the specified process or terminates the process. The KILL command is used to send a signal to a process,
Because most of the SIGKILL or SIGHUP are sent to kill the process, so called kill
Options:-9 forcibly terminate the process
Note: PID indicates the process number, which can be obtained by the PS command.
Example:% kill-9 pid
You can also use Kill-l to see the number of words that can be substituted for signal numbers. For more information on kill, see Man Kill.

20. View your IP address
Command: Ifconfig
Format: ifconfig-a

21. View the routing table
Command: Netstat
Format: Netstat-rn

22. Telnet
Command: Telnet
Format: telnet hostname

23. File Transfer
Command: FTP (file transfer program)
Format: FTP hostname
Functions: Network File transfer and remote operation.
Options: FTP command:
CD [dirname] into the remote machine directory
LCD [dirname] set directory for local machine
Dir/ls displaying remote directory files
Bin is transferred in binary mode
ASC is transmitted as a text file
Get/mget fetching one or more files from a remote machine
Put/mput sending one or more files to the remote machine
Prompt interactive hints When multiple file transfers are turned on or off
Close closes the connection to the remote machine
Quit FTP
!/exit FTP login state,! Indicates that the FTP state is temporarily exited back to the local directory, exit indicates the FTP state is returned
For example:% FTP hostname

24. View your Email
Command: MAILX
Format: MAILX
Delete Deletes
Quit quitting
Reply reply

25. Recall command
Command: History
Format: History
Features: Helps users recall executed commands.
For example:% history

26. Online dialogue
Command: Talk
Format: Talk username
Function: Chat with another user on the web.
Note: The system divides the terminal into two parts in the dialogue, the upper part displays its own type of information, the second part
Displays information typed by the other user. Type Delete or CTRL + C to end the conversation.
For example:% talk username

27. Allow or refuse to accept information
Command: MESG (message)
Format: MESG [n/y]
Functionality: Allows or denies other users from sending information to the terminal they are using.
Option: N denies other users from writing to the terminal they are using
Y allows other users to write information to the terminal they are using (default value)
Example:% MESG N

28. Write messages to other users
Command: Write
Format: Write username [ttyname]
Function: Write information to other users ' terminals.
Note: If the other party does not reject, two users can chat, type EOF or CTRL + C to end the conversation.
Example: Write username

29. Create, modify, delete users and groups
A. Create a group:
Example: Groupadd oinstall create groups named Oinstall
Groupadd-g 344 dba
Create a group with a group number of 344, at which time a group ID (GID) is generated in the/etc/passwd file as a 344 project.
B. Modify the group:
Groupmod: This command is used to change the properties of the 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 the specified group account number

D. Create a new User:
Command: Useradd [-D home] [-s Shell] [-c comment] [-M [--template]]
[-F Inactive] [-e Expire] [-P passwd] [-R] Name
Main parameters
-C: Add note text, note text is saved in passwd's remarks column.
-D: Specifies the start directory at which the user logged in.
-D: Change the preset value.
-e: Specifies the expiration date of the account and the default is permanent.
-F: Specify the number of days after the password expires to close the account.
-G: Specifies the group to which the user belongs.
-G: Specifies the additional group to which the user belongs.
-M: Automatically establish the user's login directory.
-M: Do not automatically create a user's login directory.
-N: Cancels the creation of a group named after the user name.
-R: Set up the system account.
-S: Specifies the shell to use when the user is logged in.
-U: Specifies the user ID number.

Example: # useradd-g oinstall-g DBA Oracle Create Oracle User

E. Deleting users
Command: Userdel user name
Delete the specified user account
Userdel–r User name (userdel user name; RM username): Delete the specified user account and host directory
Example: #useradd-G root KKK//Add KKK user to the root group

F. Modifying users
Command: Usermod
Modify information for an existing user
Usermod–l old username New user name: Modify user Name
USERMOD–L user name: Used to lock the specified user account so that it cannot log on to the system
Usermod–u Username: Unlocking a locked user account
Passwd–d Username: Make the Account no password, that is, the user does not need a password to log on to the system
Example: #usermod-L User2 user1//renaming user User2 to User1

30. Start and close the firewall
Open permanently or close
Chkconfig iptables on
Chkconfig iptables off
Immediate effect: Restore after reboot
Service Iptables Start
Service Iptables Stop
/etc/init.d/iptables start
/etc/init.d/iptables stop

31. Start the VSFTP service
Instant Start:/ETC/INIT.D/VSFTPD start

Boot default vsftp service starts automatically:
Method one: (Common \ Convenient)
[Email protected] etc]# chkconfig--list|grep vsftpd (view)
VSFTPD 0:off 1:off 2:off 3:off 4:off 5:off 6:off
[[email protected] etc]# chkconfig vsftpd on (performing on setting)
Or: Method Two:
Modify the file/etc/rc.local, put the line/USR/LOCAL/SBIN/VSFTPD & Insert the file in order to enable the boot automatically.

VI Tips
A. Enter input mode
New (Append)
A: From the cursor position to start the new data, the data after the cursor with the new data to move forward.
A: Start adding data from the end of the column where the cursor is located.

Inserting (insert)
I: Insert data from the cursor position, and the data after the cursor moves with the new data.
I: Insert data from the first non-whitespace character in the column where the cursor is located.

Start (Open)
O: Add a new column under the Cursor column and enter the input mode.
O: Add a column above the cursor column and enter the input mode.
B. Exit VI
In instruction mode type: Q,:Q!,:WQ or: X (note: number), you will exit VI. of which: Wq and: X is to save the exit, and: Q is to exit directly, if the file has a new change, vi will prompt you to save the file and: Q command will also be invalid, then you can use: w command saved the file and then use: Q Exit, or with: Wq or: X command exit, if you do not want to save the changed file, you need command, this command will exit VI without saving the file.

C. Delete and modify a file command:
x: Deletes the character of the cursor.
DD: Deletes the column where the cursor is located.
R: Modifies the character of the cursor, and R is followed by the characters to be corrected.
R: Enter the replace state and the new text will overwrite the original text until you press [ESC] back to instruction mode.
S: Delete the character of the cursor and enter the input mode.
S: Delete the column where the cursor is located and enter the input mode.

D. Screen Tumbling Class command
Ctrl+u: First half screen to file
Ctrl+d: Half-screen to the end of the file
CTRL+F: Flip a screen to the end of a file
Ctrl+b: Turn one screen at the top of the file
NZ: Rolls line N to the top of the screen and scrolls the current line to the top of the screen when n is not specified.

E. Delete command
NDW or NDW: Delete the n-1 characters at the beginning and after the cursor
Do: Delete to the beginning of the line
d$: Delete to end of line
NDD: Deletes the current line and its subsequent n-1 rows
X or x: Deletes a character, x deletes the cursor, and x deletes the cursor before the
Ctrl+u: Delete text entered under input mode

F. Search and Replace commands
/pattern: Searches for pattern at the end of the file from the beginning of the cursor
? pattern: Searches for pattern from the beginning of the cursor to the top of the file
N: Repeat the last search command in the same direction
N: Repeats the last search command in the opposite direction
: s/p1/p2/g: Replaces all P1 in the current row with P2
: n1,n2s/p1/p2/g: All P1 in line N1 to N2 are replaced with P2
: g/p1/s//p2/g: Replace all P1 in the file with P2

G. Copying, pasting
(1) Select text block, use V to enter visual mode; Move cursor key selection
(2) Copy the selected block to the buffer, use Y; Copy the whole line, with YY
(3) Cut the selected block to the buffer, use D; cut the whole line with DD
(4) Paste the contents of the buffer, using p

H. Other
Open the second file in the same edit window with: SP [filename]
Switch between multiple edit files, using Ctrl+w

How Linux views common commands such as process, kill process, start process, etc.

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: 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.