<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Prathima Bommannagari</title>
    <description>The latest articles on DEV Community by Prathima Bommannagari (@prathimab).</description>
    <link>https://dev.to/prathimab</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F979223%2F2ec4784c-7a98-408f-a3df-58e5a53c3452.jpg</url>
      <title>DEV Community: Prathima Bommannagari</title>
      <link>https://dev.to/prathimab</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/prathimab"/>
    <language>en</language>
    <item>
      <title>How to convert a Python file to an ELF file, and how to execute the generated ELF file with/without using the terminal in Linux?</title>
      <dc:creator>Prathima Bommannagari</dc:creator>
      <pubDate>Fri, 25 Nov 2022 22:08:27 +0000</pubDate>
      <link>https://dev.to/prathimab/how-to-convert-a-python-file-to-an-elf-file-and-how-to-execute-the-generated-elf-file-withwithout-using-the-terminal-in-linux-11l5</link>
      <guid>https://dev.to/prathimab/how-to-convert-a-python-file-to-an-elf-file-and-how-to-execute-the-generated-elf-file-withwithout-using-the-terminal-in-linux-11l5</guid>
      <description>&lt;h2&gt;
  
  
  &lt;em&gt;What is an ELF file?&lt;/em&gt;
&lt;/h2&gt;

&lt;p&gt;An ELF(&lt;strong&gt;E&lt;/strong&gt;xecutable and &lt;strong&gt;L&lt;/strong&gt;inkable &lt;strong&gt;F&lt;/strong&gt;ormat) file is an executable standard file format for the Linux and Unix platforms. &lt;/p&gt;

&lt;p&gt;The ELF file format is typically used by binary executables in Linux. These serve as Linux's equivalent to Windows' PE (Portable Executable) format, which uses the EXE file extension.&lt;/p&gt;

&lt;p&gt;In addition to the executable code, executable files also include data such as static and dynamic data, linker information, and library imports.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;em&gt;How to convert a Python file to an ELF file?&lt;/em&gt;
&lt;/h2&gt;

&lt;p&gt;To generate an ELF file from a python file, we can use &lt;em&gt;pyinstaller&lt;/em&gt;. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Install pyinstaller using the below command: &lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fie99old4539kpnternsn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fie99old4539kpnternsn.png" alt="pyinstaller command" width="222" height="32"&gt;&lt;/a&gt;If you are using a python version that's older than python3, replace pip3 with pip in the above command.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create a .py file or go to the path where your existing python file resides.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcba0jos8vimiylwq8buc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcba0jos8vimiylwq8buc.png" alt="Python file" width="493" height="21"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Run the below command to convert the python file to an executable:&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjnpmouts7foirbpobu0u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjnpmouts7foirbpobu0u.png" alt="ELF conversion" width="309" height="22"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Pyinstaller creates a dist(distribution) directory, that contains the main executable(ELF) and the dynamic libraries bundled in an executable file.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F15bwk1y7pv6juh337qjc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F15bwk1y7pv6juh337qjc.png" alt="elf file generated" width="536" height="56"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  &lt;em&gt;How to run the executable file in Linux?&lt;/em&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;Using the terminal:&lt;/em&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open the terminal.&lt;/li&gt;
&lt;li&gt;Go to the path where the ELF file is located and execute the ELF file by placing &lt;strong&gt;./&lt;/strong&gt; before the elf filename as below:
&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb7986djnzj1l9kw7bw4z.png" alt="Running the ELF file using terminal" width="290" height="22"&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;em&gt;Without using the terminal:&lt;/em&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open the File explorer and go to the path where the ELF is located.&lt;/li&gt;
&lt;li&gt;Right-click on the executable file, go to Properties--&amp;gt; Permissions tab--&amp;gt; check the box 'Allow executing file as program' --&amp;gt; Close the properties window.
&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhnmr9gn1xrjz0jkvci41.png" alt="Running ELF without using the terminal" width="462" height="457"&gt;3. Run the executable file by just double-clicking on it (similar to running an exe file on Windows).&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>watercooler</category>
    </item>
  </channel>
</rss>
