Basic Linux TutorialIntroduction – What is it? Why to learn? Linux installation directory structures Boot process Run levels in Linux Desktop Environments Different shells BASH Internal and External Commands Basic Linux Commands Important files and directories in Linux Environmental and Shell Variables Command history in Linux Character classes in Linux Text editors vim nano Searching files Creating new files Viewing File Contents File commands File permissions and ownership WildCards (Globbing) in files File compression Directory commands xargs command in Linux Comparing files Searching patterns using grep command Translating the characters using tr command Extracting data using cut command Stream editing using sed command Data extraction and reporting using awk command Sorting the file or string input uniq command in Linux Difference between grep, tr, cut, sed and awk commands Hardware commands Hard disk and memory space commands Working with Processes Managing Jobs Working with cron jobs Service command in Linux Network commands Managing Users and Groups Other Popular commands Standard streams and Redirection Pipes Package Managers in Linux
Vim editor in linux shellIn this topic, you will learn how to work with Vim editor in Linux. Vim has below features.
- Vim allows you to create,edit text files.
- Vim is advanced version of Vi editor.
- We can also compare files using vimdiff.
- Vim supports syntax highlighting for C, C++, Python etc
If you want to open file in read only mode, you can use below command.
There are 2 modes in vim.
vim -R abc.txt
- Command mode
- Insert mode
- :w – This command will save your file. :w command will save the current file. If you want to save the current file in another file say f2, you can use command “:w f2”. Note that f2 file will be created but vim will continue to hold original file in buffer. To work on new file, you will have to use command “:sav f2” instead of “:w f2”.
- :q – This command will exit the editor. ALternatively you can use :quit.
- :wq – This command can be used to save and exit at the same time.
- :q! – This command can be used to exit without saving the file.
- v – command can be used to copy the selected text.
- V – command can be used to copy entire line
- d – command can be used to cut the text or entire line
- y – command can be used to copy the text or line
- p – command can be used to paste the text at cursor location
Errors in VimYou may encounter below errors when working with vim. But you can easily avoid these errors by following basic instructions.
- Press enter or type command to continue – This error comes when you don’t use the proper command. For example if you use :!q command instead of :q!, you will get this kind of error.
- readonly option is set ( add! to override) – This error comes when you try to save the changes to read only file. For example If you have read only permission on a file and you change that file in vim, then you will not be allowed to write to that file. Note that vim allows you editing that file but does not allow you saving that file. You can make any file read-only by executing “chmod 0444 myfile” command.
- No write since last change – This error comes when you try to quit without saving changes using :q command.
- Not an editor command :W – This error comes when you are using capital W instead of small cap w.
Web development and Automation testing