Chapter 2 - Flashcards
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.
First make sure you are in the home folder or root directory.
find -user jack -group humanr -size 500k
Type out the command to make these 3 directories. dir1 favs backup2019
mkdir dir1 favs backup2019
The cp command can be used in 2 different ways. Explain and type out the commands.
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)
Why use option -a with the cp command?
cp -a file1 file2 blahfolder
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.
Explain option -v when using the cp command.
cp -v file1 file2 blahfolder
-v is the verbose option.
It displays informative messages as the copy is performed.
Explain the wildcard in this command.
cp dir1/* dir2
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)
Explain how to use the mv command.
Which command is it very similar to?
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
Explain the rm command.
Why should you be extra careful with wildcards.
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 .
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?
- i Asks for a confirmation before deleting.
- r Deletes a directory and all of its contents.
Explain a soft link / symbolic link .
How would you type it out?
- 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.
Explain a hard link.
How would you type it out?
- 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.
Explain the type command.
Gives you a brief description on the command. and gives you the location of the command.
type cd
type cat
type ls
Explain - -help
Displays a brief description of the commands supported syntax and options.
Not all commands support the - -help option.
Explain whatis and type out the command.
whatis Gives a one line description of the command.
whatis cat
With using the pipe command, how would you type 4 commands on one line?
pad; cd dir1; ls -l; cd