Command Line Interface/Commands (II) Flashcards

1
Q

print out just the first few lines of a file

A

head ________

(name of file)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

print out the last few lines of a file

A

tail _______

(name of file)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

print out a screen’s worth at a time of a file’s contents

A

more ________
(name of file)

Type q to leave this mode

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

When you need to enter navigation mode to read a file (up/down a line at a time, etc.), how do you this?

A

less _________
(name of file)

In this mode, you can use the up/down arrows to move a line at a time, or you can use the “fn” key + up/down arrows to move a page at a time

Type q to leave this mode

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

how do you exit/close the command line?

A

exit

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

how do you clear your screen of text

A

clear

but you can still scroll up to see everything you have typed before entered this command

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

list only certain files in your current directory

A

ls /* _______
(pattern)

ls /* or
(this will list only the files that end with the letters “or” )

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

make a set of nested directories

A

mkdir -p ______/______/_______/etc.

(list the names of all the directories you want)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

view a diagram of all your directories, sub-directories and files

A

tree _______________

(directory name you want to start the tree from)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

exit a process (infinite loop, long-running process, freeze)

A

ctrl + c

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

list all the files AND the hidden files in a directory

A

ls -a __________

(name of directory)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

find the location of a default executable

this command will show the path to the file

A

which _________
(name of command)

Example:
which touch
/bin/touch

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

in your current directory, move only files that fit a pattern to another directory

A

mv . /*_____ _________
(pattern) (destination folder)

Example:
mv . /*.txt ../..

  • is the “glob operator” or “splat operator”
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

list only the hidden files in a directory

A

ls -d .*

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

move all the files from your current directory to another folder

A

mv * ____________

(destination folder)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Look at this directory and its files:

beta

- work.txt
- progress.txt

What will happen if you enter this command?

rmdir beta

A

You will get a message that says:

rmdir: beta: Directory not empty

(you can only use the “rmdir” command on a directory that is empty)