Skip to main content
Share Your Experience: Take the 2024 Developer Survey

Questions tagged [ls]

The command to list the contents of a folder/directory in Unix and Unix-like systems.

Filter by
Sorted by
Tagged with
1 vote
1 answer
245 views

Powershell shortcut to list all files and folders (including hidden files) and order them by date

I'm basically looking for something like ls -alt, but in Powershell (Windows 11). Currently I'm using gci -fo | sort LastWriteTime -Descending but it's a bit of a doozy, and definitely not easy to ...
DeltaIV's user avatar
  • 427
0 votes
0 answers
2k views

ls to list directories sorted by date in timestamp AND by date in filename appendix results in little satisfaction

For listing of directories I always use commands like ls -la --time-style=long-iso <directoryname> And all is at best. Yet on some cases I append a date-time suffix to the filename. This is ...
Anton Wessel's user avatar
1 vote
1 answer
51 views

The Ranger file manager for Linux hangs with just "loading...ranger"

When I run Ranger, it prints its standard message: loading...ranger But then hangs forever. What is the root cause?
James Madison's user avatar
0 votes
1 answer
90 views

ls with range name of file

I have files with numeric as it's file name. 10asdfsfl.txt 11sdfkf.txt 20sdfdf.txt 22sdfdf.txt 30saadf.txt 40asdfdf.txt 51sadfsf.txt 62ddgfg.txt if I use ls -l [40-50]* it returning list of files ...
snydez's user avatar
  • 5
3 votes
0 answers
102 views

hiding files with Windows "hidden" attribute in msys2 "ls"

I'm running msys2 on Windows 11: $ uname -a MINGW64_NT-10.0-22621 couch-potato 3.4.9.x86_64 2023-09-15 12:15 UTC x86_64 Msys And I have it configured to use my Windows home directory (/c/Users/<...
user31708's user avatar
  • 131
0 votes
1 answer
47 views

How to understand the hardlinks field of a directory

I've run ls -l command but I have got a big confusion: Ouput of ls -l in home directory: $ ls -l total 16 drwxr-x--- 19 farah farah 4096 اگست 18 18:40 farah drwxr-x--- 40 hussain hussain 4096 ...
Muhammad Hussain's user avatar
-3 votes
2 answers
790 views

ls -R instead of find

I can see ls -R lists all files and folders. I can grep the file name from the list. What are the advantages of "find" ? Also, any caveats if I use ls -R instead of find?
Bijo's user avatar
  • 1
1 vote
1 answer
90 views

Difficulty performing complex sorting when listing files in a directory with the ls command

The behavior I'm seeking is a nested sort with the ls command where sorting by one method doesn't cancel out sorting by a second method. The exact desired behavior is essentially: First sort with ...
elucid8's user avatar
  • 78
0 votes
1 answer
131 views

ls ignoring extensions when colorizing with LS_COLORS

I'm trying to set LS_COLORS to colorize my ls output, but for some reason it is ignoring any file match patterns. It is correctly coloring executables, directories, etc., but it seems to be ...
mrjake2's user avatar
  • 121
0 votes
1 answer
300 views

Why UNIX socket files end with and equal sign in ls?

When I list (ls) files in directory, I see the equal sign = after some files. All these files in my case are UNIX domain socket files: user@Debian11:~/src/unix_sock$ l a.out* cli_stream* ...
NK-cell's user avatar
  • 195
5 votes
2 answers
1k views

How to list only tar files

I have a silly problem usr01@srvlnx01:~$ sudo ls /var/opt/gitlab/backups/ 1685014011_2023_05_25_13.2.3_gitlab_backup.tar 1685016443_2023_05_25_13.2.3_gitlab_backup.tar tmp but usr01@srvlnx01:~$ ...
0___________'s user avatar
1 vote
0 answers
318 views

What is the difference between different options for 'ls' colored output in zsh?

