热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

markdownLinux类的注释

本文由编程笔记#小编为大家整理,主要介绍了markdownLinux类的注释相关的知识,希望对你有一定的参考价值。
本文由编程笔记#小编为大家整理,主要介绍了markdown Linux类的注释相关的知识,希望对你有一定的参考价值。




# Introduction to Linux process and management
> foreground vs. backgraound process(job)
- `ctrl+z`: switch to background but stop
- `&`: switch to background and execute
- switch to foreground: `fg`
- check for job list: `jobs`
- `bg %1`: execute the first program which is stopped in the background
> nohup
>
- `nohup [job] &`: you can logout after doing nohup command, and next time when you login again you can see the result of the job in nohup.out this file
> process management `-ps`
- `ps`: show all the jobs which the user are executing currently
- `-a`: show all the process stat which has 終端控制介面
- `-A`, `-e`: show all the process stat in the system
- `x`: show 不具備終端控制介面的process information
- `-w`: show the 詳細information of the process
- `u`: use username and boot time 順序to show the process information
- `f`: show the realtionship of process use 樹狀
- `-f`: 完整格式顯示
- `-l`: 以長資訊格式顯示
- `-U`: show 實際user UID
- `-u`: show effective user UID
- `-C command`: show 符合command 指令的process
- `ps u -u username`: using BSD style to show information
- `watch -n [sec] 'ps [參數]`: 讓ps result keep updating frequency [sec] seconds
> process management `-pstree`
- `pstree`: get all the relationship of all the process in system
- `-p`: show all the PID in execution
- `-u`: show the UID of the process

> top command
- `top`: show the process's resource佔用狀態
- `top -d 1`: set the updating frequency is 1 second, default is 3 sec
- while executing top command the cammand you can use
- `h`: show 操作說明 information
- `r`: can change the NI of process in execution
- `k`: 傳遞控制訊號to a process in execution
- `N`: sort using PID
- `P`: sort using CPU 使用率
- `i`: only show the process which is not in waiting stat
- `top -u username`: 監控user's process stat
- `top -p pid`: trace specific process stat
- `top -b -n 1 > top.1`: 進行批次運作模式,且執行一次,導到top.1這個檔案
> process priority `nice`
- `nice`: search for the default NI setting of user
- `nice -n +10 [process]`: give the process default NI 10
- `renice [num] pid`: 調整the executing priority of process in execution (NI)
- PRInew=PRIold+(NInew-NIold)
> process lifecycle `-kill`
- `kill`: terminate the process in execution
- `kill -l`: list all the signal list that can be used currently
- `kill -s`: 送出specific signal to process, you can use signal name or number
- `pidof [process]`: search the PID of the process
__common process termination signal__
- 1 `SIGUP`: 與terminal所建立的process, inform the process that the terminal is closing. if it's a Daeman process than 重置execution environment
- 2 `SIGINT`: through keyboard execute interruption, `ctrl-c`
- 9 `SIGKILL`: through kernel terminate the process immediately
- 15 `SIGTERM`: 請求process to terminate by itself
- 18 `SIGCONT`: continue the execution of a stop process
- 19 `STOP`: pause the process
- `kill -9 PID`, `kill -SIGKILL PID`, `kill -s SIGKILL`: terminate the process immediately
- `kill -signal [jobid]`: you can also send signal to jobs
- `killall -signal [process]`: you don't need to know the PID and can still send signal to process
> process lifecycle `pkill`
- `pkill -signal [pattern]`: the function if pkill is same as kill, but it can 支援regular expression in [pattern]
- `-f`: [pattern]所描述的指令列資訊為完整格式,including command, 參數與引述的information
- `-x`: completely 符合[pattern]所描述的process than send signal
- `-t [terminal]`: send signal to all the process which is connect with [terminal]
- `-u UID`: send signal to the process which has userid UID
- `-P PPID`: send signal to the process which has ppid PPID
`xkill`: can use in graphical window


