CNT-2311-Chapter 4 Notes

From ITCwiki
Revision as of 20:42, 15 February 2011 by BenFranske (talk | contribs) (→‎File Naming and Wildcard Expansion Rules)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

File Naming and Wildcard Expansion Rules

Linux file names can contain uppercase/lowercase letters, numbers, and most punctuation and control characters.

(.) Files refer to the current directory

(..) Files refer to the parent directory

File names are case-sensitive.

Three classes of wildcards

  • ?: Stands in for another single character
  • *: Matches any character or any set of characters
  • []: Normally match any character in a set. Also possible to specify a range of values

File Commands

ls: displays the names of files in a directory. Short for “list”.

cp: Copies a file.

mv: Move files and directories from one place to another and rename them.

rm: Remove command used to delete files.

touch: Modifies file time stamps.

Archiving Commands

tar: Stands for tape archiver. This utility is used to archive data to other media.

cpio: Used to restore data. There are 3 modes.

  • Copy-out mode: Creates an archive and copies files into it.
  • Copy-in mode: Extracts data from an existing archive.
  • Copy-pass mode: Combines the copy-out and copy-in modes, enabling you to copy a directory from one location to another.

dd: Low level copying program normally useful with partitions.

Directory Commands

mkdir: Creates a directory

rmdir: Destroys a directory


Managing Links

ln: used to create links.

There are two types of links:

  • Hard links: create two directory entries that point to the same file.
  • Soft links: Sometimes referred to as symbolic links. Soft links are a separate file whose content points to the linked-to file.


Managing File Ownership

Security is built on file ownership and file permission.
Whenever a file is created it’s assigned an owner.

ls-l : shows the permissions on a file

chown: used to change a file's ownership and may only be used by root

chgrp: change a file's group

Permission Bits

r: read

w: write

x: execute

X: execute only if the file is a directory or already has execute permission

s: SUID or SGID

  • SUID: Set user id option used with executable files to run with permission of the owner of the file
  • SGID: Set group ID. Sets the group of the running program to the group of the file.

t: sticky bit which is used to protect files from being deleted by those who don’t own the files


File Locating Commands

find [path…] [expression…]

  • Very flexible and likely to succeed
  • Tends to be slow
  • example of an expression is –name, used to match exact file names

locate search-string

  • Typically faster than find
  • Only searches by file names
  • Likely to return false alarms becuase any file containing the name that is searched for will come up

whereis

  • Searches for files in a restricted set of locations
  • Returns filenames that begin with what you type in

which

  • Searches your path for what you type in
  • Lists the path to first match it finds

type

  • Tells you how a command you type will be interpreted
  • It might say a command is a built-in, external, or alias command.