Java programmers are bound to use Linux Quick Search Manual

Keywords: Linux firewall iptables Nginx yum

Contents

  1. System Service Management
  2. file management
  3. view log
  4. Compression and decompression
  5. Disk and Network Management
  6. firewall
  7. ftp operation
  8. Installation and Management of Software
  9. Other

System Service Management

systemctl

The state of each service in the output system:

systemctl list-units --type=service

View the running status of the service:

systemctl status firewalld

Shut down service:

systemctl stop firewalld

Start up service:

systemctl start firewalld

Restart the service (whether the current service is started or closed):

systemctl restart firewalld

Reload configuration information without interrupting service:

systemctl reload firewalld

No service boot-up self-startup:

systemctl disable firewalld

Set up service boot-up self-start:

systemctl enable firewalld

file management

Finding Documents
(Find the filename.txt file in / directory by name)

find / -name filename.txt

View files, including hidden files

ls -al

List all files under the current directory (/):
ls

ls -l /

Get the absolute path to the current working directory

pwd

Change the current working directory: cd

cd /usr/local

Display or modify system time and date;

date '+%Y-%m-%d %H:%M:%S'

Used to set user passwords: passwd

passwd root

Change User Identity (Switch to Super User):su

su -username

Used to clear screen information

clear

Display help information for the specified command:man

man ls

What level of operation is the query system at?

who -r

Displays users currently logged in to the system:

who -buT

Display system memory status (unit MB): free

free -m

Display system process running dynamics: ps

ps -ef

View the running dynamics of the sshd process:

ps -ef | grep sshd

View Real-time Active Processes, Similar to Windows Task Manager

top

Create directories

mkdir

Copy files including their subfiles to a custom directory

cp -r sourceFolder targetFolder

Delete directories (this directory is empty)

rmdir deleteEmptyFolder

Delete files including their subfiles

rm -rf deleteFile

Delete files: rm

rm text.txt

move file

mv /temp/movefile /targetFolder

Move or overwrite files: mv

mv oldNameFile.md newNameFile.md

Modify file permissions (file.java permissions - rwxrwxrwx, r for read, w for write, x for executable)

chmod 777 file.java

Used to view the contents of a file for too long pages:
View boot.log file at 10 lines per page

more -c -10 /var/log/boot.log

View the Linux startup log file file and mark the line number: cat

cat -Ab /var/log/boot.log

Create the text.txt file:touch

touch text.txt

Start Vi Editor

vi filename

1) Enter editing mode

shift+i

2) Withdrawal from editing mode

esc-->shift+:

3) Deposit and Exit

wq

4) Forced withdrawal

q

view log

Look at the file header for 10 lines

head -n 10 example.txt

Look at the bottom 10 lines of the file

tail -n 10 example.txt

View the log file (this command automatically displays the new content, and the screen only displays 10 lines of content (settable)

tail -f exmaple.log

Search for keywords in the log

less server.log

1) If you want to start searching from the first line of the log

Less server. log - > / search keyword - > n to find the next - > N to find the last one

2) If you want to start searching from the last line of the log

Less server. log - > shitf + G - >? Search keywords - > n to find the last - > N to find the next

Compression and decompression

decompression

unzip FileName.zip
//Compression:
zip -r FileName.zip DirName

File files in the / etc folder into file etc.tar (without compression): tar

tar -cvf /mydata/etc.tar /etc

Compress files in folder / etc to file etc.tar.gz with gzip:

tar -zcvf /mydata/etc.tar.gz /etc

Compress folder / etc to file / etc.tar.bz2 with bzip2:

tar -jcvf /mydata/etc.tar.bz2 /etc

Page to view the contents of the compressed package (gzip):

tar -ztvf /mydata/etc.tar.gz |more -c -10

Unzip the file to the current directory (gzip):

tar -zxvf /mydata/etc.tar.gz

Disk and Network Management

View disk usage

df -h

View disk usage
free

