Linux Flashcards
sudo !!
Runs the previous command, with sudo
.
In general, the two exclamation marks refer to the previous command you just ran.
cd -
Returns to the previous working directory
pushd
popd
pushd
changes into the new directory and pushes the current working directory to a stack.
popd
brings one of the items out of the stack and changes into it
ctrl + z
fg
ctrl + z
sends an app to the background, effectively minimizing it.fg
brings that app out.
ctrl + r
Searches through the commands previously ran. Pressing ctrl + r
again will go to the next best match.
history
Shows the command history.
!
Runs a previously ran command from history. In the Linux world, the exclamation mark is often referred to as bing
.
HISTCONTROL=ignoreboth
If you assign ignoreboth
to this variable, your can prevent commands from showing up in history by adding a space in the beginning,
HISTTIMEFORMAT=”%Y-%m-%d %T “
If you assign “%Y-%m-%d %T “ to this variable, commands stored in the history will have a specific time assigned to them. This could be placed in .bashrc
. The space at the end is for formatting.
cmatrix
A package and a command to show a Matrix-inspired screen saver sort of thing.
ctrl + u
Clears the line.
ctrl + a
Puts the cursor all the way to the front of the line.
ctrl + e
Takes the cursor to the end of the line.
What is the difference between changing commands with ;
and &&
?
When you chain commands with a semicolon, all the commands will run even if one or more of them fail.
On the other hand, when you chain commands with the double ampersand, if it encounters an error it will not run subsequent commands.
tail -f
Shows the content of a file (a log file for example) and updates if anything new is added to the file.