In Linux, is there an equivalent to
Dir /s /a /b where the full path and filename is listed? I'm new to Linux, and without a GUI, I want to get an idea of the structure of what's on the hard disk.
In Linux, is there an equivalent to
find command. By default it will recursively list every file and folder descending from your current directory, with the full (relative) path.
If you want the full path, use:
- If you want to restrict it to files or folders only, use
find -type for
find -type d, respectively.
- If you want it to stop at a certain directory depth, use
find -maxdepth 2, for example.
Read Finding Files for an extensive manual on GNU
find, which is the default on Linux.
$ pwd /home/victoria $ find $(pwd) -maxdepth 1 -type f -not -path '*/\.*' | sort /home/victoria/new /home/victoria/new1 /home/victoria/new2 /home/victoria/new3 /home/victoria/new3.md /home/victoria/new.md /home/victoria/package.json /home/victoria/Untitled Document 1 /home/victoria/Untitled Document 2 $ find . -maxdepth 1 -type f -not -path '*/\.*' | sed 's/^\.\///g' | sort new new1 new2 new3 new3.md new.md package.json Untitled Document 1 Untitled Document 2
.: current folder
-maxdepth 1to search recursively
-type f: find files, not directories (
-not -path '*/\.*': do not return
sed 's/^\.\///g': remove the prepended
./from the result list
For completeness, the
ls -lR / command will list the name of each file, the file type, file
mode bits, number of hard links, owner name, group name, size, and timestamp of every file (that you have permission to access) from the root directory down. (
l is for long list ie all that info,
R is to recurse through directories,
/ starts at the root of the filesystem.)
There are a number of params to make the output info closer to
dir /S /A, but I have to admit I can't work out how to translate the
For useful info, I would try:
ls -lAFGR --si /
- l = long list (as mentioned above)
- A = almost all files (doesn't include . and .. in each dir, but does show all hidden files)
- F = show file indicator, (one of
*for exe files,
@for symbolic links,
=for sockets, and
- G = don't show group info (remove this if you want to see it)
- R = recursively list directories (subdirectories) and
- --si = show the file size in human readable eg 1M format (where 1M = 1000B)
ls can provide an easier to read synopsis of directories and files within those directories, as
find's output can be difficult to scan when files are contained within really long directory structures (spanning multiple lines). The corollary is that each file is listed on its own (ie without directory path information) and you may have to go back a couple of pages/screens to find the directories a particular file is located in.
Also, find doesn't contain the /A information in the DIR command. I've suggested a number of attributes in the command I've shown (that coincidentally show the extra usefulness that you get from linux over a certain proprietary system), but if you read the
info pages on
ls, you will be able to see what to include or not.
Most answers here mention find or just ls or ll, and pwd but with the use of find.
here it is with the use of ll
plaj@her-dta-01:~> ll -d $PWD/* drwxr-xr-x 2 plaj users 4096 Jul 3 10:27 /home/plaj/bin -rw-r--r-- 1 plaj users 203 Aug 19 17:21 /home/plaj/file.json drwxr-xr-x 5 plaj users 4096 Aug 12 08:06 /home/plaj/file2 drwxr-xr-x 6 plaj users 4096 Sep 2 09:37 /home/plaj/file3 drwxr-xr-x 5 plaj users 4096 Aug 12 15:15 /home/plaj/file4 -rw-r--r-- 1 plaj users 566 Sep 2 11:10 /home/plaj/etcfile.log