# shell script
> how to execute shell script
- method 1
1. 建立建立一個shell file: `~/shell.sh`
2. `chmod u+rx`
3. 使用絕對路徑或相對路徑或shell所在目錄所在目錄放到$PATH環境變數中
4. `./shell.sh`
- method 2: use bash command to execute
1. `bash shell.sh`, `sh shell.sh`, `source shell.sh`
2. at this time the file only need to have the right of being execute
> basic syntax for shell script
- `#!/bin/bash`: 宣告this file is using bash syntax
- `if`, `then`,`case`, `esac`:條件判斷
- loop: `while do done`, `until do done`,`for`, `do`, `done`
> test command(檢測系統上檢測系統上某些檔案檢測系統上某些檔案或者是相關的屬性)
- `test -e [file] && echo "exist" || echo "not exist"`: if the file exist then it will show exist, if not it will show not exist
__file type判斷__
- `-e`: if the filename exist
- `-f`: if the filename exist and also is a regular file
- `-e`: if it is a directory
- `-b`: if it is a block device
- `-c`: if it is a character device
- `-S`: if it is a Socket file
- `-p`: if it is a FIFO(pipe) file
- `-L`: if it is a link file
__file 權限偵測__
- `-r`: if it has可讀權限
- `-w`: if it has可寫權限
- `-x`: if it has 可execute權限
- `-u`: if it has SUID屬性
- `-g`: if it has SGID屬性
- `-k`: if it has sticky bit屬性
- `-s`: if it isn't a blank file
__two files comparison__
- `test file1 -nt file2`: 判斷if file1 is newer than file2
- `-ot`:判斷if file1 is older than file2
- `ef`: 判斷if file1 and file2 are the same file, can be used to check hard link--> if the two files are pointing to the same inode
__check to integers__
- `test n1 -eq n2`: if n1 and n2 are equal
- `-ne`: not equal
- `-gt`: greater than
- `-lt`: less than
- `-ge`: greater than or equal
- `-le`: less than or equal
__check string information__
- `test -z string`: if the string is blank than return true
- `test -n string`: if the string is blank than return false, `-n` can be avoid
- `test str1==str2`: if str1 equal str2, if equal than return true
- `test str1!=str2`: if str1 isn't equal to str2, if equal than return false
__multiple 條件check__
- `-a`: and two condition both 成立,`test -r file -a -x file`: if file has both r and x權限,than return true
- `-o`: or two condition 任何一個成立,`test -r file -o -x file`: if the file has r or x權限, than return true
- `!`: 反向選擇,反向選擇,`test ! -x file`: if file doesn't has x權限,than return true
> variables in shell script
- `$0`: the name af this shell script
- `$1`,`$2`,,,: the first variable, the second variable,,,
- `$#`: 代表後面接的參數個數
- `"$@"`: represent "$1" "$2" ,,,
- `"$*"`: represent "$1c$2c,,," --> c為separate character, default is spacebar
> function
- define a function
```shell
function fname{
code
}
```
- variable代號: function name --> `$0`, 後續的variable --> `$1`,`$2`,,,,
- 回傳值: return
> if-then-else
- single layer simple判斷
```shell
if [condition判斷式]; then
# if the condition 成立,then you can execute the job
fi
```
- multiple layer complicated判斷式
```shell
if[condition 1]; then
# if 成立 execute
elif [condition 2]; then
# if 成立 execute
else
fi
```
> case esac
```shell
case ${variable} in
"first variable content")
#code
;;
"second variable content")
code
;;
*) # last variable content
#code
;;
esac
```
> while loop
- while-do-done
```shell
while [condition] # condition就是就是條件判斷式
do # loop start
#code
done
```
- until-do-done
```shell
until [condition]
do
#code
done
```
> for loop
```shell
for variable in condition
do
#code
done
```
```shell
for variable in $(seq range1 range2)
```
- `seq`: abbreviation of sequence, 連續的意思,from range1 to range2連續
```shell
for((初始值;限制值;執行步階))
do
# code
done
```
> debug
- `sh [參數] script.sh`
- `-n`: do not execute the script, only search for syntax error
- `-v`: show the script's content on the screen before executing the script
- `-x`: show the script's content which is in use while executing on the screen


