MALIKA KAROUM

MALIKA KAROUM

  • Home
  • Inleiding
  • Unite Arab Emirates
  • Blog
  • video’s
  • Promotion
    • Worth for free now
    • Work from Home 2023
    • Gadgets
    • All about Windows
    • about Whatsapp
    • Whats the
    • About websites
    • New Ways
    • New Way of Watching
    • Virtual
    • Website
    • All about Video
    • How to Use
    • YouTube Info
    • All about Twitter
    • The Best of
    • About Apps
    • Google News
    • For Free
    • About This
    • Need More
    • Why should you
    • Iphone news
    • Interesting News
    • About Amazone
    • Some tips
    • About Netflix
    • All about Music
    • About Facebook
  • Marketing
    • Malika Karoum Strategie Modules
    • Malika Karoum Online Marketing
    • Malika Karoum Business Service
    • Malika Karoum Marketing Platform
    • Online business marketing
  • Luxury
    • The Indulgence Business site
    • The Luxury Web site
    • The Ultimate Indulgence
    • The Indulgence Site
    • The Ultimate Luxury Information site
    • Online luxury
  • Malika Karoum
    • Malika Karoum LinkedIn
    • Malika Karoum Facebook
    • Malika Karoum Instagram
    • Malika Karoum Business News
    • Adverteren grote fraude
    • Menu POS
    • Malika Karoum Evenementen
  • Security
  • Malika Karoum link
  • Home
  • Malika Karoum Global News
  • How to Create a New File in Linux
February 3, 2023

How to Create a New File in Linux

How to Create a New File in Linux

by Malika Karoum / Sunday, 20 December 2020 / Published in Malika Karoum Global News

There are several different apps and commands in Linux that will create new files for you, even without launching an application. Which method you use will depend on your purpose for the file. Let’s have a look at the options so you can know which is most useful for you.

We’ll cover creating files both in the terminal and on a Linux desktop.

Create a File in the Desktop

If you’re not comfortable using the terminal, creating new files in the desktop environment is simple, using a couple of basic everday apps.

File Browser

Most file browsers like Thunar and Dolphin will allow you to create empty files by right-clicking in the desired directory and hitting Create empty file or a similar option from the dropdown menu.

Alternatively, in the application menu, you can often click File > Create New to get options for generating new files.

Text Editor

Your Linux distro will include one or another basic text editor app. Opening it should start you out with an empty file, and hitting Ctrl+S should give you the dialog for saving it at a specific location.

Create a File in the Terminal

Many Linux terminal commands allow you to make files quickly and efficiently, and we’ll discuss several of them below.

touch

One of the most basic Linux commands, touch will create a new file, or if the file name you specify already exists, update the file’s last modification date.

In the directory you want your file saved in, type:

touch filename.txt

Alternatively, create multiple files with one command by simply placing a space between each file name:

touch filename1.txt filename2.txt filename3.txt

You can check that the file you created exists with this command:

ls

Since you can’t edit files with touch, the command is better suited for quickly creating multiple files to edit later.

Redirect Operator (>)

The right angle bracket is used in many commands for redirecting the output to a specific file. We’ll see it used with other commands later in this article.

You can, however, enter it without a specific command to create an empty file.

> filename.txt

Beware, though, that the redirect operator on its own will overwrite any existing file already using that name.

echo

The echo command will simply print in the terminal whatever input you give it. However, it can also both create a new file and, optionally, save a single line of text inside it.

To create a new empty file, use this command:

echo -n > filename.txt

To create a new file with one line of text, use:

echo "File text" > filename.txt

Be sure when using echo to place quote marks around your text.

cat

The cat command (short for concatenate) is most often used in combining or reading files. However, it can also easily make new files with text in them.

cat > filenname.txt

The redirect operator is again here redirecting the output of cat to the specified file, the output being whatever you type next. When you’re finished writing the contents of your new file, hit Ctrl+D to save it.

printf

The printf command is similar to echo, but with a little more formatting power.

For example, you can create a file with two lines of text using the following single command:

printf 'Some text
Some more text' > filename.txt

fallocate

Fallocate allows you to create a file in Linux with a specific size. It’s mainly useful for testing purposes, like to gauge your hard drive’s writing speed.

Use fallocate with the following command:

fallocate -l 10MB filename

Replace “filename” with whatever you want to call your file.

