Exercise: Working with the Shell
Try these shell commands at the prompt. Many of these commands have extensive optional arguments.
Display $PATH, the value of the PATH variable
The PATH
environment variable stores designated paths to executables;
as a result, these executables can be executed without reference to their full paths. Commonly used paths are added to this environment variable by the system at startup.
Later we will see how to add additional paths to the environment variable. Executables in directories included in $PATH
are often referred to as being "in the path" of the current shell.
$ echo $PATH
/usr/local/bin:/usr/bin:/bin
List the available shells in the system
The cat
(concatenate)
command is a standard Linux utility that concatenates and prints the content
of a file to standard output (shell output). In this case, shells is
the name of the file, and /etc/ is the pathname of the directory where
this file is stored.
$ cat /etc/shells
/bin/sh
/bin/bash
/sbin/nologin
/usr/bin/sh
/usr/bin/bash
/usr/sbin/nologin
/bin/tcsh
/bin/csh
/usr/bin/tmux
/bin/ksh
/bin/rksh
/bin/zsh
Find the current date and time of the system
Use the date
command.
$ date
Fri Nov 9 19:23:23 CST 2018
List all of your own current running processes
Use the ps
command (process status).
In Linux, each process is associated with a PID
or process identifier.
$ ps
PID TTY TIME CMD
916 pts/58 00:00:00 bash
1531 pts/58 00:00:00 ps