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
0 votes
1 answer
34 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? ...
user avatar
0 votes
1 answer
55 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 | ...
user avatar
  • 1
0 votes
1 answer
28 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.
user avatar
0 votes
0 answers
73 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?
user avatar
0 votes
1 answer
53 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 ...
user avatar
0 votes
1 answer
36 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 ...
user avatar
  • 13
1 vote
1 answer
51 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 ...
user avatar
  • 113
0 votes
0 answers
341 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 ...
user avatar
0 votes
1 answer
111 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 &...
user avatar
  • 1
1 vote
3 answers
159 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 ...
user avatar
  • 896
0 votes
0 answers
25 views

"ls -C" uses single-column or multi-column assuming narrow window

I've traditionally used ls -C to get multi-column format. If I pipe the output through another command (e.g., less), I need ls -C to override the default single-column format. For some reason, I'm ...
user avatar
0 votes
1 answer
30 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': ...
user avatar
  • 445
0 votes
0 answers
12 views

Can not configure LS_COLORS to show blinking

I wanted to have ls display files ending in rc (such as .nanorc etc.) as blinking. I have configured $ printenv LS_COLORS di=1;4;35:*.txt=34;47:*.csv=30;47:*.*sh=36:*rc=5,7:*.rb=32:*.irbrc=5,32:*.bak=...
user avatar
0 votes
0 answers
25 views

list files with ellipsis for continuous range of numbered files

Lets say I have a directory with these files: ➜ ~ ls -1 IMG00.JPG IMG01.JPG IMG02.JPG IMG08.JPG IMG09.JPG IMG10.JPG IMG11.JPG IMG12.JPG IMG13.JPG IMG14.JPG IMG19.JPG IMG20.JPG IMG_forest.JPG IMG_tree....
user avatar
  • 1
0 votes
1 answer
43 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 ...
user avatar
0 votes
1 answer
67 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\...
user avatar
  • 63
0 votes
1 answer
523 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 ...
user avatar
2 votes
2 answers
286 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 ...
user avatar
  • 147
0 votes
2 answers
1k 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 ...
user avatar
1 vote
1 answer
18 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* ...
user avatar
0 votes
1 answer
1k 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 ...
user avatar
2 votes
1 answer
321 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 ...
user avatar
0 votes
1 answer
174 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 ...
user avatar
0 votes
2 answers
263 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.
user avatar
  • 767
2 votes
1 answer
167 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 ...
user avatar
  • 43
2 votes
2 answers
3k 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 ...
user avatar
34 votes
1 answer
5k 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 ...
user avatar
  • 341
1 vote
1 answer
3k 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 ...
user avatar
0 votes
1 answer
178 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"...
user avatar
2 votes
1 answer
110 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 ...
user avatar
4 votes
2 answers
7k 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?
user avatar
0 votes
4 answers
66 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 ...
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 ...
user avatar
2 votes
2 answers
192 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 ...
user avatar
  • 9,630
0 votes
1 answer
30 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?
user avatar
20 votes
1 answer
17k 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. ...
user avatar
  • 10.3k
0 votes
2 answers
2k 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?
user avatar
  • 135
1 vote
2 answers
181 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 ...
user avatar
0 votes
1 answer
618 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 ...
user avatar
  • 1
1 vote
0 answers
5k 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]*...
user avatar
  • 11
1 vote
1 answer
54 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
204 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 ...
user avatar
0 votes
2 answers
69 views

Preview current directory in shell

What often happens when I work in a shell - zsh - is that I have cded somewhere and I want to have a quick look at the directory. Using ls may produce a lot of output and leaves it in the terminal. ...
user avatar
  • 205
5 votes
4 answers
11k views

'ls' command very slow

I have about 17k files in a directory. When I run ls directory, I have to wait for about 15-20 seconds before the results are displayed. On the other hand, when I run ls directory | wc -l or ls ...
user avatar
  • 83
1 vote
2 answers
595 views

ls -l shows symlinked directory with two trailing slashes

I just copied my ~/.config directory to another and symlinked it back to $HOME. When I run ls -l this shows up like this with the double slash at the end: lrwxrwxrwx 1 lud lud 22 Jul 23 20:25 ...
user avatar
1 vote
1 answer
2k views

'ls' output doesn't show color anymore in macOS High Sierra

I use zsh and oh-my-zsh: As shown in the screenshot ls is not showing color output anymore. I set color theme from iTerm2 and set zsh theme (wezm+ theme) from oh-my-zsh. I try to set manually ...
user avatar
  • 11
3 votes
1 answer
475 views

find or ls does not list all files in a folder in MacOS (HFS+)

ls or find command do not seem to locate all files located in a specific folder. I'm running a Mac (under El Capitan 10.11.6 (15G21013), 500GB SSD, HFS+). In one of my folders, where I have about 700k ...
user avatar
  • 2,405
1 vote
1 answer
30 views

File/directory in the CentOS looks weird

I am connected to CentOS server via PuTTY and I see a weird file/directory in one of the sub-directory which looks unreal. I am not sure how the file exists there and Its not related to our work. Can ...
user avatar
  • 11
1 vote
1 answer
5k views

'ls' command in terminal is showing all files and file permissions. How do I get back to normal with 'ls' showing only normal files and folders?

Want to get the terminal back to bryce@macbookpro instead of bryce@machine and have the 'ls' command only show visible files and folders.
user avatar
  • 13
8 votes
2 answers
3k views

How to color output columns of ls?

Title kind of says it all: I would like to get those neat colored columns of the output of something like ls -al, say, as in 10basetom’s answer to this question.
user avatar
  • 191

1
2 3 4 5
7