1. 切换成root user
sudo su root
退出root用户
su -
2. 查看被占用的端口并删除进程
Linux/Mac
> lsof -i :8080
> kill -15 <PID>
Windows
> netstat -aon|findstr "8080"
> taskkill /T /F /PID <PID>
3. 本地文件信息查询
df: 显示磁盘分区上可以使用的磁盘空间
-a
: 查看全部文件系统,单位默认KB
-h
: 以KB、MB、GB的单位来显示,可读性高
查看磁盘容量的使用情况
df -h
显示使用率100%,解决方法是去删除比较大无用的文件
df -h
查看inode包含的信息:文件的字节数,拥有者id,组id,权限,改动时间,链接数,数据block的位置
df -i
显示使用率100%,解决方法是去删除数量过多的小文件
df -i
du: 显示每个文件和目录的磁盘使用空间~~~文件的大小
-d
或--max-depth
: 指深度,后面加一个数值
-s
: 仅显示目录的总值,单位KB
-h
: 以K M G为单位显示,提高可读性
du -d 1 -h
du -h --max-depth=1
查看文件个数
通过ls
查看,实际上显示的是ls
所得条数,等同于文件个数
ls -l | grep "^-"|wc -l # 统计当前目录下文件的个数(不包括子目录)
ls -l | grep -c "^-" # 统计当前目录下文件的个数(不包括子目录)
ls -lR | grep "^-"|wc -l # 查询当前目录下所有目录子目录下文件的个数
ls -lR | grep -c "^-" # 查询当前目录下所有目录子目录下文件的个数
ls -l <dir_name> | grep "^-"|wc -l # 查看某目录下文件夹(目录)的个数(包括子目录)
ls -l <dir_name> -c grep "^-" # 查看某目录下文件夹(目录)的个数(包括子目录)
通过find
查看
find ./ -type f | wc -l
ls: 查看实际文件大小
查看dir_name文件夹下所有文件的大小,创始人,权限等信息
ls -la dir_name
判断文件是否存在
if [ -e $file ]
then
echo "文件存在"
else
echo "文件不存在"
fi
判断文件是否为空(文件不存在同为false)
if [ -s $file ]
then
echo "文件不为空"
else
echo "文件为空"
fi
判断文件是否大于maxsize
filesize=' ls -l $filename | awk '{ print $5}' ' #获取文件本身大小
maxsize=$((1024*10)) #最大内存10k
if [ $filesize -gt $maxsize ] #判断文件是否大于某个内存大小,
then
echo "exceeds 10KB"
else
echo "does not exceed 10KB"
fi
du -sh
与df -h
大小有区别
用户删除了大量的文件被删除后,在文件系统目录中已经不可见了,所以du就不会再统计它。然而如果此时还有运行的进程持有这个已经被删除的文件句柄,那么这个文件就不会真正在磁盘中被删除,分区超级块中的信息也就不会更改,df仍会统计这个被删除的文件。
可通过lsof |grep deleted
命令查询处于deleted状态的文件,被删除的文件在系统中被标记为deleted。如果系统有大量deleted状态的文件,会导致du和df统计结果不一致。
杀死或重启持有文件句柄的进程可以释放调用,使df -h
回到与du -sh
一样大小
du -h
与ls -lah
大小有区别
ls -lah
显示的是文件的实际大小。
du -h
不是显示文件大小,而是显示文件所占用的block大小,默认linux系统分区的block size是4k,也就是说即使文件只有1个字节,也会占用4k,
4. Git
将本地项目初始化到远程dev branch上
> cd <my_local_repo>
> git init
> git checkout -b dev # create a new branch dev
> git add .
> git commit -m "First commit"
> git remote add origin <my_remote_origin_url>
> git push -u origin dev
> git log --since="2018-01-01" --before="2021-01-22" --author="yuchensun" --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s, removed lines: %s, total lines: %s\n", add, subs, loc }'
查看仓库远程地址
> git remote get-url origin
修改仓库远程地址
> git remote set-url origin <remote_origin_url>
合并分支A到B
> git checkout A
Switched to branch 'A'
> git pull origin A # 确保本地A分支已经更新到最新
From <your_git_repo_origin>
* branch A -> FETCH_HEAD
Already up to date.
> git checkout B
Switched to branch 'B'
> git pull origin B
From <your_git_repo_origin>
* branch B -> FETCH_HEAD
Already up to date.
> git merge A
Auto-merging ...
CONFLICT (content): Merge conflict in ...
(打开VSCode手动解决冲突)
回滚删除某一次提交(不小心上传了密钥时使用)
(把当前进度备份保存好)
git reset --hard <commit_id> // 将HEAD指向要删除的提交的前一次提交
git push origin HEAD --force // 强制推送到远端,想要删除的提交就会被抹去
(将最新进度拷贝回本地仓库)
git push origin dev // 重新提交最新进度
比较不同
# 当工作区有改动,临时区为空,diff的对比是“工作区与最后一次commit提交的仓库的共同文件”;
# 当工作区有改动,临时区不为空,diff对比的是“工作区与暂存区的共同文件”。
git diff
# 显示暂存区(已add但未commit文件)和最后一次commit(HEAD)之间的所有不相同文件的增删改
git diff --staged / git diff --cached
# 比较当前branch某文件当前与最后一次commit的不同
git diff <file_path>
# 比较两个branch最后一次commit的所有有差异的文件的详细差异
git diff branch1 branch2
# 罗列出两个branch最后一次commit所有有差异的文件
git diff branch1 branch2 --stat
将远程信息同步到本地
git fetech
查看所有分支
git branch -a
查看所有远程分支
git branch -r
查看所有本地分支到远程分支的映射
git branch -vv
新建分支
# 新建远程分支同名的本地分支
git checkout <local_branch_name>
# 只创建本地新分支,不会关联到远程分支
git checkout -b <local_branch_name>
# 有时候只写git checkout <local_branch_name>未必能关联到正确的远程分支
# 需要具体指明
git checkout -b <local_branch_name> origin/<remote_branch_name>```
删除分支
# 删除本地分支
git branch -D <local_branch_name>
# 删除远程分支
git push origin --delete <remote_branch_name>
5. 复制
cp
命令复制文件到某地,如果该地点有同名文件,则覆盖
> ls
test.txt childDir
> cat test.txt
This is a new scp test
> cp test.txt childDir
> cd childDir
> cat test.txt
This is a new scp test
> echo "test in child" > test.txt
> cat test.txt
test in child
> cp test.txt ../
> cd ../
> cat test.txt
test in child
cp -r
命令在不同情况下表现不一样
> ls A # see what's in directory A
index.html, index.js
# If B/C exists
> cp -r A B/C
> ls B/C
A
# If B exists, but B/C does not exist
> cp -r A B/C
> ls B/C
index.html, index.js
# If B does not exist
> cp -r A B/C
No such file error
本地复制到远程
scp .\loading.gif root@my.remote.ip.address:/var/helper
远程复制到本地
scp root@my.remote.ip.address:/var/helper/loading.gif ./
和cp
一样,如果复制到的地点有同名文件/文件夹,则源文件会被覆盖
6. cat
利用cat
查看行号
cat -n file1 # output file1 with line numbers in stdout
利用cat
清空文件
cat /dev/null > file1 # clear file1
7. wget
Linux/Mac
wget https://www.spinq.cn/media/hero_video.f79c7ed6.mp4
如果在windows powershell使用的话需要指定Outfile
才可以成功下载
wget -Uri https://www.spinq.cn/media/hero_video.f79c7ed6.mp4 -OutFile "official.mp4"
另外在windows上第一次运行时可能会报错
wget : 无法分析响应内容,因为 Internet Explorer 引擎不可用,或者 Internet Explorer 的首次启动配置不完整。请指定 UseBasicParsing 参数,然后再试一次。
所在位置 行:1 字符: 1
+ wget -Uri https://www.spinq.cn/media/hero_video.f79c7ed6.mp4
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotImplemented: (:) [Invoke-WebRequest], NotSupportedException
+ FullyQualifiedErrorId : WebCmdletIEDomNotSupportedException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
应按照这个方法配置IE的访问权限
8. 查看系统版本
Linux
# 系统版本1
> cat /etc/issue
Ubuntu 18.04.5 LTS \n \l
# 系统版本2
> lsb_release -a
LSB Version: core-9.20170808ubuntu1-noarch:security-9.20170808ubuntu1-noarch
Distributor ID: Ubuntu
Description: Ubuntu 18.04.5 LTS
Release: 18.04
Codename: bionic
# 系统位数
> getconf LONG_BIT
64
# 内核版本
> cat /proc/version
Linux version 4.15.0-111-generic (buildd@lcy01-amd64-011) (gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04)) #112-Ubuntu SMP Thu Jul 9 20:32:34 UTC 2020
Windows
> systeminfo
主机名: DESKTOP-U15VCI2
OS 名称: Microsoft Windows 10 家庭中文版
OS 版本: 10.0.18363 暂缺 Build 18363
OS 制造商: Microsoft Corporation
OS 配置: 独立工作站
OS 构建类型: Multiprocessor Free
注册的所有人: sunyuchen2014@gmail.com
注册的组织: HP
产品 ID: 00342-35830-00447-AAOEM
初始安装日期: 2020/6/28, 3:30:31
系统启动时间: 2021/3/15, 9:02:11
系统制造商: HP
系统型号: HP Pavilion Gaming Desktop TG01-1xxx
系统类型: x64-based PC
处理器: 安装了 1 个处理器。
[01]: Intel64 Family 6 Model 165 Stepping 3 GenuineIntel ~2904 Mhz
......
9. 安装和卸载软件
Ubuntu
sudo apt-get update # 更新安装列表
sudo apt-get upgrade # 升级软件
sudo apt-get install <plugin_name> # 安装软件
sudo apt-get --purge remove <plugin_name> # 卸载软件及其配置
sudo apt-get autoremove <plugin_name> # 卸载软件及其依赖的安装
10. 查看内存使用情况
Linux
free -h # 人类能看懂的方式显示
free -m # MB的方式显示
free -g # GB方式显示
Mac
$ top -l 1 | head -n 10 | grep PhysMem
PhysMem: 11G used (2952M wired), 5426M unused.
11. 查看硬盘使用情况
Linux/Mac
查看挂载磁盘的使用情况
$ top -l 1 | head -n 10 | grep Disk
Disks: 114285549/844G read, 348750697/4503G written.
$ df -h
Filesystem Size Used Avail Capacity iused ifree %iused Mounted on
/dev/disk1s1 233Gi 201Gi 22Gi 91% 2893896 9223372036851881911 0% /
devfs 189Ki 189Ki 0Bi 100% 652 0 100% /dev
/dev/disk1s4 233Gi 10Gi 22Gi 32% 10 9223372036854775797 0% /private/var/vm
map -hosts 0Bi 0Bi 0Bi 100% 0 0 100% /net
map auto_home 0Bi 0Bi 0Bi 100% 0 0 100% /home
/dev/disk1s3 233Gi 487Mi 22Gi 3% 36 9223372036854775771 0% /Volumes/Recovery
查看文件夹内每个子类的大小
du -sh * # 查看当前文件夹内每个子类的大小
du -sh # 查看当前文件夹总大小
12. RSA key-pair
生成rsa key-pair
$ ssh-keygen -t rsa -C "email@example.com" -b 4096
Generating public/private rsa key pair.
Enter file in which to save the key (/home/test/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/test/.ssh/id_rsa.
Your public key has been saved in /home/test/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:iTmthm0NBebPx1+7HOgUKi7lb6BZgkNux/lQ1Sfew5s email@example.com
The key's randomart image is:
+---[RSA 4096]----+
| o . |
| o . . o . |
| . .. . = |
| . B.o . + |
| o o=oS o . .+ |
| =o*=+. o +E. |
| ..o=Xo.. + o |
| o+.o..o . o |
| ..o. . o |
+----[SHA256]-----+
修改rsa key-pair的passphrase
$ ssh-keygen -p
Enter file in which the key is (/home/test/.ssh/id_rsa):
Enter old passphrase:
Enter new passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved with the new passphrase.
13. History
查看历史记录
通过history
和grep
组合可以通过关键词查询最近使用过的命令
$ history | grep 'git' | head -n 5
111 git commit -m "Modify the circuit board style"
112 git push
115 git status
116 git add .
117 git commit -m "Add delete buttons"
14. 滚动查看日志内容
tail -n +10 <filename> # 查看文件最后10行
tail -f <filename> # 滚动查看文件末尾
15. dmesg
dmesg命令用于显示开机信息
可以通过dmesg快速查看到因为内存溢出(OOM)而被杀死的进程
$ dmesg
[3569070.202443] [30468] 1000 30468 4304677 1426482 11968512 0 0 java
[3569070.202444] [30612] 1000 30612 10454 151 131072 0 0 top
[3569070.202446] Out of memory: Kill process 30468 (java) score 712 or sacrifice child
[3569070.203167] Killed process 30468 (java) total-vm:17218708kB, anon-rss:5705928kB, file-rss:0kB, shmem-rss:0kB
[3569070.382575] oom_reaper: reaped process 30468 (java), now anon-rss:0kB, file-rss:0kB, shmem-rss:0kB
16. top
top命令用于实时显示 process 的动态。
$ top
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
27689 mila 20 0 4563616 988872 19408 S 0.0 12.3 2:44.15 java
14781 mila 20 0 4704184 808616 18016 S 0.0 10.1 11:49.85 java
849 mila 20 0 700416 82308 25776 S 0.0 1.0 0:08.60 gunicorn
846 mila 20 0 699364 80700 25548 S 0.0 1.0 0:08.52 gunicorn
844 mila 20 0 699240 80564 25292 S 0.0 1.0 0:08.68 gunicorn
845 mila 20 0 699240 80368 25208 S 0.0 1.0 0:08.55 gunicorn
16583 mila 20 0 700432 60708 4236 S 0.0 0.8 0:08.53 gunicorn
16584 mila 20 0 700444 59512 3036 S 0.0 0.7 0:08.20 gunicorn
16585 mila 20 0 699244 59064 3844 S 0.0 0.7 0:08.22 gunicorn
16587 mila 20 0 699244 58468 3256 S 0.0 0.7 0:08.11 gunicorn
21536 root 19 -1 138584 47624 36048 S 0.0 0.6 0:14.56 systemd-journal
8668 root 10 -10 155072 25928 10944 S 0.7 0.3 114:14.94 AliYunDun
RES
行为我们需要的内存占用量,默认以字节为单位,超过1MB或1GB后末尾会有m
的字样g
进入top模式后,摁M
使进程按照内存占有量从大到小排列
进入top模式后,摁q
退出跟踪进程
17. 打包与压缩
tar 打包
gzip 压缩
无法保留源文件
无法直接压缩文件夹,压缩文件夹前需要使用tar打包
$ ls
test.sh test2.sh
$ gzip test*.sh # 压缩
$ ls
test.sh.gz test2.sh.gz
$ zcat test.sh.gz # 展示压缩文件的内容
# ============ Test 1 of zip ================
echo 'Good morning'
$ gzip -l *.gz # 查看压缩信息
compressed uncompressed ratio uncompressed_name
177 201 25.4% test2.sh
268 358 32.4% test.sh
445 559 25.0% (totals)
$ gzip -d test*.sh.gz # 解压
$ ls
test.sh test2.sh
如果目录下已经有同名压缩文件,则询问是否覆盖,若选择覆盖则替换当前目录下的同名压缩文件,若选择不覆盖则终止压缩
$ ls
test.sh test2.sh
$ gzip test.sh
$ ls
test.sh.gz test2.sh
$ zcat test.sh.gz # 展示压缩文件test.sh.gz的内容
# ============ Test 1 of zip ================
echo 'Good morning'
$ mv test2.sh test.sh
$ ls
test.sh.gz test.sh
$ gzip test.sh
gzip: test.sh.gz already exists; do you wish to overwrite (y or n)? n
not overwritten
$ gzip test.sh
gzip: test.sh.gz already exists; do you wish to overwrite (y or n)? y
$ zcat test.sh.gz # 展示压缩文件test.sh.gz的内容
# ============ Test 2 of zip ================
echo 'Good evening'
默认目录下有同名压缩文件时自动合并两个压缩文件
if [ -e $compressed_filename ]
then
echo "压缩文件存在,需要合并"
mv $1 "$1.tmp"
gzip "$1.tmp"
zcat $compressed_filename "$1.tmp.gz" | gzip - > "$1.final.gz"
mv "$1.final.gz" $compressed_filename
rm "$1.tmp.gz"
else
echo "压缩文件不存在,成功压缩"
gzip $1
fi
zip 压缩
可以保留源文件,还可以压缩目录
18. 寻找/归类文件
Linux寻找文件find
Windows寻找文件Get-ChildItem
foreach ($var in Get-ChildItem . -Recurse -Name -exclude *.png) {cat $var > test.txt}
18. Windows 休眠
取消休眠:以管理员权限运行终端,输入
powercfg.exe /hibernate off
启用休眠:以管理员权限运行终端,输入
powercfg.exe /hibernate on
19. screen
GNU Screen可以看作是窗口管理器的命令行界面版本。它提供了统一的管理多个会话的界面和相应的功能。
列出当前所有的session
screen -ls
回到yourname这个session
screen -r yourname
远程detach某个session
screen -d yourname
结束当前session并回到yourname这个session
screen -d -r yourname
杀死某个session
screen -X -S <PID> quit
进入screen会话后,可在会话中创建多个窗口(window),并对窗口进行管理,管理命令以ctrl + a开头。
ctrl + a + c:创建新窗口(create)
ctrl + a + n:切换至下一个窗口(next)
ctrl + a + p:切换至上一个窗口(previous)
ctrl + a + w: 列出所有窗口
ctrl + a + A: 窗口重命名
ctrl + a + [1-9]: 切换到指定窗口(1-9为窗口号)
ctrl + d:退出(关闭)当前窗口
ctrl + a + d:detach当前会话给后台 回到主会话
tcpdump
Linux上的抓包工具,可以抓出包后放在wireshark上可视化解析
sudo tcpdump -nnX -s 0 -w /home/spinq/tcpdump/test.cap 2>&1 &
sudo tcpdump -X -s 0 -w /home/spinq/tcpdump/test.notip.cap 2>&1 &
$(ps aux | grep tcpdump | awk '{print $2}' | xargs sudo kill -9)
20. grep
grep 指令用于查找内容包含指定的范本样式的文件,如果发现某文件的内容符合所指定的范本样式,预设 grep 指令会把含有范本样式的那一列显示出来
对于通过日志debug非常有用
可以结合head
或tail
来查找文件中最先/最后符合搜索条件的n行
$ grep "onMessage" task-INFO.log | head -n 5
[com.example.controller.MachineController 2021-07-27 00:00:00.651] INFO Method: onMessage(Line 65) - ============== Enter MachineController - onMessage ==============
[com.example.controller.MachineController 2021-07-27 00:00:00.658] INFO Method: onMessage(Line 66) - machineCode = 1, sessionId = 3
[com.example.controller.MachineController 2021-07-27 00:00:00.658] INFO Method: onMessage(Line 67) - Receive message string {"commandType": "updateMachineStatus", "machineStatus": "AVAILABLE", "timestamp": "2021-07-26T16:00:01.1069Z", "machineCode": "1", "platformCode": "platform1"}
[com.example.controller.MachineController 2021-07-27 00:00:00.659] INFO Method: onMessage(Line 93) - Request after parsing = MachineRequest(machineCode=1, platformCode=platform1, timestamp=Tue Jul 27 00:00:01 CST 2021, machineStatus=AVAILABLE, commandType=updateMachineStatus, taskResultRequest=null, stageUpdateRequest=null)
[[com.example.controller.MachineController 2021-07-27 00:00:00.659] INFO Method: onMessage(Line 110) - ============== Exit MachineController - onMessage ==============
$ grep "onMessage" task-INFO.log | tail -n 5
[com.example.controller.MachineController 2021-07-27 09:58:22.533] INFO Method: onMessage(Line 65) - ============== Enter MachineController - onMessage ==============
[com.example.controller.MachineController 2021-07-27 09:58:22.533] INFO Method: onMessage(Line 66) - machineCode = 1, sessionId = 3
[com.example.controller.MachineController 2021-07-27 09:58:22.533] INFO Method: onMessage(Line 67) - Receive message string {"commandType": "updateMachineStatus", "machineStatus": "AVAILABLE", "timestamp": "2021-07-27T01:58:23.1181Z",, "machineCode": "1", "platformCode": "platform1"}
[com.example.controller.MachineController 2021-07-27 09:58:22.533] INFO Method: onMessage(Line 93) - Request after parsing = MachineRequest(machineCode=1, platformCode=platform1, timestamp=Tue Jul 27 09:58:23 CST 2021, machineStatus=AVAILABLE, commandType=updateMachineStatus, taskResultRequest=null, stageUpdateRequest=null)
[[com.example.controller.MachineController 2021-07-27 09:58:22.557] INFO Method: onMessage(Line 110) - ============== Exit MachineController - onMessage ==============
-c
: 计算符合样式的列数
$ grep -c "onMessage" task-INFO.log
197076
-n
: 在显示符合样式的那一行之前,标示出该行的列数编号
$ grep "onMessage" task-INFO.log | tail -n 5
1058154:[com.example.controller.MachineController 2021-07-27 09:58:22.533] INFO Method: onMessage(Line 65) - ============== Enter MachineController - onMessage ==============
1058155:[com.example.controller.MachineController 2021-07-27 09:58:22.533] INFO Method: onMessage(Line 66) - machineCode = 1, sessionId = 3
1058156:[com.example.controller.MachineController 2021-07-27 09:58:22.533] INFO Method: onMessage(Line 67) - Receive message string {"commandType": "updateMachineStatus", "machineStatus": "AVAILABLE", "timestamp": "2021-07-27T01:58:23.1181Z",, "machineCode": "1", "platformCode": "platform1"}
1058160:[com.example.controller.MachineController 2021-07-27 09:58:22.533] INFO Method: onMessage(Line 93) - Request after parsing = MachineRequest(machineCode=1, platformCode=platform1, timestamp=Tue Jul 27 09:58:23 CST 2021, machineStatus=AVAILABLE, commandType=updateMachineStatus, taskResultRequest=null, stageUpdateRequest=null)
1058161:[com.example.controller.MachineController 2021-07-27 09:58:22.557] INFO Method: onMessage(Line 110) - ============== Exit MachineController - onMessage ==============
-e
: 寻找符合正则表达式的关键词
$ grep -e "onMessage.*Enter" task-INFO.log | head -n 5
[com.example.controller.MachineController 2021-07-27 00:00:00.651] INFO Method: onMessage(Line 65) - ============== Enter MachineController - onMessage ==============
[com.example.controller.MachineController 2021-07-27 00:00:02.104] INFO Method: onMessage(Line 65) - ============== Enter MachineController - onMessage ==============
[com.example.controller.MachineController 2021-07-27 00:00:02.249] INFO Method: onMessage(Line 65) - ============== Enter MachineController - onMessage ==============
[com.example.controller.MachineController 2021-07-27 00:00:02.655] INFO Method: onMessage(Line 65) - ============== Enter MachineController - onMessage ==============
[com.example.controller.MachineController 2021-07-27 00:00:04.243] INFO Method: onMessage(Line 65) - ============== Enter MachineController - onMessage ==============
-r
: 递归检索文件夹
$ grep -r "task" backup-2021-06 | head -n 5
backup-2021-06/console_2021-06-22_00.log.gz:[com.example.task.dto.TaskQueue 2021-06-21 09:31:58.187] INFO Method: hasTaskProcessingByMachine(Line 171) - ============== Enter isProcessingByMachine with mid = 1 ==============
backup-2021-06/console_2021-06-22_00.log.gz:[com.example.task.dto.TaskQueue 2021-06-21 09:31:58.187] INFO Method: hasTaskProcessingByMachine(Line 180) - ============== Exit isProcessingByMachine with mid = 1 and reuslt = false ==============
backup-2021-06/console_2021-06-22_00.log.gz:[com.example.task.service.TaskMachineService 2021-06-21 09:31:58.188] INFO Method: assignToMachine(Line 175) - ============== Enter assignToMachine ==============
backup-2021-06/console_2021-06-22_00.log.gz:[com.example.task.dto.TaskQueue 2021-06-21 09:31:58.188] INFO Method: hasTaskProcessingByMachine(Line 171) - ============== Enter isProcessingByMachine with mid = 2 ==============
backup-2021-06/console_2021-06-22_00.log.gz:[com.example.task.dto.TaskQueue 2021-06-21 09:31:58.188] INFO Method: hasTaskProcessingByMachine(Line 180) - ============== Exit isProcessingByMachine with mid = 2 and reuslt = false ==============
21. 设置软连接
# source为源文件,target为想要产生的链接
sudo ln -fs <source> <target>
sudo ln -fsn <source_dir> <target> # 包含文件夹
22. ps查看进程信息
ps的参数比较多,最常使用的格式如下
ps aux
显示所有包含其他使用者的行程,返回的格式信息为
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME CMD
ps -aux
的用法其实不正确,其真正意义为打印用户名为"x"的用户的所有进程。一些版本的系统会在用户名为x的用户不存在时直接将命令转义为ps aux
且打出一个警告。而新版Mac则会直接报错
ps: No user named 'x'
ps -ef
显示所有进程信息,连同命令行,返回的格式信息为
UID PID PPID C STIME TTY TIME CMD
ps -ef | grep mysqld. #查看mysql进程pid
ps -u <username>
查看特定用户进程
网友评论