Command Line Flashcards
What if the UNIX Shell?
Both a command-line interface (CLI) and a scripting language
What is the function of the UNIX shell
A better GUI alternative that allows repetible tasks to be done automatically and fast. Tasks that takes the GUI hours will take the shell seconds.
What is the shell?
A program where users can type commands ranging from complicated climate modeling software to simple file creations
What is the most popular UNIX Shell
Bash (Bourne Again Shell)
What are scripts? Purpose?
Sequences of commands written using the grammar of a shell to improve the reproducibility of workflows.
Examples of the shell abilities?
Can be used to interact with remote machine and super computers. It can also be used to tackle scientific questions and computational challenges.
What is $? What to do and not?
This is the shell’s prompt typically. Do not type the prompt, only the commands after it. Press enter to execute it.
What is the [ls] command and what does it mean?
[ls] - short for listing. This lists the contents of the current directory
What happens when shells can’t find ur command?
$ (command): command not found
What are the shells main disadvantages?
The shell’s main disadvantages are its primarily textual nature and how cryptic its command and operations can be.
What is the file system?
The part of the OS responsible for managing files and directories.
Current working directory
Directories are like places. At any time we r using the shell we are exactly in one this.
Why knowing ur current working directory is important?
Command mostly read and write files in the current working directory
What is the [pwd] command?
Shows you where you are
What is the [cd] command?
Navigates you to ur home directory
[/]
Root directory that hold everything else it’s the leading slash in ur home directory
What other directories are inside the root directory?
[bin], [data], [Users], and [tmp] etc.
Function of the [bin]
This is where some built-in programs are stored.
Functions of [data]
(For miscellaneous data files)
Functions of the [Users] directories
It’s where the user’s personal directories are located.
Functions of the [tmp] directory ?
For temporary files that don’t need to be stored longterm
The seconding meaning of the slash?
When it appears inside a path, it’s just a separator
Where are user Imhotep files stored in?
They are stored in all user’s directory
[ -F] option
Tells [ls] to classify the output by adding a marker to file and directory names to indicate what they are.
What does this [/] indicate as a marker by a file?
A trailing [/] indicates that this is a directory.
What does this [@] indicate as a marker by a file?
Indicates a link
What does this [*] indicate as a marker by a file?
Indicates an executable
What are plain old files?
Any names in the output without a classification
What are sub-directories?
Directories under the main directories under the root
How to clean a cluttered terminal?
[clear] command
How to access previous commands?
Up and down to retrieve past lines
How to find out what options a command have and what it does?
[ —help]
What is the error for unsupported option?
ls: invalid option — ‘j’
Try ‘ls —help’ for more information
Another way to find out what options a command have and what it does?
[man ls]
What does [man ls] do differently?
Turns ur terminal into a page with a description of the command and its option.
How to search for something in the [man] page?
use [/] followed by the character or word you are searching for.
How to quit the [man] page?
Press [Q]
[ -l] option function
Long list format of the file and directory names
With details like file size and last time or modification
[ -h] option function
Makes the file size/(numbers) human readable. 5.3K instead of 5369
In what order does [ls] list the contents?
Alphabetically
How does the [ -t] option for the ls command arrange the directory?
By the time it was last edited
How does the [ -r] option for the ls command arrange the directory?
Reverse order
How to get a listing of something other then our CWD? Name the parts.
[ls -F desktop]
[ls] - lists stuff
[ -F] - option
[ Desktop] - argument
What does argument do as used in [ls -F Desktop]?
The argument [Desktop] sets a parameter. Tells [ls] that we want a listing of something other than our current working directory.
How to look at the contents of a sub-directory of non-cwd in ur cwd?
[ls -F argument/name of directory
Describe the cd progression?
To change the shells cwd u use [cd]
You can only go down into the directory tree within the cwd or to the home directory
How to go up a directory tree?
[cd . . ]
[cd . .] meaning?
Special directory meaning the directory containing this one. The parent of the cwd.
How to show the special [ . .] when u run [ls]?
add [ a] option to [ls -F]
What does the special directory [.] mean?
CWD
Purpose of the hidden [ .bash_profile]
For file configuration settings. Files and directories with the [.] prefix before them are to prevent the config files from cluttering the terminal.
How to go down 3 steps down the directory levels with one command line?
[cd directory name/sub/sub]
This can go down for as long as there is a sub directory to access
How does the shell interprets the tilde ([~]) character?
Means the current user Cwd
=/Users/user’s name/data
How does the shell interprets the tilde ([-]) character?
Translate into the previous directory u were in
[$ ls -F / ]
[$ ] - Prompt
[ls] - Command
[ -F] - Option
[ /] - Argument
What is the functions of arguments?
Tell the command what to operate on (e.g files and directories)
Another name for arguments
Parameters
How many option and argument in a command?
Multiple
Do commands require always parameters?
No
Switch/flags
Options and mostly those that take no argument
What is the command sensitive about?
Case and Space sensitive
What does an absolute file specify?
A location from the root of the file system
What does a relative path specify?
Location starting from the current location
What is the command to make a directory?
[mkdir]