Solved

magic number in unix

Posted on 2000-02-22
5
1,138 Views
Last Modified: 2008-03-06
What is the magic number in unix???
0
Comment
Question by:bolotin
  • 4
5 Comments
 
LVL 3

Expert Comment

by:RobWMartin
ID: 2547078
It is a known sequence of bytes that always show up in a file of a certain type.  You can usually assume that if the sequence shows up in the right spot in the file, you have a file of the given type.  For example, if the file starts with 0x000001b3 it is an MPEG video stream.  The information is usually kept in a magic file.  The "file" command uses it to identify files.

Rob
0
 
LVL 3

Expert Comment

by:RobWMartin
ID: 2547100
BTW:  you can look at the contents of the magic file to find the magic numbers of well-known file types.  Since the location of the magic file depends on the flavor of *nix you are using, try

find / -name 'magic'

Then pipe the file through the more command to look at it.

Rob
0
 

Accepted Solution

by:
cartoon022100 earned 50 total points
ID: 2550049
the file "/etc/magic" contains all magic numbers. the "file" command uses this magic number to compare with the contents in the file.depending upon the matching ,the file command gives output as ascii text  ot C file or binary file etc etc

"man magic" may help u more
Inigo
0
 
LVL 3

Expert Comment

by:RobWMartin
ID: 2554760
The magic file is not located at /etc/magic on all systems.
0
 
LVL 3

Expert Comment

by:RobWMartin
ID: 2616313
bolotin,

Hate to be pushy, but you need to decide who gave you the right answer first.  You can accept one of my comments as the answer, unless you feel cartoon gave you more useful info.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

In tuning file systems on the Solaris Operating System, changing some parameters of a file system usually destroys the data on it. For instance, changing the cache segment block size in the volume of a T3 requires that you delete the existing volu…
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now