110 likes | 267 Views
Chapter 4: Exploring Linux Filesystems. Directory Structure. Similar to Windows structure but there is no drive name It uses forward slash instead of backward one Home directory Remember the difference between # and $ Command commands {pwd, cd, etc.}
E N D
Directory Structure • Similar to Windows structure but there is no drive name • It uses forward slash instead of backward one • Home directory • Remember the difference between # and $ • Command commands {pwd, cd, etc.} • Use of cd without argument or with ~ to change to home • Relative versus absolute paths • The . and .. • Tab-completion feature and history
Files • File types (text, binary, executable, directory, linked, special device, named pipes, and socket) • Name convention (up to 255, alpha, _, -, .) • Hidden files (use .) • Listing files (ls or dir) • Parameters to ls (-F, -l, -a) also ll • The eight components in the long listing • The file command • Wild characters (*, ?, [abcde], [a-e], [!a-e])
Viewing File Contents • Common commands: • cat • tac • head • tail • more • less • Using redirection | with more and less • strings • od
Searching for Text • Regular expression versus wild characters
Searching for Text (cont.) • The grep (Global Regular Expression Print) command • Syntax: grep regexp filename • It is a case sensitive. To ignore case use the –i modifier • To reverse the action of the grep command use the –v • To match whole word(s), you need to use spaces before and after • egrep for extended regexp while fgrep ignores regexp • Do sample Demo
Text Editors • Most common: vi, vim, or emacs • Important for vi: • Modes (command and insert) • How to switch • Reading, writing, exiting, etc. • Insert date :r !date • Replace texts :1,$ s/word/WORD/g • Show/hide line numbers :set number / :set nonumber • Other editors: for instance emacs uses CTRL + ch to perform various functions • GUI-based editors: e.g. Xemacs, gedit, and kedit • Demo