| 79 | | |
| 80 | | ====== Add Repositories Using add-apt-repository ====== |
| 81 | | |
| 82 | | Now that you've installed the package, it's time to add a third-party software repository to your system. The basic syntax for adding repositories is: |
| 83 | | |
| 84 | | `sudo add-apt-repository [options] repository` |
| 85 | | |
| 86 | | ex: |
| 87 | | |
| 88 | | `sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc) universe"` |
| 89 | | |
| 90 | | === Key Management === |
| 91 | | |
| 92 | | The Linux key-management facility is primarily a way for various kernel components to retain or cache security data, authentication keys, encryption keys, and other data in the kernel |
| 93 | | |
| 94 | | == Linux Editors == |
| 95 | | |
| 96 | | === nano === |
| 97 | | |
| 98 | | Nano, text editor is a user-friendly, free and open-source text editor that usually comes pre-installed in modern Linux systems. |
| 99 | | It is easy to use command line text editor for Unix and Linux operating systems. It includes all the basic functionality you'd expect from a regular text editor, like syntax highlighting, multiple buffers, search and replace with regular expression support, spellchecking, UTF-8 encoding, and more. |
| 100 | | |
| 101 | | To check if it is installed on your system type: |
| 102 | | |
| 103 | | `nano --version` |
| 104 | | |
| 105 | | 1. To create and open a new file. |
| 106 | | |
| 107 | | `$nano new_filename` |
| 108 | | |
| 109 | | 2. To save a file |
| 110 | | |
| 111 | | `press Ctrl+o` |
| 112 | | |
| 113 | | 3. To cut paste in a file. |
| 114 | | |
| 115 | | `Ctrl+k` is used to cut and `Ctrl+u` is used to paste the text. |
| 116 | | |
| 117 | | 4. To search a word in a file. |
| 118 | | |
| 119 | | `Ctrl+w` |
| 120 | | |
| 121 | | 5. To enable spell check in nano. First, install the spell check package. |
| 122 | | |
| 123 | | `$sudo apt install spell` |
| 124 | | |
| 125 | | - To do spell check first press Ctrl+t |
| 126 | | - Now it will ask you to replace the incorrect words |
| 127 | | - Enter the word to replace with there |
| 128 | | - As soon as you will press the enter key |
| 129 | | |
| 130 | | === Vim === |
| 131 | | |
| 132 | | Vim is a text editor that is an upgraded version of the Vi editor and is more compatible with Vi. The most usage of vi editors is to create a new file, edit an existing file, or just read a file. Vim editor is more useful in editing different kinds of plain text. |
| 133 | | |
| 134 | | To install vim on Debian based Linux like ubuntu run the command: |
| 135 | | |
| 136 | | `sudo apt-get install vim` |
| 137 | | |
| 138 | | 1.To open a file in vim editor just write the file name after the vim command in the terminal as follows: |
| 139 | | |
| 140 | | `vim filename.txt` |
| 141 | | |
| 142 | | 2. Write into file |
| 143 | | |
| 144 | | press `i` |
| 145 | | |
| 146 | | 3.Save and Exit: |
| 147 | | |
| 148 | | We have written the data into a file now the task is to save and close the file to do that first exit from insert mode by pressing the Esc key. To write a command first type semicolon ( : ) and then type the command wq! or x! (both do the same thing) And then hit ENTER. |
| 149 | | |
| 150 | | `:wq!` |
| 151 | | |
| 152 | | 4.Exit without saving the file: |
| 153 | | |
| 154 | | To exit from the file without saving the file just use the command q! As follows |
| 155 | | |
| 156 | | `:q!` |
| 157 | | |
| 158 | | 5.Search: |
| 159 | | |
| 160 | | To search the word After the cursor uses the backslash key and then write the word and press enter. |
| 161 | | |
| 162 | | `:/word` |
| 163 | | |
| 164 | | - Use `:n` to move on next matching word |
| 165 | | |
| 166 | | - Use `:N` to move on previous matching word |
| 167 | | |
| 168 | | |
| 169 | | 6.Search and Replace: |
| 170 | | |
| 171 | | To replace the word in file use s/ command in vim like |
| 172 | | |
| 173 | | `:s/searchword/replaceword/` |
| 174 | | |
| 175 | | To do replace all occurrence of word use g |
| 176 | | |
| 177 | | `:s/searchword/replaceword/g` |
| 178 | | |
| 179 | | This command will replace the word globally. |
| 180 | | |
| 181 | | To confirm before replacements of words use gc |
| 182 | | |
| 183 | | `:s/searchword/replaceword/gc` |
| 184 | | |
| 185 | | To use this command in the whole file use % before the command |
| 186 | | |
| 187 | | `:%s/searchword/replaceword/gc` |