Sample Header Ad - 728x90

Unix & Linux Stack Exchange

Q&A for users of Linux, FreeBSD and other Unix-like operating systems

Latest Questions

3 votes
2 answers
355 views
Is it possible to list files using ls with du directory size?
I'd like to list all the conterns of a directory (including subdirs) and their real size (including dir sizes). I can list them with `ls`, and I can see the size of each with `du -sh`. But is there a way to list all with `du`'s size output?
I'd like to list all the conterns of a directory (including subdirs) and their real size (including dir sizes). I can list them with ls, and I can see the size of each with du -sh. But is there a way to list all with du's size output?
Luca Reghellin (729 rep)
Nov 10, 2022, 09:39 AM • Last activity: Jul 31, 2025, 02:09 PM
0 votes
3 answers
2618 views
Directory listing when using setfacl ACL
I use setfacl command to grant read permission for reading files in directory, but I cant use ls to view files. I tried setfacl -Rdm g:grouptoadd:rx /path/directory/ but, I can read files (when I use direct path to file for example "/path/directory/myfile) and can't list directory (ls /path/director...
I use setfacl command to grant read permission for reading files in directory, but I cant use ls to view files. I tried setfacl -Rdm g:grouptoadd:rx /path/directory/ but, I can read files (when I use direct path to file for example "/path/directory/myfile) and can't list directory (ls /path/directory/)
grU (11 rep)
Mar 17, 2021, 10:22 AM • Last activity: Jul 24, 2025, 12:05 PM
4 votes
2 answers
450 views
recursive ls - Ignore files only in specific sub-directories
So, `ls -R` is a command I use a lot to quickly verify the file structure of my projects, or check for any leftover files, as it's simple enough to use and read, and is part of coreutils (which means I don't need to install anything, as it's already available on all distros). However, lately, my pro...
So, ls -R is a command I use a lot to quickly verify the file structure of my projects, or check for any leftover files, as it's simple enough to use and read, and is part of coreutils (which means I don't need to install anything, as it's already available on all distros). However, lately, my projects have grown more complex, having more and more files and sub-directories, and sub-directories of sub-directories, which I don't care about at all. Using ls -RI "PATTERN" used to work well, but now I'm facing an issue where there are files matching a specific pattern that I want to ignore in one specific directory, but not in the other, and vice versa. The problem is that ls -I "PATTERN" seems to look for the shell PATTERN in name of the file, rather than its full path, which makes it impossible to do something like ls -R "subdir/file.a", as the name of the file I'm trying to ignore here is "file.a", and not "subdir/file.a" (which is its path). In short, **is there any way to make** ls -I **look for the pattern in the full path of the file, instead of only its name, or is there any coreutils equivalent command that would allow me to do that without losing much human readability?** --- Here's a quick example to illustrate my problem: 1. File structure:
.
    ├── subdir1
    │   ├── file.a
    │   └── file.b
    └── subdir2
        ├── file.a
        └── file.b
2. What I want:
.:
    subdir1    subdir2
    
    ./subdir1:
    file.a
    
    ./subdir2:
    file.b
3. What I get with ls -ARIsubdir1/file.b -Isubdir2/file.a:
.:
    subdir1  subdir2
    
    ./subdir1:
    file.a	file.b
    
    ./subdir2:
    file.a	file.b
Yunara (41 rep)
Jun 22, 2025, 07:36 PM • Last activity: Jun 23, 2025, 09:12 AM
1 votes
1 answers
2092 views
LS_COLORS not respected on Cygwin
Whilst trying to configure ls' colors on Cygwin (specifically the distro babun), I found that the custom extension colors that were in the LS_COLORS environment variable weren't being used. Here's an example: `di=34:ln=35:so=32:pi=33:ex=31:bd=34;46:cd=34;43:su=30;41:sg=30;46:tw=30;42:ow=30;43:*.tar=...
Whilst trying to configure ls' colors on Cygwin (specifically the distro babun), I found that the custom extension colors that were in the LS_COLORS environment variable weren't being used. Here's an example: di=34:ln=35:so=32:pi=33:ex=31:bd=34;46:cd=34;43:su=30;41:sg=30;46:tw=30;42:ow=30;43:*.tar=1;31 Normally, the ls command should output white text for every file EXCEPT .tar files, which should be red. However, what I'm getting is white text for everything INCLUDING .tar files. I wonder if it's a problem with MSYS ls, or if it's a problem with my shell (zsh). Basically, the custom file extension colors that I try and define fall back to the default file color. Here's the corresponding part of my .zshrc where I've defined the ls alias and run the output of dircolors. eval "dircolors /etc/DIR_COLORS" alias ls="/bin/ls --color=auto"
IllinoisJackson (11 rep)
Mar 21, 2017, 09:14 PM • Last activity: Jun 22, 2025, 03:05 PM
13 votes
1 answers
67238 views
No such file or directory but I can see it!
I'm trying to run a python script, on a headless Raspberry PI using winSCP and get the following error message: Command '"./areadetect_movie_21.py"' failed with return code 127 and error message /usr/bin/env: python : No such file or directory. When I try and run from terminal, I get: : No such file...
I'm trying to run a python script, on a headless Raspberry PI using winSCP and get the following error message: Command '"./areadetect_movie_21.py"' failed with return code 127 and error message /usr/bin/env: python : No such file or directory. When I try and run from terminal, I get: : No such file or directory. I try a similar python script, in the same directory, with the same python shebang, the same permissions and using the same user pi, and it works. I also do a ls and I can see the file, so I don't know why it will not run.
reggie (533 rep)
Mar 10, 2015, 12:34 PM • Last activity: Jun 12, 2025, 04:42 PM
139 votes
15 answers
243092 views
Linux ls to show only file name, date, and size
How can I use `ls` on Linux to get a listing of files with only their name, date, and size? I don't need to see the other info such as owner or permissions Is this possible?
How can I use ls on Linux to get a listing of files with only their name, date, and size? I don't need to see the other info such as owner or permissions Is this possible?
Pinkie (1493 rep)
Oct 7, 2011, 03:33 AM • Last activity: Jun 11, 2025, 04:12 PM
192 votes
7 answers
66945 views
What does the @ mean in the permissions field of ls -l?
I am using Mac OSX. When I type `ls -l` I see something like drwxr-xr-x@ 12 xonic staff 408 22 Jun 19:00 . drwxr-xr-x 9 xonic staff 306 22 Jun 19:42 .. -rwxrwxrwx@ 1 xonic staff 6148 25 Mai 23:04 .DS_Store -rw-r--r--@ 1 xonic staff 17284 22 Jun 00:20 filmStrip.cpp -rw-r--r--@ 1 xonic staff 3843 21 J...
I am using Mac OSX. When I type ls -l I see something like drwxr-xr-x@ 12 xonic staff 408 22 Jun 19:00 . drwxr-xr-x 9 xonic staff 306 22 Jun 19:42 .. -rwxrwxrwx@ 1 xonic staff 6148 25 Mai 23:04 .DS_Store -rw-r--r--@ 1 xonic staff 17284 22 Jun 00:20 filmStrip.cpp -rw-r--r--@ 1 xonic staff 3843 21 Jun 21:20 filmStrip.h What do the @'s mean?
Larry Wang (2755 rep)
Aug 10, 2010, 07:40 PM • Last activity: Jun 8, 2025, 06:21 AM
176 votes
1 answers
95877 views
What does the "@" (at) symbol mean in the permissions field of OSX ls?
When I check permission of less files from the command line on my Snow Leopard OSX system using Bash I see `-rw-r--r--@` for certain files and for others I just see `-rw-r--r--` What does the @ mean here?
When I check permission of less files from the command line on my Snow Leopard OSX system using Bash I see -rw-r--r--@ for certain files and for others I just see -rw-r--r-- What does the @ mean here?
rhand (1925 rep)
Dec 26, 2013, 08:05 AM • Last activity: Jun 8, 2025, 06:21 AM
35 votes
6 answers
7896 views
How can I make “ls” show dotfiles first while staying case-insensitive?
Create the following files in a directory. $ touch .a .b a b A B 你好嗎 My default `ls` order ignores the presence of leading dots, intermingling them with the other files. $ ls -Al total 0 -rw-r--r-- 1 sparhawk sparhawk 0 Jun 8 17:03 a -rw-r--r-- 1 sparhawk sparhawk 0 Jun 8 17:03 .a -rw-r--r-- 1 sparh...
Create the following files in a directory. $ touch .a .b a b A B 你好嗎 My default ls order ignores the presence of leading dots, intermingling them with the other files. $ ls -Al total 0 -rw-r--r-- 1 sparhawk sparhawk 0 Jun 8 17:03 a -rw-r--r-- 1 sparhawk sparhawk 0 Jun 8 17:03 .a -rw-r--r-- 1 sparhawk sparhawk 0 Jun 8 17:03 A -rw-r--r-- 1 sparhawk sparhawk 0 Jun 8 17:03 b -rw-r--r-- 1 sparhawk sparhawk 0 Jun 8 17:03 .b -rw-r--r-- 1 sparhawk sparhawk 0 Jun 8 17:03 B -rw-r--r-- 1 sparhawk sparhawk 0 Jun 8 17:06 你好嗎 I [can](https://superuser.com/questions/448291/how-can-i-make-ls-show-dotfiles-first) [change](https://unix.stackexchange.com/questions/53598/alphabetizing-names-in-ls-alias-with-files-not-intermingled) LC_COLLATE to put the dotfiles first. $ LC_COLLATE=C ls -Al total 0 -rw-r--r-- 1 sparhawk sparhawk 0 Jun 8 17:03 .a -rw-r--r-- 1 sparhawk sparhawk 0 Jun 8 17:03 .b -rw-r--r-- 1 sparhawk sparhawk 0 Jun 8 17:03 A -rw-r--r-- 1 sparhawk sparhawk 0 Jun 8 17:03 B -rw-r--r-- 1 sparhawk sparhawk 0 Jun 8 17:03 a -rw-r--r-- 1 sparhawk sparhawk 0 Jun 8 17:03 b -rw-r--r-- 1 sparhawk sparhawk 0 Jun 8 17:06 你好嗎 Unfortunately this makes the sort order case-sensitive, i.e. A and B precede a and b. Is there a way to print dotfiles first while staying case-insensitive (A and a precede B and b)? ## Edit: attempting to modify LC_COLLATE None of the answers so far fully replicate the functionality of ls easily. Conceivably, I could wrap some of them in a function, but this would have to include some detailed code on (e.g.) how to work with no argument vs. supplying a directory as an argument. Or how to deal with an explicit -d flag. Alternatively, I thought that maybe there could be a better LC_COLLATE to use. However, I can't seem to make that work. I'm currently using LC_COLLATE="en_AU.UTF-8". I checked /usr/share/i18n/locales/en_AU (although I'm not sure if this is the right file, as I can't see any reference to UTF-8); I found the following. LC_COLLATE copy "iso14651_t1" END LC_COLLATE /usr/share/i18n/locales/iso14651_t1 contains copy "iso14651_t1_common". Finally, /usr/share/i18n/locales/iso14651_t1_common contains IGNORE;IGNORE;IGNORE; # 47 . I deleted this line, ran sudo locale-gen, and restarted my computer. Unfortunately, this changed nothing.
Sparhawk (20499 rep)
Jun 8, 2016, 07:15 AM • Last activity: Jun 5, 2025, 01:24 PM
9 votes
1 answers
6789 views
The -F option for ls
For command `ls` -F, --classify append indicator (one of */=>@|) to entries [Wikipedia][1] says `*` represents executable and `/` dir. Regular files are not followed by any of the above symbols. But `*` follows text file and pdf file too. Are they executables? Do the `-F` indicators always mean same...
For command ls -F, --classify append indicator (one of */=>@|) to entries Wikipedia says * represents executable and / dir. Regular files are not followed by any of the above symbols. But * follows text file and pdf file too. Are they executables? Do the -F indicators always mean same as the first field in -rwxrwx---? It seems like there is no difference between hardlinks and the files in either the -F indicators or the first field in -rwxrwx---. How do you distinguish them? Thanks.
Tim (106420 rep)
Jul 27, 2014, 03:44 AM • Last activity: Jun 4, 2025, 07:09 AM
5 votes
2 answers
1672 views
What does the "@" mean at the end of file names produced by ls?
What does the `@` symbol mean when appended to file names? (Note that I am NOT talking about the `@` that's shown at the end of a permission string, indicating extended attributes, referenced in [this](https://unix.stackexchange.com/questions/106642/what-does-the-at-symbol-mean-on-osx-ls), [this](ht...
What does the @ symbol mean when appended to file names? (Note that I am NOT talking about the @ that's shown at the end of a permission string, indicating extended attributes, referenced in [this](https://unix.stackexchange.com/questions/106642/what-does-the-at-symbol-mean-on-osx-ls) , [this](https://superuser.com/questions/155458/what-does-the-mean-on-the-output-of-ls-on-os-x-terminal) , [this](https://serverfault.com/questions/235368/what-does-the-sign-mean-in-ls-l-output) , [this](https://apple.stackexchange.com/questions/42177/what-does-signify-in-unix-file-permissions) and [this](https://stackoverflow.com/questions/27707134/what-does-at-sign-mean-when-listing-directory-using-ls-l) question.) My specific case is on MacOS Sequoia 15.5, in the /usr/share/dict directory; note the words file, which ls prints as words@:
Mac:dict griscom$ pwd
/usr/share/dict
Mac:dict griscom$ ls
connectives	README		web2a
propernames	web2		words@
Mac:dict griscom$ ls -l
total 2928
-r--r--r--  1 root  wheel      706 May  4 01:39 connectives
-r--r--r--  1 root  wheel     8546 May  4 01:39 propernames
-r--r--r--  1 root  wheel     1311 May  4 01:39 README
-r--r--r--  1 root  wheel  2493885 May  4 01:39 web2
-r--r--r--  1 root  wheel  1012731 May  4 01:39 web2a
lrwxr-xr-x  1 root  wheel        4 May  4 01:39 words@ -> web2
Mac:dict griscom$ ls -l@
total 2928
-r--r--r--  1 root  wheel      706 May  4 01:39 connectives
-r--r--r--  1 root  wheel     8546 May  4 01:39 propernames
-r--r--r--  1 root  wheel     1311 May  4 01:39 README
-r--r--r--  1 root  wheel  2493885 May  4 01:39 web2
-r--r--r--  1 root  wheel  1012731 May  4 01:39 web2a
lrwxr-xr-x  1 root  wheel        4 May  4 01:39 words@ -> web2
Mac:dict griscom$ stat words@
stat: words@: stat: No such file or directory
Mac:dict griscom$ stat words
16777234 1152921500312527473 lrwxr-xr-x 1 root wheel 0 4 "May  4 01:39:22 2025" "May  4 01:39:22 2025" "May  4 01:39:22 2025" "May  4 01:39:22 2025" 4096 0 0x80000 words
Mac:dict griscom$ xattr -l words 
Mac:dict griscom$
Daniel Griscom (279 rep)
Jun 1, 2025, 06:51 PM • Last activity: Jun 1, 2025, 07:35 PM
3 votes
4 answers
5101 views
Use extended globbing to list files but not directories in bash
Let' say I have the following directories tree: . ├── 11 ├── 111 ├── 112 ├── 1121 ├── 113 ├── 11a ├── 11a1 ├── 1a1 ├── 1a2 ├── 1aa1.png ├── 2a1 ├── a. ├── a1a ├── a1a.jpg ├── a2a ├── aa ├── -aa ├── aa.gif ├── aa.jpg ├── aa.png ├── aa.tiff ├── a.exe ├── a.gif ├── a.html ├── a.jpg ├── a.png ├── a.tiff...
Let' say I have the following directories tree: . ├── 11 ├── 111 ├── 112 ├── 1121 ├── 113 ├── 11a ├── 11a1 ├── 1a1 ├── 1a2 ├── 1aa1.png ├── 2a1 ├── a. ├── a1a ├── a1a.jpg ├── a2a ├── aa ├── -aa ├── aa.gif ├── aa.jpg ├── aa.png ├── aa.tiff ├── a.exe ├── a.gif ├── a.html ├── a.jpg ├── a.png ├── a.tiff ├── b2 ├── b2a ├── ba.gif ├── ba.jpg ├── ba.png ├── ba.tiff ├── b.html ├── cb1.png ├── d.gif └── sub1 ├── d.gif └── sub2 So, if I want to match everything in . ($PWD) but files with ".jpg" extension, I do the following: ls !(*.jpg) But it outputs: 11 1121 11a1 1aa1.png a1a aa.gif a.exe a.png b2a ba.tiff d.gif 111 113 1a1 2a1 a2a aa.png a.gif a.tiff ba.gif b.html .gif 112 11a 1a2 a. aa aa.tiff a.html b2 ba.png cb1.png sub1: . .. d.gif sub2 I'd like to exclude both sub1 and all of its contents (even directories), ie: > sub1: > . .. d.gif sub2 I can exclude using: GLOBIGNORE='sub1' before of ls, but what happens if I have more directories with differents names? Is there a way to do that?
sebelk (4669 rep)
Jun 26, 2017, 06:04 PM • Last activity: May 31, 2025, 01:07 PM
1 votes
2 answers
92 views
Files that end with a period are inaccessible on an exFAT drive
I have a backup that was copied from Linux (ext4) to an exFAT filesystem. File and directory names that end with a period are inaccessible. I can (partly) list them, but `ls` behaves strangely. It prints errors like `ls: cannot access '….': No such file or directory`, and then prints the file name (...
I have a backup that was copied from Linux (ext4) to an exFAT filesystem. File and directory names that end with a period are inaccessible. I can (partly) list them, but ls behaves strangely. It prints errors like ls: cannot access '….': No such file or directory, and then prints the file name (with final period included), but reports -????????? for the permissions and ? for user, group, etc. I also can't move, rename, or delete any of the affected files. Using wildcards for the offending . does not work. This isn't a permissions issue. It might be a filesystem corruption issue, but if it is, it is a systematic one caused by rsync'ing a directory from an ext4 to exFAT filesystem, and affects *all* files and directories whose name ends in .. The command sudo fsck.exfat -v -p /dev/sd** reports volume clean. #### System info This is a Ubuntu Studio Ubuntu 22.04.1 LTS machine running the 6.2.0-1018-lowlatency kernel. The exFAT is an external USB drive (WD MyBook). I am mounting it via the system default mount option via the disks graphical user utility. The output of cat /proc/filesystems includes exfat, indicating kernel support; exfat-fuse is not installed, so it is probably not mounting via fuse. #### My questions: 1. What is going on here? 2. Do these files really exist, or are they ghosts (failed to copy to exFAT for *reasons*)? 3. Can I recover this? I'd like to rename all affected nodes by removing the trailing period.
MRule (249 rep)
May 13, 2025, 04:51 PM • Last activity: May 16, 2025, 10:05 AM
0 votes
1 answers
39 views
find or ls -l recursive output in YYYY-MM-DD format on FreeBSD
I'm trying to list files recursively with this date format YYYY-MM-DD on a on FreeBSD. I tried the Linux commands I know but none of them worked : ```shell $ ls -lR --time-style=+'%Y-%m-%d %T' ls: unrecognized option '--time-style=+%Y-%m-%d %T' usage: ls [-ABCFGHIJLOPRSTUWYZabcdefghiklmnopqrstuwxyz1...
I'm trying to list files recursively with this date format YYYY-MM-DD on a on FreeBSD. I tried the Linux commands I know but none of them worked :
$ ls -lR --time-style=+'%Y-%m-%d %T'
ls: unrecognized option '--time-style=+%Y-%m-%d %T'
usage: ls [-ABCFGHIJLOPRSTUWYZabcdefghiklmnopqrstuwxyz1,] [-D format] [file ...]
$ find . -printf "%TY-%Tm-%Td %p\n"
find: -printf: unknown primary or operator
$
How can I do that ? EDIT0 : I added the recursive word in the title because it was only in the content of my question. BTW : I forgot that ls -lR is a pain to grep so I'm more interrested in a find like solution :)
SebMa (2433 rep)
May 15, 2025, 04:04 PM • Last activity: May 15, 2025, 04:50 PM
109 votes
4 answers
123649 views
The ls command is not working for a directory with a huge number of files
I had a directory which had around **5 million** files. When I tried to run the `ls` command from inside this directory, my system consumed a huge amount of memory and it hung after sometime. Is there an efficient way to list the files other than using the `ls` command?
I had a directory which had around **5 million** files. When I tried to run the ls command from inside this directory, my system consumed a huge amount of memory and it hung after sometime. Is there an efficient way to list the files other than using the ls command?
Ramesh (40416 rep)
Mar 17, 2014, 04:00 PM • Last activity: Apr 24, 2025, 12:25 PM
-1 votes
1 answers
58 views
Added quotes on the name of the new created directory
I have the following situation: I'm creating a directory with an & at the end, something like this: `inventory&` But, when I run the command `mkdir "inventory&"` the linux system adds quotes to the name as follows: `'inventory&'` Do you know why this is happening? How can I create a directory with a...
I have the following situation: I'm creating a directory with an & at the end, something like this: inventory& But, when I run the command mkdir "inventory&" the linux system adds quotes to the name as follows: 'inventory&' Do you know why this is happening? How can I create a directory with a special character in its name without the system adding the quotes?
Haroldo Payares Salgado (101 rep)
Apr 2, 2025, 11:25 PM • Last activity: Apr 3, 2025, 05:58 AM
3 votes
3 answers
1064 views
Use of special characters in filename
I need to create a file named `*'test'*` If I write `touch \'test\'` `ls` shows `'test'` But if I write `touch \*\'test\'\*` `ls` now shows `*'\''test'\''*` What's the trick ? Can someone explain me what I did wrong ? My OS is Ubuntu 20.04
I need to create a file named *'test'* If I write touch \'test\' ls shows 'test' But if I write touch \*\'test\'\* ls now shows *'\''test'\''* What's the trick ? Can someone explain me what I did wrong ? My OS is Ubuntu 20.04
Shoopi (41 rep)
Feb 14, 2024, 06:08 PM • Last activity: Mar 17, 2025, 08:59 AM
3 votes
4 answers
1881 views
Full file date (without GNU utilities)
I am trying to obtain the full date (created or modified) of a particular file for passing to another program. I have tried variations of options with the ls command but none provide a full date for files less than 6 months old and I have limit usage of the options. When I try certain options I have...
I am trying to obtain the full date (created or modified) of a particular file for passing to another program. I have tried variations of options with the ls command but none provide a full date for files less than 6 months old and I have limit usage of the options. When I try certain options I have seen trying to research this I get the following message: usage: ls [-1ACFHLNRabcdefgilmnopqrstuxEUX] [File...] None of which seems to provide what I needs as far as I can tell so I tried to use the stat command but it is not available to me. I am using the Korn shell on AIX 5.3 which has limited commands available, can anyone suggest another way that I might be able to obtain a file's created or modified date as a full date (either dd/mm/yyyy or yyyy/mm/dd).
Matt_Roberts (141 rep)
Jan 15, 2016, 12:51 PM • Last activity: Mar 8, 2025, 03:45 PM
229 votes
11 answers
185992 views
List files sorted numerically
I have a bunch of files from `log1` to `log164`. I'm trying to LIST the directory (sorted) in a UNIX terminal but the sort functions are only providing the format like this: home:logs Home$ ls -1 | sort log1.gz log10.gz log100.gz log101.gz log102.gz log103.gz log104.gz log105.gz log106.gz ...etc Wha...
I have a bunch of files from log1 to log164. I'm trying to LIST the directory (sorted) in a UNIX terminal but the sort functions are only providing the format like this: home:logs Home$ ls -1 | sort log1.gz log10.gz log100.gz log101.gz log102.gz log103.gz log104.gz log105.gz log106.gz ...etc What I want is home:logs Home$ ls -1 | sort log1.gz log2.gz log3.gz log4.gz log5.gz log6.gz log7.gz ...{more here} log99.gz log100.gz log101.gz log102.gz ...etc Any suggestions in what I could use to do this?
Rabiani
Mar 9, 2012, 02:18 AM • Last activity: Mar 7, 2025, 02:38 PM
10 votes
5 answers
11978 views
ls or find option to exclude binary files
How can I list only files that aren't compiled code in the current directory? I'm reviewing the custom scripts and code on several HPUX and Linux servers before transferring them to a newer system. I get tired of seeing `PuTTYPuTTYPuTTYPuTTYPuTTY` when I encounter a file that is compiled. I would li...
How can I list only files that aren't compiled code in the current directory? I'm reviewing the custom scripts and code on several HPUX and Linux servers before transferring them to a newer system. I get tired of seeing PuTTYPuTTYPuTTYPuTTYPuTTY when I encounter a file that is compiled. I would like to sort them so that I can skip over the compiled software and come back to them at a later time.
Jeight (2669 rep)
Mar 26, 2015, 03:08 PM • Last activity: Mar 6, 2025, 12:42 PM
Showing page 1 of 20 total questions