1. Check the process
ps command to find the PID number related to the process:
ps a Display all programs under the current terminal, including programs of other users.
ps -A shows all programs.
When ps c lists programs, display the actual command name of each program, without the path, parameter, or resident service designation.
ps -e This parameter has the same effect as specifying the "A" parameter.
ps e When listing programs, display the environment variables used by each program.
ps f Use ASCII characters to display a tree structure, expressing the relationship between programs.
ps -H Displays a tree-like structure, representing the interrelationships between programs.
ps -N displays all programs, except the programs under the ps command terminal.
ps s Displays program status in program signal format.
ps S When listing programs, include interrupted subroutine data.
ps -t <terminal number> Specifies the terminal number and lists the status of programs belonging to that terminal.
ps u Displays program status in a user-focused format.
ps x displays all programs, regardless of terminal.
The most common method is ps aux, and then use the grep command to filter through the pipeline to find a specific process, and then operate on the specific process.
ps aux | grep program_filter_word,ps -ef |grep tomcat
ps -ef|grep java|grep -v grep Show all java processes, remove the current grep process.
2. Kill the process
Use the kill command to end the process: kill xxx
Commonly used: kill -9 324
Linux also provides a killall command, which can directly use the process name instead of the process identification number, for example: # killall -9 NAME
3. Enter to Under the path where the execution file of the process is located, the execution file./file name
Attachment :
This is what I spent two days sorting out, and some of the most commonly used commands that people on earth know are omitted! Finally provide pdf manual download
1. Change file owner
Command : chown [-cfhvR] [--help] [--version] user[:group] file... Function
: Change the owner of a file or folder user : the user ID of the new file owner group : the user group (group) of the new file owner -c : if the file owner has indeed changed, only display the change action -f : if the file owner cannot Don't show an error message if changed -h : make changes only to the link, not the file the link actually points to -v : show details of the owner change -R : make changes to all files and subdirectories in the current directory make the same owner change (i.e. one by one in a recursive fashion)
For example: chown -R oracle:oinstall /oracle/u01/app/oracle
Change the owner of the directory to oracle
2. Modify the permission
command: chmod (change mode)
Function: Change the read, write and execute permissions of the file. Signed and octal numbers.
Options: (1) Notation:
Command format: chmod {u|g|o|a}{+|-|=}{r|w|x} filename
u (user) means the user himself.
g (group) means users in the same group.
o (oher) means other user.
a (all) means all users.
+ is used to grant permissions to the specified user.
- Used to revoke the permission of the specified user.
= assigns the permitted permissions to the file.
r (read) Read permission, indicating that the contents of the file or directory can be copied.
w (write) Write permission, indicating that the contents of the file or directory can be modified.
x (execute) execute permission, indicating that the file can be executed or the directory can be entered.
(2) Octal number method:
command format: chmod abc file
Among them, a, b, and c are each an octal number, representing the permissions of User, Group, and Other, respectively.
4 (100) means readable.
2 (010) means writable.
1 (001) means executable.
4+2+1=7 for rwx attributes;
4+2=6 for rw- attributes;
4+1=5 for rx attributes.
For example: # chmod a+rx filename
makes the file filename readable and executable by all users.
# chmod go-rx filename
cancels the permissions of the same group and other users to read and execute the file filename.
# chmod 741 filename
makes the file filename readable and writable by myself, readable by users in the same group, and executable by other users.
# chmod -R 755 /home/oracle
recursively change directory permissions, I can read and write, users in the same group can read and execute, other users can read and execute
3. Modify file date
command: touch
format: touch filenae
function: change file date, the content of the file is not changed, and a new file is created if the file does not exist.
For example: % touch file
4. Link file
command: ln (link)
Format: ln [option] filename linkname
ln [option] directory pathname
Function: Create a chain for a file or directory. Among them, filename and directory are the source file name and
source directory name; linkname and pathname respectively represent the file or directory linked with the source file or source directory name
.
Options: -s Make a symbolic link to a file or directory. Without -s, it means to establish a hard link for a file or directory.
Note: The purpose of the link is to give a file or directory more than two names, so that it can
appear in different directories, which can not only make the file or directory share, but also Can save disk space.
For example: % ln -s filename linkname
5. Display date
command: date
Example: % date
6. Display calendar
command: cal (calendar) format : cal
[month]
year . Display file header command: head format: head [option] filename
Function: Display the header of the file
Options: Default Display the first 10 lines of the file.
-i Display the first i line of the file.
For example: % head filename
8. Display file tail
command: tail
format: tail [option] filename
function: display file tail
option: default Display the last 10 lines of the file.
-i Display the last i line of the file.
+i Displays from line i of the file.
For example: % tail filename
9. Display the user ID
command: id
format: id [option] [user]
Function: Display the user ID and all groups to which the user belongs.
Option: -a Display the user name, user ID and all groups to which the user belongs
Comments:
For example: % id username
10. View the currently logged in user
command: users
11. Display who is logged on to the machine
Command: who
Format: who
Function: Displays the names of all users currently in the system, the terminal device number used, and the registration time.
For example: % who
12. Display the user name on the current terminal
Command: whoami
Format: whoami
Function: Display the user used on the current terminal.
For example: % whoami
13. Find file
command: find
Format: find pathname [option] expression
Function: Find the file that matches the expression under the given path name.
Options: -name means the file name
-user username, select the file to which the user belongs
-size Search by size, in block, a block is 512B
-mtime n Search by the last modification time, select the file modified within n days
-perm Find by permission
-type Find by file type
-atime Find 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: search the specified file or standard input line by line, and display each line matching the pattern.
Option: -i ignore case when matching
-v find out the lines with mismatched patterns
for example: % grep -i 'java*' ./test/run.sh
15. Count the number of words in the file
command: wc [option] filename
function: count The number of file lines, words, and characters in the file.
Options: -l count the number of lines in the
file -w count the number of words in the
file -c count the number of characters in the file
Comment: if the default file name refers to the standard input
, for example: % wc -c ./test/run.sh
16. Display Disk space
command: df (disk free)
Format: df [option]
Function: Display the usage of disk space, including the file system installation directory name, block device name, total
bytes, used bytes, remaining bytes occupancy percentage.
Options:
-a: Display the disk usage of all file systems and partitions
-i: Display the usage of i-nodes
-k: The size is represented by k (default value)
-t: Display all the files of a file system Partition disk usage
-x: Display the disk usage of all partitions that are not a certain file system
-T: Display the file system name to which each partition belongs
-h: Indicates the use of "Human-readable" output, that is, the use of readable formats such as GB, MB, etc. in the file system size.
Note:
For example: % df -hi
17. Query the disk usage space of a file or directory
Command: du (disk usage)
Format: du [option] [filename]
Function: Display each subdirectory under the specified directory as a unit Disk space size
options occupied by all files in the directory :
-a: Display the disk space occupied by all files in the directory and the next directory
-b: The size is expressed in bytes (the default value is k bytes)
-c: The last Add the total (default value)
-s: only display the total size of each file
-x: only calculate the files belonging to the same file system
-L: calculate the size of all files
-h: indicate the file system size using GB, MB etc. readable format.
For example: % du -a
% du -sh /etc only displays the total of the directory
% du /etc | sort -nr | more The statistical results are sorted by the sort command
. to sort.
18. Display process
command: ps
format: ps [option]
Function: Display the information of the process in the system. Including process ID, controlling process terminal, execution time and command.
Options:
-a Display all process information
-U uidlist List all processes of this user
-e Display information about each currently running process
-f Display a complete list
-x Display the status of processes including those without terminal control.
Note:
For example: % ps -ef
% ps -aux Then use a pipe symbol to direct grep to find a specific process, and then operate on a specific process.
19. Terminate the process
command: kill
format: kill [option] pid
function: send a signal to the specified process or terminate the process. The purpose of the kill command is to send a signal to a certain process,
because most of the messages sent are SIGKILL or SIGHUP used to kill the process, so it is called the kill
option: -9 forcibly terminates the process
Note: pid indicates the process number, which can be determined by ps command to get.
For example: % kill -9 pid
You can also use kill -l to see numbers that can replace the signal number. For details on kill, see man kill.
20. Check your own IP address
command: ifconfig
Format: ifconfig -a
21. View routing table
command: netstat
Format: netstat -rn
22. Remote login
command: telnet
format: telnet hostname
23. File transfer
command: ftp (file transfer program)
Format: ftp hostname
Function: network file transfer and remote operation.
Options: ftp command:
cd [dirname] Enter the directory of the remote machine
lcd [dirname] Set the directory of the local machine
dir/ls Display the remote directory file
bin Transfer in binary mode
asc Transfer in text file mode
get/mget from remote machine Take one or more files
put/mput Send one or more files to the remote machine
prompt Open or close the interactive prompt when transferring multiple files
close Close the connection with the remote machine
quit Exit ftp
!/exit In the ftp login state, ! means to temporarily exit the ftp state and return to the local directory, exit means to return to the ftp state
Note:
For example: % ftp hostname
24. Check your own email
command: mailx
format: mailx
option:
delete delete
next
quit exit
reply reply
25. recall command
Command: history
format: history
function: help users recall the executed commands.
Options:
Comments:
For example: % history
26. Online chat
command: talk
Format: talk username
Function: Chat with another user online.
Option:
Note: During the dialog, the system divides the terminal into two parts: the upper part displays the information entered by yourself, and the lower part
displays the information entered by the other party. Type delete or Ctrl+C to end the conversation.
For example: % talk username
27. Allow or deny receiving information
Command: mesg (message)
Format: mesg [n/y]
Function: Allow or deny other users to send information to their own terminal.
Options: n Deny other users to write information to their own terminal
y Allow other users to write information to their own terminal (default value)
Comment:
For example: % mesg n
28. Write information to other users
Command: write
format: write username [ttyname]
function: write information to other users' terminals.
Option:
Note: If the other party does not refuse, the two users can chat. Type EOF or Ctrl+C to end the conversation.
For example: write username
29. Create, modify, delete users and groups
a. Create groups:
For example: groupadd oinstall Create a group named oinstall
groupadd -g 344 dba
Create a group with group number 344, at this time in / 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 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 group:
groupdel group name: this command is used to delete the specified group account
d. new user:
command: useradd [-d home] [-s shell] [-c comment] [-m [-k template]]
[-f inactive] [-e expire ] [-p passwd] [-r] name
main Parameter
-c: Add the remark text, and the remark text is saved in the remark column of passwd.
-d: Specifies the starting directory when the user logs in.
-D: Change the default value.
-e: Specifies the validity period of the account. The default is permanent.
-f: Specifies how many days after the password expires to close the account.
-g: Specifies the group to which the user belongs.
-G: Specifies additional groups to which the user belongs.
-m: Automatically create the user's login directory.
-M: Do not automatically create the user's login directory.
-n: Cancel the creation of a group named after the user name.
-r: Create a system account.
-s: Specifies the shell used by the user after logging in.
-u: Specifies the user ID number.
Example: # useradd -g oinstall -G dba oracle Create Oracle user
e. Delete user
Command: userdel username
delete the specified user account
userdel -r username (userdel username; rm username): delete the specified user account and home directory
Example : #useradd -g root kkk //Add the kkk user to the root group
f. Modify the user
Command : usermod
modify the information of the existing user
usermod -l old user name new user name: modify the user name
usermod -L user name: used to lock the specified user account so that it cannot log in to the system
usermod -U user name: Unlock the locked user account
passwd -d Username: Make the account without password, that is, the user can log in to the system without a password
Example : #usermod -l user2 user1 //Rename user user2 to user1
30. Enable and disable firewall
Permanent Turn on or off
chkconfig iptables on
chkconfig iptables off
Immediate effect: restore
service iptables start
service iptables stop after restart
or:
/etc/init.d/iptables start
/etc/init.d/iptables stop
31. Start VSFTP service
Instant start: /etc/init.d/vsftpd start
Instant stop: /etc/init.d/vsftpd stop
Default VSFTP service starts automatically:
Method 1: (commonly used\convenient)
[root@localhost etc]# chkconfig --list |grep vsftpd (check the situation)
vsftpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
[root@localhost etc]# chkconfig vsftpd on (execute ON setting)
or: Method 2:
Modify File /etc/rc.local , insert the line /usr/local/sbin/vsftpd & into the file to automatically start at boot.
32. vi skills
a. Enter input mode
Add (append)
a: start adding data from behind the cursor position, and the data behind the cursor move backwards with the new data.
A: Add data from the last position of the column where the cursor is located.
Insert
i: Insert data from the front of the cursor position, and the data behind the cursor will move backward with the new data.
I : Insert data before the first non-blank character in the row where the cursor is located.
Open (open)
o : Add a new column under the column where the cursor is located and enter input mode.
O: Adds a new column above the column where the cursor is located and enters input mode.
b. Exit vi.
Type :q, :q!, :wq or :x (note: sign) in command mode, and vi will be exited. Among them: wq and :x are to save and exit, and :q is to exit directly. If the file has new changes, vi will prompt you to save the file and the :q command will also be invalid. At this time, you can use the :w command to save the file after Then use :q to exit, or use the :wq or :x command to exit. If you don't want to save the changed file, you need to use the :q! command, which will directly exit vi without saving the file.
c. Commands for deleting and modifying files:
x: delete the character where the cursor is located.
dd : Delete the column where the cursor is located.
r : Modify the character where the cursor is located, followed by the character to be modified.
R: Enter the replacement state, the new text will overwrite the original text, until you press [ESC] to return to the command mode.
s: Delete the character where the cursor is and enter the input mode.
S: Delete the column where the cursor is located and enter input mode.
d. Screen scrolling commands
Ctrl+u: turn half a screen to the
beginning of the file Ctrl+d: turn half a screen to the end of the file
Ctrl+f: turn one screen to the end of the file
Ctrl+b: turn one screen to the beginning of the file
nz: turn the nth line Scroll to the top of the screen, scroll the current line to the top of the screen when n is not specified.
e. Delete command
ndw or ndW: delete the n-1 words starting at the cursor and after it
do: delete to the beginning of the line
d$: delete to the end of the line
ndd: delete the current line and the next n-1 lines
x or X: delete a character, x deletes the one after the cursor, and X deletes the one before the cursor
Ctrl+u: delete the text entered in the input mode
f. Search and replace command
/pattern: search pattern from the beginning of the cursor to the end of the file
?pattern: search the pattern from the beginning of the cursor to the beginning of the file
n: repeat the last time in the same direction Search command
N: Repeat the last search command in the opposite direction
: s/p1/p2/g: Replace all p1 in the current line with p2
: n1,n2s/p1/p2/g: Replace all lines in lines n1 to n2 Replace p1 with p2
: g/p1/s//p2/g: Replace all p1 in the file with p2 for
g. Copy, paste
(1) Select a text block, use v to enter visual mode; move the cursor keys Selection
(2) Copy the selected block to the buffer, use y; copy the entire line, use yy
(3) Cut the selected block to the buffer, use d; Cut the entire line and use dd
(4) Paste the buffer Use
ph. Other to open the second file
in the same editing window, use :sp [filename]
to switch between multiple editing files, use Ctrl+w
linux process operation
Guess you like
Origin http://10.200.1.11:23101/article/api/json?id=326996008&siteId=291194637
Recommended
Ranking