Terminal Cheatsheet for Mac

作者: 分类: 时间: 2017-09-19 评论: 暂无评论

快捷键

按键/命令 描述
Ctrl + A 移动光标至行首
Ctrl + E 移动光标至行尾
Ctrl + L 清屏
Command + K 清屏
Ctrl + U 删除光标前的所有文字。如果光标位于行尾则删除整行。
Ctrl + H 与退格键相同
Ctrl + R 检索使用过的命令
Ctrl + C 终止当前执行
Ctrl + D 退出当前shell
Ctrl + Z 将执行中的任何东西放入后台进程。fg可以将其恢复。
Ctrl + W 删除光标之前的单词
Ctrl + K 删除光标后的所有文字
Ctrl + T 将光标前的两个文字进行互换
Option + → 光标向前移动一个单词
Option + ← 光标向后移动一个单词
Esc + T 将光标前的两个单词进行互换
Tab 自动补全文件或文件夹的名称

核心命令

按键/命令 描述
cd Home目录
cd [folder] 切换目录
cd ~ Home目录, 例如 'cd ~/folder/'
cd / 根目录
ls 文件列表
ls -l 文件详细列表
ls -a 列出隐藏文件
ls -lh 文件详细列表中的文件大小以更友好的形式列出
ls -R 递归显示文件夹中的内容
sudo [command] 以超级用户身份执行命令
open [file] 打开文件 ( 相当于双击一个文件 )
top 显示运行中的进程,按q终止
nano [file] 打开编辑
pico [file] 打开编辑
q 退出
clear 清屏

阅读全文»

UML

作者: 分类: 时间: 2017-09-16 评论: 暂无评论

UML中包括九种图: 用例图、类图、对象图、状态图、时序图、协作图、活动图、组件图、配置图

1.用例图

它是UML中最简单也是最复杂的一种图。说它简单是因为它采用了面向对象的思想,又是基于用户视角的,绘制非常容易,简单的图形表示让人一看就懂。说它复杂是因为用例图往往不容易控制,要么过于复杂,要么过于简单。
用例图表示了角色和用例以及它们之间的关系。

2.类图

是最常用的一种图,类图可以帮助我们更直观的了解一个系统的体系结构。通过关系和类表示的类图,可以图形化的方式描述一个系统的设计部分。

阅读全文»

zookeeper

作者: 分类: 时间: 2017-09-09 评论: 暂无评论

http://hisen.me/20170224-Ubuntu-16-LTS-%E5%AE%89%E8%A3%85zookeeper%E5%B9%B6%E5%BC%80%E6%9C%BA%E5%90%AF%E5%8A%A8/

sample init.d script

作者: 分类: 时间: 2017-09-09 评论: 暂无评论

Create a script and place in /etc/init.d

(e.g /etc/init.d/myscript). The script should have the following format:

#!/bin/bash
# chkconfig: 2345 20 80
# description: Description comes here....

# Source function library.
. /etc/init.d/functions

start() {
    # code to start app comes here 
    # example: daemon program_name &
}

stop() {
    # code to stop app comes here 
    # example: killproc program_name
}

case "$1" in 
    start)
       start
       ;;
    stop)
       stop
       ;;
    restart)
       stop
       start
       ;;
    status)
       # code to check status of app comes here 
       # example: status program_name
       ;;
    *)
       echo "Usage: $0 {start|stop|status|restart}"
esac

exit 0 

The format is pretty standard and you can view existing scripts in /etc/init.d. You can then use the script like so /etc/init.d/myscript start or chkconfig myscript start. The ckconfig man page explains the header of the script:

This says that the script should be started in levels 2, 3, 4, and
5, that its start priority should be 20, and that its stop priority
should be 80.

Enable the script

$ chkconfig --add myscript 
$ chkconfig --level 2345 myscript on

Check the script is indeed enabled - you should see "on" for the levels you selected.

$ chkconfig --list | grep myscript

http://man.linuxde.net/chkconfig

Installation as a systemd service

作者: 分类: 时间: 2017-09-06 评论: 暂无评论

Systemd is the successor of the System V init system, and is now being used by many modern Linux distributions. Although you can continue to use init.d scripts with systemd, it is also possible to launch Spring Boot applications using systemd ‘service’ scripts.

Assuming that you have a Spring Boot application installed in /var/myapp, to install a Spring Boot application as a systemd service create a script named myapp.service using the following example and place it in /etc/systemd/system directory:

[Unit]
Description=myapp
After=syslog.target

[Service]
User=myapp
ExecStart=/var/myapp/myapp.jar
SuccessExitStatus=143

[Install]
WantedBy=multi-user.target

Remember to change the Description, User and ExecStart fields for your application.
Note that ExecStart field does not declare the script action command, which means that run command is used by default.

https://docs.spring.io/spring-boot/docs/current/reference/html/deployment-install.html#deployment-systemd-service

Top ↑