MALIKA KAROUM

MALIKA KAROUM
  • Home
  • Inleiding
  • Blog
  • video’s
  • Dubai UAE
  • Promotie
  • Marketing
    • Malika Karoum Strategie Modules
    • Malika Karoum Online Marketing
    • Malika Karoum Business Service
    • Malika Karoum Platform
    • 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
    • Malika Karoum Promotion
      • Worth for free now
      • Work from Home 2020
      • 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
    • Adverteren grote fraude
    • Menu POS
    • Malika Karoum Evenementen
  • Malika Security
  • Home
  • Malika Karoum Global News
  • How to Create a New File in Linux
December 11, 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

Create a Virtual Machine Clone of Your Existing Windows Hard Drive
Buying Used Smart Home Technology? Be Aware of These Risks
How to Use the RANDBETWEEN Function in Google Sheets

Malika Karoum Blog 2023

  • Windows 11’s 22H2 Release Date Finally Appears Online

    Windows 11 has had the chance to prove itself t...
  • 8 Simple Photography Genres for Beginners to Try

    Even if you’ve just picked up photography...
  • How to Change the Name of Your Mac

    When you set up your Mac for the first time, Ap...
  • 3 Different Ways to Remotely Record a Podcast Interview

    At some point in your podcasting journey you wi...
  • What Size Should Your Instagram Photos and Videos Be?

    Being a completely visual platform, Instagram h...
  • The 10 Best Raspberry Pi IoT Projects

    Launched in 2012, the Raspberry Pi single-board...
  • 5 Rust WebAssembly Frameworks for Your Next Application

    WebAssembly (WASM) is a portable, low-level bin...
  • How to Switch Off Live Captions in Chrome

    Chrome's Live Caption feature automatically...
  • What to Do if You Drop Your Kindle in Water

    Everyone knows that paper books and water don&#...
  • The Differences Between Level 1, Level 2, and Level 3 EV Charging Explained

    EVs are now omnipresent, and you're probabl...
  • 6 Fixes for AirPods Not Switching Automatically Between Apple Devices

    Whenever you make a call, play some music, or w...
  • The Most Fun Workout Tutorials on YouTube

    Who says exercise has to be a serious endeavor?...
  • Remove the GarageBand Sound Library From Your Mac to Save Storage

    Every Mac comes with GarageBand pre-installed. ...
  • How to Control Your Mouse With the Keyboard in macOS

    Back in the day, before computer mice and track...
  • How to Turn Off Google Assistant on Android, Chromebook, and Smart Devices

    Virtual assistants such as Amazon’s Alexa...
  • Get a Lifetime Microsoft Windows 10 License for $14, Office for $26 

    When you have a Microsoft Windows license, you ...
  • Manage Passwords and Private Data With Keeper

    The many companies with which we all have accou...
  • How to Remove Items From the New Context Menu in Windows 10-11

    Streamlining Microsoft Windows to make it suit ...
  • Geekom’s IT8 Mini PC Is a Palm-Sized, Portable, Powerhouse ‘Puter

    Is your workspace crying out for some additiona...
  • A Beginner’s Guide to Reddit: 9 Tips for New Users

    Reddit can be a daunting place for new users. W...

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