Chapter 4 - Managing Files Flashcards
A few characters have special meaning and should never be used in filename. There are 5 of them:
4-179
Asterisk Question mark Forward slash Backslash Quotation mark
What is the limit on filename length?
4-179
255 characters (255 bytes)
Talking about dots and directories. If your current directory is /home/jerry, what does “.” And “..” refer to?
4-179
. = /home/jerry (current directory) .. = /home (parent directory)
What is a wildcard?
4-180
Symbol or set of symbols that stands in for other characters
What are the 3 classes of wildcards?
4-180
Question mark – single character
Asterisk – matches any character, set of characters, no character
Bracketed values – these characters match any characters in the set
When you are understanding file commands, there are 5 everyday commands that are CRITICAL. Tell me what they are:
4-180
List Copy Move Rename Delete
Tell me the syntax for the list command
4-180
ls [options] [files]
if you do the ls command as ls –a or ls –all, what will happen?
4-181
You’ll see the configuration files (begin with a .)
If you do the ls command as ls –r or ls –recursive, what will happen?
4-182
You’ll display the target directory’s files AND all of its subdirectories.
Tell me the syntax for the copy command.
4-183
cp [options] source destination
if you do a cp –R, what will happen?
4-184
You’ll copy the directory and all its subdirectories
What is the syntax for the move command?
4-185
mv [options] source destination
what’s the command for deleting a file? What’s the syntax for it?
4-186
rm
rm [options] files
in linux, there are 3 time stamps for every file. Tell me what they are:
4-187
Last file-modification time
Last inode change time
Last access time
What does the “make” utility do?
4-187
Compiles a program from source code
What do you use the “touch” command for?
4-187
Modifying the time stamps
There are several commands you can use for archiving files. Tell me what they are.
4-187
tar
cpio
dd
the tar utility has 7 commands you should know. What are they and what do they do?
4-188
Create – c – creates an archive
Concatenate – A – appends tar files to an archive
Append – r – appends non tar files to an archive
Update – u – appends files that are newer than those in an archive
Diff (or compare) – d – compares an archive to files on disk
List – t – lists an archive’s contents
Extract (or get) – x – extracts files from an archive
What do qualifiers do?
4-188
They modify what commands do.
What are the 6 most useful qualifiers and what do they do?
4-189
g – perform incremental backup p – keep permissions z – use gzip compression j – use bzip2 compression J – use xz compression v – be verbose
there are 3 compression tools used with the tar command. Tell me what they are and whether they apply compression to the archive file or to the individual files of the archive file.
4-189
gzip
bzip2
xz
They apply compression to the whole archive file.
Of the 3 compression tools, which one offers the best compression? What is something that is compressed by it?
4-190
xz
The linux kernel
Tell me the syntax for tar archiving.
4-190
tar [options] destination/tar_file_name files-to-archive
if you use the tar command to archive data, what command do you use to restore data from archive file or media device?
4-191
cpio
the cpio utility has 3 modes. Tell me what they are.
4-191,192
Copy out mode –o, this creates an archive and copies files into it
Copy in mode –i, this extracts data from an existing archive
Copy-pass mode –p, it combines the copy-out and copy-in
There are options for use with cpio. They are listed below, tell me their abbreviations and what they do.
- Reset-access-time
- Append
- Pattern-file=filename
- File=filename
- Format=format
- No-absolute-file-names
- List
- Unconditional
- Verbose
4-192,193
- Resets the access time after reading a file so that it doesn’t appear to have been read
- Appends data to an existing archive
- Uses the contents of filename as a list of files to be extracted in copy-in mode
- Uses filename as the cpio archive file; if this parameter is omitted, cpio uses standard input or output
- Uses a specified format for the archive file (bin, crc, and tar)
- uses the filename specified by filename instead of standard output
- desplays a table of contents for the input
- replaces all files without first asking for verification
- displays filenames as they’re added to or extracted from the archive
What do you have to do in order to use cpio to archive a directory?
4-193
You have to pipe the standard output of the find utility into the cpio command.
In linux, what is a link?
4-195
It is a way to give a file multiple identities.
What are the two types of links?
4-195
Hard links and symbolic links. Hard links are produced by creating two directory entries that point to the same file. The only difference is that one of the filenames was created before the other.
Symbolic links are special file types, they are separate files whose contents point to the linked-to file.
Show me the difference in creating hard and symbolic links via commands.
4-196,197
ln afile.txt hlink_afile
ln –s bfile.txt slink_bfile
what does the mkdir command do?
4-198
Creates a directory
What does the rmdir command do?
4-198
Destroys a directory
You want to use the ls command to show ownership and permission information. How do you modify the command?
4-199
ls –l
which command allows you to change a file’s owner?
4-200
chown
which command allows you to change a file’s group?
4-200
chgrp
for a file, there are special bits called permission bits. For example, when you do ls –l test, the first part of the returned message is –rwxr-xr-x. the first character has special meaning. What does that first character tell you?
4-201
The file type code
There are 7 file type codes which are part of the access control string when the –l option is used on ls. Tell me what they are.
- d l p s b c
4-201
normal data file directory symbolic link named pipe socket block device character device
how many bits does it take to represent the main linux permission options?
4-202
10
Tell me the breakdown of the access control string (what are the 10 bits for?)
4-202
1st bit – file type code
2nd, 3rd, 4th bits – owner permissions
5th, 6th, 7th bits – group permissions
8th, 9th, 10th bits – world permissions
The sum of bits adds up to a permission. What is read worth? What is write worth? What is execute worth?
4-203
Read – 4
Write – 2
Execute – 1
What is the sticky bit used for?
4-205
To protect files from being deleted by those who don’t own the files
When you change a file’s mode, what are you changing? What command allows you to do this?
4-206
Its permissions
chmod
you can specify a file’s mode in two basic forms. What are they?
4-206
Three digital octal
Symbolic
There are codes used in symbolic mode. These include the permission set code, the change type mode, and the permission to modify code. I’ll give you the name, you tell me what they mean.
Permission set codes: u, g, o, a
Change type codes: +, -, =
Permission to modify codes: r, w, x, X, s, t, u, g, o
4-207
u- owner, g- group, o- other, a- All
+- Add, – Remove, =- set equal to
r- read, w- write, x- execute, X- execute only if the file is a directory or already has execute permission, s- SUID or SGID, t- sticky bit, u- existing owner’s permissions, g- existing group permissions, o- existing other permissions
when you are setting the default mode and group, you subtract the umask from the directory permissions and file permissions. These permissions start at some number by default, what are they?
4-210
File permissions – 666
Directory permissions – 777
What are disk quotas?
4-213
Limits enforced by the OS on how many files or how much space a single user may consume.
If you are the superuser, you can turn quotas on at any time. What command do you use for this? What about for turning them off?
4-214
quotaon, quotaoff
Say that you wanted to edit sally’s quota. What command do you use? What about for a whole group?
4-215,216
edquota sally
edquota –g users
FSSTND had limitations that were becoming more and more troublesome by 1995. What new standard replaced FSSTND? What does the acronym stand for?
4-217
FHS
Filesystem Hierarchy Standard
I’m going to through some directories at you. You tell me if they are static, variable, shareable, unshareable.
/usr /opt /etc /boot /home /var/mail /var/ru /var/lock
4-218
/usr and /opt are static and shareable
/etc and /boot are static and unshareable
/home and /var/mail are variable and shareable
/var/run and /var/lock are variable and unshareable
What does / mean?
4-218
The root directory, the root filesystem.
What does /boot have?
4-218
Static and unshareable files related to the computer’s initial booting.
What does /etc have?
4-218
Higher level startup files and system configuration files that control the various programs and services offered on a system.
What is /bin for?
4-219
This directory contains critical executable files (like ls, cp and mount).
What is /sbin for?
4-219
Similar to /bin, but it contains programs that are normally run only by the system administrator.
What is /lib for?
4-219
Similar to /bin and /sbin, but it contains program libraries.
What is /usr for?
4-219
Hosts the bulk of a linux computer’s programs.
What is /usr/local for?
4-219
Contains files that a system administrator installs locally.
What is /usr/share/man for?
4-219
Stores the manual pages used by the man command.
What is /usr/X11R6?
4-219
Houses files related to the X Window System.
What is /opt for?
4-219
Similar to /usr/local, but intended for ready-made packages that don’t ship with the OS.
What is /home for?
4-220
Contains users’ data
What is /root for?
4-220
Home directory for the root user.
What is /var for?
4-220
Contains transient files of various types (system log files, print spool files, mail and news files
What is /tmp for?
4-220
When programs need to create temporary files, they can be found here.
What is /mnt for?
4-220
Mounting removable media devices within its normal directory structure.
What is /media for?
4-220
Optional part of the FHS, contains subdirectories for specific media types.
What is /dev for?
4-220
Files that function as hardware interfaces
What is /proc for?
4-221
Virtual filesystem that is created dynalically to provide access to certain types of hardware information that aren’t accessible via /dev.
It is recommended to keep certain directories on their own partition. There are 7 of them. Tell me what they are.
4-221
/boot /home /opt /tmp /usr /usr/local /var
There are directories that should NOT be on their own partition. There are 5 of them. Tell me what they are.
4-221
/bin /dev /etc /lib /sbin
There are several approaches to finding files. What commands do this? There are 4 of them
4-222,223,224
find, locate, whereis, which