推荐阅读
  • 计算机存储系统的层次结构及其优势
    本文介绍了计算机存储系统的层次结构,包括高速缓存、主存储器和辅助存储器三个层次。通过分层存储数据可以提高程序的执行效率。计算机存储系统的层次结构将各种不同存储容量、存取速度和价格的存储器有机组合成整体,形成可寻址存储空间比主存储器空间大得多的存储整体。由于辅助存储器容量大、价格低,使得整体存储系统的平均价格降低。同时,高速缓存的存取速度可以和CPU的工作速度相匹配,进一步提高程序执行效率。 ... [详细]
  • Linux重启网络命令实例及关机和重启示例教程
    本文介绍了Linux系统中重启网络命令的实例,以及使用不同方式关机和重启系统的示例教程。包括使用图形界面和控制台访问系统的方法,以及使用shutdown命令进行系统关机和重启的句法和用法。 ... [详细]
  • 本文由编程笔记#小编为大家整理,主要介绍了logistic回归(线性和非线性)相关的知识,包括线性logistic回归的代码和数据集的分布情况。希望对你有一定的参考价值。 ... [详细]
  • 生成式对抗网络模型综述摘要生成式对抗网络模型(GAN)是基于深度学习的一种强大的生成模型,可以应用于计算机视觉、自然语言处理、半监督学习等重要领域。生成式对抗网络 ... [详细]
  • 本文介绍了在rhel5.5操作系统下搭建网关+LAMP+postfix+dhcp的步骤和配置方法。通过配置dhcp自动分配ip、实现外网访问公司网站、内网收发邮件、内网上网以及SNAT转换等功能。详细介绍了安装dhcp和配置相关文件的步骤,并提供了相关的命令和配置示例。 ... [详细]
  • 本文介绍了数据库的存储结构及其重要性,强调了关系数据库范例中将逻辑存储与物理存储分开的必要性。通过逻辑结构和物理结构的分离,可以实现对物理存储的重新组织和数据库的迁移,而应用程序不会察觉到任何更改。文章还展示了Oracle数据库的逻辑结构和物理结构,并介绍了表空间的概念和作用。 ... [详细]
  • 开发笔记:加密&json&StringIO模块&BytesIO模块
    篇首语:本文由编程笔记#小编为大家整理,主要介绍了加密&json&StringIO模块&BytesIO模块相关的知识,希望对你有一定的参考价值。一、加密加密 ... [详细]
  • CSS3选择器的使用方法详解,提高Web开发效率和精准度
    本文详细介绍了CSS3新增的选择器方法,包括属性选择器的使用。通过CSS3选择器,可以提高Web开发的效率和精准度,使得查找元素更加方便和快捷。同时,本文还对属性选择器的各种用法进行了详细解释,并给出了相应的代码示例。通过学习本文,读者可以更好地掌握CSS3选择器的使用方法,提升自己的Web开发能力。 ... [详细]
  • 阿,里,云,物,联网,net,core,客户端,czgl,aliiotclient, ... [详细]
  • 使用Ubuntu中的Python获取浏览器历史记录原文: ... [详细]
  • 图解redis的持久化存储机制RDB和AOF的原理和优缺点
    本文通过图解的方式介绍了redis的持久化存储机制RDB和AOF的原理和优缺点。RDB是将redis内存中的数据保存为快照文件,恢复速度较快但不支持拉链式快照。AOF是将操作日志保存到磁盘,实时存储数据但恢复速度较慢。文章详细分析了两种机制的优缺点,帮助读者更好地理解redis的持久化存储策略。 ... [详细]
  • 本文介绍了作者在开发过程中遇到的问题,即播放框架内容安全策略设置不起作用的错误。作者通过使用编译时依赖注入的方式解决了这个问题,并分享了解决方案。文章详细描述了问题的出现情况、错误输出内容以及解决方案的具体步骤。如果你也遇到了类似的问题,本文可能对你有一定的参考价值。 ... [详细]
  • Java学习笔记之面向对象编程(OOP)
    本文介绍了Java学习笔记中的面向对象编程(OOP)内容,包括OOP的三大特性(封装、继承、多态)和五大原则(单一职责原则、开放封闭原则、里式替换原则、依赖倒置原则)。通过学习OOP,可以提高代码复用性、拓展性和安全性。 ... [详细]
  • Go Cobra命令行工具入门教程
    本文介绍了Go语言实现的命令行工具Cobra的基本概念、安装方法和入门实践。Cobra被广泛应用于各种项目中,如Kubernetes、Hugo和Github CLI等。通过使用Cobra,我们可以快速创建命令行工具,适用于写测试脚本和各种服务的Admin CLI。文章还通过一个简单的demo演示了Cobra的使用方法。 ... [详细]
  • Java在运行已编译完成的类时,是通过java虚拟机来装载和执行的,java虚拟机通过操作系统命令JAVA_HOMEbinjava–option来启 ... [详细]
author-avatar
芨芨草_的美丽家园
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有