Slippery Rock University |
Dr. Deborah Whitfield
|
Go Browns!
|
Filesystem
Boiled down:
pathnames |
system directories |
links |
od |
wc |
pwd |
cd |
mkdir |
mv |
cp |
ls - l |
rmdir |
ln |
who am i |
gzip |
zip |
Everything is a File
- Linux has a hierarchical file system with access controls for the user, group, and all others
- A file is a sequence of characters (or bytes)
- The size of the file is not stored in the file
- The name of the file is not stored in the file
- The is no end-of-file (EOF) marker in the file
- There are ordinary, directory & device files
- text files vs Binary files
- Text files
- Contain plain text as typed at the keyboard
- Basic separator is the newline (LF char)
- Uses with cat, more,(less a superset of more with vi commands), vi, pico etc
- Binary files:
- Contain characters not .on the keyboard. and that can.t be displayed on the screen
- Created by a compiler (or even MS Word)
Directories vs. Files
- Directories
- a file representation of the disk structure
- Can't be directly modified by the user . the shell does this for you
- User can view "it"s contents. using ls
- It is a representation of (part of) the file structure
- Contains filename & indode #
- Inode is the data structure that contains files attributes, disk block location(s), etc
- Device Files
- A file system representation of each linux device
- You can read from a device (file)
- You can write to a device (file)
- But it is actually empty. it provides a consistent way to address all devices by representing them as files
Hierarchical File System
- Absolute path names
- Relative path names
- . and ..
- $PATH
- What is searched and in what order?
- Is the current working directory (pwd) part of the path?
- $HOME
- $HOME is the shell (environment) variable that keeps track of your home directory.
Like an absolute web address, you should never "hard code" your home directory. it might move
- pwd is very useful when starting with linux
- - Keep track of your current working directory
- - Used in scripts
- cd we will use directories for organization, but also as places for project separation
Filenames
- Letters, digits, -, period, comma
- 255 characters was old limit
- Hidden files
- Common for "start up" files
- In Linux a hidden file is not displayed in response to a normal listing (ls)
- File Commands
- make a directory - mkdir
- Change to a directory - cd
- List files in a directory - ls (See page 70 for options to ls)
- Display working directory - pwd
- Remove a directory - rmdir
- File Copy - cp source destination (-R for recursive)
- Move file - mv source destination
- Print file - lpr filename
- wc - count lines word and characters in file
- od -bc
- tar -cvf archive.tar file_list (-x extracts, -t displays)
- gzip list of files (creates .gz file_
- unzip filename.zip
Typical Unix directories
- /etc
- /var
- /usr
- /tmp
- you should know /tmp where you (anyone) may create temporary files
- /sys
- cd without any parameters takes you to home directroy (echo $HOME)
All work herein is subject to copyright. Original content to Dr. Deborah Whitfield, text content (Practical Guide to Linux) to Prentice Hall publishing.