Shell Flashcards
https://www.datacamp.com/courses/introduction-to-shell-for-data-science
Which command lets you find out where you are in the filesystem?
pwd
Which command lets you list the content of your directory?
ls
Which command lets you list the content of a specific directory?
ls /path/to/file
What is the conceptual difference between asbolute and relative paths?
An absolute path is like a latitude and longitude: it has the same value no matter where you are.
A relative path, specifies a location starting from where you are: it’s like saying “20 kilometers north”.
How does the shell decide if a path is relative or absolute?
An absolute path starts with a /.
A relative path doesn’t.
Which command lets you move around the filesystem?
cd
What is the parent of a directory?
The parent of a directory is the directory above it. For example, /home is the parent of /home/repl, and /home/repl is the parent of /home/repl/seasonal.
Which special path corresponds to the one above the one you’re currently in?
..
Which path is the root directory?
/
Which path corresponds to the current directory?
.
Which path corresponds to the home directory?
~
Which command lets you copy files?
cp path/original.txt path/duplicate.txt
How do you copy several files to a directory?
cp original1.txt original2.txt path/to/directory
Which command lets you move files from on directory to another?
mv path/to/file1.txt path/to/file2.txt path/to/directory
Which command lets you rename a file?
mv old_name.txt new_name.txt
Which command lets you remove files?
rm file/to/file1.txt file/to/file2.txt
What happens if you move or copy to an existing filename?
The original file with that filename is overwritten.
Which command lets you remove an empty directory?
rmdir directory_name
Which command lets you create a directory?
mkdir directory_name
Where should you store files and programs you only need briefly?
/temp
Which command lets you look at the content of files?
cat file1.txt file2.txt
When printing the content of a file, how do you go to the next page?
Press the spacebar
When printing the content of a file, how do you quit?
Press q
When printing the content of several files, how do you move to the next file?
Type :n
When printing the content of several files, how do you move to the previous file?
Type :p
When printing the content of several files, how do you quit?
Type :q
Which command lets you print the first 10 lines of a csv file?
head file.csv
What are command-line flags?
They are a way to specify options for command-line programs. For example, head -n 5 file.csv specifies head should print 5 lines instead of the default 10.
By convention, where should command-line flags be placed?
By convention, command-line flags should be placed before any filenames.
How do you display everything that is underneath directory?
ls -R
When listing files, how do you make it clear which ones are directory names and which ones are runnable programs?
ls -F
Which command lets you obtain documentation on a specific command?
man command
Which command lets you display columns?
cut
When selecting columns, which flag lets you specify the column delimiter?
-d ,
(for columns separated by commas)
When selecting columns, which flag lets you specify the columns or range of columns to select?
-f 1-4 7
(columns 1 to 4 and 7)
When displaying the content of a file, how do you skip the first x lines?
-n +x
Which command lets you display a list of commands you have run recently?
history
How do you rerun your most recent use of a command?
!command