Skip to content

Instantly share code, notes, and snippets.

@kezzico
Last active November 10, 2023 21:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kezzico/8b43df52d3771291ff203b3503ad748c to your computer and use it in GitHub Desktop.
Save kezzico/8b43df52d3771291ff203b3503ad748c to your computer and use it in GitHub Desktop.

What is a Shell?

Sometimes called a command prompt or terminal.app, the shell is an interface to the kernel. A shell can be a GUI (Graphical User Interface), but for the purposes of this guide the shell will only refer to a command line shell. I use a standard POSIX shell.

A seashell

Windows users, checkout WSL. Also, Visual Studio Code is a great tool for Windows, Mac, and Linux users. Just hit Ctrl+` to open a shell.

Common Shell Programs & Params

List every process currently running on the system. Each Process is identified by a PID. Use the PID to reference it in other commands.

ps -A

Background (bg) / Foreground (fg) a process.

bg <PID>

fg <PID>

bg 1234

fg 888

To terminate or stop a process use kill. If it won't die. Add the -9 parameter

kill <PID>

kill -9 1337

Each of these programs (ps,fg,bg,kill) are in the system path. If they weren't, you would need to enter the full path to the program to start it. To find out whether a program is installed in your system path, and to find out where it is use the which command.

which ps

On my system, ps is installed at /bin/ps. If I enter /bin/ps -A it's functionally the same as writing ps -A into the shell. This is because of a variable called $PATH. To see the value of the variable let's use the echo command.

echo $PATH

These are all the directories on your system that are checked for programs. The shell can conveniently access these binaries without the user needing to provide a full path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment