Managing Files Flashcards

(91 cards)

1
Q

basic skills for managing files

A
  • create
  • delete
  • move
  • rename
  • archive
  • manipulate via scripts
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Restrict non-alphanumeric characters in file naming to…

A

_

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

Special use characters for filenames

A
*
?
/
\
"
`
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

True or False: Linux filenames are case-insensitive

A

False

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

Special filenames

A
  • single dot (.) refers to current directory

- double dot (..) refers to parent directory

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

wildcard ?

A

stands for a single character

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

wildcard *

A

matches zero or more characters

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

wildcard []

A

match any character in the set of characters within the square brackets

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

wildcard range

A

match any character within the range

i.e. b[a-z]ck matches back, buck, and other four letter names

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

common file manipulation commands

A
  • ls
  • cp
  • mv
  • rm
  • touch
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

command ls

A

syntax: ls [OPTION]… [FILE]…

- displays the names of files in a directory

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

ls switches

A
  • a displays all files including dot files
  • -color produces color-coded listing differentiating directories, symbolic links, files, and more
  • d lists only directory name
  • l long listing including information such as the file’s permission string owner, group, size, and creation date
  • f appends an indicator code to end of each name to display type of file
  • r displays sub-contents recursively
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

command cp

A
  • copies and with wildcards

syntax: cp [OPTION]… SOURCE… DIRECTORY

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

cp switches

A
  • a archive option similar to -R but preserves ownership and copies links
  • f force without prompting
  • i prompt before overwrite
  • p preserves ownership and permissions if possible
  • r copy directories recursively
  • u copy only when the SOURCE file is newer than the destination file or when the destination file is missing
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

command mv

A

move - commonly used to move files and directories from one location to another or to rename them
syntax: mv [OPTION]… SOURCE… DIRECTORY

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

mv switches

A
  • b back up destination file like –backup but does not accept an argument
  • f do not prompt before overwriting
  • i prompt before overwrite
  • n do not overwrite an existing file
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

options which do not apply to mv

A
  • -preserve
  • -recursive
  • -archive
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

best practice for mv command

A

use trailing slash (/) to avoid typos like renaming a file instead of moving to a directory
(i.e.
mv document.doc important/purchases/ moves to directory
mv document.doc important/puchases renames to purchases)

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

command rm

A

remove

syntax: rm {options] files

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

rm switches

A
  • r recursive, will remove each listed directory along with contents
  • d remove empty directories
  • f force no prompt

note: by default rm does not remove directories.

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

command touch

A

set modification and access time to current time

syntax: touch [options] files

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

touch switches

A
  • a access time
  • m modification time
  • c do not create file
  • t specify a timestamp
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

common file archiving commands

A
  • tar
  • cpio
  • Dd
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

command tar

A
  • tape archiver
  • tar [options] Archive File
    (i. e. tar cvfz /media/document.tgz /my_archive)
  • without z, no compression
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
tar switches
- c create a new archive - v verbose list of processed files - f following is archive name - z filter archive through gzip
26
tarball
files rolled up into one package
27
command cpio
copy files to and from archives - cpio [options] archive (i. e. find ./my-work | cpio -o | gzip > /media/archivename
28
cpio switches
- o create , copy out mode - i extract, copy in mode - p pass-through, combines copy-out and copy-in
29
command Dd
low level copying program to copy input device file to output file - dd [options] backs up entire partition including empty space, which means removed files still remaining on disk are copied (removing a file initially only removes pointer to that file)
30
dd switches
- if=inputFile | - of=outputFile
31
links
- links are like shortcuts, giving a file multiple identities - hard links - soft links (symbolic links)
32
command ln
manage links | syntax: ln [options] sourceFile linkName
33
ln switches
- f force remove any existing files that have the target link name - i interactive prompt before replacing existing files and links - s create symbolic link
34
command mkdir
syntax: mkdir [options] directoryName(s)
35
mkdir switches
- m mode causes new directory to have a specified permission expressed as an octal number - p creates parent directories
36
rmdir
not as good as rm -r
37
foundations of security
- file ownership | - file permissions
38
two tiers of file ownership
- individual | - group
39
assess file ownership
ls -l
40
file creator gets what permission
individual owner of file
41
command chown
- superuser can use this to change a file's owner - syntax: chown [options] [newowner][:newgroup] filenames - cannot emit both newowner and newgroup
42
command chgrp
- root and ordinary users can use this to change a file's group - regular users may only change the group to a group in which they reside - syntax: chgrp [options] newgroup filenames
43
command chmod
- modify file's permissions - syntax: chmod [options] [mode[,mode...]] filename - octal or symbolic modes - octal permissions for setting an absolute permission - symbolic permissions for making a simple change or changes to many files without affecting other permissions
44
command chattr
alters attributes of a file | syntax: chattr [ -RVf ] [ -v version ] [ mode ] files
45
set default mode and group
umask
46
expression of a permission as a number
- 9-bit number | - 3 base-8 numbers, each 3 bits in length
47
execute bit is used differently by...
- directories - allows searching of directory contents -
48
set user ID (SUID)
used along with executable files, forces linux to run program with permissions of the owner rather than permissions of the user who runs the program
49
set group ID (SGID)
runs a program in the context of the group of the file
50
execute bit is used differently by...
- directories | - allows searching of directory contents
51
indentifier of a SUID program
's' in the owner's execute bit of the permission string (i.e. rwsr-xr-x)
52
identifier of a SGID program
's' in the group's execute bit position in the permission string (i.e. rwxr-sr-x)
53
acl
access control list | - replaces group to allow us to apply multiple permissions
54
default group
user's primary group
55
command umask
- configure default permissions - most distributions use a default umask of 002 or 022 - umask -s produces the umask expressed symbolically - syntax: umask [symbols] or umask [numeric expression] (i.e. umask u-x,g=r,o+w or umask 022)
56
chattr switches
- a sets append mode, allowing only writing that appends to document - c compressed mode, kernal compresses written data and uncompresses when read - i immutable mode, can't be deleted, links to it can't be created, and file can't be renamed - j data journaling for all data written to file - s secure deletion, kernel zeros the data blocks upon deletion
57
linux quota system
disk space limits for individual users and groups
58
quota system requirements
- filesystem support - enabling option via kernel - modify /etc/fstab entries for every partition - add usrquota filesystem mount to employ user quotas - add grpquota option to use group quotas
59
filesystems which support quota system
- ext2fs - ext3fs - reiserfs - jfs - xfs
60
set a quota
- edquota | starts the Vi editor on a temporary config file (/etc/quotatab)
61
soft quota and grace period
warning about limit for a grace period, beyond which user is set back to their soft limit forcibly without necessarily reaching the hard quota
62
FHS
Filesystem Heirarchy System is a standard to define the layout of files on unix-like OSs
63
important directories
- /boot - /etc - /sbin - /bin - /lib - /usr - /usr/local - /usr/X11r6 - /opt - /home - /root - /var - /tmp - /mnt - /media - /dev - /proc
64
/ directory
root
65
/boot directory
static and unshareable files related to the low level initial booting of the computer
66
/etc directory
higher level startup and config files, usually pointing to services
67
/bin directory
critical executable files accessible to all users and constitute the most important command to use
68
/bin directory
critical executable files accessible to all users and constitute the most important command to use
69
/sbin directory
programs normally run only by admin
70
/lib directory
contains program libraries | - /lib/modules contains a subset of kernel modules
71
/usr directory
hosts all computer programs, shareable and static, can be mounted read-only and shared with other users
72
/usr/local directory
- hosts files that an admin installs locally, safe from automatic software upgrades - can be split off on own partition to protect from OS reinstallation
73
/usrx11r6 directory
files related to the x window system
74
/opt directory
like /usr, hosts readymade packages that don't ship with the OS, static and shareable
75
/home directory
hosts user specific data
76
/root directory
home directory for root user
77
/var directory
hosts transient files, often put in its own partition except on user workstation
78
/tmp directory
- hosts temporary files created by programs | - often good to put in its own partition to easily cleanup after troubled programs
79
/mnt directory
mount removable media
80
/media directory
like /mnt but with subdirectories for specific media types
81
/dev directory
hosts device files
82
/proc directory
virtual filesystem mostly read only and used for hardware info typically
83
common tools for locating files
- find - locate - whereis - which - type
84
common tools for locating files
- find - locate - whereis - which - type
85
command find
- brute force | - slow but flexible and reliable
86
command locate
- find file by name only - database, so faster but must be updated (updatedb) - slocate doesn't find files you don't have permission to see
87
command whereis
- searches for files only in standard binary file directories, library directories, and man page directories - ignores many user directories
88
command which
- searches your path for the command you tupe and lists the first match's complete path
89
command type
shows how a file will be interpreted by the system | syntax: type [command]
90
hard link
- duplicate directory entries that both point to the same inode and hence to the same file - Must reside on a single filesystem
91
symbolic link
- special files that point to another file or directory by name - May point across filesystems