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
5 votes
2 answers
810 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
30 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
53 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
212 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
84 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
97 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
0 answers
43 views

Change ls colors RPi4 zsh

I can't change the the colors on the ls output. I had setup a bit of a theme on my MacBook, and then on my RPi4 running the standard raspbian or whatever they changed it to, I installed zsh and made ...
Zach L's user avatar
  • 1
0 votes
2 answers
245 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
  • 1,897
0 votes
0 answers
176 views

Spacing of "ls" output in macOS Terminal and iTerm2

I'm looking for a way to modify the output spacing behavior of 'ls' Right now it seems the logic is to measure the spacing between the beginnings of each word and set that to be the length of the ...
Pierre Baudin's user avatar
0 votes
1 answer
120 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
258 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
551 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
386 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
31 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.
Mohammad Jafari's user avatar
0 votes
0 answers
135 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
128 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
154 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
179 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
1k 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
220 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
549 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 ...
jippyjoe4's user avatar
  • 1,188
0 votes
1 answer
402 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
47 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
391 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\...
nerdguy's user avatar
  • 63
1 vote
1 answer
2k 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
790 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
  • 152
0 votes
2 answers
3k 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
30 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
2k 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
937 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
397 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
491 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
  • 841
2 votes
1 answer
457 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
5k 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
364 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
210 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
6 votes
2 answers
12k 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
74 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
2k 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
254 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
0 votes
1 answer
31 views

Invisible directory names

When I do ls -l I get the picture below and I have no idea why. I know the names of the directories and I can cd to them no problem but can't see the actual names. How do I fix that?
Sreten Jocić's user avatar
27 votes
1 answer
24k views

Why does ls wrap some filenames in single quotes?

I've noticed that when I do ls in a terminal, some filenames are wrapped in single quotes and some aren't. I don't like the way this looks as I prefer my terminal outputs to be nice and uniform. ...
Hashim Aziz's user avatar
  • 11.6k
0 votes
2 answers
3k views

What's the difference between these ls command line arguments: -d vs *

What's the difference between ls /example or ls /example/ vs ls -d /example/* Why do they give (almost) the same output?
Jibin's user avatar
  • 135
1 vote
2 answers
643 views

How do I show all the files in a directory with a name containing a number?

How do I show all the files in a directory with a name contain a number? I tried ls [0-9] textfiles (textfiles) is my directory. This is how my Linux pocket guide shows me. I am just trying to ...
StPatrick's user avatar
0 votes
1 answer
1k views

Remove the padding spaces in the `ls` result on macOS

When I run command ls on macOS, it shows the folder names with same length, padding spaces for short folder names: jihu@ksm1 Home $ ls bin code devel opt personal shared While on ...
jihu's user avatar
  • 1
1 vote
0 answers
6k views

ls command not working in the home directory

The ls command works fine for me in all other directories except my home directory, where I get the following error: * Exit with code 1, no result found, command line was:?? locate -b -i [\^g]*g[\^a]*...
rama's user avatar
  • 11
1 vote
1 answer
57 views

Why are files lwith the same time stamp not sorted alphabetically when listed using "ls -lt"?

I read that ls -lt will order files by modification time before sorting by lexicographical order. However, when I use the command with this syntax, I get this result: ls -lt total 192 -rw-r--r-- 1 ...
user avatar
0 votes
1 answer
258 views

Can't show manual pages for `ls` in Vagrant

That's my first question in here and I'm still a beginner so please bear with me. I'm having a Linux Command Line Basics course on Udacity. I got to the point where I'm asked to open a manual page for ...
Omar Ashraf's user avatar

1
2 3 4 5
7