Linux
Bash: Interactive Shell
49 flashcards · answers and spaced-repetition review in the KnowCard app
You launched a long command but forgot the &, and it's tying up your terminal. How do you push it to the background without killing it?
What is the difference between what a terminal program does and what a shell like bash does?
What does the name Bourne Again Shell (bash) actually refer to, and which classic Unix shells is it related to?
You open a terminal and want to confirm which shell and version you are running before debugging a script. Which two commands tell you?
Where is a Linux user's default login shell stored, and how do you change it permanently?
Your script works when you run it directly but fails when invoked via /bin/sh on Debian or Ubuntu. What is the likely cause?
You want to add a permanent alias and extend your PATH for interactive use. Which config file is almost always the right place?
What is the division of labor between the profile files, the bashrc files, and /etc/environment for setting up a shell?
What do the inputrc files configure, and which bash subsystem do they affect?
Both a login shell and an interactive terminal shell accept your commands interactively — so what actually distinguishes a login shell?
Which environment variable defines the content of your bash prompt, and where do you set it just for yourself?
In a PS1 prompt string, what is the difference between the \w and \W placeholders?
Besides PS1, which variable lets you run a command automatically every time the prompt is about to appear?
You pressed the up arrow and saw commands from a previous session. Where does bash keep that history and when is it saved?
A Vi user finds bash line editing uses Ctrl+A / Ctrl+E style keys. How do they switch bash to Vi editing?
In bash line editing, what do Ctrl+A, Ctrl+E, Ctrl+K, and Ctrl+Y each do?
A program is running in the foreground and you want it to keep running but hand the terminal back. Which key do you press, and how is that different from Ctrl+C?
You typed a few letters of a command and pressed Tab, but nothing completed — only a beep. What does pressing Tab a second time do?
When bash completes a command name versus a file name with Tab, which directories does it search in each case?
You want to know exactly which program runs when you type a command, and also whether it might be a built-in or alias. How do whereis, which, and type differ?
Beyond completing plain file names, how does bash know that after latex only *.tex files, or after man only pages with help texts, are valid completions?
You just ran cp report.txt report.bak and now want to rm the copy without retyping its name. Which shortcut inserts the last-used parameter?
You know you ran a long command earlier but can't recall it exactly. How does Ctrl+R help, and how do you cycle through matches?
You pressed Ctrl+S to search history and the terminal appeared to freeze. What happened and how do you both recover and prevent it?
What does the alias command define, and which part of a command line does the substitution apply to?
You defined alias more=less but now genuinely need the real more. How do you bypass the alias?
You defined an alias in your terminal but it's gone after you log out. Why, and how do you make it stick?
Whenever you run rm it keeps prompting to confirm each deletion, even without the -i flag. What is usually the cause?
What are the three standard files (file descriptors) every bash command works with, and what is each connected to by default?
You redirected a command's output with > file but the error messages still appeared on screen. Which operators redirect errors, or both streams together?
What is the difference between > and >> when redirecting to a file, and which variant appends both output and errors?
You run sort file > file to sort a file in place, and end up with an empty file. Why does this destroy the data, and what fixes it?
What does a pipe with the | character actually do between two commands?
A pipe connects two commands started together. How is a FIFO (named pipe) different, and when is it useful?
You want to save a long-running command's output to a file but still watch it scroll on screen. Which command does both, and where can it sit in a pipe?
What is the difference in behavior between cmd1; cmd2, cmd1 && cmd2, and cmd1 || cmd2?
You wrote a script in your current directory but typing its name gives command not found. Why, and how do you run it?
When you start a background job with &, bash prints something like [1] 3345. What do the two numbers mean?
You want the combined output of two commands (ls and date) redirected into one file. Why does wrapping them in parentheses work?
In the bash special-character table, what do ; and : (colon) each do, and how does . (dot) relate to source?
What does the << delimiter operator (a heredoc) do, and how does it differ from < file?
What do backticks around a command do, and what is the modern equivalent?
You need to type a very long command and want to break it across multiple lines. How do you do that, and what signals that bash is still waiting for the rest?
Beyond Ctrl+A / Ctrl+E for start and end of line, which bash (emacs-mode) shortcuts let you move and edit by whole words, swap text, clear the screen, or undo?
How do you make your bash prompt appear in color, and what is the general form you embed in PS1 to do it?
A command with wildcards and variables isn't behaving as expected, and you want to see exactly how bash expands and parses it before running. Which option turns that on?
You pipe find's output into ls -l, but ls just lists the current directory and ignores the piped list. Why, and which command makes ls act on that input?
Passing file names from find to xargs breaks when some names contain spaces. Which two options make the hand-off space-safe?
The bash config-file table lists /etc/bashrc, .bash_profile, and .bash_login — but which files actually get read differs on Debian and Ubuntu. What are the two distribution-specific twists?
Start learning today
Free to start — download the app or use it in your browser.
