Skip to main content
Engineering LibreTexts

01-B.19: Leftovers, What Else Do We Need?

  • Page ID
    26795
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

    \( \newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\)

    ( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\)

    \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)

    \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\)

    \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)

    \( \newcommand{\Span}{\mathrm{span}}\)

    \( \newcommand{\id}{\mathrm{id}}\)

    \( \newcommand{\Span}{\mathrm{span}}\)

    \( \newcommand{\kernel}{\mathrm{null}\,}\)

    \( \newcommand{\range}{\mathrm{range}\,}\)

    \( \newcommand{\RealPart}{\mathrm{Re}}\)

    \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)

    \( \newcommand{\Argument}{\mathrm{Arg}}\)

    \( \newcommand{\norm}[1]{\| #1 \|}\)

    \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)

    \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    \( \newcommand{\vectorA}[1]{\vec{#1}}      % arrow\)

    \( \newcommand{\vectorAt}[1]{\vec{\text{#1}}}      % arrow\)

    \( \newcommand{\vectorB}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vectorC}[1]{\textbf{#1}} \)

    \( \newcommand{\vectorD}[1]{\overrightarrow{#1}} \)

    \( \newcommand{\vectorDt}[1]{\overrightarrow{\text{#1}}} \)

    \( \newcommand{\vectE}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash{\mathbf {#1}}}} \)

    \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

    \(\newcommand{\avec}{\mathbf a}\) \(\newcommand{\bvec}{\mathbf b}\) \(\newcommand{\cvec}{\mathbf c}\) \(\newcommand{\dvec}{\mathbf d}\) \(\newcommand{\dtil}{\widetilde{\mathbf d}}\) \(\newcommand{\evec}{\mathbf e}\) \(\newcommand{\fvec}{\mathbf f}\) \(\newcommand{\nvec}{\mathbf n}\) \(\newcommand{\pvec}{\mathbf p}\) \(\newcommand{\qvec}{\mathbf q}\) \(\newcommand{\svec}{\mathbf s}\) \(\newcommand{\tvec}{\mathbf t}\) \(\newcommand{\uvec}{\mathbf u}\) \(\newcommand{\vvec}{\mathbf v}\) \(\newcommand{\wvec}{\mathbf w}\) \(\newcommand{\xvec}{\mathbf x}\) \(\newcommand{\yvec}{\mathbf y}\) \(\newcommand{\zvec}{\mathbf z}\) \(\newcommand{\rvec}{\mathbf r}\) \(\newcommand{\mvec}{\mathbf m}\) \(\newcommand{\zerovec}{\mathbf 0}\) \(\newcommand{\onevec}{\mathbf 1}\) \(\newcommand{\real}{\mathbb R}\) \(\newcommand{\twovec}[2]{\left[\begin{array}{r}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\ctwovec}[2]{\left[\begin{array}{c}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\threevec}[3]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\cthreevec}[3]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\fourvec}[4]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\cfourvec}[4]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\fivevec}[5]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\cfivevec}[5]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\mattwo}[4]{\left[\begin{array}{rr}#1 \amp #2 \\ #3 \amp #4 \\ \end{array}\right]}\) \(\newcommand{\laspan}[1]{\text{Span}\{#1\}}\) \(\newcommand{\bcal}{\cal B}\) \(\newcommand{\ccal}{\cal C}\) \(\newcommand{\scal}{\cal S}\) \(\newcommand{\wcal}{\cal W}\) \(\newcommand{\ecal}{\cal E}\) \(\newcommand{\coords}[2]{\left\{#1\right\}_{#2}}\) \(\newcommand{\gray}[1]{\color{gray}{#1}}\) \(\newcommand{\lgray}[1]{\color{lightgray}{#1}}\) \(\newcommand{\rank}{\operatorname{rank}}\) \(\newcommand{\row}{\text{Row}}\) \(\newcommand{\col}{\text{Col}}\) \(\renewcommand{\row}{\text{Row}}\) \(\newcommand{\nul}{\text{Nul}}\) \(\newcommand{\var}{\text{Var}}\) \(\newcommand{\corr}{\text{corr}}\) \(\newcommand{\len}[1]{\left|#1\right|}\) \(\newcommand{\bbar}{\overline{\bvec}}\) \(\newcommand{\bhat}{\widehat{\bvec}}\) \(\newcommand{\bperp}{\bvec^\perp}\) \(\newcommand{\xhat}{\widehat{\xvec}}\) \(\newcommand{\vhat}{\widehat{\vvec}}\) \(\newcommand{\uhat}{\widehat{\uvec}}\) \(\newcommand{\what}{\widehat{\wvec}}\) \(\newcommand{\Sighat}{\widehat{\Sigma}}\) \(\newcommand{\lt}{<}\) \(\newcommand{\gt}{>}\) \(\newcommand{\amp}{&}\) \(\definecolor{fillinmathshade}{gray}{0.9}\)

    Before We Move On

    Just a few more points to cover before we move on.

    Shutdown/Reboot

    Those who come from the world of Windows systems are used to having to reboot the system at various times. While Linux does not suffer from the frequency of reboots that Windows seems to, there are still times when Linux need to be powered off, or simply rebooted. Current distros are better at dealing with being shut down by a user hitting the power off button on their computer, BUT, that is never the recommended method. It is best to perform an orderly shutdown, and for that there is the shutdown command and a reboot command.

    A couple of the more common invocations of shutdown:

    • shutdown -h
      • The  -h option tells shutdown to halt the system, that is, to power it off after an orderly shutdown.
    • shutdown -h -t 60
      • The system will shut down after the specified time delay - in this example the delay is 60 seconds
    • shutdown -r
      • If a reboot is desired, the -r option is available. You can also issue the reboot command from the terminal to achieve the same resultsBash History

    The bash shell comes with a very powerful command called “history.” This command is used to extract the history information about commands that have been executed by the user including all previous login sessions. Linux stores the command history for each user in a file ~/.bash_history by default.

    As each command is issued, it is recorded in the history file. The history command reads the history file and displays the contents to the terminal screen. You can see an example of the output in the image to the left. This history is set up to record 2000 entries, so you will be able to view the previous 2000 commands you enter, and the history file is persistent between login sessions.

    pbmac@pbmac-server $ history
     2000  ./"HW-01" 
     2001  journalctl
     2002  ls /var/log/journal/
     2003  ls -l /var/log/journal/
     2004  ls -l /var/log/journal/75d57d2bcd2831ebf58bcc1a000008d4/
     2005  journalctl -x
     2006  journalctl 
     2007  journalctl -x
     2008  last
     2009  lastlog
     2010  man dar
     2011  cd /usr/share/man
     2012  ls
     2013  cd man8
     2014  cd ../man1
     2015  ls tar*
    

    To access previous commands you can use the UpArrow and DownArrow to find the command you wish to re-issue. Often it is a matter of a typo - use the arrow keys to find the command, then use the left/right arrow keys to move your cursor and use the backspace or delete keys to remove characters and type in the correct input.

    There is much more that can be done with history in regards to command recall and command editing. There are several web sites and blogs that discuss this topic in great detail. Search for "bash history" and find one that works for you.

    Shell Tricks

    TAB completion saves typing. The completion feature in Bash permits typing a partial command, then pressing the [Tab] key to auto-complete the command sequence. If multiple completions are possible, then [Tab] lists them all. Let's see how it works.

    bash$ xtra[Tab]
    xtraceroute       xtrapin           xtrapproto
    xtraceroute.real  xtrapinfo         xtrapreset
    xtrapchar         xtrapout          xtrapstats
    
    bash$ xtrac[Tab]
    xtraceroute       xtraceroute.real
    
    bash$ xtraceroute.r[Tab]
    xtraceroute.real

    There is a clear command, which clears your terminal window. Sometimes things get cluttered, and to ease reading the terminal you can use the clear command to clean up your workspace.

    Use your history - see the previous section.

    Adapted from:
    "Appendix J. An Introduction to Programmable Completion" by David Merrill is licensed under CC BY-SA 3.0


    This page titled 01-B.19: Leftovers, What Else Do We Need? is shared under a CC BY-SA 4.0 license and was authored, remixed, and/or curated by Patrick McClanahan.

    • Was this article helpful?