I want to display colored output for the 'ls' command in the terminal for my MAC but I do not understand the differences between some of the methods. On some articles and reddit posts I saw people ...
Ravi C's user avatar
  • 11
1 vote
0 answers
171 views

set colored-stats ignores $LS_COLORS

Problem I am trying to make auto-completed files be colored according to $LS_COLORS in bash. But autocompletion ignores my $LS_COLORS variable and gets color values from some-place else. Setting I ...
Karolis Koncevičius's user avatar
0 votes
1 answer
1k views

file hyperlink not working under tmux

When using tmux hyperlink feature does not work. For example: ls --hyperlink *.pdf list .pdf files and provide a link to click and open when using under terminal emulator, but fails when using tmux. ...
LEo's user avatar
  • 103
1 vote
1 answer
192 views

Ubuntu - ls -Z only shows question marks and file names

When I'm using ls -Z /etc I only get question marks and filenames. I don't get anything about the security context. Does anyone know anything about this?
Volodya Shulga's user avatar
1 vote
1 answer
229 views

Are /var/mail/root and /var/spool/mail/root hardlinks for the same inode?

Just found out this: # diff /var/mail/root /var/spool/mail/root # (nothing) # ls -i /var/mail/root /var/spool/mail/root 1284 /var/mail/root 1284 /var/spool/mail/root Same content, same 1284 inode ...
colemar's user avatar
  • 61
0 votes
2 answers
994 views

Why does `ls 'C:\$Recycle.Bin\'` show nothing?

I have a lot of files in Recycle Bin, yet using either ls 'C:\$Recycle.Bin\' or Get-ChildItem 'C:\$Recycle.Bin\' in PowerShell 7.1.5 there is no result. Do you know why?
Ooker's user avatar
  • 2,081
0 votes
1 answer
546 views

With `ls -sh` is 1K a kilobyte, a kilobit, 1000 bytes, 1024 bytes, or what?

