Updates to terminal commands

This commit is contained in:
Kenneth John Odle 2026-02-07 15:29:13 -05:00
parent 90c5a9521f
commit 1fb4a0ab27
2 changed files with 13 additions and 2 deletions

View File

@ -56,3 +56,4 @@ Date,Topic,Minutes
2026.01.31, more edits to ch 4, 148 2026.01.31, more edits to ch 4, 148
2026.01.31, proofreading, 60 2026.01.31, proofreading, 60
2026.02.01, terminal commands, 405 2026.02.01, terminal commands, 405
2026.02.04, terminal commands, 35
1 Issue #6
56 2026.01.31, proofreading, 60
57 2026.02.01, terminal commands, 405
58 2026.02.04, terminal commands, 35
59

View File

@ -223,10 +223,20 @@ mv cat.txt animals/mammals/bat.txt
The command in line 1 simply renames the file ``cat.txt'' to ``bat.txt'' and leaves it in the same directory. The command in line 2 moves the file ``cat.txt'' to the subdirectory ``mammals'' which is located in the subdirectory ``animals'' which itself is a subdirectory of the current directoy. The third command is a combination of the first two: it both moves the ``cat.txt'' file and also renames it as ``bat.txt''. The command in line 1 simply renames the file ``cat.txt'' to ``bat.txt'' and leaves it in the same directory. The command in line 2 moves the file ``cat.txt'' to the subdirectory ``mammals'' which is located in the subdirectory ``animals'' which itself is a subdirectory of the current directoy. The third command is a combination of the first two: it both moves the ``cat.txt'' file and also renames it as ``bat.txt''.
\paragraph{rmdir} \paragraph{rmdir} To remove a directory, just use the \texttt{rmdir} command. There is one caveat with this command, however: the directory must be empty, because this command only works on empty directories.
\paragraph{rm} To remove a file, use the \texttt{rm} command which does take wildcards. For example, this command:
\begin{Verbatim}[]
rm *.log
\end{Verbatim}
will remove \textit{all} files in your current directory that have a \texttt{.log} extension. The \texttt{rm} command doesn't have a \texttt{stdout}; if it is successful in deleting the file or files it was directed to delete, it just exits quietly without saying anything. And unlike just about every GUI out there, the Linux command line does not have a trash can or recycling bin that deleted files go to. When you delete a file using \texttt{rm}, it's just gone forever, and there is no easy way to get it back.\footnote{You \textit{can} recover the contents of a deleted file if you have the right tools and you just deleted it, but that's pretty advanced stuff. It's better to not delete things you are unsure of and to keep backups. On the other hand, if you really want to get rid of files in a way that people with the skills and the time and inclination can recover, use the \texttt{shred} command.}
If you are accumstomed to using a GUI, and the thought of wiping out a bunch of files without having a chance to think about it makes you nervous, you can always use interactive mode.
\section{Two More Important Things} \section{Two More Important Things}
If your terminal window gets filled with text and you find that distracting (which my ADHD brain often does), just use the command \texttt{clear} to get an empty window. If your terminal window gets filled with text and you find that distracting (which my ADHD brain often does), just use the command \texttt{clear} to get an empty window.
Also, if you type a command and it starts giving you \textit{tons} of output and you realize that you've done something wrong, you can usually make it exit by typing \kkey{ctrl+d}. Depending on what command you executed, there may or may not be any damage done. Also, if you type a command and it starts giving you \textit{tons} of output and you realize that you've done something wrong, you can usually make it exit by typing \kkey{ctrl+c}. Depending on what command you executed, there may or may not be any damage done.