Chapter 1 Flashcards

1
Q

List Files and Directories

A

ls

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

List All Files

A

ls -a

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

List Files in Long Form

A

ls -l

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

List Files with Human Readable Sizes

A

ls -h

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

List files, sorted by size

A

ls -S

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

List files, sorted by last modified time

A

ls -t

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

List files, reverse sorted

A

ls -r

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

Hard links vs a symbolic link?

A

Hard links create an identical copy of the linked file on disk, that gets updated automatically as the source file gets updated. That means if the content of the source is changed, so will the target file.

Unfortunately hard links do not work for directories. To create a link to a directory, we can use the -s flag to create a symbolic link. This can also be used for linking to files as well, not just directories.

Symbolic links can also link to files or directories on other file systems.

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

Link from source to linked file

A

ln a.txt b.txt

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

Force a link to be created

A

ln -f a.txt b.txt

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

Create a symbol link

A

ln -s a.txt b.txt

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

Navigate up a directory

A

cd ..

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

Navigate to home directory

A

cd

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

Create a directory

A

mkdir foo

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

Create intermediate directories

A

mkdir -p a/b/c

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

Create directory with verbose output (useful in shell scripts)

A

mkdir -v a

17
Q

Copy a single file

A

cp a.txt b.txt

18
Q

Copy multiple files

A

cp a.txt b.txt foo
or
cp *.txt foo

Last argument must be a directory

19
Q

Copy with verbose output

A

cp -v a.txt b.txt

20
Q

Copy a directory’s contents

A

cp -R foo bar

21
Q

Force copying of a file, e.g. if you don’t have permission to do so.

A

cp -f a.txt b.txt

22
Q

Copy with confirmation of overwriting each file

A

cp -i a.txt b.txt

23
Q

Delete a file, with verbose output

A

rm -v a.txt

24
Q

When would you use cp followed by rm, instead of only mv?

A

This can be useful when trying to move a file across file systems, as the mv command doesn’t support that.

25
Q

How would you find all the files in your home directory that contain an underscore?

A

ls -a ~ | grep _

26
Q

How would you write output from a command to a file?

A

ls -a ~ | grep _ > underscores.txt

27
Q

How would you read from a file and send it to a command?

A

cat