Linux Ch10 Editing Files

  1. Different editors
    –Emacs–gedit–vi–pico–Nano–Kwrite and Kate
  2. Plain Text Files
    • Viewable with any editor
    • No special formatting (no images or embedded features)
    • Used for configuration files and scripts
    • Use ASCII format (American Standard Code for Information Interchange)
    • Moving to Unicode format
    • Each line in a text file is usually no more than 80 characters long
    • Contents: Human language files (README)
    • Source code for Programs
    • Formatted text files
    • Program and System configuration files
    • Log files and more
  3. ASCII
    • –Date to 1960’s
    • Support only 7-8 bit codes
    • Maximum of 128-256 characters
    • Different variations
    • Difficult to support languages other than English
  4. Unicode
    • More up to date coding scheme
    • Can represent any alphabet in common use on Earth
    • Different coding schemes within
    • UTF-8 used to represent ASCII
    • UTF-16 16 bit coding scheme
  5. Text mode editors
    • vi: Available on any Linux or Unix install
    • Installed by default
    • Runs in different modes
    • very common editor (questions on certification exams)
    • emacs: Available on any Linux or Unix install
    • Installed by default
    • Runs in different modes
    • Can take a lot of resources
    • pico: Small command-line editor
    • nano: Clone of “pico”
    • Extra features
  6. GUI Editors
    • emacs: Both GUI and text-mode
    • gedit: Available with GNOME desktop
    • Usually installed by default
    • Much like Windows Notepad
    • Kwrite and Kate: Editors for K Desktop Environment
    • Nedit: Like Kwrite
    • May have to be installed
  7. Different ways to launch GUI editor
    • From a file-manager double click the file and the default GUI editor will launch
    • From a terminal session:
    • gedit filename
    • vi filename
  8. vi” editor
    • Very powerful program
    • Available on virtually every Linux system
    • Not easy to use
    • Three modes within “vi”:
    • Command Mode
    • Ex Mode
    • Insert Mode
  9. Editing Files with vi
    Basic steps:
    • Open a file in vi
    • Enter into Insert mode
    • Add text to file
    • Edit text in file
    • Save file
    • Exit vi
  10. vi commands
    • Edit a new file: :e filename
    • Include an existing file: :r filename
    • Execute an external command: :!command
    • Quit: :q or :q!
    • Write & Quit: :wq
  11. vi Insert Mode
    • This mode will allow you to actual make changes in the file
    • When finished all changes make sure you press the “Esc” to return to “Command Mode”
    • Then either save your changes and exit, or exit without saving.
    • To save and quit: :wq
    • To quit without saving: :q!
    • To save and continue editing: :w
    • To save with filename :w filename
    • search for searchtext /searchtext
    • search again for searchtext /[Enter] or n
    • execute cmdName and return to vi
    • :!cmdName
  12. To start “vi”:
    • Command: vi myfile
    • The above command will begin “vi” session of the named file
    • To actually start editing the file you can press the “i” key (insert)
  13. Majority of system configuration files found in
    “/etc” or a subdirectory within
  14. User’s configuration resides
    • in the user’s home directory
    • configuration files usually begin with a “.” (hidden)
    • Example: .bashrc
    • Always make a copy before making any changes
  15. Most configuration files contain
    • comments:
    • Used to explain specific functions or operations
    • Read all comments
    • Most comments usually begin with a “#” number sign
    • Example: # The following routine sets a variable value
    • Other comments may begin with a “;” semicolon
  16. Named Variables
    • $PATH
    • $PS1 used to create your display prompt
    • localhost.localdomain is default set during the installation of this system
    • $HOME
    • to see value echo $varName
Card Set
Linux Ch10 Editing Files
Linux Ch10 Editing Files