Linux Commands Flashcards
bash
Drops you to prompt
Let’s you know you’re in the bash shell
Ubuntu runs this
(mint too since it’s a variation on Ubuntu)
echo $SHELL
Shows which shell you are in by folder
$SHELL = Variable that’s stored in the shell
csh
C shell
Based around C programming language
tshell
Variation on the csh (cshell)
Why in a terminal do you see directory structure?
Linux treats everything as a file. So the folder structure is used to organize everything.
For shells, what does CLI stand for?
Command line interpreter
The shell interprets commands as instructions to give the computer
What’s the difference between internal commands and external commands?
Internal commands are anything the shell does by default. Or built into the shell.
External commands are commands that call to a third party program or runs through the shell out to a third party program.
ls -l
ls -f | more
ls -lah
LS lists the files and folders in the working directory
ls -L gives the long output. Displays file details user and group that owns them including read write permissions.
-F shows folders from files because a file doesn’t need an extension in Linux
- a show all including hidden
- h human readable, files sizes as MB etc.
- la long and show all
You can also use MAN to learn about sorting by size, etc.
MORE displays one screen at a time
pwd
Print working directory
Shows which folder you’re in currently.
Username@domain: ~
^^ this is the command prompt, what does the ~ mean?
It means we are in the home directory for that user
Example
/home/Username
Normally that would be the current working directory
cd cd by itself cd / cd /folder/folder cd ..
Change directory.
Same as windows
Cd by itself goes to home folder
cd / takes you to root
cd /directory/folder takes you directly to that directory (from the root of the folder structure)
cd .. takes you up one folder in the directory structure
What’s the difference between exit and logout?
When in a GUI, exit will log you out and close the terminal window.
When you are in a LOGON SHELL, where all you see is the command line, Logout logs you out. Doesn’t shut down system or anything else etc.
What are the ways you can pull CLI commands from a command prompt?
Can you run these commands again?
Up and down arrows to select previous commands, but when SSH’d in you may not be able to use arrow keys.
history command shows the last 500 commands
Use !501 to run the 501st command
Use !! To run the last command. Helpful when remoting in.
These are stored in a text document locally.
~/.bash_history
What does .sh_history keep a record of?
Each shell maintains its own history separate from one another.
At the prompt with a long string,
How can you move forward and backward through the arguments?
How do you move to the front or the back of the string?
Esc+F or B = jump forward or backward through the arguments
Ctrl+a or e = Jump to the front or the end of the string (like the tv show)
Helpful for when connecting remotely to a server or in a VM because arrow keys will not work.