Chapter 2 - Flashcards

1
Q

How would you use the find command to find a file that belongs to the user jack, in group humanr and has a file size of 500kb. Please type out the command.

A

First make sure you are in the home folder or root directory.

find -user jack -group humanr -size 500k

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

Type out the command to make these 3 directories. dir1 favs backup2019

A

mkdir dir1 favs backup2019

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

The cp command can be used in 2 different ways. Explain and type out the commands.

A

Can copy a file or directories into another file or directory.
cp item1 item2

Copies multiple files or directories into a directory.
cp item1 item3 logs backup2019

(Keep in mind directories must already be created)

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

Why use option -a with the cp command?

cp -a file1 file2 blahfolder

A

The option -a copies the files and directories original attributes like ownership and permissions.

Normally copying takes on the attributes of the person doing the copying.

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

Explain option -v when using the cp command.

cp -v file1 file2 blahfolder

A

-v is the verbose option.

It displays informative messages as the copy is performed.

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

Explain the wildcard in this command.

cp dir1/* dir2

A

The /* will copy all files in dir1 into dir2
(Keep in mind it will Not copy directories found in dir1, just files.)
(Keep in mind dir2 must already exist)

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

Explain how to use the mv command.

Which command is it very similar to?

A

mv command is used in much the same way as the cp command.

mv can both move files and rename them.

mv file1 file2

mv file1 file2 dir2

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

Explain the rm command.

Why should you be extra careful with wildcards.

A

rm is used to remove/delete files and directories. Remember once deleted it’s gone for good.

If you want to delete all the html files, you type. rm *.html But if you accidentally place a space between the * and .html (like so * .html ) you’ll delete all the files in the directory and get an no file called .html error.

Useful tip: test the wildcard with the ls command, press up arrow to recall the command and replace ls with rm .

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

What rm option asks you for a confirmation before deleting the file?

What rm option let’s you delete a directory and all of its contents?

A
  • i Asks for a confirmation before deleting.

- r Deletes a directory and all of its contents.

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

Explain a soft link / symbolic link .

How would you type it out?

A
  • A symbolic link (aka soft link) works just like a windows shortcut link. It’s a pointer to the original file.
  • Symbolic link file sizes are usually smaller then the original file size.
  • A file can have more then one symbolic link.
  • Once the original file or directory is deleted or moved the link doesn’t work anymore.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Explain a hard link.

How would you type it out?

A
  • A hard link is just like a Copy of the original file (remember a soft link is like a short cut). It also has the same file size.
  • If the original file gets deleted the hard link still works.
  • You can’t create a hard link for a directory.
  • Hard links must live in the same disk partition.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Explain the type command.

A

Gives you a brief description on the command. and gives you the location of the command.

type cd

type cat

type ls

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

Explain - -help

A

Displays a brief description of the commands supported syntax and options.

Not all commands support the - -help option.

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

Explain whatis and type out the command.

A

whatis Gives a one line description of the command.

whatis cat

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

With using the pipe command, how would you type 4 commands on one line?

A

pad; cd dir1; ls -l; cd

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

How do you create your own alias command?

A

alias blah=‘ ls -l; cd /usr; ls -l ‘

To see our alias command use type blah

To remove our alias unalias blah

alias are automatically removed once we end the shell session.