LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-12-2014, 04:52 PM   #1
theKbStockpiler
Member
 
Registered: Sep 2009
Location: Central New York
Distribution: RPM Distros,Mostly Mandrake Forks;Drake Tools/Utilities all the way!GO MAGEIA!!!
Posts: 986

Rep: Reputation: 53
Dumb gedit question


Why is it that Nautilus does not ask how to save a gedit file and when you inspect the file name there is no .txt after the name you gave the file?

Thanks in advance!
 
Old 02-12-2014, 05:09 PM   #2
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
On Linux, in opposite to Windows systems, the filetype is not determined by file extensions, like .txt, but by their actual format.
 
Old 02-12-2014, 05:09 PM   #3
DavidMcCann
LQ Veteran
 
Registered: Jul 2006
Location: London
Distribution: PCLinuxOS, Debian
Posts: 6,142

Rep: Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314
Extensions are a feature of Windows. It's true that many Linux programs use them, but they are not a feature of the operating system itself. If your file is called "thing.odt", then that's the name, while in non-Unix type systems the name would be "thing".

Gedit is not a program that insists on creating extensions. The office suites do it, but that's because they have a lot of specialised formats to keep track of.
 
Old 02-12-2014, 07:05 PM   #4
theKbStockpiler
Member
 
Registered: Sep 2009
Location: Central New York
Distribution: RPM Distros,Mostly Mandrake Forks;Drake Tools/Utilities all the way!GO MAGEIA!!!
Posts: 986

Original Poster
Rep: Reputation: 53
thanks for the help!

Lets say I open a gedit file with abiword. Does abiword inspect the file (calculate the file format) or is gedit's file format stored in the gedit file somewhere so abiword just look at a header or something to determine how to represent the file?
 
Old 02-12-2014, 07:39 PM   #5
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 2,150

Rep: Reputation: 449Reputation: 449Reputation: 449Reputation: 449Reputation: 449
Question

Quote:
Originally Posted by TobiSGD View Post
On Linux, in opposite to Windows systems, the filetype is not determined by file extensions, like .txt, but by their actual format.
So when the file or program is run against a particular file. The program being used to open the file will determine whether it can open the file or not?

If not the right program for the file; Linux kernel will just throw an error?
 
Old 02-12-2014, 08:04 PM   #6
sgosnell
Senior Member
 
Registered: Jan 2008
Location: Baja Oklahoma
Distribution: Debian Stable and Unstable
Posts: 1,943

Rep: Reputation: 542Reputation: 542Reputation: 542Reputation: 542Reputation: 542Reputation: 542
Gedit has no file format, it just saves whatever you put into it. Normally that's just text. Abiword would look at the file and determine that it's ASCII text, and open it as such. Yes, it's up to the program to decide if it can open the file. The kernel doesn't do anything, the program you told to open the file is responsible for giving you the error message if it can't open it.

LibreOffice has to use extensions, because the file may be opened by other operating systems like Windows, which insist on having the proper extension, or else they just refuse to open the file. For a plain text file, you can name it anything you like, with any extension you like, or none at all, it makes no difference to a Linux program. Gedit will happily try to open any file you give it, but if it's not a text file, it will tell you so and ask if you really, really want to it to try to open the file. If you say yes, it will attempt to display the file as text, even though the ASCII symbols may look strange. Think before you say yes, and attempt to edit a binary file.

Last edited by sgosnell; 02-12-2014 at 08:09 PM.
 
Old 02-12-2014, 09:20 PM   #7
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 2,150

Rep: Reputation: 449Reputation: 449Reputation: 449Reputation: 449Reputation: 449
Offtopic:
Quote:
Think before you say yes, and attempt to edit a binary file.
Would there be a case that you can open a malicious file?
 
Old 02-13-2014, 05:23 AM   #8
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
Quote:
Originally Posted by theKbStockpiler View Post
Lets say I open a gedit file with abiword. Does abiword inspect the file (calculate the file format) or is gedit's file format stored in the gedit file somewhere so abiword just look at a header or something to determine how to represent the file?
There is no such thing as a Gedit file, gedit is a plain text editor. If you open it in Abiword Abiword will recognize that it is a plain text file and open it accordingly.

Quote:
Originally Posted by JJJCR
So when the file or program is run against a particular file. The program being used to open the file will determine whether it can open the file or not?
Yes.
Quote:
If not the right program for the file; Linux kernel will just throw an error?
No, the kernel doesn't care about file formats and also does not know which programs can open which filetypes. It is the program that tries to open that file that is throwing the error messages.

