Skip to content

Shell Commands

Each shell has its own set of commands that it understands, but they all follow the same general format. Commands are broken into words (separated by spaces) with the first word being the command or program to run, and subsequent words being passed to the program as arguments for it to use.

Illustration of shell commands

Run as admin (sudo)

Operating systems restrict some actions to admin users, particularly when the actions will change the behaviour of the system. In Unix, you can use the sudo shell command to get the superuser to do something. You follow the sudo command with the details of the command you want to do.

Example

The following are some example shell commands. Lines starting with a # are comments, so these are ignored by the shell program. We use them here to explain how each shell command is structured.

Terminal window
# the ls command with flags -l -h and -a
ls -l -h -a
# shorthand for the above, with -lha
ls -lha
# cd command, with a folder path as an argument
cd /c/Users/andrew/Documents/Code
# mkdir command with Project1 as an argument
mkdir Project1
# dotnet program with 2 arguments: new and console
dotnet new console
# dotnet program with 3 arguments: add, package, and splashkit
dotnet add package splashkit
# clang++ program with 5 arguments: test.cpp, -o, test, -l, SplashKit
# -o and test are linked (test is the value for the -o option)
# -l and splashkit are linked (splashkit is the value for this -l)
clang++ test.cpp -o test -l SplashKit