Files and Directories

Switching working Directory

cd .. Return to the upper directory CD.. /.. CD go to the personal home directory CD ~user1 Go to the personal home directory CD - Go back to the last directory PWD Displays the working pathCopy the code

Check the file

Ls -l: displays the file list in long format ls -d: displays detailed information about the directory ls: displays all files in the current directory ls -al: displays hidden files ls -k: displays file sizes in k bytes ls -s: sorts files by file sizes ls -lh: displays the current file information in a more intuitive way ls - lhS: file size is more intuitive to check the ls * [0-9] * that contains the number of the file name and directory name tree display files and directories from the root directory tree structure lstree display files and directories from the root directory tree structure lsof -n | grep does View files that cannot be deleted because of resource usageCopy the code

File operation command

Conf /home/ Copy the /etc/sys.conf file to the home directory cp -r test/ /home/ Copy the current directory "test/" and all its files to the home directory Touch -d "6/20/10 18:32" Ed Create the Ed file and change its timestamp mkdir ab Create the ab directory mkdir -p a/b/v create the abv directory in sequence./a/b/v mv a test/ Move file A from the current directory to the test directory mv test file/ Move directory test to file mv a B C d file/ Move both ABcds to the file directory mv file test Rename file to test cp CNF smb.cofile Copy the SMB file and rename it rm ab Delete ab file rm -rf test Delete all files in the test directory rm -rf * Delete all files in the current directory rm -rf /opt/software/* delete all files under the file but do not delete the folder rmdir file delete an empty directory file file a view the text type of file a.conf view the contents of the a.conf file cat -v a.conf Out View the first five lines of the file. Tail -f cata.out Dynamically display the cata.out file. Tail -5 cata.out View the last five lines of the file Less cata. Out Displays less files in separate screensCopy the code
Linux copies all files in a specified directory to another directory. Copying files and directories is often used. Assume that the source directory is dir1 and the target directory is dir2. How to copy all files from dir1 to dir2; If the dir2 directory does not exist, use cp -r dir1 dir2. If the dir2 directory already exists, use cp -r dir1/. Dir2. If cp -r dir1 dir2 is used, copy the dir1 directory to dir2. Clearly does not meet the requirements. Ps: change dir1 and dir2 to corresponding directory paths. /home/ WWW /statics/. /home/ WWW /statics/* if you don't want to delete the file, run the following command: rm -rf /home/www/statics/*Copy the code

File search

  1. Find is the most common and powerful find command, and you can use it to find any file you want.

The format of find is as follows: find < specify directory > < specify condition > < specify action > – < specify directory > : the directory to be searched and all its subdirectories. The default is the current directory. – < Specify criteria > : characteristics of the file to be searched. – < Specify action > : performs specific processing on the search results. If nothing is added, find defaults to searching the current directory and its subdirectories and does not filter any results (that is, returning all files), displaying them all on the screen. Examples of using find:

Find /−namehttpd.conffind / -name httpd.conffind/−namehttpd.conf find. -name ‘my*’ -ls Searches for all files whose names start with my in the current directory (including subdirectories, the same below). And display their details. Find /home/userrtos Searches for files with the RTOS owner in /home. Find /home/user RTOS Searches for files with the RTOS owner in /home. Find /home/userrtos Searches for files with the RTOS owner in /home -type f-mmin-10 Searches for all common files updated in the past 10 minutes in the current directory. If the -type f parameter is not specified, the system searches for common files, special files, and directories. Find /− Typef − Size +100M Note: It is a good idea to use find if you are looking for a file. However, because find uses a lot of hard disk to find data, there is no reason not to use find. Locatelocate is actually a different form of find−name, but much faster because it searches a database (/var/lib/locatedb) instead of a directory. This database contains information about all local files. Linux automatically creates the database and updates it daily, so you can’t find the most recently changed files using the locate command. To avoid this, manually update the database using the updatedb command before using LOCATE. Example of the locate command: find / -type f-size +100M Find all files larger than 100M in the system Description: It is a good idea to use find if you are looking for a file. However, because find uses a lot of hard disk to find data, there is no reason not to use find. There are better alternatives to whereis and locate. The locate command is actually a different way of writing “find-name,” but it’s much faster because it doesn’t search a specific directory. Instead, search a database (/var/lib/locatedb) that contains information about all files locally. Linux automatically creates the database and updates it daily, so you can’t find the most recently changed files using the locate command. To avoid this, manually update the database using the updatedb command before using LOCATE. Example of the locate command: find/−typef−size+100M Find all files larger than 100M in the system Note: It is a good idea to use find if you are looking for a file. However, because find uses a lot of hard disk to find data, there is no reason not to use find. Locatelocate is actually a different form of find−name, but much faster because it searches a database (/var/lib/locatedb) instead of a directory. This database contains information about all local files. Linux automatically creates the database and updates it daily, so you can’t find the most recently changed files using the locate command. To avoid this, manually update the database using the updatedb command before using LOCATE. Example Of the locate command: locate /etc/sh Searches for all files in the etc directory that start with sh. Locate − I /m Searches for all files that start with M in the user’s home directory and ignores case and case. 3. The whereiswhereis command can only be used to search for program names, and only binary files (parameter −b), man description files (parameter −m), and source code files (parameter − S). If the argument is omitted, all information is returned. An example of the whereis command is as follows: locate -i ~/m Searches for all files starting with M in the user’s home directory and case is ignored. The whereis command can only be used to search for program names, and only search binary files (parameter -b), man description files (parameter -m), and source code files (parameter -s). If the argument is omitted, all information is returned. The example of the whereis command is as follows: locate− I /m Searches for all files starting with M in the user’s home directory and case is ignored. 3. The whereiswhereis command can only be used to search for program names, and only binary files (parameter −b), man description files (parameter −m), and source code files (parameter − S). If the argument is omitted, all information is returned. Whereis command using the instance: whereis grep grep: / bin/grep/usr/share/man/man1p/grep. 1 p. gz/usr/share/man/man1 / grep. 1. Gz

Find / -name file1 Searches for files and directories in the root file system starting from '/'. Find / -user user1 Searches for files and directories belonging to user 'user1'. Find /home/user1-name \* Find /usr/bin-type f-atime +100 Search for the execution file that has not been used in the past 100 days find /usr/bin-type f-mtime-10 Find / -name \*. RPM -exec chmod 755 '{}' \; Find / -xdev-name \*. RPM Find / -xdev-name \*. RPM Find / -xdev-name \*. RPM Ignore the CD drive, flash drive, etc. Locate \*.ps to find a file ending in '. Ps' - first run the 'updatedb' command whereis halt to display a binary file, source code, or the location of man which halt Displays the full path to a binary or executable fileCopy the code

File statistics command

Wc - c at the. TXT file statistics and the number of bytes output - m: statistics and to display file, the number of characters - l: display file rows - l: the longest length - w: statistics and output file alphanumeric grep -o 'haha' file | wc -l statistical occurrences in a character in a file Tr - CD 'h' < file | wc - c can only match a single character awk - v RS = 'haha' 'END NR} {print -' fileCopy the code

Vim edits files

Page turning: pageUp/pageDown Number keys 0: Page to the top of the current line Home: Page to the top of the current line End: Page to the bottom of the current line DD: Delete the cursor a whole line YY: Copy the cursor a whole line General mode Operation to switch to edit mode: 【 I 】 from the current cursor insert from current cursor 【 a 】 【 I 】 from the current cursor next character start insert 【 a 】 from the cursor in the lines of the last character start insert [o] English lowercase o, in the current cursor is done in the next row inserts a new row and began to insert o [o] English capital letter, Insert a new line in the line above the current cursor and start inserting (6) General mode Switch to command line mode save the file If the file is read-only, forcibly save the file from vi. No save forced exit vi [:wq] Save the file and exit. Force save and leave Command display result after executing a command temporarily leaving vi [:set nu] display line number [:set nonu] cancel display line number [:w newfile] save as [:set fileencoding] view the current fileencoding format [:set fileencoding=utf-8] set the current fileencoding to utf-8, You can also set it to another encoding format [:set fileFormat] to view the line breaking format of the current file (DOS \ Windows, Unix or Macintosh) [:set Fileformat = Unix] To set the line breaking format of the current file to Unix 【[O]pen read-only 】 Open file in read-only mode 【[E]dit anyway】 Open file in normal mode. [[Q]uit] Press Q to leave vi, no further action. [[A]bort] Similar to quitCopy the code

File permissions

++ Use “+” to set permission, and use “-” to cancel ++

Ls - lh show permissions ls/TMP | pr - T5 - W $COLUMNS will be divided into terminal 5 bar shows chmod ugo + RWX directory1 all set the directory (u), group (g) and others (o) to read (r ), write (w), and execute (x) permissions chmod go-rwx directory1 Deletes the read and write execute permissions on directories of groups (G) and others (O) chown user1 file1 Changes the owner attribute of a file chown -r user1 Directory1 Changes the owner properties of a directory and all files in the directory CHGRP group1 file1 Group in which the file is changed chown user1:group1 file1 Changes the owner and group properties of a file find / -perm -u+s Lists all files in a system that use SUID control chmod u+s /bin/file1 Sets the SUID bit of a binary file - The user running the file is also granted the same permissions as the owner chmod u-s /bin/file1 Chmod g+s /home/public Sets the SGID bit of a directory - similar to SUID, Chmod g-s /home/public Disables the SGID bit of a directory chmod o+t /home/public sets the STIKY bit of a file - only allows legal owners to delete files chmod o-t /home/public Disables the STIKY bit of a directoryCopy the code

File special properties

Chattr +c file1 allows the file to be automatically compressed/uncompressed by the kernel. Chattr +d file1 During file system backup, Chattr +s file1 allows a file to be safely deleted once an application writes to the file. Chattr +s file1 Chattr +u file1 If a file is deleted, the system will allow you to restore the deleted file later. Lsattr displays special propertiesCopy the code

Package and compress files

Bz2 unzip a file called 'file1.bz2' bzip2 file1 unzip a file called 'file1. gunzip file1.gz Unzip a file called 'file1.gz' gzip file1 Compress a file called 'file1' gzp-9 file1 compress rar a file1.rar test_file Create a package called 'file1.rar' Also compress 'file1', Rar package unrar x file1.rar Decompress the rar package tar -cvf archive.tar file1 Creates an uncompressed tarball tar -cvf Archive. tar file1 file2 dir1 Creates a file containing 'file1', Tar displays the contents of a package. Tar -xvf archive.tar Releases a package. Tar -xvf archive.tar -c/TMP releases the compressed package to Bz2 dir1 Create a bzip2 package. Tar -jxvf archive.tar.bz2 Decompress a bzip2 package, tar -cvfz Gz dir1 Create a compressed package in gzip format. Tar -zxvf archive.tar.gz Decompress a compressed package in gzip format. Zip file1 Create a compressed package in ZIP format Zip file1 file2 dir1 Compress several files and directories into a ZIP package. Unzip file1.zip Decompresses a ZIP packageCopy the code

Text processing

cat file1 file2 ... | command <> file1_in.txt_or_file1_out.txt general syntax for text manipulation using PIPE, STDIN and STDOUT cat file1 | command( sed, grep, awk, grep, etc...) > result. TXT merge a text file detailed instructions, and during the introduction to writing a new file cat file1 | command (sed, grep, awk, grep, etc...). >> result.txt To merge a file's verbose text, Grep Aug /var/log/messages Find the keyword "Aug" in the file '/var/log/messages' grep ^Aug /var/log/messages in the file Grep [0-9] /var/log/messages Select all lines containing numbers in the '/var/log/messages' file grep Aug -r /var/log/* Search for the string "Aug" sed 's/stringa1/stringa2/g' example.txt replace "string1" in example.txt with "string2" sed '/^$/d' example.txt delete all blank lines from example.txt sed '/ *#/d; / ^ $/ d 'example. TXT from example. TXT file delete all comments and blank lines echo' esempio '| tr / : the lower: "' [: upper:] 'merger sed up and down the cell contents - e 1 d' Sed -e 's/ *$//' example. TXT removes the blank character sed at the end of each line from the file example. TXT -e 's/stringa1//g' example. TXT delete only the word "string1" from the file and keep the rest of it. Sed -n '5p; sed -n '5p; sed -n '5p; 5 q 'example. TXT see line 5 sed -e' 00 s / * / 0 / g 'example. TXT replace multiple with a single zero zero cat cat - n file1 labeled file lines example. TXT | awk' NR % 2 = = 1 ' Delete example. TXT file all even lines of the echo a b c | awk '{print $1}' view the line of the first column echo a b c | awk '{print $1, $3}' to view a line of the first and the third column paste file1 Paste -d '+' file1 File2 combines the contents of two files or columns. "+" to distinguish between sort file1 file2 sort the contents of two files sort file1 file2 | uniq took out two files and set (duplicate rows only keep a) sort file1 file2 | uniq - u delete the intersection, Leave other line sort file1 file2 | uniq - d out the intersection of two files, leaving only exists in two files at the same time files) in a comm - 1 file1 file2 compares the contents of two files to delete "file1" only contain the contents of the comm - 2 File1 file2 Compares the contents of two files and deletes only the contents contained in 'file2'. Comm-3 file1 file2 Compares the contents of two files and deletes only the common parts of the two filesCopy the code

Character Settings and file format conversion

TXT Converts the format of a text file from MSDOS to UNIX unix2dos fileunix. TXT Filedos. TXT converts the format of a text file from UNIX to MSDOS recode .. HTML < page. TXT > page. The HTML to convert a text file to HTML recode - l | more show all allow conversion formatsCopy the code

File System Analysis

Badblocks -v /dev/hda1 Check bad magnetic blocks on disk hda1 FSCK /dev/hda1 Repair/Check the integrity of the Linux file system on disk hda1 fsck.ext2 /dev/hda1 Restore the integrity of the ext2 file system on hda1 e2fsck /dev/hda1 Restore the integrity of the ext2 file system on hda1 e2fsck -j /dev/hda1 Restore the integrity of the ext3 file system on hda1 Ext3 /dev/hda1 Repair/Check the integrity of the ext3 file system on hda1 fsck.vfat /dev/hda1 Repair/Check the integrity of the FAT file system on hda1 fsck.msdos /dev/hda1 Dosfsck /dev/hda1 Repair/check the integrity of the DOS file system on the Hda1 diskCopy the code

Example Initialize a file system

Initialize a file system MKFS /dev/hda1 Create a file system in hda1 partition mke2fs /dev/hda1 Create a Linux ext2 file system in hda1 partition mke2fs -j /dev/hda1 Create a Linux ext3(journal-type) file system in hda1 partition MKFS -t vfat 32 -f /dev/hda1 create a FAT32 file system fdformat -n /dev/fd0 format a floppy disk mkswap /dev/hda3 Creates a swap file systemCopy the code

SWAP file system

Mkswap /dev/hda3 Create a swap file system swapon /dev/hda3 Enable a new swap file system swapon /dev/hda2 /dev/hdb3 Enable two swap partitionsCopy the code

The backup

Dump-0aj -f/TMP /home0.bak /home Make a full backup of the '/home' directory dump-1aj -f/TMP /home0.bak /home Make an interactive backup of the '/home' directory restore -if/TMP /home0.bak Restore an interactive backup rsync-rogpav --delete /home/tmp Synchronize directories on both sides rsync-rogpav -e SSH --delete /home Ip_address :/ TMP Through the SSH channel rsync rsync-az -e SSH --delete ip_addr:/home/public /home/local Synchronize a remote directory to the local directory rsync-az through SSH and compression - e SSH -- delete/home/local ip_addr: / home/public via SSH and compression to local directory synchronization to the remote directory dd bs = 1 m if = / dev/hda | gzip | SSH user @ ip_addr 'dd of=hda.gz' Backs up the local disk on the remote host using SSH dd if=/dev/sda of=/ TMP /file1 Backs up the disk content to a file tar -puf backup.tar /home/user Performs a pair of files Directory '/ home/user interactive backup operation (CD/TMP/local / && tar c.) | SSH - c user @ ip_addr' CD/home/share / && tar x - p ' Via SSH to copy a directory content in the remote directory (tar c/home) | SSH - c user @ ip_addr 'CD/home/backup - home && tar x - p' via SSH in the remote directory replication tar cf a local directory - . | (cd /tmp/backup ; Tar xf -) locally copy a directory to another location, Retain the original permissions and link the find/home/user1 - the name '*.txt' | xargs cp - av -- target - directory = / home/backup / -- parents from a directory to find and copy all to '. TXT ' At the end of the file to another directory, find the/var/log - the name '*. The log' | tar CV - files - from = - | bzip2 > the tar. The.bz2 find all to 'log' at the end of the file and make a bzip package dd If =/dev/hda of=/dev/fd0 bs=512 count=1 Copy the MBR (Master Boot Record) to the floppy disk dd if=/dev/fd0 of=/dev/hda bs=512 count=1 Restores MBR content from a backup already saved to floppy diskCopy the code

network

Ifconfig eth0 Displays the configuration of an Ethernet card. Ifup eth0 Enables one 'eth0' network device. Ifdown eth0 Disables one 'eth0' network device 255.255.255.0 Control IP address ifconfig eth0 promisc Set 'eth0' to the promiscuous mode to sniff packets. Dhclient eth0 Run the 'eth0' route-n show command in DHCP mode Routing table route add-net 0/0 GW IP_Gateway configura default gateway route add-net 192.168.0.0 netmask 255.255.0.0 Gw 192.168.1.1 configure static route to reach network '192.168.0.0/16' route del 0/0 gw IP_gateway remove static route  echo "1" > /proc/sys/net/ipv4/ip_forward activate ip routing hostname show hostname of system host www.example.com lookup hostname to resolve name to ip address and viceversa nslookup www.example.com lookup hostname to resolve name to ip address and viceversa ip link show show link status of all interfaces mii-tool eth0 show link status of 'eth0' ethtool eth0 show statistics of network card 'eth0' netstat -tup show all active network connections and their PID netstat -tupl show all network services listening on the system and their PID tcpdump tcp port 80 show all HTTP traffic iwlist scan show wireless networks iwconfig eth1 show configuration of a wireless network card hostname show hostname host www.example.com lookup hostname to resolve name to ip address and viceversa nslookup www.example.com lookup hostname to resolve name to ip address and viceversa whois www.example.com lookup on Whois databaseCopy the code

Disk space

Df -h display the list of partition is mounted ls - lSr | more arranged in size file and directory du - sh dir1-name estimate directory 'dir1-name' have to use the disk space 'du -h view directory size of various subdirectories, including subdirectories subdirectories du - a | sort - rn | head - 5 for the top five file du - sk * | sort - rn) based on SIZE, in turn, according to the SIZE of the files and directories RPM - q - a - qf '10 {NAME} {SIZE} t % % n' | sort - k1, 1 n Dppg-query -w -f='${instar-size; dppG-query -w -f='${instar-size; 10} ${Package} n 't | sort - k1, 1 n based on the size of the display installed deb Package used by space (ubuntu, debian system)Copy the code

Users and Groups

Groupadd group_name Creates a user group groupdel group_name Deletes a user group groupmod -n new_group_name old_group_name Renames a user group useradd -c "Name Surname "-g admin -d /home/user1 -s /bin/bash user1 Create a user belonging to user group admin useradd user1 Create a new user userdel -r user1 Delete a User ('-r' excludes the home directory) usermod -c "User FTP" -g system -d/FTP /user1 -s /bin/nologin user1 Modify the User attribute passwd Modify the password passwd user1 Change the password of a user (root only) chage -e 2005-12-31 user1 Set the validity period of the user password PWCK Check the file format and syntax of '/etc/passwd' and the existence of user GRPCK check Newgrp group_name Logs in to a new group to change the default group for the newly created file who View the current user accessing the system finger View the details of the current user accessing the system w Check the usage of system resources su root Switch to user root whoami The current user name is listedCopy the code

The RPM package

++RedHat: RedHat, Centos, and Fedora ++

RPM Install an RPM package RPM -ivh --nodeeps package. RPM Install an RPM package and ignore dependency warnings RPM -u package. RPM Update an RPM package without changing its configuration file RPM - F package. The RPM update a sure you have installed the RPM package RPM -e package_name. RPM to remove an RPM package RPM - qa list all installed in the system of RPM package RPM - qa | grep HTTPD shows all name contains RPM -qg "System Environment/Daemons" Displays the RPM package RPM -ql package_name of a component RPM -qc package_name Displays the list of configuration files provided by an installed RPM package. RPM -q package_name -- Whatrequires Displays the list of dependencies with an RPM package RPM -q package_name --whatprovides Displays the volume occupied by an RPM package. RPM -q package_name --scripts displays scripts executed during installation or deletion - change history changelog shows a RPM package RPM - qf/etc/HTTPD/conf/HTTPD. Conf the confirmation to the file which RPM - RPM package provided by qp package. The RPM - l RPM --import /media/cdrom/RPM -gpg-key Import public KEY digital certificate RPM --checksig package. RPM Verify the integrity of an RPM package RPM -qa Gpg-pubkey Check the integrity of all installed RPM packages RPM -v package_name Check the file size, license, type, owner, group, MD5 check, and last modified time RPM -va Check all installed RPM packages in the system - Use RPM -vp with caution To identify a RPM package. The RPM package has not been installed rpm2cpio package. The RPM | cpio, extract, the make - bin directories * * from a RPM package run RPM - the ivh for executable files Rpmbuild --rebuild package_name.src. RPM Build an RPM package from an RPM sourceCopy the code

YUM package

++RedHat: RedHat, Centos, and Fedora ++

Install package_name yum localinstall package_name. RPM Yum update package_name yum update package_name yum update package_name yum remove Package_name Yum list Yum search package_name Yum search package_name Yum clean packages Yum clean packages Yum Clean All Deletes all cached packages and headersCopy the code

DEB package

++Debian, Ubuntu and similar systems ++

DPKG -i package. Deb installation/update a deb package DPKG -r package_name deleted from the system a deb package DPKG -- l display system all has been installed in the deb package DPKG -l | grep HTTPD DPKG -l package_name Specifies the name of a deb package that has been installed in your system --contents package.deb displays the list of files provided by a package that has not yet been installed. DKG -s /bin/ping confirms which deb is providing the given fileCopy the code

APT Software Tools

Apt-get install package_name Install deb package apt-cdrom install package_name Install deb package apt-cdrom install package_name Install deb package apt-get update install deb package Apt-get upgrade Upgrade all installed software apt-get remove package_name delete a deb package from the system apt-get check Check dependent repositories correct apt-get clean Clean the cache from downloaded software packages Apt-cache search searched-package returns the name of the package containing the searched string apt update command: updates the list of installable software; Apt Search: searches for available software in the software list. Apt install command: install software; Apt autoremove command: uninstall software; Apt upgrade command: Upgrade all installed software.Copy the code

Shut down system command

Shutdown -h 15:30 shutdown -r 2 restart the system after 2 minutes poweroff restart the system immediately reboot restart the system immediately halt shutdown the systemCopy the code

The JPS command

JPS (Java Virtual Machine Process Status Tool) is a command provided by JDK 1.5 to display the PID of all Java processes. It is simple and practical. It is very suitable for viewing the simple situation of the current Java Process on Linux/Unix platform.  I think many people have used the Unix system ps command, this command is mainly used to display the current system process status, which processes, and their ID. JPS is the same, it is used to display the current system Java process status, and its ID number. It allows you to see how many Java processes have been started (since each Java program has a Java virtual machine instance), their process numbers (in preparation for the following programs), and the detailed startup parameters of these processes can be viewed with opt. Usage: Type JPS in the current command line (JAVA_HOME is required, if not, to modify the program directory to type). $> JPS 23991 JPS 23789 BossMain 23651 Resin $> JPS -q 28680 23789 23651 -m Displays the parameters passed to main. May be NULL $> jps-M 28715 jps-M 23789 BossMain 23651 resin-Socketwait 32768-stdout on embedded JVMS / data/aoxj/resin/log/stdout. Log - stderr/data/aoxj/resin/log/stderr output application log - l main full package name or of the class Application of the full path to the jar file name $> JPS -l 28729 sun. View the JPS. The JPS 23789 com. Asiainfo. Aimc. Bossbi. BossMain 23651 Com. Caucho. Server. Resin. The resin - v output is passed to the JVM parameter $> JPS - 28802 v 23789 BossMain JPS -Denv.class.path=/data/aoxj/bossbi/twsecurity/java/trustwork140.jar:/data/aoxj/bossbi/twsecurity/java/:/data/aoxj/bossbi /twsecurity/java/twcmcc.jar:/data/aoxj/jdk15/lib/rt.jar:/data/aoxj/jd k15/lib/tools.jar -Dapplication.home=/data/aoxj/jdk15 -Xms8m 23651 Resin -Xss1m -Dresin.home=/data/aoxj/resin -Dserver.root=/data/aoxj/resin -Djava.util.logging.manager=com.caucho.log.LogManagerImpl - Djavax. Management. Builder. Initial = com. Caucho. JMX. MBeanServerBuilderImpl sudo JPS most complete see the number of processes the JPS 192.168.0.77 List all JVM instances of the remote server 192.168.0.77, using rmI protocol, default connection port 1099 (provided the remote server provides jSTATd service) The JPS command has an unfortunate feature that seems to show only the Java process of the current user, and the ps command of Unix/Linux is still the only way to show other users' processes.Copy the code

View the current port usage

Netstat NTLP / / view the current all TCP port netstat NTLP | grep / 80 / check all 80 port usage netstat - an | grep / 3306 / check all 3306 port usage netstat - nap | grep pid check process using ls -l/proc/pid/exe view under the process of pid corresponding file (note that replace pid) in the command netstat -a - numeric - ports - p - t view port usageCopy the code

DEBIAN firewall

Apt-get install uFW Install ufw Ufw status Ufw enable // Enable ufw disable // disable ufw allow 22/ TCP UFW allow 445 ufw delete allow 53 Allow /deny 20/ TCP allow/deny 20/udp The highlighted output indicates the network interface name. They are usually named eth0 or ENp3S2. Therefore, if your server has a public network interface named eth0, you can use the following command to allow HTTP traffic (port 80) : sudo ufw allow in on eth0 to any port 80 doing so will allow your server to receive HTTP requests from the public Internet. Alternatively, if you want the MySQL database server (port 3306) to listen for connections on the private network interface eth1, for example, you can use this command: Sudo ufw allow in on eth1 to any port 3306 this will allow other servers on the private network to connect to the MySQL database.Copy the code