Just a few weeks until the 2021 JavaScript Full-Stack Bootcamp opens.
Signup to the waiting list!
Your computer is running, at all times, tons of different processes.
You can inspect them all using the ps
command:
This is the list of user-initiated processes currently running in the current session.
Here I have a few fish
shell instances, mostly opened by VS Code inside the editor, and an instances of Hugo running the development preview of a site.
Those are just the commands assigned to the current user. To list all processes we need to pass some options to ps
.
The most common I use is ps ax
:
The
a
option is used to also list other users processes, not just our own.x
shows processes not linked to any terminal (not initiated by users through a terminal).
As you can see, the longer commands are cut. Use the command ps axww
to continue the command listing on a new line instead of cutting it:
We need to specify
w
2 times to apply this setting, it’s not a typo.
You can search for a specific process combining grep
with a pipe, like this:
ps axww | grep "Visual Studio Code"
The columns returned by ps
represent some key information.
The first information is PID
, the process ID. This is key when you want to reference this process in another command, for example to kill it.
Then we have TT
that tells us the terminal id used.
Then STAT
tells us the state of the process:
I
a process that is idle (sleeping for longer than about 20 seconds)
R
a runnable process
S
a process that is sleeping for less than about 20 seconds
T
a stopped process
U
a process in uninterruptible wait
Z
a dead process (a zombie)
If you have more than one letter, the second represents further information, which can be very technical.
It’s common to have +
which indicates the process is in the foreground in its terminal. s
means the process is a session leader.
TIME
tells us how long the process has been running.
This command works on Linux, macOS, WSL, and anywhere you have a UNIX environment
Download my free Linux Commands Handbook
The 2021 JavaScript Full-Stack Bootcamp will start at the end of March 2021. Don't miss this opportunity, signup to the waiting list!
More cli tutorials:
- The Bash shell
- Introduction to Bash Shell Scripting
- The Fish Shell
- Shell, watch file content as it populates
- How to exit Vim
- UNIX Editors
- The UNIX Filesystem Commands
- Unix Shells Tutorial
- How to set an alias in a macOS or Linux shell
- A practical guide to Homebrew
- How to fix the xcrun invalid active developer path error in macOS
- The Command Line for Complete Beginners
- Introduction to Linux
- How to find the process that is using a port
- Linux commands: mkdir
- Linux commands: cd
- Linux commands: pwd
- Linux commands: rmdir
- Linux commands: ls
- Linux commands: mv
- Linux commands: cp
- Linux commands: less
- Linux commands: tail
- Linux commands: touch
- Linux commands: cat
- Linux commands: find
- Linux commands: ln
- Linux commands: ps
- Linux commands: echo
- Linux commands: top
- Linux commands: kill
- Linux commands: killall
- Linux commands: alias
- Linux commands: jobs
- Linux commands: bg
- Linux commands: fg
- Linux commands: type
- Linux commands: which
- Linux commands: whoami
- Linux commands: who
- Linux commands: clear
- Linux commands: su
- Linux commands: sudo
- Linux commands: chown
- Linux commands: chmod
- Linux commands: passwd
- Linux commands: open
- Linux commands: wc
- Linux commands: history
- Linux commands: du
- Linux commands: umask
- Linux commands: grep
- Linux commands: man
- Linux commands: uname
- Linux commands: sort
- Linux commands: uniq
- Linux commands: diff
- Linux commands: nohup
- Linux commands: df
- Linux commands: xargs
- Linux commands: gzip
- Linux commands: gunzip
- Linux commands: ping
- Linux commands: traceroute
- Linux commands: tar
- Linux commands: export
- Linux commands: crontab
- Linux commands: dirname
- Linux commands: basename
- Linux commands: printenv
- Linux commands: env
- A short guide to the ed editor
- A short guide to vim
- A short guide to emacs
- A short guide to nano
- Linux, no space left on device
- How to use Netcat
- How to use pm2 to serve a Node.js app