Chapter 1: Exploring Linux Command-Line Tools Flashcards
shell
A program that interprets text commands and provides an interface to the system, e.g. bash in terminal.
Environment Variables
Placeholders for for data that may be useful to many programs
bash
Most common default shell
sh
The original Bourne shell which bash is based off of, and not often used
tcsh
Based on the C shell (csh), fairly popular
ksh
The Korn shell, designed to combine the best features of sh and csh
zsh
Tries to extend ksh
Default Interactive Shell
The shell a user uses to enter commands, run run programs, run shell scripts, etc., from command line.
Default System Shell
Used to run system shell scripts, typically at startup
/bin/sh
A file that points to the system’s default system shell (normally bin/bash)
uname -a
Shows the operating system being run, along with hostname and kernel version
Built-In Commands
Commands built into the shell program, AKA internal commands
time
Command that tells you how long commands take to execute, e.g. time pwd tells you how long pwd takes to execute
set
Displays options relating to bash shell operation.
Can also change options if specified.
exit and logout
exit terminates any shell, and logout terminates only login shells
type ____
Checks if a command is internal or external
type -a ____
Same as type, but checks to see if there are both internal and external versions of the command
path
A list of directories in which commands can be found
How to Search for a Previously Done Command
Ctrl+R then type what you’re looking for.
Ctrl+S to search forward if you pass what you were looking for
If Ctrl+S not working when searching for a command, what command should you use to fix it?
stty -ixon
How to exit searching for a command?
Ctrl+G
How to move to beginning of line?
Ctrl+A
How to move to end of line?
Ctrl+E
How to move through a line one word at a time?
Ctrl+Left or Right Arrow
Backspace vs. Delete
Backspace deletes the character to the left of the cursor, while Delete deletes the character under the cursor
How to delete all text from cursor to the end of the line?
Ctrl+K
How to delete all text from cursor to beginning of the line?
Ctrl+X then Backspace
How to transpose letters or words?
Ctrl+T
How to change a word to uppercase? lowercase?
Esc then U
Esc then L
How to change a single letter to uppercase?
Esc then C
How to bring up an editor of the command on the line?
Ctrl+X then Ctrl+E
How to retrieve the last command and execute it?
!!
How to clear the command history?
history -c
How to execute a command by number?
! followed by the number
What is the name of the file where command history is stored?
.bash_history
What does an environment variable look like?
$VAR
How to view all environment variables?
env
How to delete an environment variable?
unset
How to search man pages?
man -k along with your keyword in quotes
whatis database
Contains a short description of each man page
How to create or update the whatis database?
makewhatis
man section 1
Executable programs and shells
man section 2
System calls provided by the kernel
man section 3
Library calls provided by program libraries
man section 4
Device Files
man section 5
File formats
man section 6
Games
man section 7
Miscellaneous
man section 8
System administration commands
man section 9
Kernel routines
An alternative to man
info
What are the pages about the built in commands called?
help pages
Stream
A data entity that can be manipulated
>
Creates a new file containing STDOUT
> >
Appends STDOUT to an existing file
2>
Creates a new file containing STDERR
2»
Appends STDERR to the existing file
&>
Creates a new file containing STDOUT and STDERR
Sends the contents of the specified file to be used at STDIN
Accepts text on the following lines as STDIN
Causes the specified file to be used as both STDIN and STDOUT
What is the file you redirect output to if you want to get rid of it?
/dev/null
here document
Takes text from subsequent lines as standard input
How do you indicate that you are done with typing input when you use the
EOF
(pipe)
Redirects the first program’s standard output to the second programs standard input