View disk space occupancy:

df -hT

dh
View the size of files and folders in the current directory:

du -h --max-depth=1 ./*

Display the current network interface status

ifconfig

View the current routing information: netstat

netstat -rn

View all valid TCP connections:

netstat -an

View the monitoring services started in the system:

netstat -tulnp

View a port listening service in the system:

netstat -ntlp|grep 8080

View system resource information in connection state:

netstat -atunp

Check to see if a process exists

ps -ef|grep java/pid

Download files from the network

wget

firewall

There are two kinds of firewall software in Linux, firewall is used above ConterOS 7.0, and iptables are used below ConterOS 7.0. This article will introduce the use of two kinds of firewall software.

Firewall

Open the firewall:

systemctl start firewalld

Close the firewall:

systemctl stop firewalld

View firewall status:

systemctl status firewalld

Set boot start:

systemctl enable firewalld

Disable boot-up:

systemctl disable firewalld

Restart the firewall:

firewall-cmd --reload

Open Port (Firewall Restart is required to take effect after modification):

firewall-cmd --zone=public --add-port=8080/tcp --permanent

View open ports:

firewall-cmd --list-ports

Close the port:

firewall-cmd --zone=public --remove-port=8080/tcp --permanent

Iptables

install
Since the version of CenterOS 7.0 or above does not pre-install Iptables, we need to install them ourselves.
Close firewall firewall before installation

Install iptables:

yum install iptables

Install iptables-services:

yum install iptables-services

Open the firewall:

systemctl start iptables.service

Close the firewall:

systemctl stop iptables.service

View firewall status:

systemctl status iptables.service

Set boot start:

systemctl enable iptables.service

Disable boot-up:

systemctl disable iptables.service

Look at several chain rules of the filter table (the INPUT chain shows which ports are open):

iptables -L -n

Look at the chain rules of the NAT table:

iptables -t nat -L -n

Clear all rules of firewall:

iptables -F
iptables -X
iptables -Z

Add rules to the INPUT chain (open port 8080):

iptables -I INPUT -p tcp --dport 8080 -j ACCEPT

Find the line number of the rule:

iptables -L INPUT --line-numbers -n

Delete the filter rule according to the line number (close port 8080):

iptables -D INPUT 1

ftp operation

ftp ip
Enter password;
bin converts files to binary
get gets the file name

Installation and Management of Software

rpm

Installation package:

rpm -ivh nginx-1.12.2-2.el7.x86_64.rpm

Fuzzy Search Software Package:

rpm -qa | grep nginx

Find the package accurately:

rpm -qa nginx

Query the installation path of the package:

rpm -ql nginx-1.12.2-2.el7.x86_64

View the package summary information:

rpm -qi nginx-1.12.2-2.el7.x86_64

Verify that the package content is consistent with the installation file:

rpm -V nginx-1.12.2-2.el7.x86_64

Update the package:

rpm -Uvh nginx-1.12.2-2.el7.x86_64

Delete packages:

rpm -e nginx-1.12.2-2.el7.x86_64

yum

Installation package:

yum install nginx

Check for updatable packages:

yum check-update

Update the specified package:

yum update nginx

Find package information in the repository:

yum info nginx*

List all packages installed:

yum info installed

List the package names:

yum list nginx*

Fuzzy Search Software Package:

yum search nginx

Other

Termination threads (threads that terminate thread number 19979)

kill -9 19979

Check the number of threads (to see if the program is wrong)

Ps-Lf port number | wc-l

View Network Connectivity

ping ip

Check the connectivity of the ip port (firewall connectivity)

telnet ip port - > exit mode shift +] - > quit

View local ip

ifconfig

View Scheduler

crontab -l

Edit Scheduler

crontab -e

To learn more about Facebook and develop small skills, you are welcome to scan the two-dimensional code below, and continue to pay attention to it!

Posted by Crystal Dragon on Wed, 04 Sep 2019 05:54:13 -0700