Beruflich Dokumente
Kultur Dokumente
Path Names
A path name represents the route through the hierarchy that is traversed to reach the desired file or directory
Types of Pathnames
Absolute Pathname
Specifies the entire file hierarchy Start at root (/) and list each directory along the path to the destination Slash (/) between each directory name in the path Example: /home/user3/f1
Relative Pathname
Always starts at your current location in the hierarchy If a pathname does not begin with a slash, it is a relative pathname you must know what directory you are currently in since that is your starting point
Absolute Path
Absolute Path
Absolute pathname to the user2 directory /home/user2 Absolute pathname to the dir1 directory /home/user2/dir1 Absolute pathname to the coffees directory /home/user2/dir1/coffees
Relative Path
Relative Path
If your current directory is /home: Relative pathname to the user2 directory user2 Relative pathname to the dir1 directory user2/dir1 Relative pathname to the coffees directory user2/dir1/coffees
The entry called dot(.) represents your current directory position The entry called dot dot(..) represents the directory immediately above your current directory position
Examples of DOT
If you are currently in the directory /home/user3: . ./f1 ./memo/f1
cd (change directory) command used with absolute or relative pathnames to navigate by itself takes you to your home directory cd .. command takes you up one level cd ~/ command takes you to a directory under your home directory (tilde = home)
Examples:
$ pwd
/home/user3
$ cd memo; pwd /home/user3/memo $ cd .. /..; pwd
Using ls Command
ls
(list) listing of files and directories within the current directory or specified directories
ls a
list all files in a directory, including hidden (.) files and current (.) and parent (..) directories
ls F
displays listing with a symbol to tell what the type the file is: directory A forward slash (/) after the name ASCII Text File - no symbol Executable asterisk (*) after the name Symbolic Link An at sign (@)
Recursive Listing
ls -R (recursive) command
- Displays the contents of all directories, subdirectories and their contents for a particular part of the directory tree - If done at a high level in the directory structure, the output can be substantial!
rm
- removes a single file or multiple files specify their names or use wildcard metacharacters (*) (?) files that are deleted are permanent and cannot be recovered! rm -i (interactive) - prompts the user before removing files
Example:
$ pwd $ mkdir fruit $ mkdir fruit/apple $ cd fruit $ mkdir grape orange $ rmdir orange $ cd .. $ rmdir fruit $ rmdir fruit/apple fruit/grape fruit
lp cp mv
mv ln rm
-print a file -make a copy of a file -change the name of a file or directory -move a file to another directory -create another name for a file -remove a file
tail
displays the last n lines of a file last 10 lines are displayed by default if the -n option is omitted. allows you to check the end result of the backup without looking at the whole file -n option allows you to start displaying lines from a specific point in a file
Copy Files
Syntax: cp [-i] file1 new_file cp [-i] file [file] dest_dir cp r [-i] dir [dir] dest_dir
diff Output
Link Files
Syntax: ln file new_file ln file [file. . .] dest_dir Example: $ ls l f1 $ ln f1 /home/user2/f1.link $ ls l f1
$ ls l /home/user2
$ ls i /home/user2/f1.link