Objectives
1) Upon completion of this unit, you should be able to:
- Describe important elements of the filesystem hierarchy
- Copy, move and remove files
- Create and view files
- Manage files with Nautilus
Linux File Hierarchy Concepts
1) Files and directories are organized into a single-rooted inverted tree structure
2) Filesytem begins at the root directory, represented by a lone / (forward slah) charactre
3) Name are case-sensitive
4) Paths are delimited by /
Some important Directories
1) Home Directories: /root, /home/username
2) User Executables: /bin, /usr/bin, /usr/local/bin
3) System Execuables: /sbin, /usr/sbin, /usr/local/sbin
4) Other Mountpoints: /media, /mnt
5) Configuration: /etc
6) Temporary Files: /tmp
7) Kernels and bootloader: /boot
8) Server Data: /var, /srv
9) System Information: /proc, /sys
10) Shared Libraries: /lib, /usr/lib, /usr/local/lib
Current Working Directory
1) Each shell and system process has a current working direcotry (cwd)
2) pwd
- Displays the absolute path to the shell’s cwd
File and Directory Names
1) Names may be up to 255 characters
2) All characters are valid, except the forward-slash
- It may be unwise to use certain special characters in file or directory names
- Some characters should be protected with quotes when referencing them
3) Names are case-sensitive
- Example: MAIL, Mail, mail and mAiL
- Again, possible, but may not be wise
Absolute and Relatvie Pathnames
1) Absolute pathnames
- Begin with a forward slash
- Complete “road map” to file location
- Can be used anytime you wish to specify a file name
2) Relative pathnames
- Do not begin with a slash
- Specify location relative to your current working directory
- Can be used as a shorter way to specify a file name
Changing Directories
1) cd changes directories
- To an absolute or relative path:
   > cd /home/joshua/work
   > cd project/docs
2) To a directory e level up
- cd ..
3) To your home directory
- cd
4) to your previous working directory
- cd -
Listing Directory Contents
1) Lists the contents of the current directory or a specified directory
2) Usage:
- ls [options] [files_or_dirs]
3) Examples:
- ls –a (include hidden files)
- ls –l (display extra information)
- ls –R (recurse through directories)
- ls –ld (directory and symlink information)
Copying Files and Directories
1) cp – copy files and directories
2) Usage:
- cp [options] file destination
3) More than e file may be copied at a time if the destination is a directory
- cp [options] file1 file2 destination
Copying Files and Directories: The Destination
1) If the destination is a directory, the copy is placed there
2) If the destination is a file, the copy overwrites the destination
3) If the destination does not exisit, the copy is renamed
Moving and Renaming Files and Directories
1) mv – move and /or rename files and directories
2) Usage
- mv [options] file destination
3) More than e file may be move d at a time if the destination is a directory
- mv [options] file1 file2 file3 destination
4) Destination works like cp
Creating and Removing Files
1) touch – create empty files or updates file timestamps
2) rm – remove files
3) Usage:
- rm [options] <file>…
4) Example:
- rm –l file (interactive)
- rm –r directory (recursive)
- rm –f file (force)
Creating and Removing Directories
1) mkdir create directories
2) rmdir removes empty directories
3) rm –r recursively removes dircectory trees
Using Nautilus
1) Gnome graphical filesystem browser
2) Can run in spatial or browser mode
3) Accessed via…
- Desktop icons
   &gt; Home: Your home directory
   &gt; Computer: Root filesystem, network resources and removable media
4) Applications –&gt; System Toolss –&gt; File Browser
Moving and Copying in Nautilus
1) Drag and Drop
- Drag: Move same filesystem, copy different filesystem
- Drag + Ctrl: Always copy
- Drag + Alt: Ask whether to copy, move or create symbolic link (alias)
2) Context menu
- Right-click to rename, cut, copy or paste
Determing File Content
1) Files can contain many types of data
2) Check file type with file before opening to determine appropriate comand or applicaiton to use
3) file [option] <filename>…
End of Unit4
1) Questions and Answers
2) Summary
- The Linux filesystem hierarchy
- Command-line file managment tools
- The Nautilus file manager