This is the third day of my participation in the August More text Challenge. For details, see: August More Text Challenge

1 Command Content

  • Connect to the Linux server using Xshell
  • Check whether the Redis service is enabled:ps -ef | grep redis
  • Close redis service:redis-cli -p 6379 shutdownandkill -9
  • Modifying a Configuration File
  • Checking and opening firewall ports

If no specific command content is written, multiple commands are required or descriptions are required. For details, see section 2

The author server is Centos7 64-bit, and all commands are available on this system

2 Command description

2.1 Using Xshell to connect to the Linux Server

The xshell website is attached directly

It is very simple to use and will not be repeated here

2.2 Checking whether the Redis service is started

Command to ps – ef | grep redis

In fact, this is a combination of two commands via the pipe character, ps -ef and grep redis

The former is the ps command with parameters -e and f

-e indicates that all programs are displayed, and f indicates that the tree structure is displayed with ASCII characters to express the relationship between programs

Pipe | said after previous output of the command as a command input

Combined with grep redis filter, we can easily understand this command as:

From the list of programs, filter programs whose keyword is Redis

It should be noted that there is a high probability that it will appear as follows:

Especially pay attention to the second line results grep — color = auto redis, this is the command ps – ef | grep redis itself, is not really a redis service well

2.3 Disabling the Redis Service

There are two ways to disable the Redis service:

  • Redis-cli -p Indicates the port number shutdown
  • Kill -9 Indicates the process ID

The default redis port is 6379, that is, redis-cli -p 6379 shutdown, but if Redis has a password, it will prompt you for authentication

At this point, it is too troublesome to search for redis-cli command authentication. Just kill -9 program process id

The program process number can be found in the last command, such as the author is 4908

2.4 Modifying the Redis configuration file

There are many tutorials on how to modify redis profiles to enable remote access

The key is that when using Vim to modify the contents of a file, how do we find the fields we want to change with the vast number of configurations? (Not like Idea with Ctrl+F)

In fact, there is a very convenient way to search in Vim, type/add what you want to search, and then press Enter

After the search result is found, hit n to jump to the next, n to jump to the previous

2.5 Checking and Opening firewall Ports

After the Redis configuration is modified, the remote access is still unavailable

That must be because the firewall does not release the port of the Redis service. The following command defaults to port 6379

First check: firewall-cmd –query-port=6379/ TCP, the result is a cold no

Firewall – CMD –get-active-zones (firewall- CMD –get-active-zones

Irewall-cmd –zone=public –add-port=6379/ TCP –permanent

The last step is to restart the firewall: firewall-cmd –reload. The result is still a happy success

At this point, I finally have remote access to Redis, and I seem to know more about Linux commands

3 summary

  • Would it be easier to remember a command if you took five minutes more to understand why
  • If you want to access Redis remotely, it’s a good idea to use a password