• Home
  • Ubuntu
  • Debian
  • Linux
  • Commands
No Result
View All Result
TECH DHEE
  • Home
  • Ubuntu
  • Debian
  • Linux
  • Commands
No Result
View All Result
TECH DHEE
No Result
View All Result
Home Commands

How to Create a File in Linux

techdhee by techdhee
February 8, 2023
0 0
0

In this article, we will learn how to create a new file in Linux on a regular basis. You can create a new file either from the command line or from the desktop file manager.

Contents hide
1 What you’ll learn
2 What you’ll need
3 Create a File in Linux
3.1 Creating a File with touch Command
3.2 Creating a File with cat Command
3.3 Creating a File with echo Command
3.4 Creating a File using a text editor
4 Video
5 Conclusion

What you’ll learn

  • How to create a file in Linux
  • Some basic about nano

What you’ll need

  • Ubuntu Desktop
  • Sudo-privileged user account
  • Basic Linux command line knowledge

Create a File in Linux

There are various ways to quickly create a new file in Linux using the command line.

  • Using touch Command
  • Using cat Command
  • Using echo Command
  • Using text editor

Creating a File with touch Command

The touch command allows us to update the timestamps on existing files and directories as well as create new, empty files.

To create a new file simply run the touch command followed by the name of the file you want to create:

$ touch file1.txt

To create multiple files at once, specify the file names separated by space:

$ touch file1.txt file2.txt file3.txt

Creating a File with cat Command

The cat command is mainly used to read and concatenate files, but it can also be used for creating new files.

To create a new file run the cat command followed by the redirection operator > and the name of the file you want to create. Press Enter type the text and once you are done press the CRTL+D to save the files.

$ cat > file1.txt

Creating a File with echo Command

The echo command prints the strings that are passed as arguments to the standard output, which can be redirected to a file.
To create a new file run the echo command followed by the text you want to print and use the redirection operator > to write the output to the file you want to create.

$ echo "Some line" > file1.txt

If you want to create an empty simply use the:

$ echo > file1.txt

Creating a File using a text editor

There are many text editors where you can create and edit the file. In this tutorial, we are using the Nano text editor.

$ nano [file name]

This is the way how to create a new file in Linux on a regular basis using the command line and you can use any text editor.

Video

You can watch this video on how to create a new file in Linux on a regular basis.

Conclusion

In this tutorial, you learned how to create a new file in Linux from the command line using various commands and a text editor.

If the command line is not your thing you can easily create a blank text file using the right-click menu in the File Manager.

If you have questions, feel free to leave a comment below.

ShareTweetSendShareSend
Previous Post

How to Install Tor Browser on Ubuntu 22.04

Next Post

Su Command in Linux (Switch User)

techdhee

techdhee

Related Posts

How to Install Arch Linux
Linux

How to Install Arch Linux [Step by Step Guide]

August 6, 2023
Terminal Emulators for Linux
Linux

Top 6 Terminal Emulators for Linux

August 5, 2023
add user to sudoers in Debian
Commands

How to Add User to Sudoers in Debian 11

February 27, 2023
Install Nano Text Editor in Linux
Commands

How to Install Nano Text Editor in Linux

February 24, 2023
Commands

Whoami command in Linux

February 23, 2023
Install ZSH on Ubuntu 22.04
Commands

How to Install ZSH on Ubuntu 22.04 LTS

February 22, 2023

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

You might also like

How-to-Check-Windows-10-is-Genuine-or-Not-Genuine

How to Check Windows 10 is Genuine or Not Genuine

August 6, 2023
How to Install Arch Linux

How to Install Arch Linux [Step by Step Guide]

August 6, 2023
Terminal Emulators for Linux

Top 6 Terminal Emulators for Linux

August 5, 2023
How to Install Tor Browser in Kali Linux 2023.1

How to Install Tor Browser in Kali Linux 2023.1

April 2, 2023

How to install Tweak Tool on Ubuntu 22.04 LTS

March 3, 2023
Install Ngrok on Ubuntu 22.04 LTS

How to Install Ngrok on Ubuntu 22.04 LTS

March 2, 2023

© 2024 tecdhee.com - Tech Tips, Tricks and Tutorials.

  • Home
  • About Us
  • Contact
  • Disclaimer
  • Privacy Policy
No Result
View All Result
  • About Us
  • Contact
  • Disclaimer
  • Home
  • Privacy Policy

© 2024 tecdhee.com - Linux Tips, Tricks and Tutorials.

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In