Chapter 3 Study Guide: Difference between revisions

From ITCwiki
Jump to navigation Jump to search
(Created page with "CNT-2311-Chapter 3  Exploring Linux Filesystems Objectives Comparison of Windows and Linux filesystems Navigate the directory structure using relative and absolute pathnames Typ...")
 
No edit summary
Line 1: Line 1:
CNT-2311-Chapter
==CNT-2311-Chapter 3==
Exploring Linux Filesystems
Exploring Linux Filesystems
Objectives
 
Comparison of Windows and Linux filesystems
==Objectives==
Navigate the directory structure using relative and absolute pathnames
*Comparison of Windows and Linux filesystems
Types of files
*Navigate the directory structure using relative and absolute pathnames
View filenames and file types
*Types of files
Use shell wildcards
*View filenames and file types
Display contents of files
*Use shell wildcards
Search files for regular expressions using grep
*Display contents of files
Use vi to modify text files
*Search files for regular expressions using grep
Alternatives to vi
*Use vi to modify text files
File Hierarchy
*Alternatives to vi
Comparison of Windows v. Linux filesystems�
*File Hierarchy
*Comparison of Windows v. Linux filesystems�
 
 


Navigate the directory structure using relative and absolute pathnames 
Navigate the directory structure using relative and absolute pathnames 
start in home dir
start in home dir
 use ~ to reference home directories
 use ~ to reference home directories
present dir = pwd
present dir = pwd
/home/randy/
/home/randy/
change dir = cd
change dir = cd
cd /etc - change directory to /etc
cd /etc - change directory to /etc
relative path name = path to the file in relation to the current working directory
relative path name = path to the file in relation to the current working directory
".." references the next higher up dir
".." references the next higher up dir
tab-completion!
tab-completion!
 
 
Types of files
===Types of files===
Text, Binary, Executable
Text, Binary, Executable
Directory = still just a file  
 
Directory = still just a file
Linked = reference other files, shortcut  
Linked = reference other files, shortcut  
Special device files = reference hard disks or ports, contained in /dev
Special device files = reference hard disks or ports, contained in /dev
Named pipes = communication between process in memory
Named pipes = communication between process in memory
Created using mkfifo or mknod
Created using mkfifo or mknod
One process is a reader other is a writer
One process is a reader other is a writer
Line 41: Line 57:
 may or may not have extension to denote type
 may or may not have extension to denote type
Lots of different extensions 
Lots of different extensions 
http://learn.clemsonlinux.org/wiki/File_extensions 
==Links==
http://www.debianhelp.co.uk/fileext.htm 
*http://learn.clemsonlinux.org/wiki/File_extensions 
http://filext.com/alphalist.php?extstart=%5EL  (not limited to linux) 
*http://www.debianhelp.co.uk/fileext.htm 
View filenames and file types
*http://filext.com/alphalist.php?extstart=%5EL  (not limited to linux) 
 
