Select the tool manually
Typically, when using the terminal window and command lines, you are expected to know which tool you want to use. I know that this can be difficult in the beginning, but there are several things you might want to do.
If you use a graphical file manager, there is
- a main tool (for the main task), that you start by left-double-clicking on the file's icon.
- and often a few other tools (for other tasks), that you can select after right-clicking on the file's icon.
The main tasks for a text file might be editing and viewing.
In standard Ubuntu desktop there is gedit
for these tasks.
If you want only viewing in text mode, you can use less
If you want to edit in text mode, you can use nano
So I suggest that you try
gedit file.txt
less file.txt
nano file.txt
You mentioned some alternatives that do not work (because ...)
./myFile.txt
This is typically used to run an executable file
/myFile.txt
This points to a file in the root directory /
cd myFile.txt
cd ./myFile.txt
cd /myFile.txt
This changes the terminal window to the specified directory (cd
'change directory' makes the terminal window look at the specified directory. You should specify a directory (not a file) after the cd
command.)
eog myFile.txt
eog
"Eye of Gnome" is a viewer for picture files.
xdg-open
Until you know which tool to use, you can try with xdg-open
. It will select a tool for you depending of the kind of file you are using. I would expect that it will select gedit
for text files and eog
for picture files (in standard Ubuntu desktop).
xdg-open file.txt
./myFile.txt
, but you only need to set the file to be executable:chmod +x myFile.txt
. Hope this helps.myfile.txt
in the first place or did something else create it? If you created it what program did you use to create it? This question might be an X-Y problem