Touch cat vi linux

Fully Explained Difference Between Cat, Touch, Vi/Vim, and Nano in Linux

This article will clear all the confusion in creating and editing files in Linux. Linux is an open-source kernel and become an operating system with open-source software.

It was the project of UNIX at Bell Laboratory in New Jersey. After five years the project withdraw but the employee who was working on this project started again and made a kernel UNICS i.e. Uniplexed information and computing services as an open-source.

In 1975 around the version six launched of UNIX also as an open-source. But many tech giants made their own paid version.

UNIX
|
|--> IBM- AIX
|--> SUN Solaris
|--> Mac OS
|--> HP-UX
|--> Flavours of UNIX

The Linux was developed from scratch by Linus Torvald with the understanding of MINIX made by professor Andrew Tanenbaum to teach his students.

There is also a flavor of UNIX named Linux that is different from the Linux made by Sir Linus Torvald. This Linux flavor gave many more flavors as shown below:

UNIX
|
|-->Linux
|
|--> Redhat EL : Giving services
|--> Fedora : Group of organizations
|--> Debian
|--> Others(Free)
|
|--> Ubuntu: Third most used OS
|--> CentOS: faster than other Linux
|--> Kali : Used for Ethical hacking
 Linux 
|
|
/ ---> Root Directory
|
----------------------------------------------------------
| | | | | |
/root /home /boot /etc /usr /bin
  • /home: Home directory for other users
  • /root: Home directory for root users
  • /boot: Contains bootable files for Linux
  • /etc: Contains all configuration files
  • /usr: By-default software is installed in…

Источник

6 Commands to Edit File With and Without vi, vim Linux Editor

You might be knowing opening and editing file in vi/vim editor in Linux system. Do you wonder- how you can edit file without vi or vim editor?

Читайте также:  Ps2 linux kernel loader

Many times you have to create a file, write the content on your Unix-line or Linux systems. Sometimes you require to write a program and run it. For all this, you need a text editor to read and write in the file.

So let’s see different commands for creating and editing the files even if you don’t have vi or vim editor, one-by-one…

File handling using vi and vim editor

The vi and vim are two widely used command line editors on the Unix-like systems (including Linux). And many of the users know about vi and vim editor.

Following are the simple commands you can use to create the file and edit it.

1. Using vi editor

There are two modes of opening file in vi editors. One is command mode and other is insert mode. As it’s not the part of this discussion. And it’s a big topic to discuss in full fledge. We will describe it in the upcoming article.

2. Using vim editor

What if you don’t have vi or vim editor installed on your system?

How to Edit File without vi/vim Editor in Linux?

You can use cat or touch command.

3. Using cat as a text editor

Using cat command to create file

Write the content and once it is done press ctrl+D.

It will save the contents to the file.

Note: Every time when you run this command, it will erase all the contents and write newly entered content. So, be careful if you have any important data in your file.

If you want to edit a file using cat, try the following the command

4. Using touch command

You can also create the file using touch command.

5. using ssh and scp commands

If you are working on the Linux server, you can see there are limited packages installed on the server. There may be a restriction of using resources and so installed packages.

If none of the commands work, follow the steps give below.

  • Login into Linux server using ssh command.
  • Download the file on the local machine from server.
  • Update the file on the local machine.
  • Copy the file back to the server. You can use the scp command (Secure Copy Paste command) to copy a file from the local machine to the server.
Читайте также:  Очистка команд терминала линукс

You can use the simple scp command to copy the file from server to your local system.

6. Using other Programming Language

If you have scripting or any other programming language installed on your system, you can use that to create and edit the file. For example…

It is pretty easy to edit the file using vi and vim editor. But sometimes you may need to edit the file without vi and vim editor. Hope these commands will help you to edit file if there is no vi, vim.

Other vi/vim editor’s commands f0r enhancing your Linux experience:

If you have any doubt or if you have any another alternative to edit file without vi/vim editor, feel free to write in a comment below.

Источник

How to create and edit text files using command-line from Linux Terminal

creating text files command line

I n today’s Terminal Tuts session, we shall show you several ways of creating and editing text files that can be done easily and quickly using the command line.

  1. Cat command
  2. Touch command
  3. Standard Redirect Symbol
  4. Nano command
  5. Vi command

1. Cat Command

Cat command is mainly used to preview the text file content. However, you can use it to create new files and edit them, too, by using the redirection method. For example, use the following command to create a new file:

After executing the command, a cursor will appear waiting for you to enter any text you need to edit the newly created file.

Create a File Using The Cat Command

Once you finished editing your file and you need to exit, press CTRL+D. Now you can see the standard command prompt comes again.

To check if the file was created successfully, you can use the list command as follows:

Check Newly Created File

To ensure that the text you have entered was saved successfully, then you can use the command:

Display The Cat File Content

Display The Cat File Content

Читайте также:  Directx 11 linux proton

2. Touch Command

In this method, you will be able to create single or multiple files using the touch command.

Create a File Using The Touch Command

To check if the new file was created successfully.

Check Newly Created Touch File

Now, in case you need to create multiple files. Then you can use the following command.

touch file1.txt file2.txt file3.txt file4.txt

Create Multiple Files Using The Touch Command

To check if the previous files were created or not.

Check Newly Created Multiple Touch File

Check Newly Created Multiple Touch File

3. Redirect command

In this method, we will use the standard redirect command to create a new file. Unlike the touch command, this method will be able to create one single file only at the time.

Create File Using The Standard Redirect Symbol

To check that the file was created successfully.

Check Newly Created File By Standard Redirect Symbol

4. Nano Command

Using the nano command, you will be able to create a new file and edit it too.

Create File Using The Nano Command

A nano editor will open like the below screenshot, and you will be able to write and edit your file. Once you have finished editing your file, use the CTRL+O to save your file and use the CTRL+X to exit the nano editor.

Edit The Newly Created Nano File

Edit The Newly Created Nano File

To ensure that the previous file was created successfully, use the list command.

Check Newly Created File By The Nano Command

To display the file content, use the following command.

Display The Nano File Content

Display The Nano File Content

6. Vi Command

In this method, we will use the vi command to create a new file and edit it.

Create And Edit New File Using The Vi Editor

A vi editor will open then you can start editing your file. Vi is a little bit different than the nano editor, which means for every action you need to do, there is a command that you need to execute first. For example, if you need to enter the vi command mode first you need to press ESC, then one of the following commands:

:i --> To insert a new line. :w --> To save file. :q --> To exit file. :wq --> To save and quit file. :q! --> To exit file without saving .

Edit New File Using The Vi Editor

To check if the file was created successfully.

Check Newly Created File By The Vi Command

To display the file content.

Display The Vi File Content

Display The Vi File Content

Conclusion

That ends our guide on creating text files and editing them using command-lines via the Linux Terminal. I hope you enjoyed it.

Источник

Оцените статью
Adblock
detector