The “-l” option denotes that you want a specific size, and the “10MB” argument indicates what size. You may use larger byte sizes as well, like GB and TB. You can also use M instead of MB to designate mebibytes instead of mega bytes.

vim

Vim is a terminal-based text editor that will launch when you specify a file name:

vim filename.txt

With vim running, press the i key to begin typing. When you’re done, hit Esc and and type :wq followed by Enter to save and exit.

nano

GNU nano is another text editor similar to Vim, but perhaps a bit more user-friendly.

You can quickly create and start editing a file with this command:

nano filename.txt

Type whatever you wish into the file, then hit Ctrl+S to save and Ctrl+X to exit.

Related: nano vs. Vim: The Best Terminal Text Editors, Compared

Make New Files with Boldness

As a new file creating wizard, go forth and start landscaping your directories with glorious files.

As you gain skills in Linux file management, you’ll find there are a lot of cool tricks for manipulating and hiding files you’ve created.

MakeUseOf – Feed

  • Tweet
Tagged under: Create, FILE, Linux

About Malika Karoum

What you can read next

The Most Fascinating Twitter Moments for Tech Fans
Pocket Sky: Shines Light in Your Eyes to Help You Feel Awake
Want to Know Who’s Trying to Unlock Your Phone? Catch Them in the Act

Malika Karoum Blog 2023

  • How to Delete the Last 15 Minutes of Your Google Search History

    There’s a quick way for you to clear your...
  • Lenovo Wants You to Know Its Yoga Pad Pro Can Be Used as a Portable Switch Display

    Sometimes, when playing with your Nintendo Swit...
  • The 5 Best Apps for Buying and Selling Pre-Owned Books

    We’ve all been at the point where we have...
  • Humble’s Recent "Heal Covid-19" Bundle Raised 1.2 Million for Charity

    To help raise money for COVID-19 relief in Indi...
  • Nintendo Partners With PlayVS to Make Its Games Recognized High School Varsity Athletics

    It’s odd—Nintendo gets a lot of flak for ...
  • The Pros and Cons of Playing Video Games on an Emulator

    If you’re a fan of playing retro video ga...
  • 5 Curators to Find the Best Articles Worth Reading on the Internet

    When anyone and everyone is a publisher, it isn...
  • Apple Could Unveil iPads With OLED Screens in 2023

    Apple only just switched from LCD to mini-LED d...
  • What Is Signal and How Does It Work?

    The chances are that you use at least one of th...
  • Samsung’s Upcoming Flagship Exynos Chipset Will Feature AMD’s RDNA2 GPU

    AMD confirmed its partnership with Samsung at C...
  • Atari Finally Reveals the Launch Date for the New Atari VCS Console

    At last, after what seems like an age (it pract...
  • Twitter Starts Testing Full-Screen Ads in Fleets

    Twitter has announced that it will be adding fu...
  • When Is Facebook Messenger Going to Offer End-to-End Encryption?

    Facebook Messenger is easy to use and has great...
  • Get Paid to Play Apps: How They Work and What You Risk

    You’ve probably seen advertisements for a...
  • When Will PS5 Production Ensure Supply Meets Demand?

    Despite the PS5’s launch taking place in ...
  • How to Manage Processes on Ubuntu Using System Monitor

    Linux, like most modern operating systems, is v...
  • How to Get Verified on Twitter and Finally Get That Blue Check Mark

    Twitter, like most social media platforms, offe...
  • 10 Street Photography Tips That Will Make You a Better Photographer

    Street photography is enjoyed by many enthusias...
  • Huawei Freebuds 4i Review: Quality ANC Earbuds for $100

    Huawei Freebuds 4i 8.00 / 10 Read Reviews Read ...
  • What Is Extended Reality (XR) and How Does It Work?

    We’re living in a digital age where the virtual...

MALIKA KAROUM ONLINE MARKETING PLATFORM

Office:
RME HOLDINGS SARL – DUBAI BRANCH

BUSINESS CENTER

Parcel ID: 345-835

Area: Bur Dubai

Sub Area: Burj Khalifa

UNITED ARAB EMIRATES

 

 

 

Malika Karoum Concept

Malika Karoum Projects

  • GET SOCIAL

© 2014 Malika Karoum -United Arab Emirate Dubai- All Rights Reserved

TOP