---
# System prepended metadata

title: Shell learning *system service*
tags: [shell]

---

# Shell learning *system service*

###### tags: `shell`

Copyright 2021, [月下麒麟 YMont](https://hackmd.io/@YMont/note-catalog)

---
## outline
學習shell腳本與linux指令認識

## command
```which python3```
![](https://i.imgur.com/EBsye2n.png)

```which python3 | sed 's/\//\\\//g'```
![](https://i.imgur.com/S2q4LOs.png)
產生反斜線(backslash)

```cat main.py | sed "s/python/java/g" > `pwd`/main```
![](https://i.imgur.com/8SMciQi.png)
main(.py)

![](https://i.imgur.com/479xhou.png)
main(no file extension)

``` cat `pwd`/main```(補充)
![](https://i.imgur.com/l8q8QjO.png)

```ln -sf /test.service /etc/systemd/system/```
![](https://i.imgur.com/ifC3Ww0.png)
建立軟連結至系統配置處(administrate)

![](https://i.imgur.com/ulH5CSx.png)
於/etc/systemd/system就會看到該main.service被連結在此

```sudo systemctl enable main```
即可針對該service執行啟用
systemctl 的 start 與 stop 兩個操作指令是用來控制目前服務的狀態
如果想要設定開機自動啟動服務的話，就要改用 enable 與 disable




Reference:[Linux 指令 SED 用法教學、取代範例、詳解](https://terryl.in/zh/linux-sed-command/)
Reference:[Linux systemd 系統服務管理基礎教學與範例](https://blog.gtwang.org/linux/linux-basic-systemctl-systemd-service-unit-tutorial-examples/)