How to list more than one thing at a time with the /bin/ls command for Linux.

Posted: April 2, 2017. At: 10:39 PM. This was 6 months ago. Post ID: 7110

The ls command for Linux may be used to list more than one thing at a time. These examples demonstrate this.

homer@deusexmachina ~ $ ls -p /opt/ /bin/rm
/bin/rm
 
/opt/:
firefox/  mint-flashplugin-11/

Here is a more verbose version of this command. With human readable file sizes and a vertical directory listing.

homer@deusexmachina ~ $ ls -puhal /opt/ /bin/rm
-rwxr-xr-x 1 root root 59K Apr  2 20:55 /bin/rm
 
/opt/:
total 8.0K
drwxr-xr-x  4 root root   16 Apr  2 22:16 ./
drwxr-xr-x 22 root root 4.0K Apr  2 21:02 ../
drwxr-xr-x  4 root root   16 Nov 27 04:54 firefox/
drwxr-xr-x  2 root root    8 Nov 27 04:54 mint-flashplugin-11/

You may also list only directories.

homer@deusexmachina ~ $ ls -puhal /opt/ /
/:
total 96K
drwxr-xr-x  22 root root 4.0K Apr  2 21:02 ./
drwxr-xr-x  22 root root 4.0K Apr  2 21:02 ../
drwxr-xr-x   2 root root 4.0K Nov 27 05:06 bin/
drwxr-xr-x   3 root root   72 Apr  2 21:00 boot/
drwxr-xr-x   2 root root    1 Apr  2 21:00 cdrom/
drwxr-xr-x  17 root root 4.2K Apr  3  2014 dev/
drwxr-xr-x 146 root root 4.0K Apr  2 22:28 etc/
drwxr-xr-x   4 root root   16 Oct 14 07:41 home/
lrwxrwxrwx   1 root root   33 Apr  2 21:02 initrd.img -> boot/initrd.img-3.11.0-12-generic
lrwxrwxrwx   1 root root   34 Apr  2 21:02 initrd.img.old -> /boot/initrd.img-3.11.0-12-generic
drwxr-xr-x  23 root root 4.0K Apr  2 21:02 lib/
drwxr-xr-x   2 root root    8 Nov 27 04:07 lib64/
drwxr-xr-x   3 root root    8 Nov 27 04:06 media/
drwxr-xr-x   2 root root    1 Oct 14 07:41 mnt/
drwxr-xr-x   4 root root   16 Apr  2 22:16 opt/
dr-xr-xr-x 202 root root    0 Apr  3  2014 proc/
drwx------   4 root root   32 Nov 27 05:05 root/
drwxr-xr-x  24 root root  780 Apr  3  2014 run/
drwxr-xr-x   2 root root 4.0K Apr  2 22:28 sbin/
drwxr-xr-x   2 root root    1 Nov 27 04:06 srv/
dr-xr-xr-x  13 root root    0 Apr  3  2014 sys/
drwxrwxrwt  11 root root 4.0K Apr  2 21:24 tmp/
drwxr-xr-x  10 root root   64 Apr  2 22:07 usr/
drwxr-xr-x  11 root root   88 Nov 27 05:05 var/
lrwxrwxrwx   1 root root   30 Apr  2 21:02 vmlinuz -> boot/vmlinuz-3.11.0-12-generic
 
/opt/:
total 8.0K
drwxr-xr-x  4 root root   16 Apr  2 22:16 ./
drwxr-xr-x 22 root root 4.0K Apr  2 21:02 ../
drwxr-xr-x  4 root root   16 Nov 27 04:54 firefox/
drwxr-xr-x  2 root root   24 Nov 27 04:54 mint-flashplugin-11/

This is a very useful trick to use with the /bin/ls command.

Navigating around the Linux filesystem is very easy, if you want to get back to your home folder, use the cd ~ command. On Windows 7 you can use cd %userdir% but that would not work for me on Windows 8.1 build 9600. The Linux shell is easier to use than CMD anyway. Powershell has gone to great lengths to fix this, but I prefer the bash shell. Each to his own though.

No comments have been made. Use this form to start the conversation :)

Leave a Reply