Useful Commands/System Management: Difference between revisions

From Fundamental Ramen
Jump to navigation Jump to search
No edit summary
 
Line 9: Line 9:
|-
|-
| List process ||
| List process ||
<source lang="bash">
<syntaxhighlight lang="bash">
ps -axo pid,command
ps -axo pid,command
ps -axo pid,command | awk 'match($2, /^ssh/) { print $0; }'
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, /^login/) { print $0; }'
ps -axo pid,command | awk 'match($2, /^-?bash/) { print $0; }'
ps -axo pid,command | awk 'match($2, /^-?bash/) { print $0; }'
</source>
</syntaxhighlight>
|-
|-
| List process tree ||
| List process tree ||
<source lang="bash">
<syntaxhighlight lang="bash">
pstree 713
pstree 713
pstree $(ps -axo pid,command | awk 'match($2, /^login/) { print $1 }')
pstree $(ps -axo pid,command | awk 'match($2, /^login/) { print $1 }')
</source>
</syntaxhighlight>
|-
|-
| CPU & Memory ||  
| CPU & Memory ||  
<source lang="bash">
<syntaxhighlight lang="bash">
# Linux
# Linux
cat /proc/cpuinfo
cat /proc/cpuinfo
Line 29: Line 29:
free
free
sudo dmidecode --type 17,19,20
sudo dmidecode --type 17,19,20
</source>
</syntaxhighlight>
|-
|-
| Locale ||
| Locale ||
<source lang="bash">
<syntaxhighlight lang="bash">
locale          # current locale
locale          # current locale
locale -a      # available locales
locale -a      # available locales
sudo locale-gen # rebuild locales
sudo locale-gen # rebuild locales
</source>
</syntaxhighlight>
|-
|-
| Run a command one minute later ||
| 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