Questions tagged [ls]
Questions relating to the Linux 'list' command (ls)
49
questions
487
votes
5
answers
1.0m
views
What do the different colors mean in ls?
What do the different colours in Ubuntu's ls command mean? For example, when I type the ls command in one of my folders, I get one of the files in light green, the other (which is a folder) in blue ...
279
votes
13
answers
493k
views
How do I change the color for directories with ls in the console?
On my console the color for directories is such a blue, that it is hard to read on a dark background.
How can I change the color definitions for ls?
16
votes
2
answers
111k
views
What does 'ls -la' do?
When I entered the -al attribute with the ls command, I got the following:
anupam@JAZZ:~/blog$ ls -al
total 76
drwxrwxr-x 13 anupam anupam 4096 Aug 28 21:45 .
drwxr-xr-x 34 anupam anupam 4096 Aug 28 ...
91
votes
5
answers
95k
views
Difference between 'dir' and 'ls' terminal commands?
I've been trying to find the difference between using the dir and ls commands in terminal. I know ls is the traditional UNIX method of viewing the files in a directory, and that dir is the windows ...
29
votes
2
answers
11k
views
Why does `ls -l` count more files than me?
Apparently I cannot count. I think there are three files in /media
$ tree /media
/media
├── foo
├── onex
└── zanna
3 directories, 0 files
However, ls -l finds 12.
$ ls -l /media
total 12
drwxr-xr-x ...
13
votes
2
answers
20k
views
What does each part of the `ls -la` output mean? [duplicate]
What do the following numbers represent?
243
votes
25
answers
885k
views
How to show only hidden files in Terminal?
I have a directory that contains thousands of files, some of which are hidden.
The command ls -a lists all files, including hidden ones, but I need to just list hidden files.
What command should I use?...
44
votes
2
answers
29k
views
Why does ls -l output a different size from ls -s?
I can't figure out why I'm getting the following results:
ls -l tells me the size of a given file (HISTORY) is "581944":
$ ls -l HISTORY
-rw-rw-r-- 1 waldyrious waldyrious 581944 Feb 22 10:...
2
votes
2
answers
3k
views
How to make locate output look like `ll` or `ls -la` but nicer?
The locate command output is a little bland:
$ time locate etc/profile
/etc/profile
/etc/profile.d
/etc/profile.d/appmenu-qt5.sh
/etc/profile.d/apps-bin-path.sh
/etc/profile.d/bash_completion.sh
/etc/...
20
votes
3
answers
11k
views
What does the l command do?
There is a command l available on my machine which appears to do nothing. which l also produces no output. Is this a real command, and does it actually do anything?
17
votes
1
answer
91k
views
Difference between ls -l , ls -ltr and ll?
When i am using these commands , i am getting the same output but only order is getting changed for ls -ltr command.
Can anyone please tell me what is the difference between the below commands?
ll
ls ...
203
votes
5
answers
908k
views
How to Search for Files Recursively into Subdirectories
I am trying to look for all XML files in a particular directory and all sub-directories (recursively) inside it.
ls -R *.xml is only listing files in the current directory. I am quite sure, the sub-...
68
votes
10
answers
184k
views
Count total number of files in particular directory with specific extension
I want to count the total number of files in particular directory that ends with ".mp4" extension.
I am getting following command:
ls -F |grep -v / | wc -l
It count all the files in particular ...
38
votes
5
answers
26k
views
What does the second column in the output of 'ls -n' mean?
When I run:
ls -n
I get something like:
-rwxrwxrwx 1 1000 1000 765528 2009-10-15 18:41 file1
drwxr-xr-x 10 1000 1000 4096 2010-12-07 20:50 dir1
drwxr-xr-x 3 1000 1000 4096 2010-10-24 16:...
33
votes
8
answers
10k
views
Why doesn't the command "ls | file" work?
I've been studying about the command line and learned that | (pipeline) is meant to redirect the output from a command to the input of another one.
So why does the command ls | file doesn't work?
...
5
votes
2
answers
15k
views
What is the la command?
I just mistyped ls as la. Without noticing, I ran it:
tim@Hairy:~$ la
detection.sh output-2.jpg output-4.jpg output-6.jpg output-8.jpg Test1.pdf
output-1.jpg output-3.jpg output-5.jpg output-...
13
votes
2
answers
38k
views
Best way to list 100 first files in a directory sorted by time
What would be the best way to list 100 first files in a directory sorted by the created timestamp (oldest first). The directory is quite large (around 100000 files). ls piped to head takes an awful ...
6
votes
2
answers
28k
views
File permissions: why can't I list a directory? [duplicate]
I am able to list directories in a root shell,
root@ThinkPad:~# ll /media/
total 36
drwxr--r-- 6 root root 4096 2011-05-12 16:41 ./
drwxr-xr-x 22 root root 4096 2011-05-12 13:14 ../
drwxr-xr-x 5 ...
-1
votes
1
answer
650
views
Why do `ls` and `du` commands show a different size for the same file? [duplicate]
I am currently using Ubuntu 20.04.
When I check a file's size using the du command, I get the following output:
ubuntu@ip-172-31-49-39:/myxfs$ du -h newquota
4.0K newquota
With the ls -la command, ...
35
votes
10
answers
9k
views
Will ls always list the files that rm will remove?
Something I feel I ought to know for sure: if I ls <something>, will rm <something> remove exactly the same files that ls displayed? Are there any circumstances where rm could remove files ...
33
votes
4
answers
61k
views
How can I direct a pipe input to ls command?
When I type something like:
find . -name *foo* | ls -lah
it returns the same result as a plain ls command, as though it had no input.
However:
ls -lah $( find . -name *foo* )
works well, but only ...
28
votes
8
answers
146k
views
listing files in a directory without listing subdirectories and their contents in that directory
I want to create a list of all the files in a directory, without listing any of the subdirectories that reside in that same directory, and print that list to a new file.
ls -d * > filelist
will ...
21
votes
5
answers
54k
views
How to find all PDF files in directories and their subdirectories?
I want to list all PDF files in the directories of the current working directory. What command can do this?
I remember a combination of ls and */*.pdf but don't remember what exact combination.
19
votes
6
answers
8k
views
What's the difference between ls and la? Why do they give the same output?
I entered la accidentally instead of ls to view the contents of a directory and it produces exactly the same output as ls...
Why is this? Surely it doesn't make sense to have two commands that do the ...
15
votes
4
answers
3k
views
Tell `ls` to sort by regular ASCII codes, not "intelligently"
I have a couple files and ls sorts them like this:
a
_b
c
but I want to have
_b
a
c
How can I do that?
2
votes
1
answer
4k
views
ls system command not showing terminal colors
I've just been fooling around with some code in C, an example of a really basic program is as follows which just, obviously, lists the directories using the ls system command.
#include <stdio.h>...
2
votes
1
answer
1k
views
Why does ls show wrong permissions for the group when using ACL?
I have the following script for setting permissions for the Joomla CMS directory:
#!/bin/bash
if [ ! -d "$1" ]; then
echo "Error: Folder does not exist or no folder given."
echo ""
exit 1
fi
# ...
2
votes
2
answers
2k
views
ls command very slow after deletion of thousand files on a directory
I have a dir under /home/myuser dir which an application stores and deletes millions of temporary files. When I do ls on this dir (now it only has a hundred files only) it is too slow (actually I do ...
2
votes
2
answers
169
views
ls -d not doing what I'm told it should
Ubuntu 14.04 LTS
Straight machine, no dual boot or anything.
I am in ~/scratch
I want a list of directories only.
tree -dL 1
Got it!
man ls says:
-d List directories only instead of their ...
276
votes
10
answers
1.1m
views
How to list all symbolic links in a directory
I have a symbolic link in my /var/www/ directory that links to WordPress. When I run the command ls -la from the /var/www/ directory the link to WordPress doesn't show up. Is there a way to list all ...
124
votes
5
answers
207k
views
How to exclude certain files in `ls`?
I would like to run ls and exclude certain files in the output.
When I run the following command, I get all files, each on a separate line:
$ ls -1
file1
file2
file3
temp
I would like to run this ...
45
votes
10
answers
84k
views
How to list all the files in a tree (a directory and its subdirs)?
For a task of mine I need to list all the files in a tree (a directory, all its subdirs, all subdirs of those, etc.).
I'd prefer to see them in Nautilus or Krusader, but a command-line solution is ...
43
votes
5
answers
68k
views
How to activate pagination for ls command?
What is the equivalent option for the ls command to activate pagination as in DOS the dir /p does?
36
votes
5
answers
24k
views
Why is ls -R called "recursive" listing?
I understand that ls -R displays a listing of directories.
But why is it recursive? How is recursion used in the process?
33
votes
2
answers
8k
views
How to make ls produce ISO 8601 format
In older versions of Ubuntu, like 9.10, ls(1) produced ISO 8601 format by default, in the way
ls -l --time-style=long-iso
does it. With 12.04, we're back at the older Unix style. Thus replacing the ...
24
votes
2
answers
3k
views
Filenames with space showing as 'file name' after upgrade to 18.04
After a upgrade to 18.04, from 16.04, all file names with spaces shows as 'file name'. Previously it was simply file name. File names without space shows up normally:
$ ls
bar 'foo bar'
While it ...
23
votes
3
answers
21k
views
What does the 's' in srwxr-xr-x in the 'ls' output mean?
I have a directory entry as follows
srwxr-xr-x 1 ubuntu ubuntu 0 May 29 05:03 0.0.0.0=
I do not know what the s means and also that is a strange file name and I wonder what it is good for. Could ...
19
votes
1
answer
4k
views
What do the symbols like =, * and | in the output of "ls -F" mean?
I am working on creating a 'cheat sheet' of shell commands. I am currently researching the ls command and its flags. For the -F flag I know what the majority of the appended indicators mean but for; = ...
18
votes
5
answers
4k
views
What does `ls --directory` stand for?
In my Ubuntu version the man ls has the next info about --directory:
list directory entries instead of contents, and do not dereference symbolic links
So I'm a little confused how it works.
I used ...
10
votes
3
answers
61k
views
List files of particular extension
Ok this is strange. I am using this code,
ls *.prj
To list all the files with the .prj extension in the dir but I am getting this error,
bash: /bin/ls: Argument list too long
I eventually wish ...
7
votes
3
answers
3k
views
How do you get details from the output of the locate command?
When I run the ls -l command I get details about the files in the current directory like permissions, owner, group, file size.
Is there a way I can get these same details instead of just the ...
6
votes
3
answers
50k
views
Find all files in the current directory and its subdirectories with the extension .png [duplicate]
In a directory and its subfolders I need to see all the files with the png extension.
For this, I used the command ls -R *.png
I get an error saying that the directory *.png doesn't exist. I am ...
5
votes
1
answer
762
views
Nautilus sort order with ls
I am creating image sprites and have neatly named around 100 files. I am using the following to generate an image sprite from individual images:
convert $(ls -w 1000) +append sprite.png
I have just ...
4
votes
3
answers
3k
views
How to view list of files in Google Drive?
When I list directory components with
$ ls /run/user/1000/gvfs/google-drive:host=gmail.com,user=address
1BzrSykm6X7BBm09yZ7Qcsj_5lL1dMtrN 1p55c8zr6M617qoFU8BopppxaLh0qJTd8
...
3
votes
3
answers
3k
views
Is it possible to rename files selected by ls?
I have some files I downloaded recently and I want to name. It is possible to do something like:
rename 's/ /_/g' $(ls -t | head -n5)
Actually, I would like to rename last downloaded 5 files.
...
3
votes
2
answers
348
views
Use read line to iterate over variables
I have the following files:
$ ls *.png | egrep -i "am|pm"
output-0 11.42.30 AM.png
output-0 5.10.12 PM.png
....
I want to remove them but get this error:
$ ls *.png | egrep -i "am|pm" | while read ...
2
votes
1
answer
7k
views
how can I recursively run chmod -x?
So I have my music collection living on my 12.04.2 server. This Collection has traveled with me over the years from a Windows machine to a MacBook Pro, and then finally to where it is today on the ...
0
votes
2
answers
2k
views
Accidently make ls colors (folders, files, links...) to white
I accidentally delete/change LS colors when listing directories with the 'ls' command, so I tried the command "ls --color=auto" it works temporarily because when I reboot my terminal ls ...
0
votes
1
answer
236
views
Display all the files with read and write permissions and display result in a file
I need to display all the files with read and write permissions and save the result in a file.
Can anybody help me with that?
It's easy but I am little bit confused, so please help me on this.