Ubuntu Basic Terminal commands List files and folders


Example

To list files and folders inside current directory, we use ls command:

user@host:/$ ls
bin  boot  cdrom  dev  etc  home  initrd.img  lib  lib64  lost+found  
media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var  vmlinuz

ls prints folder structure in simple view, color coded by type. The Ubuntu default colors for ls are:

blue for directories, green for executable files, sky blue for linked files, yellow with a black background for devices, pink for image files, and red for archive files.

ls -la will print folder structure with additional info:

user@host:/$ ls -la
total 104
drwxr-xr-x  23 root root  4096 јул 25 12:40 .
drwxr-xr-x  23 root root  4096 јул 25 12:40 ..
drwxr-xr-x   2 root root  4096 јул 25 12:42 bin
drwxr-xr-x   4 root root  4096 јул 25 12:42 boot
drwxrwxr-x   2 root root  4096 јул 25 12:38 cdrom
drwxr-xr-x  16 root root  4300 јул 30 12:18 dev
drwxr-xr-x 134 root root 12288 јул 30 12:18 etc
drwxr-xr-x   5 root root  4096 јул 25 12:50 home
lrwxrwxrwx   1 root root    33 јул 25 12:40 initrd.img -> boot/initrd.img-3.19.0-39-generic
drwxr-xr-x  23 root root  4096 јул 25 12:42 lib
drwxr-xr-x   2 root root  4096 дец  9  2015 lib64
drwx------   2 root root 16384 јул 25 12:32 lost+found
drwxr-xr-x   3 root root  4096 јул 25 14:56 media
drwxr-xr-x   2 root root  4096 апр 11  2014 mnt
drwxr-xr-x   3 root root  4096 јул 25 13:37 opt
dr-xr-xr-x 227 root root     0 јул 30 12:18 proc
drwx------   2 root root  4096 јул 25 13:06 root
drwxr-xr-x  23 root root   780 јул 31 14:30 run
drwxr-xr-x   2 root root 12288 јул 25 12:46 sbin
drwxr-xr-x   2 root root  4096 дец  8  2015 srv
dr-xr-xr-x  13 root root     0 јул 30 12:18 sys
drwxrwxrwt   8 root root  4096 јул 31 16:05 tmp
drwxr-xr-x  10 root root  4096 дец  8  2015 usr
drwxr-xr-x  13 root root  4096 дец  9  2015 var
lrwxrwxrwx   1 root root    30 јул 25 12:40 vmlinuz -> boot/vmlinuz-3.19.0-39-generic

Another shortcut for ls -la is ll. However, this is not a builtin command. Rather its an alias common in ubuntu systems, in full its ls -laF. The alias will give you the same output as ls -la, but with additional slash (/) at the end of each folder, to help you with easier folder identification.

The ll alias can be viewed in full by typing alias ll. As illustrated below. If the alias is not set then the command will give an error.

vagrant@host ~ ->>
08:05 AM Mon Sep 12$ alias ll
 alias ll='ls -alF'