Quote:
Would there be a case that you can open a malicious file?
Difficult question. Malicious files are usually those that have either an executable part in the content, like Flash or makros of an office program, or when the content is interpreted, like PDF files. Usually you won't get a malicious reaction from a program that is not meant to open a specific filetype.
 
Old 02-13-2014, 07:10 AM   #9
qlue
Member
 
Registered: Aug 2009
Location: Umzinto, South Africa
Distribution: Crunchbangified Debian 8 (Jessie)
Posts: 747
Blog Entries: 1

Rep: Reputation: 172Reputation: 172
Quote:
Originally Posted by JJJCR View Post
Offtopic:


Would there be a case that you can open a malicious file?
Well, since a malicious file will usually be an executable file, there are safeguards in place that greatly reduce the risk. An executable file must be marked as executable by most modern systems in order to run. If it's not, it will simply open as a text file. (assuming it's a plain text script)

You can also limit file execution to files in the appropriate directories. (/bin /usr/bin etc.)
Most distros are configured that way out the box and won't run an executable file from your home directory regardless.

Since you need root privileges to copy files to the root directories where executables are normally launched from, it is a not easy for a hacker or some malware to put a malicious file there.

What the extension dose do is provide an easy, readable visual clue to the end user as to what the function of a file might be.

For example, .doc .pdf .odt are clearly documents while .txt is probably human readable plain text and .py .sh suggests plain text scripts and are likely executable.
 
Old 02-13-2014, 07:33 AM   #10
sgosnell
Senior Member
 
Registered: Jan 2008
Location: Baja Oklahoma
Distribution: Debian Stable and Unstable
Posts: 1,943

Rep: Reputation: 542Reputation: 542Reputation: 542Reputation: 542Reputation: 542Reputation: 542
The real problem with editing executable binary files with a text editor is that you will probably make the file unusable. If it's a necessary part of the OS you may make the system unusable. As long as you don't edit the file, or don't save it after editing, there should be no problem. Even if the binary does contain malicious code, opening it in a text editor should have no effects. You would need to run the binary before it could do anything.
 
Old 02-13-2014, 08:03 AM   #11
theKbStockpiler
Member
 
Registered: Sep 2009
Location: Central New York
Distribution: RPM Distros,Mostly Mandrake Forks;Drake Tools/Utilities all the way!GO MAGEIA!!!
Posts: 986

Original Poster
Rep: Reputation: 53
Quote:
There is no such thing as a Gedit file, gedit is a plain text editor. If you open it in Abiword Abiword will recognize that it is a plain text file and open it accordingly.
Does "recognize" mean that the type of file is stored in a header of the gedit file?

Edit: Does the linux loader do the work for gedit?

Last edited by theKbStockpiler; 02-13-2014 at 01:32 PM.
 
Old 02-13-2014, 05:08 PM   #12
sgosnell
Senior Member
 
Registered: Jan 2008
Location: Baja Oklahoma
Distribution: Debian Stable and Unstable
Posts: 1,943

Rep: Reputation: 542Reputation: 542Reputation: 542Reputation: 542Reputation: 542Reputation: 542
No, and no.

There is no header for text files. It's just plain ASCII text. The binary which opens the file is responsible for recognizing that.

What Linux loader? What happens is that gedit, or any other Linux program, is loaded into memory and then has the responsibility for doing whatever it does. In the case of gedit, it either opens the file passed to it via the command line or another program, or if there is none, it waits for the user to tell it what to do. If it is told to open a file, it opens the file. It makes no difference what the filename is, or what the format is. It just opens the file. It should look at the file it opened, and act accordingly. Gedit will check the file, and if it finds that it's not a plain ASCII text file, it will ask you what you want it to do. If it is a text file, it will show the contents in the edit window. Any Linux program should do something similar - open the file it's told to open, and then do something. If it finds the file is not the type it expects, it should default to asking the user what to do. The file type is dependent entirely on the contents of the file, and not at all on the filename.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Gnome 3, Gedit 3.0.5, when I open file with gedit, it created one more unneeded tab Mr. Alex Linux - Software 1 06-18-2011 07:58 AM
dumb Question mdpMaDaFaKa Linux - General 1 05-06-2009 04:47 PM
Really dumb question peonuser Solaris / OpenSolaris 2 01-30-2009 07:23 AM
Gedit question jaepi Linux - Software 1 02-03-2008 09:09 PM
dumb question jmarsh Linux - Networking 5 02-19-2003 06:34 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:41 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration