Useful Commands/System Management: Difference between revisions

From Fundamental Ramen
Jump to navigation Jump to search
(Created page with "{| class="wikitable" ! 情境 || 指令 |- | 顯示CPU資訊 || <source lang="bash"> cat /proc/cpuinfo </source> |- | 顯示記憶體資訊 || <source lang="bash"> cat /proc/...")
 
 
(18 intermediate revisions by the same user not shown)
Line 1: Line 1:
== OS Management ==
123
== TODO ==
{| class="wikitable"
{| class="wikitable"
! 情境 || 指令
! 情境 || 指令
|-
|-
| 顯示CPU資訊 ||  
| List process ||
<source lang="bash">
<syntaxhighlight lang="bash">
ps -axo pid,command
ps -axo pid,command | awk 'match($2, /^ssh/) { print $0; }'
ps -axo pid,command | awk 'match($2, /^login/) { print $0; }'
ps -axo pid,command | awk 'match($2, /^-?bash/) { print $0; }'
</syntaxhighlight>
|-
| List process tree ||
<syntaxhighlight lang="bash">
pstree 713
pstree $(ps -axo pid,command | awk 'match($2, /^login/) { print $1 }')
</syntaxhighlight>
|-
| CPU & Memory ||
<syntaxhighlight lang="bash">
# Linux
cat /proc/cpuinfo
cat /proc/cpuinfo
</source>
|-
| 顯示記憶體資訊 ||
<source lang="bash">
cat /proc/meminfo
cat /proc/meminfo
</source>
|-
| 釋放記憶體並且顯示記憶體資訊 ||
<source lang="bash">
free
free
</source>
sudo dmidecode --type 17,19,20
|-
</syntaxhighlight>
| 執行一個工作,同時輸出到畫面上也寄到信箱 ||
<source lang="bash">
# TODO
ls -l | tee ${SSH_TTY} | ???
</source>
|-
| 查詢應用程式預設值 (OSX) ||
<source lang="bash">
defaults find {關鍵字} <nowiki>|</nowiki> less
</source>
|-
| 讀取應用程式預設值 ||
<source lang="bash">
defaults read {關鍵字} <nowiki>|</nowiki> less
</source>
|-
|-
| 檢查使用中的語系 ||
| Locale ||
<source lang="bash">
<syntaxhighlight lang="bash">
locale
locale         # current locale
</source>
locale -a       # available locales
|-
sudo locale-gen # rebuild locales
| 檢查可使用的語系 ||
</syntaxhighlight>
<source lang="bash">
locale -a
</source>
|-
| 重建語系定義檔 ||
<source lang="bash">
sudo locale-gen
</source>
|-
| 變更使用者語系 ||
<source lang="bash">
 
</source>
|-
|-
| 一分鐘後執行指令 ||
| Run a command one minute later ||
<source lang="bash">
<syntaxhighlight lang="bash">
echo "ls -l > `tty`" | at now + 1 minute
echo "ls -l > `tty`" | at now + 1 minute
</source>
</syntaxhighlight>
|}
|}

Latest revision as of 20:23, 3 April 2025

OS Management

123

TODO

情境 指令
List process
ps -axo pid,command
ps -axo pid,command | awk 'match($2, /^ssh/) { print $0; }'
ps -axo pid,command | awk 'match($2, /^login/) { print $0; }'
ps -axo pid,command | awk 'match($2, /^-?bash/) { print $0; }'
List process tree
pstree 713
pstree $(ps -axo pid,command | awk 'match($2, /^login/) { print $1 }')
CPU & Memory
# Linux
cat /proc/cpuinfo
cat /proc/meminfo
free
sudo dmidecode --type 17,19,20
Locale
locale          # current locale
locale -a       # available locales
sudo locale-gen # rebuild locales
Run a command one minute later
echo "ls -l > `tty`" | at now + 1 minute