{"id":21490,"date":"2023-09-30T12:36:02","date_gmt":"2023-09-30T12:36:02","guid":{"rendered":"https:\/\/linuxways.net\/?p=21490"},"modified":"2023-09-30T12:36:02","modified_gmt":"2023-09-30T12:36:02","slug":"how-do-i-find-a-file-list-in-linux-ubuntu","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/centos\/how-do-i-find-a-file-list-in-linux-ubuntu\/","title":{"rendered":"How do I Find a File List in Linux\/Ubuntu?"},"content":{"rendered":"<p>Running specific commands in the Terminal of Ubuntu sometimes involve the name of a file. Thus, knowing the name of the file is essential for the user to use it in commands. Ubuntu Operating System makes it easy to list the files in the terminal with various commands. In Terminal, listing files can be more flexible as you can list specific files, specific types of files, or files in a specific directory.<\/p>\n<p>In this article, we will discuss the different methodologies, each having different approaches to listing files in Ubuntu.<\/p>\n<h2><strong>How do I Find a File List in Linux\/Ubuntu?<\/strong><\/h2>\n<p>File List means listing all the files in a specific directory or listing files of a specific type. Files can be listed in Ubuntu using any of the commands among \u201c<strong>ls<\/strong>\u201d, \u201c<strong>find<\/strong>\u201d, and \u201c<strong>locate<\/strong>\u201d. All three methods for listing files in Ubuntu are discussed in detail below.<\/p>\n<h2><strong>Method 1: Find a File List in Ubuntu using the \u201cls\u201d Command<\/strong><\/h2>\n<p>The \u201cls\u201d is the most common command used to display files and directories in a specific directory. The \u201cls\u201d command can be used in numerous methodologies discussed in the following sections:<\/p>\n<ul>\n<li>Listing Files in the Current Directory.<\/li>\n<li>Listing Files in Another Directory.<\/li>\n<li>Listing Files in the Users\u2019 Home Directory.<\/li>\n<li>Listing Only Directories.<\/li>\n<li>Listing Files and Directories including Subdirectories.<\/li>\n<li>Listing Files and Only the Directories having Sub-Directories.<\/li>\n<li>Listing Files with Size.<\/li>\n<li>Listing Files with File Details.<\/li>\n<li>Listing Files with Sorted Date and Time.<\/li>\n<li>Listing Files with Sorted File Size.<\/li>\n<\/ul>\n<h2><strong>List Files in the Current Directory Using the \u201cls\u201d Command<\/strong><\/h2>\n<p>The basic syntax to list all the files in the current working directory is:<\/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, our current working Directory is \u201cDocuments\u201d. To list all the files inside the \u201cDocuments\u201d Directory, the command used is<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">ls<\/span><\/div><\/div>\n<p>All the files and folders inside the Documents Directory will be listed in the Terminal:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"739\" height=\"183\" class=\"wp-image-21491\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-1.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-1.png 739w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-1-300x74.png 300w\" sizes=\"auto, (max-width: 739px) 100vw, 739px\" \/><\/p>\n<h2><strong>List Files in Another Directory using the \u201cls\u201d Command<\/strong><\/h2>\n<p>The \u201cls\u201d command can also be used to list the files inside other directories. To list files in another directory the \u201cls\u201d command is followed by the path to the directory:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">ls<\/span> <span class=\"sy0\">&lt;<\/span>directory-path<span class=\"sy0\">&gt;<\/span><\/div><\/div>\n<p>In our case, using the previous example we have a \u201cMultDir\u201d Directory inside the Documents Directory. To list the files inside the \u201cMultDir\u201d Directory, the command used is<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">ls<\/span> MultDir<\/div><\/div>\n<p>All the files and folders inside the MultDir will be displayed in the Terminal:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"731\" height=\"145\" class=\"wp-image-21492\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-2.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-2.png 731w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-2-300x60.png 300w\" sizes=\"auto, (max-width: 731px) 100vw, 731px\" \/><\/p>\n<h2><strong>List Files in the User\u2019s Home Directory using the \u201cls\u201d Command<\/strong><\/h2>\n<p>The \u201cls\u201d command can also list all the files inside the Home Directory of the current User. It can be used anywhere followed by the \u201c<strong>~<\/strong>\u201d symbol:<\/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, the user is \u201ctaha\u201d and to list all the files inside the Home Directory of \u201ctaha\u201d, the command will be:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">ls<\/span> ~<\/div><\/div>\n<p>The \u201cls\u201d command, in this case, can be used in any directory. In our case, we used the \u201c<strong>ls ~<\/strong>\u201d command from the Documents Directory and it still returned the list of files inside the Home Directory:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"723\" height=\"112\" class=\"wp-image-21493\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-3.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-3.png 723w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-3-300x46.png 300w\" sizes=\"auto, (max-width: 723px) 100vw, 723px\" \/><\/p>\n<h2><strong>List only Directories using the \u201cls\u201d Command<\/strong><\/h2>\n<p>Instead of Listing all the files and Directories, the \u201cls\u201d command can be used to list only the directories inside the current working directory using the \u201c-d\u201d flag with ls:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">ls<\/span> <span class=\"re5\">-d<\/span> <span class=\"sy0\">*\/<\/span><\/div><\/div>\n<p>In our case, only the Directories inside the Documents Directory will be listed:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"729\" height=\"121\" class=\"wp-image-21494\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-4.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-4.png 729w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-4-300x50.png 300w\" sizes=\"auto, (max-width: 729px) 100vw, 729px\" \/><\/p>\n<h2><strong>List All Files and Directories With Subdirectories Using the \u201cls\u201d Command<\/strong><\/h2>\n<p>The \u201cls\u201d command is used with an asterisk to list all the files and the directories with subdirectories as well:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">ls<\/span> <span class=\"sy0\">*<\/span><\/div><\/div>\n<p>All the files and directories having sub-directories will be displayed. In our case, it will display all the files and directories with subdirectories inside the Documents Directory:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"725\" height=\"276\" class=\"wp-image-21495\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-5.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-5.png 725w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-5-300x114.png 300w\" sizes=\"auto, (max-width: 725px) 100vw, 725px\" \/><\/p>\n<h2><strong>List All Files, Directories, and Sub-Directories using the \u201cls\u201d Command<\/strong><\/h2>\n<p>The \u201c-R\u201d flag can also be used to find the files recursively, i.e. list all files, folders, and sub-directories:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">ls<\/span> <span class=\"re5\">-R<\/span><\/div><\/div>\n<p>All the files, folders, and sub-directories will be listed:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"730\" height=\"278\" class=\"wp-image-21496\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-6.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-6.png 730w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-6-300x114.png 300w\" sizes=\"auto, (max-width: 730px) 100vw, 730px\" \/><\/p>\n<h2><strong>List Files with Sizes Using the \u201cls\u201d Command<\/strong><\/h2>\n<p>To list the files with their respective sizes, the command used is:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">ls<\/span> <span class=\"re5\">-s<\/span><\/div><\/div>\n<p>The \u201c-s\u201d will ensure to list all the files and directories along with their sizes:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"727\" height=\"125\" class=\"wp-image-21497\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-7.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-7.png 727w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-7-300x52.png 300w\" sizes=\"auto, (max-width: 727px) 100vw, 727px\" \/><\/p>\n<h2><strong>List Files With File Details Using the \u201cls\u201d Command<\/strong><\/h2>\n<p>The \u201cls\u201d command can also be used to list the files and directories along with details:<\/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>The \u201c-l\u201d flag will display the details of files including the file permissions, owner, group, size, and previous modification date of the file. In our case, it will display the files along with details inside the Documents Directory:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"725\" height=\"275\" class=\"wp-image-21499\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-8.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-8.png 725w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-8-300x114.png 300w\" sizes=\"auto, (max-width: 725px) 100vw, 725px\" \/><\/p>\n<h2><strong>List Files with Sorted Data and Time using the \u201cls\u201d Command<\/strong><\/h2>\n<p>The files listed can also be sorted. To sort the files using the \u201cls\u201d command with date and time, the command used is:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">ls<\/span> <span class=\"re5\">-t<\/span><\/div><\/div>\n<p>In our case, to list the files with details and in sorted Date and Time, the command will be:<\/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> <span class=\"re5\">-t<\/span><\/div><\/div>\n<p>The listed files will be sorted according to the last modified date in descending order:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"727\" height=\"237\" class=\"wp-image-21500\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-9.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-9.png 727w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-9-300x98.png 300w\" sizes=\"auto, (max-width: 727px) 100vw, 727px\" \/><\/p>\n<p>The sorted list of files can also be displayed in ascending order using the \u201cr\u201d flag:<\/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> <span class=\"re5\">-rt<\/span><\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"720\" height=\"217\" class=\"wp-image-21501\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-10.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-10.png 720w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-10-300x90.png 300w\" sizes=\"auto, (max-width: 720px) 100vw, 720px\" \/><\/p>\n<h2><strong>List Files With Sorted File Size Using the \u201cls\u201d Command<\/strong><\/h2>\n<p>The files listed can also be sorted with respect to Size using the command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">ls<\/span> <span class=\"re5\">-S<\/span><\/div><\/div>\n<p>In our case, to list the files with details and in sorted Size, the command will be:<\/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> <span class=\"re5\">-S<\/span><\/div><\/div>\n<p>The listed files will be sorted according to the size in descending order:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"726\" height=\"271\" class=\"wp-image-21502\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-11.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-11.png 726w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-11-300x112.png 300w\" sizes=\"auto, (max-width: 726px) 100vw, 726px\" \/><\/p>\n<p>To list in ascending order, the \u201cr\u201d flag can be used to reverse it:<\/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> <span class=\"re5\">-rS<\/span><\/div><\/div>\n<p>The listed files will now be in ascending order(small size to large size)<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"727\" height=\"246\" class=\"wp-image-21503\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-12.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-12.png 727w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-12-300x102.png 300w\" sizes=\"auto, (max-width: 727px) 100vw, 727px\" \/><\/p>\n<h2><strong>Method 2: Find a File List in Ubuntu Using the \u201cfind\u201d Command<\/strong><\/h2>\n<p>The \u201cfind\u201d command is useful in searching for files based on a given condition. To search for files based on a given condition, the \u201cfind\u201d command along with the \u201cpath\u201d to a directory is used:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">find<\/span> <span class=\"sy0\">&lt;<\/span>path<span class=\"sy0\">&gt;<\/span><\/div><\/div>\n<p>Similar to the \u201cls\u201d command, the \u201cfind\u201d command can also be used in a variety of ways discussed in the sections below:<\/p>\n<ul>\n<li>List Files in a Specific Directory.<\/li>\n<li>List Files and Directories having Sub-Directories.<\/li>\n<li>List Files with a Query.<\/li>\n<li>List Files and Directories that are Empty.<\/li>\n<li>List Files based on Date and Time.<\/li>\n<li>List Files based on Size.<\/li>\n<li>List Files based on Permissions.<\/li>\n<\/ul>\n<h2><strong>List Files in a Specific Directory Using the \u201cfind\u201d Command<\/strong><\/h2>\n<p>To list all the files in a specific directory, the \u201cfind\u201d command will be used:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">find<\/span> <span class=\"sy0\">&lt;<\/span>path-to-directory<span class=\"sy0\">&gt;<\/span><\/div><\/div>\n<p>In our case, to list all the files in the \u201cMultDir\u201d Directory, the \u201cfind\u201d command will be used as follows:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">find<\/span> Documents<span class=\"sy0\">\/<\/span>MultDir<span class=\"sy0\">\/<\/span><\/div><\/div>\n<p>The MultDir exists in the Documents Directory and the files listed with the \u201cfind\u201d command are:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"734\" height=\"213\" class=\"wp-image-21504\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-13.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-13.png 734w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-13-300x87.png 300w\" sizes=\"auto, (max-width: 734px) 100vw, 734px\" \/><\/p>\n<h2><strong>List Files and Directories With Subdirectories Using the \u201cfind\u201d Command<\/strong><\/h2>\n<p>The \u201cfind\u201d command to list all the files recursively is:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">find<\/span> .<\/div><\/div>\n<p>The \u201c<strong>.<\/strong>\u201d will list all the files and files in subdirectories. In our case, working in the current Documents Directory, the Documents Directory files and Sub-Directories will be listed:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"727\" height=\"490\" class=\"wp-image-21505\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-14.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-14.png 727w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-14-300x202.png 300w\" sizes=\"auto, (max-width: 727px) 100vw, 727px\" \/><\/p>\n<h2><strong>List Files With a Query Using the \u201cfind\u201d Command<\/strong><\/h2>\n<p>The \u201cfind\u201d command can also list files according to specific keywords. In our case, to list all the files having the \u201cfile\u201d name, the \u201cfind\u201d command will be:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">find<\/span> <span class=\"re5\">-iname<\/span> <span class=\"st0\">&quot;file*&quot;<\/span><\/div><\/div>\n<p>The files having the string \u201cfile\u201d in their name will be displayed:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"727\" height=\"313\" class=\"wp-image-21506\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-15.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-15.png 727w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-15-300x129.png 300w\" sizes=\"auto, (max-width: 727px) 100vw, 727px\" \/><\/p>\n<h2><strong>List Files and Directories that are Empty using the \u201cfind\u201d Command<\/strong><\/h2>\n<p>To display all the files that are empty, the \u201cfind\u201d command will be used as follows:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">find<\/span> <span class=\"re5\">-empty<\/span><\/div><\/div>\n<p>In our case, it will display all the empty files inside the Documents Directory and Sub-Directories:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"724\" height=\"329\" class=\"wp-image-21507\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-16.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-16.png 724w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-16-300x136.png 300w\" sizes=\"auto, (max-width: 724px) 100vw, 724px\" \/><\/p>\n<h2><strong>List Files based on Date and Time using the \u201cfind\u201d Command<\/strong><\/h2>\n<p>Files can also be filtered according to the Date and Time in which those files were last accessed or modified. Three different options can be used with the \u201cfind\u201d command:<\/p>\n<ul>\n<li>Find File based on Last Modification (-mtime &lt;date&gt;)<\/li>\n<li>Find File based on Last Access (-atime &lt;date&gt;)<\/li>\n<li>Find File based on Last Attributes Change (-ctime &lt;date&gt;)<\/li>\n<\/ul>\n<p>In our case, to list the files that were modified in the last 1 day, the \u201cfind\u201d command will be:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">find<\/span> . <span class=\"re5\">-mtime<\/span> <span class=\"re5\">-1<\/span><\/div><\/div>\n<p>Only 1 file was modified in the last 1 day:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"727\" height=\"60\" class=\"wp-image-21508\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-17.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-17.png 727w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-17-300x25.png 300w\" sizes=\"auto, (max-width: 727px) 100vw, 727px\" \/><\/p>\n<p>To list files accessed in the last 2 days, the \u201cfind\u201d command will be:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">find<\/span> . <span class=\"re5\">-atime<\/span> <span class=\"re5\">-2<\/span><\/div><\/div>\n<p>The files accessed in the last 2 days will be displayed:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"728\" height=\"202\" class=\"wp-image-21510\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-18.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-18.png 728w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-18-300x83.png 300w\" sizes=\"auto, (max-width: 728px) 100vw, 728px\" \/><\/p>\n<p>To list the files that were changed in the last 5 days, the \u201cfind\u201d command will be:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">find<\/span> . <span class=\"re5\">-ctime<\/span> <span class=\"re5\">-5<\/span><\/div><\/div>\n<p>This will display the files that were changed in the last 5 days:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"727\" height=\"459\" class=\"wp-image-21511\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-19.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-19.png 727w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-19-300x189.png 300w\" sizes=\"auto, (max-width: 727px) 100vw, 727px\" \/><\/p>\n<h2><strong>List Files Based on Size Using the \u201cfind\u201d Command<\/strong><\/h2>\n<p>Files can be listed in the terminal based on the size of the file using the find command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">find<\/span> <span class=\"sy0\">&lt;<\/span>path<span class=\"sy0\">&gt;<\/span> <span class=\"re5\">-size<\/span> <span class=\"sy0\">&lt;<\/span>size-value<span class=\"sy0\">&gt;<\/span><\/div><\/div>\n<p>In our case, to list the files greater than 1MB in the Downloads Directory, the command used will be:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">find<\/span> . <span class=\"re5\">-size<\/span> +1M<\/div><\/div>\n<p>Only one file is greater than 1MB in our directory and it will be displayed:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"730\" height=\"65\" class=\"wp-image-21512\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-20.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-20.png 730w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-20-300x27.png 300w\" sizes=\"auto, (max-width: 730px) 100vw, 730px\" \/><\/p>\n<h2><strong>List Files Based on Permissions Using the \u201cfind\u201d Command<\/strong><\/h2>\n<p>Files can also be listed using the \u201cperm\u201d command with the \u201ctype\u201d command for file or folder. The \u201cperm\u201d command will take the numeric number for permission and the \u201ctype\u201d command will either take the \u201cf\u201d value for a file or \u201cd\u201d for a directory.<\/p>\n<p>In our case, to list the files in the Documents Directory having the read, write, and execute permission for every user, the command used will be:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">find<\/span> . <span class=\"re5\">-type<\/span> f <span class=\"re5\">-perm<\/span> <span class=\"nu0\">777<\/span><\/div><\/div>\n<p>The \u201c777\u201d indicates the files have the \u201crwe\u201d permissions meaning any user can read the file, edit the file, and can also access or execute the file. The \u201cf\u201d value indicates only files will be listed:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"732\" height=\"59\" class=\"wp-image-21513\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-21.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-21.png 732w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-21-300x24.png 300w\" sizes=\"auto, (max-width: 732px) 100vw, 732px\" \/><\/p>\n<h2><strong>Method 3: Find a File List in Ubuntu Using the \u201clocate\u201d Command<\/strong><\/h2>\n<p>Locate is another useful command that can be used to search for a specific file, multiple files, or files of any specific type. By default, the \u201clocate\u201d command is not installed in Ubuntu. To install \u201clocate\u201d, the command used is:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> <span class=\"kw2\">apt-get install<\/span> <span class=\"kw2\">locate<\/span><\/div><\/div>\n<p>This will install the necessary locate packages:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"732\" height=\"431\" class=\"wp-image-21514\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-22.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-22.png 732w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-22-300x177.png 300w\" sizes=\"auto, (max-width: 732px) 100vw, 732px\" \/><\/p>\n<p>The locate command can be used in multiple scenarios:<\/p>\n<h2><strong>List Specific Files using the \u201clocate\u201d Command<\/strong><\/h2>\n<p>To list files according to a specific file name, the \u201clocate\u201d command used is:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">locate<\/span> <span class=\"re5\">-i<\/span> <span class=\"sy0\">&lt;<\/span>fileName<span class=\"sy0\">&gt;<\/span><\/div><\/div>\n<p>In our case, to list the files with the name \u201cfirefox\u201d, the below command will be used:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">locate<\/span> <span class=\"re5\">-i<\/span> firefox<\/div><\/div>\n<p>It will return all the files with the name \u201cfirefox\u201d:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1097\" height=\"460\" class=\"wp-image-21515\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-23.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-23.png 1097w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-23-300x126.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-23-1024x429.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-23-768x322.png 768w\" sizes=\"auto, (max-width: 1097px) 100vw, 1097px\" \/><\/p>\n<h2><strong>List Specific Files With a Query Using the \u201clocate\u201d Command<\/strong><\/h2>\n<p>Specific files having the same extension can also be listed using the \u201clocate\u201d Command. In our case, to locate the files with the \u201c.iso\u201d extension, the \u201clocate\u201d command will be used:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">locate<\/span> <span class=\"re5\">-i<\/span> <span class=\"sy0\">*<\/span>.iso<\/div><\/div>\n<p>The files having the \u201c.iso\u201d extensions will be displayed:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1095\" height=\"57\" class=\"wp-image-21516\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-24.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-24.png 1095w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-24-300x16.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-24-1024x53.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21490-24-768x40.png 768w\" sizes=\"auto, (max-width: 1095px) 100vw, 1095px\" \/><\/p>\n<h2><strong>Conclusion<\/strong><\/h2>\n<p>Listing Files can be executed or carried out easily using the Command Line in Ubuntu. The \u201cls\u201d, \u201cfind\u201d, and \u201clocate\u201d are useful commands in Ubuntu that offer multiple approaches to listing files and directories. With these commands, listing files in a specific directory, listing only directories, listing sub-directories, or listing specific types of files can be accomplished with no sweat. This article explains all the different methodologies and briefly discusses the different approaches to listing files in Ubuntu.<\/p>","protected":false},"excerpt":{"rendered":"<p>The \u201cls\u201d, \u201cfind\u201d, and \u201clocate\u201d can be used to list files in a specific directory, list only directories, list sub-directories, or list specific types of files. <\/p>","protected":false},"author":110,"featured_media":21509,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-21490","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-centos"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/21490","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=21490"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/21490\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/21509"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=21490"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=21490"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=21490"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}