Felitaur Site
Offerings
|
   
|
File Manipulation and Maintenance
Lecture Overview Index | Linux SysAdmin Homepage
| Overview |
Goals:
- How to view and edit files
- How to use the standard vi editor
- How to locate files
- The power of the "rm" command
The following programs/files/directories will be discussed for this
topic:
- cat
- more or less
- pico
- vi
- i I a A o O
- dd 3dd d/^[0-9] d/Finally
- yy 4yy t4yy p tp (for multiple copy buffers)
- / ? (n or N) and then . for repeat replacement
- :1,$s/arizona/arizona/gi
- :set number (nu), :set cindent (cin)
- :set autoindent (ai, noai), :set shiftwidth=4
- :set tabstop=4
- :syntax enable (vim on by default)
- .vimrc
map <F5> :set hls!<bar>set hls?<CR>
- find
- which
- whereis
- locate (not on our solaris machine)
- rm
|
| Questions |
cat vs. more vs. less
- Why don't you normally use cat to view files anymore?
- Why is cat still around?
- What are the differences between more and less?
- How do you back up in more or less?
- How do you get OUT of more or less?
- Which text viewer do the man pages use by default?
vi questions
- How do you open a text file with vi?
- What is the difference between text mode and command mode?
- What key do you hit to enter command mode?
- How do you save in vi?
- How do you quit and save, or quit and not save?
- How do you delete a line? 5 lines? A single character?
- To switch to text mode, you can type a i A I (amongst others),
how are those four characters different?
- How do you cut and paste in vi? How about copy and paste?
- How do you search for a word?
- How do you insert an external file?
- How would you change all instances of Arizona and Ariz. to AZ for an
entire document?
- what happens when you place the cursor over a { } or ( ) when there are matched pairs of them? (note, a vim not vi feature)
pico questions
- What is pico actually designed to do?
- Why will many system administrators laugh at you if you mention pico?
- What is the default editor on nearly every flavor of UNIX?
- How do you save in pico?
- How do you delete lines, characters?
- How do you "cut" and "paste" in pico?
- How do you search in pico?
- How do you insert an external file?
- Does pico have any advanced editing capabilities?
find, which and locate questions
- If you just want to find where a command is located, the which
command is the easiest to use, assuming what?
- locate is a spammy search command? Explain.
- how are whereis and which similar? different? What are some of the
options for whereis ?
- find is the default search tool on the system, explain how to do the
following
- Find a file called ugh.jpg that is somewhere in the /home
directory.
- Find all files that belong to the user pwa.
- How would you use find to find all files ending in .bak and
then run the command mv ~/tmp ?
- What does find . -name "*.html" -exec chmod 644 '{}' \; do?
rm questions
- Why is it a good idea to use the -i option, especially if you are
root?
- Is there an undo option for rm?
- How do you delete a directory and all sub directories within?
- Why should you NEVER type rm -r / , especially as root?
- If you have the -i option set by default (say for root in redhat), how
could you override it?
- How do you delete files with strange characters in the name?
|
| Activities & Assignments |
- Create a file called "test" using pico. Type a few lines. Try and cut
and paste lines, correct words, search, and save.
- Now, open up the same file in vi, and do the same.
- Try out this in vi :%s/term1/term2/g (term1 is what you
search for,
term2 is what to replace it with)
- Try the vimtutor program
- Try to find the program traceroute using find (hint, you can limit
your search to /usr )
|
| Resources |
Text Editor Help
rm help
find help
|
|
|