235 lines
6.8 KiB
HTML
235 lines
6.8 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'; style-src 'self'; font-src 'self' data:; img-src 'self' data:; connect-src 'self'; base-uri 'self'; form-action 'self' https://defcon.social https://bsky.app;">
|
|
<meta http-equiv="X-Content-Type-Options" content="nosniff">
|
|
<link rel="stylesheet" href="../assets/css/style.css">
|
|
<link rel="icon" type="image/x-icon" href="../favicon.ico">
|
|
<script>
|
|
// Apply theme immediately to prevent flash
|
|
(function() {
|
|
const theme = localStorage.getItem('theme') ||
|
|
(window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light');
|
|
document.documentElement.setAttribute('data-theme', theme);
|
|
})();
|
|
</script>
|
|
<title>ps Cheatsheet - Cheatsheets - Launch Pad</title>
|
|
</head>
|
|
<body>
|
|
<button class="theme-toggle" id="themeToggle" aria-label="Toggle dark mode">
|
|
<svg class="theme-icon theme-icon-moon" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"></path></svg>
|
|
<svg class="theme-icon theme-icon-sun" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="display: none;"><circle cx="12" cy="12" r="5"></circle><line x1="12" y1="1" x2="12" y2="3"></line><line x1="12" y1="21" x2="12" y2="23"></line><line x1="4.22" y1="4.22" x2="5.64" y2="5.64"></line><line x1="18.36" y1="18.36" x2="19.78" y2="19.78"></line><line x1="1" y1="12" x2="3" y2="12"></line><line x1="21" y1="12" x2="23" y2="12"></line><line x1="4.22" y1="19.78" x2="5.64" y2="18.36"></line><line x1="18.36" y1="5.64" x2="19.78" y2="4.22"></line></svg>
|
|
</button>
|
|
<br/><br/>
|
|
<div class="name">
|
|
__ _______________________ _________._________________________
|
|
\_ _____/ \______ \ / _ \ / _____/ / _____/ | | \_ _____/
|
|
| __) | _/ / /_\ \ / \ ___ / \ ___ | | | __)_
|
|
| \ | | \ / | \ \ \_\ \ \ \_\ \ | |___ | \
|
|
\___ / |____|_ / \____|__ / \______ / \______ / |_______ \ /_______ /
|
|
\/ \/ \/ \/ \/ \/ \/
|
|
</div>
|
|
<div class="blog-page-header">
|
|
<div class="blog-header-content">
|
|
<a href="/cheatsheets" class="back-link" title="Back to Cheatsheets">
|
|
<svg xmlns="http://www.w3.org/2000/svg" width="42" height="42" viewBox="0 0 24 24" class="home-icon"><path fill="currentColor" d="M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z"/></svg>
|
|
</a>
|
|
<h1 class="blog-page-title">ps Cheatsheet</h1>
|
|
</div>
|
|
</div>
|
|
<div class="blog-post-container">
|
|
<div class="blog-posts-container" style="max-width: 900px; margin: 0 auto;">
|
|
<div class="blog-post">
|
|
<div class="blog-post-content">
|
|
<p><a href="index.html">← Back to cheatsheets</a></p>
|
|
<p><a href="../index.html">← Home</a></p>
|
|
<hr>
|
|
<p>ps (process status) displays information about running processes. Shows process IDs, resource usage, and command lines. Essential for system monitoring and process management.</p>
|
|
<hr>
|
|
<h2>Basic Usage</h2>
|
|
<ul>
|
|
<li>ps - List processes in current session</li>
|
|
</ul>
|
|
<ul>
|
|
<li>ps aux - All processes (BSD style)</li>
|
|
</ul>
|
|
<ul>
|
|
<li>ps -ef - All processes (System V style)</li>
|
|
</ul>
|
|
<ul>
|
|
<li>ps -e - All processes</li>
|
|
</ul>
|
|
<ul>
|
|
<li>ps -f - Full format</li>
|
|
</ul>
|
|
<ul>
|
|
<li>ps -u user - User processes</li>
|
|
</ul>
|
|
<hr>
|
|
<h2>Common Options</h2>
|
|
<ul>
|
|
<li>-a - All processes except session leaders</li>
|
|
</ul>
|
|
<ul>
|
|
<li>-e - All processes</li>
|
|
</ul>
|
|
<ul>
|
|
<li>-f - Full format</li>
|
|
</ul>
|
|
<ul>
|
|
<li>-l - Long format</li>
|
|
</ul>
|
|
<ul>
|
|
<li>-u user - User processes</li>
|
|
</ul>
|
|
<ul>
|
|
<li>-p PID - Specific PID</li>
|
|
</ul>
|
|
<ul>
|
|
<li>-C command - Command name</li>
|
|
</ul>
|
|
<ul>
|
|
<li>-x - Include processes without TTY</li>
|
|
</ul>
|
|
<hr>
|
|
<h2>Output Format</h2>
|
|
<ul>
|
|
<li>ps aux - User-oriented format</li>
|
|
</ul>
|
|
<ul>
|
|
<li>ps -ef - Full format</li>
|
|
</ul>
|
|
<ul>
|
|
<li>ps -l - Long format</li>
|
|
</ul>
|
|
<ul>
|
|
<li>ps -o format - Custom format</li>
|
|
</ul>
|
|
<ul>
|
|
<li>ps --forest - Tree format</li>
|
|
</ul>
|
|
<ul>
|
|
<li>ps --sort key - Sort by key</li>
|
|
</ul>
|
|
<hr>
|
|
<h2>Custom Columns</h2>
|
|
<ul>
|
|
<li>ps -o pid,comm,cmd - Custom columns</li>
|
|
</ul>
|
|
<ul>
|
|
<li>ps -o pid,user,%mem,%cpu - Resource usage</li>
|
|
</ul>
|
|
<ul>
|
|
<li>ps -o pid,etime,cmd - Elapsed time</li>
|
|
</ul>
|
|
<ul>
|
|
<li>ps -o pid,ppid,cmd - Parent process</li>
|
|
</ul>
|
|
<hr>
|
|
<h2>Common Examples</h2>
|
|
<h3>All Processes</h3>
|
|
<pre><code>ps aux</code></pre>
|
|
<p>List all processes with details.</p>
|
|
<h3>User Processes</h3>
|
|
<pre><code>ps -u username</code></pre>
|
|
<p>Processes for specific user.</p>
|
|
<h3>Specific Process</h3>
|
|
<pre><code>ps -p 1234</code></pre>
|
|
<p>Information about PID.</p>
|
|
<h3>Command Search</h3>
|
|
<pre><code>ps -C firefox</code></pre>
|
|
<p>Find process by command.</p>
|
|
<h3>Tree Format</h3>
|
|
<pre><code>ps --forest</code></pre>
|
|
<p>Show process tree.</p>
|
|
<h3>Custom Format</h3>
|
|
<pre><code>ps -o pid,%mem,%cpu,cmd</code></pre>
|
|
<p>Custom columns.</p>
|
|
<h3>Sort by Memory</h3>
|
|
<pre><code>ps aux --sort=-%mem | head</code></pre>
|
|
<p>Top memory consumers.</p>
|
|
<h3>Sort by CPU</h3>
|
|
<pre><code>ps aux --sort=-%cpu | head</code></pre>
|
|
<p>Top CPU consumers.</p>
|
|
<h3>Full Command</h3>
|
|
<pre><code>ps -f -p 1234</code></pre>
|
|
<p>Full command line.</p>
|
|
<h3>Elapsed Time</h3>
|
|
<pre><code>ps -o pid,etime,cmd</code></pre>
|
|
<p>Show how long process has run.</p>
|
|
<hr>
|
|
<h2>Common Fields</h2>
|
|
<ul>
|
|
<li>PID - Process ID</li>
|
|
</ul>
|
|
<ul>
|
|
<li>PPID - Parent Process ID</li>
|
|
</ul>
|
|
<ul>
|
|
<li>USER - Process owner</li>
|
|
</ul>
|
|
<ul>
|
|
<li>%CPU - CPU usage</li>
|
|
</ul>
|
|
<ul>
|
|
<li>%MEM - Memory usage</li>
|
|
</ul>
|
|
<ul>
|
|
<li>VSZ - Virtual memory size</li>
|
|
</ul>
|
|
<ul>
|
|
<li>RSS - Resident set size</li>
|
|
</ul>
|
|
<ul>
|
|
<li>TTY - Terminal</li>
|
|
</ul>
|
|
<ul>
|
|
<li>STAT - Process state</li>
|
|
</ul>
|
|
<ul>
|
|
<li>START - Start time</li>
|
|
</ul>
|
|
<ul>
|
|
<li>TIME - CPU time</li>
|
|
</ul>
|
|
<ul>
|
|
<li>COMMAND - Command line</li>
|
|
</ul>
|
|
<hr>
|
|
<h2>Tips</h2>
|
|
<ul>
|
|
<li>Use ps aux for comprehensive view</li>
|
|
</ul>
|
|
<ul>
|
|
<li>Use --sort to find resource hogs</li>
|
|
</ul>
|
|
<ul>
|
|
<li>Use --forest to see process trees</li>
|
|
</ul>
|
|
<ul>
|
|
<li>Combine with grep to filter</li>
|
|
</ul>
|
|
<ul>
|
|
<li>Use -o for custom output</li>
|
|
</ul>
|
|
<ul>
|
|
<li>Essential for system monitoring</li>
|
|
</ul>
|
|
<ul>
|
|
<li>Check STAT column for process state</li>
|
|
</ul>
|
|
<ul>
|
|
<li>Use with kill for process management</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<script async type="text/javascript" src="../blog/analytics.js"></script>
|
|
<script src="../theme.js"></script>
|
|
</body>
|
|
</html>
|
|
|