{"id":22596,"date":"2023-10-27T17:15:04","date_gmt":"2023-10-27T17:15:04","guid":{"rendered":"https:\/\/linuxways.net\/?p=22596"},"modified":"2023-10-27T17:15:04","modified_gmt":"2023-10-27T17:15:04","slug":"how-to-check-executable-file-in-linux-ubuntu","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/ubuntu\/how-to-check-executable-file-in-linux-ubuntu\/","title":{"rendered":"How to Check Executable File in Linux\/Ubuntu?"},"content":{"rendered":"<p>An Executable File in Ubuntu is a File that contains a program or a code that the user or system can run. Executable Files in Ubuntu tells the Ubuntu System what to do and it instructs the CPU on how to do it. With Executable Files, there is no need for Additional Software to be Installed or any Dependency to be Added. An Ubuntu User can easily download and share executable files that can easily be executed.<\/p>\n<p>This article describes the methods to check executable files in Ubuntu.<\/p>\n<h2><strong>How to Check an Executable File in Linux\/Ubuntu?<\/strong><\/h2>\n<p>The Executable Files in Ubuntu are either the <strong>ASCII Text Files<\/strong>, <strong>Text Executable Files<\/strong>, or the <strong>ELF 64-bit LSB pie Executable Files<\/strong>. The ELF or the <strong>Executable &amp; Linkable File <\/strong>Format is a common Binary File Format in Ubuntu for Executable Files. The Text Executable file is the file that the user makes executable, i.e. a Text file or a script file is made executable using the \u201cchmod +x\u201d command. To learn more about \u201cchmod\u201d and to <a href=\"https:\/\/linuxways.net\/de\/linux-commands\/understanding-chmod-x-making-files-executable\/\">Make Files Executable<\/a>, follow the complete Guide. ASCII Text Files are those that contain simple Text Content inside. The File Type tells us if the File is Executable or not. To Check the File Type in Ubuntu, the following common methods are used:<\/p>\n<ul>\n<li>Check if a File is Executable with the \u201cfile\u201d Command.<\/li>\n<li>Check if a File is Executable with the \u201cfind\u201d Command.<\/li>\n<li>Check if a File is Executable with the \u201cls\u201d Command.<\/li>\n<li>Check if a File is Executable through the File Properties.<\/li>\n<\/ul>\n<h2><strong>Check the Executable File using the \u201cfile\u201d Command<\/strong><\/h2>\n<p>One of the most widely used commands to check if the File is Executable or not is the \u201cfile\u201d command. The \u201cfile\u201d command returns the file type in the Terminal. The \u201cfile\u201d command in the Terminal can simply be used along with the File Name:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">file<\/span> <span class=\"sy0\">&lt;<\/span>fileName<span class=\"sy0\">&gt;<\/span><\/div><\/div>\n<p>In our case, to check the executable files, we navigated to the Home Directory and opened the Terminal:<\/p>\n<p>Now, in the Home Directory, to check the File type of the \u201cencrypted.txt\u201d file, execute the \u201cfile\u201d command as follows:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">file<\/span> encrypted.txt<\/div><\/div>\n<p>The File Type will return in the Terminal Confirming if it is Executable or not. In our case, the file \u201cencrypted.txt\u201d is simply an ASCII Text File meaning it cannot be executed:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"736\" height=\"147\" class=\"wp-image-22597\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22596-2.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22596-2.png 736w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22596-2-300x60.png 300w\" sizes=\"auto, (max-width: 736px) 100vw, 736px\" \/><\/p>\n<p>Now, in the same directory, to check the File Type of the File \u201cscript.sh\u201d, the \u201cfile\u201d command used will be:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">file<\/span> script.sh<\/div><\/div>\n<p>In this case, the Terminal returns the File Type of the \u201cscript.sh\u201d file to be ASCII text Executable. This means that the file initially was not an executable file, rather it was made executable by the user:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"882\" height=\"377\" class=\"wp-image-22598\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22596-3.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22596-3.png 882w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22596-3-300x128.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22596-3-768x328.png 768w\" sizes=\"auto, (max-width: 882px) 100vw, 882px\" \/><\/p>\n<p>Multiple files can also be checked if they are executable or not with the \u201cfile\u201d command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">file<\/span> <span class=\"sy0\">&lt;<\/span>file1<span class=\"sy0\">&gt;<\/span> <span class=\"sy0\">&lt;<\/span>file2<span class=\"sy0\">&gt;<\/span> ... <span class=\"sy0\">&lt;<\/span>fileN<span class=\"sy0\">&gt;<\/span><\/div><\/div>\n<p>In our case, to check the \u201cpythonScript.sh\u201d and the \u201crubygems\u201d file, the \u201cfile\u201d command will be:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">file<\/span> pythonScript.sh rubygems-3.3.7.tgz<\/div><\/div>\n<p>The Terminal displays the File Type of both the files line by line and you can see the \u201cpythonScripts.sh\u201d file is an ASCII Text Executable File whereas the \u201crubygems\u201d is the Compressed File:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"857\" height=\"315\" class=\"wp-image-22599\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22596-4.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22596-4.png 857w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22596-4-300x110.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22596-4-768x282.png 768w\" sizes=\"auto, (max-width: 857px) 100vw, 857px\" \/><\/p>\n<p>To check the File Type of the file \u201cnew\u201d in our current working directory, the \u201cfile\u201d command will be executed as follows:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">file<\/span> new<\/div><\/div>\n<p>The \u201cnew\u201d file is an ELF 64-bit Executable File:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"769\" height=\"290\" class=\"wp-image-22600\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22596-5.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22596-5.png 769w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22596-5-300x113.png 300w\" sizes=\"auto, (max-width: 769px) 100vw, 769px\" \/><\/p>\n<h2><strong>Check the Executable File using the \u201cfind\u201d Command<\/strong><\/h2>\n<p>The \u201cfind\u201d command can also be used to list and check the Executable Files in a Directory. The \u201cfind\u201d Command usually finds files and directories but with the \u201ctype\u201d option, you can list the Executable Files as well. In our case, we will list all the Executable Files in the Home Directory:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1659\" height=\"266\" class=\"wp-image-22601\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22596-6.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22596-6.png 1659w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22596-6-300x48.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22596-6-1024x164.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22596-6-768x123.png 768w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22596-6-1536x246.png 1536w\" sizes=\"auto, (max-width: 1659px) 100vw, 1659px\" \/><\/p>\n<p>The \u201cfind\u201d command to list all the Executable files in the Home Directory is:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> <span class=\"kw2\">find<\/span> . <span class=\"re5\">-type<\/span> f <span class=\"re5\">-executable<\/span> <span class=\"re5\">-print<\/span><\/div><\/div>\n<p>The \u201cf\u201d option looks for the Regular Files and the \u201c-executable\u201d option will return only those files in the Terminal that are executable:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"989\" height=\"558\" class=\"wp-image-22602\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22596-7.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22596-7.png 989w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22596-7-300x169.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22596-7-768x433.png 768w\" sizes=\"auto, (max-width: 989px) 100vw, 989px\" \/><\/p>\n<p>With the \u201cfind\u201d command, you can also return all the non-executable files. The command to list all the Non-Executable Files with the \u201cfind\u201d command will be:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> <span class=\"kw2\">find<\/span> <span class=\"sy0\">\/<\/span>usr<span class=\"sy0\">\/<\/span><span class=\"kw3\">local<\/span> <span class=\"re5\">-type<\/span> f <span class=\"sy0\">!<\/span> <span class=\"re5\">-executable<\/span> <span class=\"re5\">-print<\/span><\/div><\/div>\n<p>All the Non-Executable files in the Current Working Directory will be displayed:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1200\" height=\"588\" class=\"wp-image-22603\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22596-8.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22596-8.png 1200w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22596-8-300x147.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22596-8-1024x502.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22596-8-768x376.png 768w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/p>\n<h2><strong>Check the Executable File Using the \u201cls\u201d Command<\/strong><\/h2>\n<p>The \u201cls\u201d command is another useful way to find the Executable Files in a Directory. The \u201cls\u201d command displays all the files and directories inside a specific working directory:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">ls<\/span><\/div><\/div>\n<p>In our case, we are working in the Home Directory:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1410\" height=\"230\" class=\"wp-image-22604\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22596-9.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22596-9.png 1410w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22596-9-300x49.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22596-9-1024x167.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22596-9-768x125.png 768w\" sizes=\"auto, (max-width: 1410px) 100vw, 1410px\" \/><\/p>\n<p>Now, to display all the files and the directories inside the Home Directory, the \u201cls\u201d command is used. To display the details of each file and directory as well, the \u201c-l\u201d option is used along with the \u201cls\u201d command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">ls<\/span> <span class=\"re5\">-l<\/span><\/div><\/div>\n<p>This will display the files and directories along with the details:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"854\" height=\"495\" class=\"wp-image-22605\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22596-10.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22596-10.png 854w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22596-10-300x174.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22596-10-768x445.png 768w\" sizes=\"auto, (max-width: 854px) 100vw, 854px\" \/><\/p>\n<p>Notice the First Column of the Listed Files and Directories and you will see the file and directories permission. In the Permissions, the \u201c-x\u201d is displayed with the file that is executable. All the files having the \u201c-x\u201d permission are ASCII Text Executable Files as well as the ELF 64-bit Executable Files:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"856\" height=\"500\" class=\"wp-image-22606\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22596-11.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22596-11.png 856w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22596-11-300x175.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22596-11-768x449.png 768w\" sizes=\"auto, (max-width: 856px) 100vw, 856px\" \/><\/p>\n<p>This is how users can check if a file is executable or not using a Linux terminal.<\/p>\n<h2><strong>Check the Executable File through the File Properties<\/strong><\/h2>\n<p>Checking the File Type through the File Properties in the GUI is the easiest and simplest way to see if the File is Executable or not. You can access the File Properties through the Properties option by right-clicking on a specific file. Considering our case, we have a file \u201cnew\u201d in our Home Directory:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1161\" height=\"285\" class=\"wp-image-22608\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22596-12.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22596-12.png 1161w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22596-12-300x74.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22596-12-1024x251.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22596-12-768x189.png 768w\" sizes=\"auto, (max-width: 1161px) 100vw, 1161px\" \/><\/p>\n<p>To check the File Type, right-click on the File which will list the options available. Click on the Properties Option:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"701\" height=\"641\" class=\"wp-image-22609\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22596-13.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22596-13.png 701w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22596-13-300x274.png 300w\" sizes=\"auto, (max-width: 701px) 100vw, 701px\" \/><\/p>\n<p>The Basic Properties Menu will appear. The Type of File can be seen under the Name details of the File. In our case, the File \u201cnew\u201d is of Executable File Type:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"512\" height=\"438\" class=\"wp-image-22610\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22596-14.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22596-14.png 512w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22596-14-300x257.png 300w\" sizes=\"auto, (max-width: 512px) 100vw, 512px\" \/><\/p>\n<p>The \u201cexecutable\u201d file type verifies that the file \u201cnew\u201d is an ELF 64-bit Executable File.<\/p>\n<p>Similarly, we can check the file type of the file \u201cscript.sh\u201d in our Home Directory:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"884\" height=\"246\" class=\"wp-image-22611\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22596-15.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22596-15.png 884w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22596-15-300x83.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22596-15-768x214.png 768w\" sizes=\"auto, (max-width: 884px) 100vw, 884px\" \/><\/p>\n<p>Right-clicking on the file will list the options, and among the Options, we will select \u201cProperties\u201d:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1026\" height=\"431\" class=\"wp-image-22612\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22596-16.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22596-16.png 1026w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22596-16-300x126.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22596-16-1024x430.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22596-16-768x323.png 768w\" sizes=\"auto, (max-width: 1026px) 100vw, 1026px\" \/><\/p>\n<p>The file \u201cscript.sh\u201d as seen in the File Type of File Properties, is a Shell Script File: <img loading=\"lazy\" decoding=\"async\" width=\"508\" height=\"503\" class=\"wp-image-22613\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22596-17.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22596-17.png 508w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22596-17-300x297.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22596-17-150x150.png 150w\" sizes=\"auto, (max-width: 508px) 100vw, 508px\" \/><\/p>\n<p>The Shell Script File in Ubuntu is also an Executable File or ASCII Text Executable File. Thus the file \u201cscript.sh\u201d is considered an Executable File as it was made executable with the \u201cchmod\u201d command.<\/p>\n<h2><strong>Conclusion<\/strong><\/h2>\n<p>The Executable Files in the Ubuntu System are either the ASCII Text Executable Files or the ELF 64-bit LSB pie Executable Files. The ASCII Text Executable are those files that are made executable by the user using the \u201cchmod\u201d command. To list or check the Executable Files in the Ubuntu System, the \u201cfile\u201d, \u201cfind\u201d, or \u201cls\u201d commands can be used. Apart from the commands, the File Properties through the GUI can also display if the File is Executable or not. All the mentioned commands to check executable files are explained in detail in this article.<\/p>","protected":false},"excerpt":{"rendered":"<p>To Check Executable Files in Ubuntu, the \u201cfile\u201d, \u201cfind\u201d, or the \u201cls\u201d commands are used. The Executable Files are either the ASCII Text Executable or ELF Files.<\/p>","protected":false},"author":110,"featured_media":22607,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-22596","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ubuntu"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/22596","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/110"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=22596"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/22596\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/22607"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=22596"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=22596"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=22596"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}