Managing Files Flashcards

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
Q

tar switches

A
  • c create a new archive
  • v verbose list of processed files
  • f following is archive name
  • z filter archive through gzip
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

tarball

A

files rolled up into one package

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

command cpio

A

copy files to and from archives

  • cpio [options] archive
    (i. e. find ./my-work | cpio -o | gzip > /media/archivename
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

cpio switches

A
  • o create , copy out mode
  • i extract, copy in mode
  • p pass-through, combines copy-out and copy-in
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

command Dd

A

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)

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

dd switches

A
  • if=inputFile

- of=outputFile

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

links

A
  • links are like shortcuts, giving a file multiple identities
  • hard links
  • soft links (symbolic links)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
32
Q

command ln

A

manage links

syntax: ln [options] sourceFile linkName

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

ln switches

A
  • 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
34
Q

command mkdir

A

syntax: mkdir [options] directoryName(s)

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

mkdir switches

A
  • m mode causes new directory to have a specified permission expressed as an octal number
  • p creates parent directories
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
36
Q

rmdir

A

not as good as rm -r

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

foundations of security

A
  • file ownership

- file permissions

38
Q

two tiers of file ownership

A
  • individual

- group

39
Q

assess file ownership

A

ls -l

40
Q

file creator gets what permission

A

individual owner of file

41
Q

command chown

A
  • superuser can use this to change a file’s owner
  • syntax: chown [options] [newowner][:newgroup] filenames
  • cannot emit both newowner and newgroup
42
Q

command chgrp

A
  • 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
Q

command chmod

A
  • 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
Q

command chattr

A

alters attributes of a file

syntax: chattr [ -RVf ] [ -v version ] [ mode ] files

45
Q

set default mode and group

A

umask

46
Q

expression of a permission as a number

A
  • 9-bit number

- 3 base-8 numbers, each 3 bits in length

47
Q

execute bit is used differently by…

A
  • directories
  • ## allows searching of directory contents
48
Q

set user ID (SUID)

A

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
Q

set group ID (SGID)

A

runs a program in the context of the group of the file

50
Q

execute bit is used differently by…

A
  • directories

- allows searching of directory contents

51
Q

indentifier of a SUID program

A

’s’ in the owner’s execute bit of the permission string (i.e. rwsr-xr-x)

52
Q

identifier of a SGID program

A

’s’ in the group’s execute bit position in the permission string (i.e. rwxr-sr-x)

53
Q

acl

A

access control list

- replaces group to allow us to apply multiple permissions

54
Q

default group

A

user’s primary group

55
Q

command umask

A
  • 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
Q

chattr switches

A
  • 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
Q

linux quota system

A

disk space limits for individual users and groups

58
Q

quota system requirements

A
  • 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
Q

filesystems which support quota system

A
  • ext2fs
  • ext3fs
  • reiserfs
  • jfs
  • xfs
60
Q

set a quota

A
  • edquota

starts the Vi editor on a temporary config file (/etc/quotatab)

61
Q

soft quota and grace period

A

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
Q

FHS

A

Filesystem Heirarchy System is a standard to define the layout of files on unix-like OSs

63
Q

important directories

A
  • /boot
  • /etc
  • /sbin
  • /bin
  • /lib
  • /usr
  • /usr/local
  • /usr/X11r6
  • /opt
  • /home
  • /root
  • /var
  • /tmp
  • /mnt
  • /media
  • /dev
  • /proc
64
Q

/ directory

A

root

65
Q

/boot directory

A

static and unshareable files related to the low level initial booting of the computer

66
Q

/etc directory

A

higher level startup and config files, usually pointing to services

67
Q

/bin directory

A

critical executable files accessible to all users and constitute the most important command to use

68
Q

/bin directory

A

critical executable files accessible to all users and constitute the most important command to use

69
Q

/sbin directory

A

programs normally run only by admin

70
Q

/lib directory

A

contains program libraries

- /lib/modules contains a subset of kernel modules

71
Q

/usr directory

A

hosts all computer programs, shareable and static, can be mounted read-only and shared with other users

72
Q

/usr/local directory

A
  • 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
Q

/usrx11r6 directory

A

files related to the x window system

74
Q

/opt directory

A

like /usr, hosts readymade packages that don’t ship with the OS, static and shareable

75
Q

/home directory

A

hosts user specific data

76
Q

/root directory

A

home directory for root user

77
Q

/var directory

A

hosts transient files, often put in its own partition except on user workstation

78
Q

/tmp directory

A
  • hosts temporary files created by programs

- often good to put in its own partition to easily cleanup after troubled programs

79
Q

/mnt directory

A

mount removable media

80
Q

/media directory

A

like /mnt but with subdirectories for specific media types

81
Q

/dev directory

A

hosts device files

82
Q

/proc directory

A

virtual filesystem mostly read only and used for hardware info typically

83
Q

common tools for locating files

A
  • find
  • locate
  • whereis
  • which
  • type
84
Q

common tools for locating files

A
  • find
  • locate
  • whereis
  • which
  • type
85
Q

command find

A
  • brute force

- slow but flexible and reliable

86
Q

command locate

A
  • 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
Q

command whereis

A
  • searches for files only in standard binary file directories, library directories, and man page directories
  • ignores many user directories
88
Q

command which

A
  • searches your path for the command you tupe and lists the first match’s complete path
89
Q

command type

A

shows how a file will be interpreted by the system

syntax: type [command]

90
Q

hard link

A
  • duplicate directory entries that both point to the same inode and hence to the same file
  • Must reside on a single filesystem
91
Q

symbolic link

A
  • special files that point to another file or directory by name
  • May point across filesystems