Preface to my question (this isn't my question): I've been looking for a command-line tool to that tells me how many bytes, kilobytes, megabytes, gigabytes, etc. that a file is (not some other form of ...
Brōtsyorfuzthrāx's user avatar
1 vote
1 answer
590 views

Can you underline directories in zsh with ls?

I would like to underline directories when I do ls. Is this possible in a default Mac terminal and zsh? Or do I need something like iTerm2 + ohmyzsh. From what I found LSCOLORS doesn't support ...
Bn.F76's user avatar
  • 134
0 votes
1 answer
998 views

How can I watch a folder on an sftp server for new files?

I log in to a sftp server, and to see the files I type ls. Is there any way to recursively watch a folder? For now I just keep typing ls -tlh. Is there a way for that to happen without me typing it? ...
Hcabnettek's user avatar
0 votes
1 answer
733 views

How to refresh terminal after function call

I've written a simple function to search the current folder when I press ctrl+f with exa and peco, after I choose a directory I want to cd into it. (ll is modified version of ls) pecofunc() { ll | ...
MikiS's user avatar
  • 1
0 votes
1 answer
66 views

How to restrict a user from seeing hierarchy of files?

Is it possible to restrict a user from seeing hierarchy of files? The user shouldn't be able to see the hierarchy of files with ls or any other commands.
itismoej's user avatar
  • 101
0 votes
0 answers
191 views

How to ls files with output starting on a specific letter?

I want to ls all files from /bin that starts with letter s, and this is the furthest I could think, but it does not print out information: ls /bin | grep ^s Does anyone have a hint?
Martin Dub's user avatar
0 votes
1 answer
247 views

Folder that is not hidden does not appear in `ls`, autocomplete or Finder

I have a folder ~/Library/Application Support/minecraft that does not appear at all in ls, autocomplete or Finder. If I navigate to the directory in the terminal and use open ., Finder opens up to the ...
theodinspire's user avatar
0 votes
1 answer
215 views

How to separate mixed Home directory files and User created files - Ubuntu 20.04

I have download android source code in /home/username/ directory, without creating separate folder(/home/username/folder). Now my home directory files and downloaded files are mixed. How to find and ...
sire's user avatar
  • 23
1 vote
1 answer
245 views

Linux permissions varies between parent directory and double dots

I have a directory content: [root@myserver ~]# ll -a /home/user/.ssh drwx------. 2 thomas water 48 26 nov. 15:57 . drwxrwxrwx. 12 thomas water 4096 25 nov. 11:36 .. -rwx------. 1 thomas water ...
wiltomap's user avatar
  • 113
0 votes
0 answers
3k views

ls: cannot access file, bad message

i can't see the Downloads folder from GUI, a message appear "The location could not be displayed" pointing one pdf file so i enter using the terminal but when i run the ls -l command i see ...
Mauricio Velasco's user avatar
0 votes
1 answer
415 views

Kali Linux chmod 666

I'm using a user I created with adduser that I logged into. I created a directory through this user (not root) and changed permissions from the standard 644 to 666 (no pun intended) with chmod 666 &...
Petter's user avatar
  • 1
1 vote
3 answers
923 views

Why doesn't ls -U list files in alphabetical order?

On my Xubuntu install, in some folders, if I list all the files with ls -U, sometimes they are not listed in alphbetical order. For example, once I had it list every single file in alphabetical order ...
EllipticalInitial's user avatar
0 votes
1 answer
636 views

Why does `xargs` not work with `echo` but work with `ls`?

root@home:~$ ls root@home:~$ echo abc > z1 root@home:~$ echo xyz > z2 root@home:~$ ls z1 z2 root@home:~$ ls | xargs -I{} cat {} abc xyz root@home:~$ echo z1 z2 | xargs -I{} cat {} cat: 'z1 z2': ...
xmllmx's user avatar
  • 444
0 votes
1 answer
55 views

Why find is giving inaccurate responses for 1M and 1G size?

Why find is giving inaccurate/weird responses when I try to look for files that are 1 megabyte size or 1 gigabyte size ? Or even less than 1 megabyte or 1 gigabyte. [root@server1 ~]# ls -lh total 7.8M ...
linuxuser's user avatar
0 votes
1 answer
869 views

What is a purple file from the LS command?

I am working on a c++ project and had a failed compilation (normal kind of errors). When I ran ls (a bit of a habit), it showed a file with a seemingly random sequence of characters: '!4'$'\377\377\...
weirdpusheen's user avatar
2 votes
2 answers
4k views

Why ls -l total is 0 even even there are files in the directory?

I have a directory, inside that, I have created 2 files and have written some content in these files when I run ls -l. It still displays the total as 0. Why? It should return some positive integer. I ...
Vivek Nuna's user avatar
2 votes
2 answers
1k views

How do I change the color ls in the console for files if group owner is `root`?

I am inside a mounted folder: /mnt/hgfs because of this all the files' owner is root. In this folder when I do ls color for all the files show up as green and for all the folders, there is green ...
alper's user avatar
  • 190
0 votes
2 answers
4k views

Can't run the ls command on the root directory without using sudo

CentOS 7.6.180 GNOME-CLASSIC 3.28.2 I've always been able to run ls on the / directory in the system above. Now it just hangs when I run ls. Same if I try to see the / dir with software other than ...
user787832's user avatar
1 vote
1 answer
37 views

Trying to copy files with multi-patterns from directory to another directory?

I am trying to copy all files that start with specific pattern from directory to another directory I tried using the command below, cp 8405T* 1208T* 1783T* 6321T* 9269T* 479T* 1743T* 6527T* 6153T* ...
Mohammad Awni Ali's user avatar
0 votes
1 answer
3k views

ls doesn't work in mobaxterm local terminal

I'm having a strange issue running mobaxterm v20.2 on Windows 10: I am unable to use ls to see the contents of the local directory. For example, in this screenshot, the output of ls is empty, but the ...
Andrew Ronald Friedman's user avatar
2 votes
1 answer
2k views

Pipe the output of “ls -G1” to “sed” while retaining output colors in macOS

When using the terminal in macOS I created an alias in ~/.bash_profile that lets me list folders and files in one column and with color using the -G1 option like this: something = "ls -G1" This work ...
Giuseppe's user avatar
0 votes
1 answer
550 views

Long listing format ls command [special character file data]

When using the ls -l command files that are not Character special file (c) or Block special file (b) before the last modification date they have just one number; the file size. Those 2, have 2 number ...
Power_of_zero's user avatar
0 votes
2 answers
742 views

List only files for current user

How can I limit ls to only show files where I am the owner? I might be able to string together something using find along with ls, but I'm looking for an ls only solution.
Dave's user avatar
  • 929
2 votes
1 answer
713 views

How to ls --group-directories-last?

The question is basically the same of this post, however there are 2 things that I don't like in the accepted answer: it breaks the natural column structure of ls; tac inverts the order of the output ...
noibe's user avatar
  • 43
3 votes
2 answers
7k views

Bash Script to delete oldest files but keep latest files including sub-directories

I'm trying to delete old files but should keep latest 3 days log files.i tried below command, ls -tr /home/httpd/htdocs/pathname/pathname/config//build/logs/apps/.log | tail -n +4 | xargs rm -- but ...
Sudesh Lakmal Pathirana's user avatar
34 votes
1 answer
6k views

Why does the `ls` command sort files like this?

As I was trying to reverse engineer the ls command, I came upon an interesting behavior. When I make 3 files, foo.png, foopa.png, and fooqa.png, ls sorts them as foopa.png, foo.png, and fooqa.png. I ...
mooncat39's user avatar
  • 341
1 vote
1 answer
5k views

Use awk command to output of ls command

I have a e-book directory that has following format: <authorname> <authorsurname> - <bookname> I want to separate the books by authors. I use the below command in a for-loop for ...
Jo Shepherd's user avatar
0 votes
1 answer
496 views

How to align the columns of ls command output in Xubuntu 16.04.6?

I have this function in .bashrc : { ls -lhNGhgF --color=always --group-directories-first --time-style="+%d-%b-%Y $newline%H:%M" | awk ' { $3 ="\033[1;31m" $3 "\033[0m"...
vladimir pavloski's user avatar
2 votes
1 answer
328 views

Why an empty directory has large volume?

All the directories below are empty [user@xxxx ~]$ ls -lah /home/1m total 387M drwxr-xr-x 22 foo foo 4.0K Apr 17 22:49 . drwxr-xr-x 10 foo foo 4.0K Apr 17 22:49 .. drwxr-xr-x 2 foo foo 9.2M Apr 17 ...
dimitris lepipas's user avatar
7 votes
2 answers
14k views

Run `ls` recursively with wildcards

I'm trying to find all the project files of a particular file type with: ls -ltR *.mb I know there are the files I want in several folders, but I get no results back. What did I do wrong?
whatIsLife's user avatar
0 votes
4 answers
87 views

Enumerate files *.pdf exclude *_book.pdf

How can enumerate all file file in dir, exclude by pattern. For example: all *.pdf exclude *_book.pdf. I try so: for $PDF in $(ls *.pdf | grep -v *_book.pdf); do echo "File $PDF" done It is a ...
Igor Yukhimenko's user avatar
0 votes
1 answer
3k views

dir / ls not displaying files outside of root directory in Windows 10

I've been trying to point to files and directories via my command line or powershell in windows, but for whatever reason the dir or ls command will not display files or folders within the directory ...
Negimaki's user avatar
2 votes
2 answers
299 views

Exclude system entries with "ls" or "find"

Compare Cygwin: $ ls -1 -N /cygdrive/c $Recycle.Bin cygwin64 Documents and Settings pagefile.sys PerfLogs Program Files Program Files (x86) ProgramData Recovery System Volume Information Users ...
Zombo's user avatar
  • 1

1
2 3 4 5
7