Sage-Code Laboratory
index<--

Shell Commands

Bash has an impresive list of builtin commands that can be used in scripts, some can be used in the console. You can find a list of all commands using this first command: man. Most of the times the operating system provide help for each command.
To find out if a command is internal or external you can use the commmand: type. If you need help for a command parameters you can type command name with parameter "-h". Sometimes this not works so you can use long option: --help, ant this should work.

Getting Help

Start the console and try some commands. If this works, you have Bash installed and you can find help for any command. If you can't run this on your PC, you can try on replit.com website. However, on this website the help for man command is not available.

console
~>bash
bash-3.2$ type man
man is /usr/bin/man
bash-3.2$ man -h
man, version 1.6g
usage: man [-adfhktwW] [section] [-M path] [-P pager] [-S list]
    [-m system] [-p string] name ...

  a : find all matching entries
  c : do not use cat file
  d : print gobs of debugging information
  D : as for -d, but also display the pages
  f : same as whatis(1)
  h : print this help message
  k : same as apropos(1)
  K : search for a string in all pages
  t : use troff to format pages for printing
  w : print location of man page(s) that would be displayed
      (if no name given: print directories that would be searched)
  W : as for -w, but display filenames only

  C file   : use `file' as configuration file
  M path   : set search path for manual pages to `path'
  P pager  : use program `pager' to display pages
  S list   : colon separated section list
  m system : search for alternate system's man pages
  p string : string tells which preprocessors to run
               e - [n]eqn(1)   p - pic(1)    t - tbl(1)
               g - grap(1)     r - refer(1)  v - vgrind(1)
bash-3.2$ 

List of commands

Is out of scope in this tutorial to post help for Bash commands. You can find this in reference manuals. Here we list all the commands we found so far in the documentation of Bash 7.3 in alphabetic order with a short description.

Command Description
: Returns a zero exit value
. Reads and executes commands from a file parameter and then returns.
break Exits from the enclosing for, while, or until command loops, if any.
cd Changes the current directory to the specified directory.
continueResumes the next iteration of the enclosing for, while, or until command loops.
echo Writes character strings to standard output.
eval Reads the arguments as input to the shell and executes the resulting command or commands.
exec Executes the command specified by the Argument parameter, instead of this shell, without creating a new process.
exit Exits the shell whose exit status is specified by the n parameter.
export Marks names for automatic export to the environment of subsequently executed commands.
hash Finds and remembers the location in the search path of specified commands.
pwd Displays the current directory.
read Reads one line from standard input.
readonlyMarks name specified by Name parameter as read-only.
return Causes a function to exit with a specified return value.
set Controls the display of various parameters to standard output.
shift Shifts command-line arguments to the left.
test Evaluates conditional expressions.
times Displays the accumulated user and system times for processes run from the shell.
trap Runs a specified command when the shell receives a specified signal or signals.
type Interprets how the shell would interpret a specified name as a command name.
ulimit Displays or adjusts allocated shell resources.
umask Determines file permissions.
unset Removes the variable or function corresponding to a specified name.
wait Waits for the specified child process to end and reports its termination status.

Using the Commands

You can learn and use the commands one by one when you need them. An effective ussage of commands require understanding of computer architecture, operating system design and file system. These things are explained in previous chapters of Software Engineering. I asume you know these topics.

You can learn how to use each command in the: Commands for AIX, documentation listed by IBM. I advise you to study this list in details and memorise several most important commands. In next articles we will use examples for some of these commands.


Read next: Command Groups