- How to Create a file in Ubuntu Linux using command & GUI
- Create a file in Ubuntu 20.04 using GUI & right-click
- Command-Line to create a new document on Ubuntu Linux
- 5 Best Ways to create a new file on Linux
- 1. Using the Touch command
- 2. Nano Editor
- 3. Vim or Vi text editor
- 4. Echo command using Redirect operator
- 5. Cat command
- Linux: Shell Commands for GUI Apps
- Method 3: Use top
- Command to Put Machine to Sleep
- Command to Set Default App
- launch GUI app from terminal?
- Linux: Sync X11 Primary Selection and Clipboard
- Linux Shell Basics
- Directory and Files
- Compress, Archive, Download
- Text Processing
- User, Group, File Perm
- misc
- Process, Job Control
- Bash/Terminal
- Linux Desktop
- 6 Useful X-based (Gui Based) Linux Commands – Part II
- 9. Googlizer
- What’s special about Googlizer?
- 10. xwininfo
- 11. xmag
- 12. xkbwatch
- 13. xclock
- 14. xgc
- Linux CLI and GUI Tools
- Linux Command Line (CLI) Tools
- Linux Graphical (GUI) Tools
How to Create a file in Ubuntu Linux using command & GUI
Creating files on Linux is not a cumbersome task, however, those who are new to it or just shifting from Windows to Ubuntu-like systems may face some problems with creating files using command line especially.
Well, even on Linux anybody can create files and folders using a graphical user interface that works just like a charm. Simply right-click and select the New folder or New Document for text files. However, this is not true with every Linux system. For example on Ubuntu right-clicking will give you the only option to create a new folder, thus when it comes to creating a text using GUI you will get stuck.
Therefore, to create a file on Ubuntu Linux, there are two options either using the command terminal or enabling the “new document” option in the right-click context menu of Ubuntu. We will show both the methods.
Create a file in Ubuntu 20.04 using GUI & right-click
Although here we are using Ubuntu 20.04 LTS, the steps given below are applicable for Ubuntu 19.04/18.04 and previous versions.
By default, when we right-click inside anywhere in the Ubuntu Nautilus file manager, it will not give us the “New document” option. Thus, to get this missing option, we need to run a command.
- Open Ubuntu command terminal.
- Run command-
mkdir -p ~/Templates/Text cd ~/Templates/Text touch document
For example, I want to create some text document files on my Linux Desktop, then inside the Desktop folder I will right-click, rest of the below picture can describe.
Command-Line to create a new document on Ubuntu Linux
There are a couple of ways to create an empty file without any content or one with some on Linux, here we show all the best possible ways to do that using the command terminal. The below-given commands are applicable for all types of Linux distros.
5 Best Ways to create a new file on Linux
Note: Inside any folder that was created with root rights, create a file there. we have to use sudo with every command given below.
1. Using the Touch command
As we already have seen in the GUI method, how we have created an empty document using the Touch command in the terminal. Thus, in the same way anywhere in any directory, we can use the touch tool to create an empty file.
The command syntax is:
touch file-name
Now, here we can define the extension to let the system what kind of file we want to create such as a txt, docx.
For example, I want to create a Text file or Docx, thus the command will be:
Here is the example screenshot, where we have created a file on the Ubuntu Desktop using command terminal and touch command:
2. Nano Editor
Nano is the popular and easy-to-use command-line visual text editor that not allows users to edit any existing file on the system using the terminal but also lets us create a new file to add some content and save it anywhere on Linux.
Some Linux may not have nano editor by default, thus to install it run:
For Ubuntu/Debian – sudo apt install nano
For REHL based Linux- sudo yum install nano
Now, how to use a nano text editor to create a new file? Well, it is quite simple, on command terminal type- nano along with the filename.
for example, I want to create a text file then the command will be:
Add some lines or just press the Enter key. Then save the file by pressing Ctrl+X , type Y , and hit the Enter key.
3. Vim or Vi text editor
Vi is a command-line text editor that is available to use on every Linux including Ubuntu out of the box, thus no need to install anything, just use its command to create or edit an existing file on your system.
Now, what is the difference between VIM and VI text editors? Vi is the early implementation of a visual text editor and that is why it is available on all Linux systems, whereas VIM that stands for Vi IMproved, is the enhanced version for Vi text editor with many additions. Thus, you may not find VIM by default on all Linux distros and need to install it manually.
To install VIM on Ubuntu/Debian type- sudo apt install vim
For RHEL based– sudo yum install vim
Nevertheless, the syntax to create a new file on Linux using both the editors will be the same. However, they are slightly complex to use as compared to nano .
To create a file using Vim or Vi type
vi filename.txt
To add the content, press the “INSERT” key on your keyboard. Once you are done and want to save the created file’s content press the Esc key and then type :wq , and finally hit the Enter key to exit.
4. Echo command using Redirect operator
The echo command is another one available on all Linux distros to not only create a new file but also add the text in the same. I mean you can add the text into your file right the moment you are creating it.
echo > file-name
Let’s see some examples using the Echo command:
So, if I want to create a new file on Linux with echo and at the same time I also want to add some text into it, let’s say “My name is Linux” thus the command will be like this:
echo «My name is linux» > h2s.txt
In the above, the command h2s.txt file will be created having the content “My name is Linux“.
If you want to create a blank file with echo then don’t type anything before Redirect > operator i.e >
5. Cat command
Cat is also easy to use Linux command that can create a file using a command-line interface.
Add the text you want in your file and hit the Enter button. To save the file, press- Ctrl+D .
Note: For empty files don’t add any text and use only the shortcut to save it.
If you want to read the text of any existing file without opening it, then cat can be used.
For example, let’s create a file demo.txt and then add the text “My name is Linux” into it. Once done, save it and again call the same using the cat to read its text directly inside the terminal but without actually opening the file.
Add text and hit the Enter key
Save the file – Ctrl + d
If you want to read the text of the file using the cat command then type:
Linux: Shell Commands for GUI Apps
launch the app by mouse. Then, in terminal type ps -ef | grep string , where string is what you think the name contains, for example, .
Method 3: Use top
type top first, then launch the app, and watch it appear in top.
Command to Put Machine to Sleep
Command to Set Default App
launch GUI app from terminal?
xyz & → launch GUI app named “xyz”.
Linux: Sync X11 Primary Selection and Clipboard
2012-04-19 thanks to [ amirhoshangi ] [ 2012-10-11 https://twitter.com/amirhoshangi ], [Manuel Lara https://plus.google.com/100356143682994881415/posts], Leonardo Torres, Yanko Simeonoff.
Linux Shell Basics
Directory and Files
Compress, Archive, Download
Text Processing
User, Group, File Perm
misc
Process, Job Control
Bash/Terminal
- Bash/Terminal Keys
- Man Page Keys
- Bash Prompt Setup
- Bash Color Prompt
- bash init/profile
- zsh Prompt Setup
- Virtual Terminal
- Terminal Control Sequence Keys
- Ctrl+s Freeze vim
- Reset Terminal
- tmux
- Bash Manual in Chapters
- Bash Misc Tips
- Log Terminal Session
- xterm Copy Paste, Font Size
Linux Desktop
- Useful GUI App Names
- Set Default App
- Commands for GUI Apps
- Image Viewers
- Music Players
- Move to Trash Command
- X11 Selection and Clipboard
- Switch to LXDE/Xfce
- Restart X11
- Why Tiling Window Manager Sucks
- Standard Fonts
- Install Font
6 Useful X-based (Gui Based) Linux Commands – Part II
In our first article on X-window (Gui Based) Linux commands, we’ve covered some useful and interesting Graphical commands. Adding to that list, here we again presenting 6 other useful X-based Linux commands/programs.
- 8 X-based Useful Linux Commands – Part I
9. Googlizer
This is one of the very handy and useful application which lets you search any text within the X-selection. Googlizer may not be available in your repo. On Debian Squeeze there is a package called “Googlizer” where as on Debian wheezy, the said package is not available in repo.
In case, the package is not available in repo, of the distribution you are using. You can always download the tarball from the links provided below and build it from there.
What’s special about Googlizer?
After installing Googlizer, put a launcher shortcut either on Dock bar or launcher. Just select the text, anywhere on X, and click the Googlizer shortcut launcher to search that text on Google.
For example, I’ve selected the Text ‘Tecmint‘ on a document file and clicked Googlizer application launcher. Here is the screen grab below for your reference.
As soon as I clicked the Googlizer application, my default web browser opened the Google search Engine and searched for the selected text.
10. xwininfo
The xwininfo is a very wonderful tool which runs in command line to provide detailed information about any already Opened X-window. We run the command in terminal and selected the browser window.
On selection, we got the detailed Windows Information right in our terminal, instantly.
11. xmag
The xmag is another beautiful application which comes handy specially for those who are visually impaired. xmag magnifies a part of x windows selection.
A part magnified, on selection.
12. xkbwatch
This application reports changes in the fundamental components of the XKB keyboard State. It actually is a XKB extension user utility.
13. xclock
This is an interesting application. As soon as you run xclock in terminal, you get an Analogue clock in the GUI. Well if you are going to ask me, the use of this xclock in productivity, i am sorry! I myself could not figure out if there is any better use of this xclock other than a little fun. If you know much better use of this application feel free to give your view.
14. xgc
The Xgc opens up X windows Graphics demo. The xgc program demonstrates various features of the X graphics primitives.
Not to Mention, You would be aware of xedit which will open simple GUI Text editor and xcalc which will open GUI calculator. This is not the end. We do have a lot of X windows application both in the repository of almost all standard Linux Distribution as well as available from Third party.
If we find any other useful/funny X windows application we will create an article on that. If you know of any other X windows Application, Please make us know by commenting in our feedback section.
Moreover, we already have published an article on Funny Linux Commands which includes many of Funny X Windows Application. You may refer to that post by clicking the link below.
I’ll be here again, with another interesting article. Till then Stay Healthy, Tuned and Connected to Tecmint. Don’t Forget to Provide us with your valuable feedback.
Linux CLI and GUI Tools
This Linux CLI (Command Line Interface) and GUI (Graphical User Interface) series presents you with some cool useful terminal tools and graphical utilities.
Linux Command Line (CLI) Tools
- ExifTool – Read, Write and Manipulate Image, Audio, Video and PDF Metadata
- 8 Best du Command Alternatives to Check Disk Usage in Linux
- CLI Tools to Remove PDF Password in Linux
- ttyd – Share Your Linux Terminal Over Web Browser
- CPU-X – Shows Information on Linux CPU, Motherboard and More
- Nala – A Neat Structured Frontend for APT Package Manager
- Best Command Line Torrent Clients for Linux
- How to Install and Use WP-CLI on Linux [Beginners’ Guide]
- 6 Best To-Do List Managers for Linux Command Line
- Stig – A TUI and CLI Client for BitTorrent Transmission
- ytfzf – Find and Watch YouTube Videos in Linux Terminal
- Gum – A Tool for Glamorous Shell Scripts in Linux
- Ranger – A Vim-Inspired Console File Manager for Linux
- Hledger – A Plain Text Accounting Tool for Linux Terminal
- mps-youtube – A Terminal Based YouTube Player and Downloader
- Calcurse – A CLI Based Calendar and Scheduling Tool Linux
- ugm – A TUI to View User and Group Information in Linux
- gosling – Natural Sounding Text-to-Speech in the Terminal
- BusyBox: The Swiss Army Knife of Embedded Linux
- Htop – An Interactive Linux System Monitor/Process Viewer
- How to Install and Use Terminator Terminal in Linux
- How to Install and Use Tmux (Terminal Multiplexer) in Linux
- Silver Searcher – A Code Searching Tool Similar to Ack
- Ripgrep – The Fastest Command Line Search Tool for Linux
- How to Install and Use Tilix Terminal Emulator in Linux
- Micro – A Command Line Based Text Editor for Linux
Linux Graphical (GUI) Tools
- Best Du Command Alternatives to Check Disk Usage in Linux
- Best GUI Tools to Remove PDF Password in Linux
- Best Graphical Package Managers for Arch Linux
- Gwenview – Crop and Resize Images on Linux
- Skanlite – A Simple Image Scanning Tool for Linux
- Wine – Run Windows Applications in Ubuntu
- MySQL Workbench – A Visual Database Design Tool for Linux
- Okteta – A Simple Editor for RAW Data Files
- Meld – A Visual Diff and Merge Tool for Linux
- Best Tools to Merge PDF Files in Linux
- WebSSH – Connect Linux Terminal from Your Web Browser