In this article, we are going to see how to run five basic linux commands.
List of commands:
- touch
- vi(visual editor)
- cat (concatenate)
- cp(copy)
- mv(move)
1.touch
- Touch command is used to create an empty new file.
- Syntax: touch <filename>
$ touch flower
2.vi
- vi is an editor command used to create a new file and/or edit an existing file.
- Syntax : vi <filename>
$ vi flower
- There will be two modes in vi editor:
- Command mode
- Insert mode
- In the insert mode following instructions can be used to edit or modify a file.
- i – insert at cursor (goes into insert mode)
- Esc – terminate insert mode
- u – undo last change
- o – opens a new line (goes into insert mode)
- dd – delete line
- :wq/ZZ – save and exit the editing terminal.
- :q! – to exit the terminal without saving the changes.
3.cat
- cat command is used to display the content of a file in the terminal.
- Syntax: cat <file name>
$ cat flower
- This command is also used to concatenate two or more files and display the output in the terminal.
- Syntax: cat <file name1> <file name2>
$ cat file1 file2
4.cp
- cp command is used to copy a file or a directory.
- Syntax: cp <filename 1> <filename 2>
$ cp file1 file2
5.mv
- To move files, use the mv command which is similar to the cp command, except that with mv the file is physically moved from one place to another, instead of being duplicated, as with cp.
- Syntax: mv <source file> <destination file>
$ mv file1 file2
- mv command is also used to rename a file or directory.
- Syntax: mv <old filename> <new filename>
$ mv file2 file1
Thanks for viewing this article.I hope it is useful for you.