==Commands to view filenames and file types==
pwd - Show current directory
pwd - Show current directory
pwd - /home/randy
pwd - /home/randy
ls -ltr   - Show listing and give color codes to information
ls -ltr   - Show listing and give color codes to information
listing including file permissions, ownership and date/time stamp.
listing including file permissions, ownership and date/time stamp.
Executable files: Green
Executable files: Green
Normal file : Normal
Normal file : Normal
Directory: Blue
Directory: Blue
Symbolic link : Cyan
Symbolic link : Cyan
Pipe: Yellow
Pipe: Yellow
Socket: Magenta
Socket: Magenta
Block device driver: Bold yellow foreground, with black background
Block device driver: Bold yellow foreground, with black background
Character device driver: Bold yellow foreground, with black background
Character device driver: Bold yellow foreground, with black background
Orphaned syminks : Blinking Bold white with red background
Orphaned syminks : Blinking Bold white with red background
Missing links ( - and the files they point to) : Blinking Bold white with red background
Missing links ( - and the files they point to) : Blinking Bold white with red background
Archives or compressed : Red (.tar, .gz, .zip, .rpm
Archives or compressed : Red (.tar, .gz, .zip, .rpm
Image files : Magenta (.jpg, gif, bmp, png, tif)
Image files : Magenta (.jpg, gif, bmp, png, tif)
View filenames and file types
 
 ls -F = gives file type, special character is listed on the left of the name  = Metacharacters=
===View filenames and file types===
@ = linked file
 
= exe
* ls -F = gives file type, special character is listed on the left of the name  = Metacharacters=
/ = subdirectory
 
= is a socket
*@ = linked file
| = named pipe
 
*= exe
 
*/ = subdirectory
 
*= is a socket
 
*| = named pipe
 
Other files do not have special character appended to them - they can be anything not listed above
Other files do not have special character appended to them - they can be anything not listed above


 ls -l = ls long listing
 
*ls -l = ls long listing
 
When listing files/directories a special character on the left indicates what type of file it is
When listing files/directories a special character on the left indicates what type of file it is
 d = dir
*d = dir
L = linked
*L = linked
 b & c = special device files
*b & c = special device files
 n = named pipe
*n = named pipe
 s = socket
*s = socket
 - = other - txt, bin
*- = other - txt, bin


Display contents of files 
Display contents of files 
Line 194: Line 237:
vi is the most common text editor however GUI options exits  
vi is the most common text editor however GUI options exits  


References
==References==
Anatomy of the Linux File System
*Anatomy of the Linux File System
http://www.ibm.com/developerworks/linux/library/l-linux-filesystem/
http://www.ibm.com/developerworks/linux/library/l-linux-filesystem/
File extensions
*File extensions
http://learn.clemsonlinux.org/wiki/File_extensions
http://learn.clemsonlinux.org/wiki/File_extensions
http://www.debianhelp.co.uk/fileext.htm
http://www.debianhelp.co.uk/fileext.htm
Linux/Unix/BSD Post-Exploitation Command List
 
*Linux/Unix/BSD Post-Exploitation Command List
https://docs.google.com/document/d/1ObQB6hmVvRPCgPTRZM5NMH034VDM-1N-EWPRz2770K4/edit?hl=en_US
https://docs.google.com/document/d/1ObQB6hmVvRPCgPTRZM5NMH034VDM-1N-EWPRz2770K4/edit?hl=en_US
vi tutorial
*vi tutorial
http://www.unix-manuals.com/tutorials/vi/vi-in-10-1.html
http://www.unix-manuals.com/tutorials/vi/vi-in-10-1.html
VI Cheatsheet
*VI Cheatsheet
 http://www.atmos.albany.edu/deas/atmclasses/atm350/vi_cheat_sheet.pdf
 http://www.atmos.albany.edu/deas/atmclasses/atm350/vi_cheat_sheet.pdf
Learning the vi and Vim Editors
*Learning the vi and Vim Editors
http://www.amazon.com/Learning-Vim-Editors-Arnold-Robbins/dp/059652983X/ref=sr_1_1?s=books&ie=UTF8&qid=1326846342&sr=1-1 
http://www.amazon.com/Learning-Vim-Editors-Arnold-Robbins/dp/059652983X/ref=sr_1_1?s=books&ie=UTF8&qid=1326846342&sr=1-1 
Command Guides
*Command Guides
http://wiki.ihcnt.net/w/Linux_command_guide
http://wiki.ihcnt.net/w/Linux_command_guide
http://wiki.ihcnt.net/w/Linux-command-list 
http://wiki.ihcnt.net/w/Linux-command-list 
 Emac Guide
*Emac Guide
http://sean.wenzel.net/docs/emacs/quick_reference/ 
http://sean.wenzel.net/docs/emacs/quick_reference/ 
15 Practical examples of ls commands
*15 Practical examples of ls commands
http://www.thegeekstuff.com/2009/07/linux-ls-command-examples/
http://www.thegeekstuff.com/2009/07/linux-ls-command-examples/
50 Most Frequently Used UNIX / Linux Commands http://www.thegeekstuff.com/2010/11/50-linux-commands/ 
*50 Most Frequently Used UNIX / Linux Commands http://www.thegeekstuff.com/2010/11/50-linux-commands/ 

Revision as of 02:07, 30 January 2012

CNT-2311-Chapter 3

Exploring Linux Filesystems

Objectives

  • Comparison of Windows and Linux filesystems
  • Navigate the directory structure using relative and absolute pathnames
  • Types of files
  • View filenames and file types
  • Use shell wildcards
  • Display contents of files
  • Search files for regular expressions using grep
  • Use vi to modify text files
  • Alternatives to vi
  • File Hierarchy
  • Comparison of Windows v. Linux filesystems�

 

Navigate the directory structure using relative and absolute pathnames 

start in home dir

 use ~ to reference home directories

present dir = pwd

/home/randy/

change dir = cd

cd /etc - change directory to /etc

relative path name = path to the file in relation to the current working directory

".." references the next higher up dir

tab-completion!

 

Types of files

Text, Binary, Executable

Directory = still just a file

Linked = reference other files, shortcut

Special device files = reference hard disks or ports, contained in /dev

Named pipes = communication between process in memory

Created using mkfifo or mknod One process is a reader other is a writer Sockets = named pipes between remote computers Filenames Filename facts 255 max characters alphanumeric, _ -  .   may or may not have extension to denote type Lots of different extensions 

Links

Commands to view filenames and file types

pwd - Show current directory

pwd - /home/randy

ls -ltr   - Show listing and give color codes to information

listing including file permissions, ownership and date/time stamp.

Executable files: Green

Normal file : Normal

Directory: Blue

Symbolic link : Cyan

Pipe: Yellow

Socket: Magenta

Block device driver: Bold yellow foreground, with black background

Character device driver: Bold yellow foreground, with black background

Orphaned syminks : Blinking Bold white with red background

Missing links ( - and the files they point to) : Blinking Bold white with red background

Archives or compressed : Red (.tar, .gz, .zip, .rpm

Image files : Magenta (.jpg, gif, bmp, png, tif)

View filenames and file types

  •  ls -F = gives file type, special character is listed on the left of the name = Metacharacters=
  • @ = linked file
  • = exe
  • / = subdirectory
  • = is a socket
  • | = named pipe

Other files do not have special character appended to them - they can be anything not listed above


  • ls -l = ls long listing

When listing files/directories a special character on the left indicates what type of file it is

  • d = dir
  • L = linked
  • b & c = special device files
  • n = named pipe
  • s = socket
  • - = other - txt, bin

Display contents of files   vi - editing a file   emas - alternative to vi   cat - concatenation - similar to "type" in DOS/Windows.   tac - reverse concatenation - types file in reverse   head - displays the top ten lines of a file   tail - displays the bottom ten lines of a file   more - displays file page by page   less - similar to more but allow line by line manipulation Key Terms ~ metacharacter absolute pathname binary data file command mode concantenation directory Emacs (Editor MACroS) editor executable program filename filename extension gedit editor home directory insert mode linked file log file   named pipe file nano editor parent directory regexp regular expressions relative pathname socket file special device file subdirectory Tab-completion feature text file text tools vi editor wildcard metacharacters    � � Key � �Commands� �    cat  cd (change directory) egrep fgrep file grep head less ls more pwd (print working directory) strings tac tail Search files for regular expressions using grep grep allows you to search through a file for text argument.   grep "localhost" /etc/hosts     return lines that include localhost in the file /etc/hosts

grep -v "localhost" /etc/hosts     return lines that DONT include localhost in the file /etc/hosts

grep -l "LOCALHOST" /etc/hosts     return lines that include localhost in the file /etc/hosts that is not case-sensitive       Regular Expressions Commands to Display Contents of Binary Files  strings = searching binary file for text  od = displays file in octal format  od -x = displays contents in hex

Searching for Text within Files Tools: grep, awk, sed, vi, emacs, ex, ed, C++, PERL, tcl Regular expressions Wildcard metacharacters are interpreted by the shell Regular expressions are interpreted by text tool program Wildcard metacharacters match characters in file & dir names Regular expressions match charters within file Wildcard metacharacters typically have different definitions than regular expressions metacharacters There are more regular expression metacharacters than wildcard metacharacters


Emacs
Not installed by default in Fedora 13.
Can run in a GUI environment.
More GUI than vi.

 Written in C and Emacs Lisp.  Licensed GNU GPL  Users can combine commands into macros

   to automate task.

Summary Linux file system is a hierarchy,  series of directories paths are absolute or relative Many types of files - text, scripts, executable, dirs, linked, special device ls - view file names and many options to modify view Wildcard metacharacters help to select multiple files Regular expression metacharacters are used in many ways. Text files can be viewed differently with commands such as, head, tail, cat, tac, more and less. vi is the most common text editor however GUI options exits  

References

  • Anatomy of the Linux File System

http://www.ibm.com/developerworks/linux/library/l-linux-filesystem/

  • File extensions

http://learn.clemsonlinux.org/wiki/File_extensions

http://www.debianhelp.co.uk/fileext.htm

  • Linux/Unix/BSD Post-Exploitation Command List

https://docs.google.com/document/d/1ObQB6hmVvRPCgPTRZM5NMH034VDM-1N-EWPRz2770K4/edit?hl=en_US

  • vi tutorial

http://www.unix-manuals.com/tutorials/vi/vi-in-10-1.html

  • VI Cheatsheet

 http://www.atmos.albany.edu/deas/atmclasses/atm350/vi_cheat_sheet.pdf

  • Learning the vi and Vim Editors

http://www.amazon.com/Learning-Vim-Editors-Arnold-Robbins/dp/059652983X/ref=sr_1_1?s=books&ie=UTF8&qid=1326846342&sr=1-1 

  • Command Guides

http://wiki.ihcnt.net/w/Linux_command_guide

http://wiki.ihcnt.net/w/Linux-command-list 

  • Emac Guide

http://sean.wenzel.net/docs/emacs/quick_reference/ 

  • 15 Practical examples of ls commands

http://www.thegeekstuff.com/2009/07/linux-ls-command-examples/