Viewing and changing the file system Flashcards

1
Q

$ ls

A

Will “list” the files and folders in the current directory/specified directory.

Common Options;
-a list all contents including hidden files.
-l list contents in long format.
long format includes: file permissions, hard links, file owner, group owner, file size, date last modified and file name.
-t order files and folders by the time they were last modified.

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

$ mkdir

A

“make directory” takes the name or path of a directory you would like to create.

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

$ touch

A

takes the name or path of a new file you would like to create. If the file already exists the modification time stamp will be updated.

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

$ cat

A

Takes the name or path of a file and outputs its contents to the terminal.

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

$cp

A

The cp command takes the name or path of a file and copies it from one destination to another.
command format:
$ cp source.txt destination.txt

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

Wildcards

A

A wildcard is a special character used to represent one or more characters in a search pattern.
In addition to using exact filenames as arguments, we can use special characters like * to select groups of files.

cp examples:
cp * my_directory/
This will copy all files in the working directory to my_directory.

cp *.txt my_directory/
To copy just the ‘.txt’ files you can use a wild card with a suffix:

cp w*.txt my_directory/
Will copy all files that start with w and have a .txt extension.

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

$mv

A

“Move” is simular to cp in how it works except the file is not copied it is simply moved.
$mv my_file.txt my_directory/

moving multiple files.
mv my_file_1.txt my_file_2.txt my_directory/

mv can also be used to rename a file.
$mv file_original.txt file_renamed.txt

wildcard example
$mv * school/
mv takes the first argument * to mean all the files in the current directory, and moves them to the destination school/ specified by the second argument.

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

$rm

A

The rm command deletes files and directories.
$rm unwanted_file.txt

The -r (recursive) option is used to delete a directory and all of its child directories.
$rm -r unwanted_directory

wildcard
$rm my_directory/*
deletes all the files in the directory.

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