Windows

开启redis服务

  1. redis-server.exe redis.windows.conf

开启redis客户端

  1. redis-cli.exe -h 127.0.0.1 -p 6379

开启Mongodb服务

  1. c:\software\mongodb\bin\mongod --dbpath c:\data\db

查看ip

  1. ipconfig/all

查看某一端口占用情况

  1. netstat -aon|findstr "8080"

查看进程

  1. tasklist|findstr "14948"

杀死一个进程

  1. taskkill /f /t /im QQ.exe

Springboot

版本

2.6.4

Java

获取当前项目的根目录

System.getProperty("user.dir")

存放一个文件

  1. File destination = new File(rootFilePath);
  2. file.transferTo(destination); //上传文件

FileUtil工具

  1. <dependency>
  2. <groupId>cn.hutool</groupId>
  3. <artifactId>hutool-all</artifactId>
  4. <version>5.7.3</version>
  5. </dependency>

下载一个图片时的接口

  1. public void getFiles(HttpServletResponse response, @PathVariable("flag") String flag){
  2. OutputStream os;//创建输出流
  3. String basePath = System.getProperty("user.dir") + "/springboot/src/main/resources/files/"; // 上传文件的目录
  4. List<String> fileNames = FileUtil.listFileNames(basePath);
  5. String fileName = fileNames.stream().filter(name -> name.contains(flag)).findAny().orElse("");
  6. try {
  7. if (StringUtils.isNotEmpty(fileName)){
  8. response.addHeader("Content-Disposition","attachment;filename="+ URLEncoder.encode(fileName,"UTF-8"));
  9. response.setContentType("application/octet-stream");
  10. byte[] bytes = FileUtil.readBytes(basePath + fileName);
  11. os = response.getOutputStream();
  12. os.write(bytes);
  13. os.flush();
  14. os.close();
  15. }
  16. }catch (Exception e) {
  17. System.out.println("文件下载失败");
  18. }
  19. }

Linux

清理loop

  1. sudo apt autoremove --purge snapd

扩展虚拟机的根目录
https://www.maxlicheng.com/notes/328.html?unapproved=2986&moderation-hash=a582378445672a834c9a180ef5d39f6810

安装dlib时需要root运行

查看ip

  1. ifconfig

查看硬盘使用情况

  1. df -h

Redis

删除当前数据库中所有的key

  1. flushdb

MAC

查看进程号

  1. ps aux |grep process_name

注意

mongod服务不能直接关闭,应该打开另一个控制台使用

  1. db.shutdownServer()