Lesson 5: Managing Files and Directories Flashcards
What are the most common text editors?
vi (visual text editor, originally created for Unix, later cloned into FOSS versions)
Vim (default text editor in most distributions)
Emacs (flexible, powerful, and popular text editor used in Linux and Unix)
gVim (graphical version of the Vim editor)
gedit (powerful GUI-based text editor used in the GNOME desktop environment)
GNU nano (small, user-friendly text editor)
How would you work with display multiple files in multiple windows?
You can press Ctrl+W+V to create a vertical split, or press Ctrl+W+S to split the screen horizontally
In vi insert mode how do you inserts text to the left of the cursor?
use i
How do you enter insert mode in Vi?
type the letter “ i “ in command mode
In vi insert mode how do you adds text at the end of a line?
Use A
In vi insert mode how do you inserts text at the beginning of a line?
use I
What will result if you enter the following command “:!” in vi?
Executes the command and displays the result inthe Vim interface.
How do you enter execute mode in Vi?
you type : (colon) while in command mode
How do you delete a line in Vi?
In command mode type “ dd “ OR “ d “ in execute mode
What are motions and how do you use them?
Motions are single-key shortcuts that are used to navigate through files in command mode.
h Move left one character.
j Move down one line.
k Move up one line.
l Move right one character
^ Move to the beginning of the current line.
$ Move to the end of the current line.
w Move to the next word.
b Move to the previous word.
e Move to the end of the current word or to the end of thenext word if you are already at the end of the word.
Shift+L Move the cursor to the bottom of the screen.
Shift+H Move the cursor to the first line of the screen.(Line number)
Shift+G Move the cursor to the specified line number.
gg Move the cursor to the first line of the file.
Shift+G Move the cursor to the last line of the file.
What are editing operators and how do you use them?
Editing operators are tools that are used to manipulate text and can be used in combination with motions to edit multiple characters.
x Delete the character selected by the cursor.
d Delete text.ddDelete the current line.
p Paste text on the line directly below the cursor or directly above the cursor.
/{text string} Search through the document for specific text.
?{text string} Search backward through the document for specific text.
y Copy text or yy Copy the line directly above the cursor.
c{range of lines}c Begin a change in the specified range.
u Undo the latest change or U Undo all changes in the current line.
ZZ Write the file only if changes were made, then quit the Vim editor.
How do you enable line numbers in Vi?
run “: set number” in execute mode
Where can you change and set Vi preferences?
in the .vimrc file if does not show try vi ~/.vimrc to create and edit
How do you delete multiple lines in Vi?
in execute mode :start_line#,end_line#d
What does the count command accomplish?
A count is a number that multiplies the effect of keystrokes in Vim. an be used incombination with motions, operators, or both.
syntax for using a count with an operator and a motion is operator [count] {motion}
In Vi command mode what does / prompt you to do?
search context
In Vi command mode what does / prompt you to do?
search context
How do you search and replace a string in Vi?
/string/replace_string OR :%s/string/replace_string (to change for the entire doc)
How would you open a document and perform a search at the same time?
vi +/{search_string} doc_name
In Vi, if you type o from command mode, what will it do?
Enters insert mode start new line
In Vi, if you type a from command mode, what will it do?
Starts insert after cursor
When in vi execute mode, what does the e character do?
lets you edit another file
:e (new_file_name)
How do you open the GNU nano editor?
The nano command invokes the GNU nano editor.
syntax -> nano {file name}
What are some GNU nano, shortcuts and their functions?
Ctrl+G Open nano to the help screen.
Ctrl+X Exit nano or close the current “buffer” (e.g., the help screen itself).
Ctrl+O Save the currently open file.
Ctrl+J Justify the current paragraph.
Ctrl+R Insert another file into the current one.
Ctrl+W Search the file.
Ctrl+K Cut the currently selected line.
Ctrl+U Paste the line that was cut.
Ctrl+C Display the cursor’s position.
Ctrl+V to navigate to the next page and Ctrl+Y to navigate to the previous page.
Copying parts of text on a line requires you to “mark” the text you want to copy with the Ctrl+^ shortcut.
You then navigate your cursor to highlight the text you want to copy. Pressing Alt+^ copies the marked/highlighted text.
What are the most useful option for the ls command?
- l Display a long list including the permissions, number of hardlinks, owner, group, size, date, and file name.
- F Display the nature of a file, such as * for an executable file and /for a directory.
- a Display all files present in the directory, including the files whosenames begin with a period ( . ).
- R Recursively display all subdirectories.
- d Display information about symbolic links or directories rather than the link’s target or the contents of the directory.
- L Display all files in a directory, including symbolic links.
- h show file sizes in human readable formate
syntax of the ls command is ls [options] [file/directory names]
How do you change the time of access or modification time of a file to the current time, or to a specified time?
Use the touch command
syntax of the touch command is touch {file names}
useful: intesting permissions or in simply creating files that will later be processed by someapplication.
What are some commands to view files?
cat (concatenate) - frequently used to display the contents of small text files, as it does not havea screen scrolling capability.
more (allows you to scroll through but unable to scroll back up)
less (allows you to scroll through files, allows you to use search commands)
head (show first 10 lines) unless you specify head -n (#of_pages)
tail (shows last 10 lines) unless you specify tail -n (#of_pages)
-f (follows changes)
What command can display, combine, and create text files?
The cat command, short for concatenate, frequently used to display small text files.
syntax -> cat [options] {file names}
Options:
- n Precede the output with its respective line number.
- b Number the lines, excluding the blank lines.
- s Suppress output of repeated empty lines.
- v Display non-printing characters as visible characters, other than tabs, new lines, and form feeds.
- e Print a $ character at the end of each line, prior to the new line.
- t Print tabs as ^I and form feeds as ^L