ls command is used to list all files and directories in linux for the current working directory. By default, ls command returns the list in alphabetical order. In this tutorial, you will learn how to list and sort files by date and time in Linux or Ubuntu.

ls command

 

List All Files Along With Hidden Files

Use ls -a  or ls --all command in terminal to display all files and directories along with hidden files for the current working directory.

ls  -a

Output:

ls -a command

ls --all

Output:

ls -all command

List Files From Other Directories

Use ls /directory_name   command in terminal to display all files and directories along for the other directory.

** Don’t forget to change directory_name to available directory name on your computer.

List Files Based on Time and Date

Use ls -t  command in terminal to display files and directories based on modification time and date. The most recently modified files and directories will be shown at the top of the command output.

ls -t

Output:

ls-t command

 

List Files Based on Time and Date in Reverse Order

Use ls -tr  command in terminal to display files and directories based on modification time and date in reverse order. The most recently modified files and directories will be shown at the bottom of the command output.

ls -tr

Output:

ls-tr command

 

List Files Based on Time and Date in Human Readable Format

Use ls -halt  command in terminal to display files and directories based on modification time and date in a human-readable format. The most recently modified files and directories will be shown at the top of the command output. 

** -h for the human-readable format, and -a for showing all dot prefixed files or hidden files.

ls -halt

Output:

ls-halt command



Linux command with examples

A
adduser  |  addgroup  |  alias  |  anacron  |  apt  |  aptitude  |  arp  |  at atq  |  atrm  |  awk
B
basename banner | batch |  bc  |  bg  |  bzip
C
cat cal  |  cd  |  chgrp  |  chown  |  cksum  |  chmod  |  clear  |  cmp  |  comm  |  cp
D
date  |  dd  |  df  |  diff  |  dir  |  dmidecode  |  du
E
echo  |  eject  |  env  |  exit  |  expr
F
factor  |  find  |  free
G
grep  |  groups  |  gunzip  |  gzip
H
head  |  history  |  hostname  |  hostnamectl  |  htop  |  hwclock  |  hwinfo
I
id  |  ifconfig  |  ionice  |  iostat  |  ip  |  iptables  |  iw  |  iwlist
J
K
kill  |  kmod
L
last  |  less  |  ln  |  locate  |  login  |  lp  |  ls  |  lshw  |  lscpu  |  lsof  |  lsusb
M
man  |  mdsum  |  mkdir  |  more|  mv
N
nano  |  nc  |  neofetch  |  netcat  |  netstat  |  nice  |  nmap  |  nproc
O
openssl
P
passwd  |  pidof  |  ping  |  pr  |  ps  |  pwd  |  pstree
Q
R
rdiff-backup  |  reboot  |  rename  |  rm  |  rmdir
S
scp  |  shred  |  shutdown  |  sleep  |  sort  |  split  |  ssh  |  stat  |  su  |  sudo  |  sum
T
tac  |  tail  |  talk  |  tar  |  tee  |  time  |  tree  |  top  |  touch  |  tr
U
unalias  |  uname  |  uniq  |  unzip  |  uptime  |  users
V
vim  |  vi
W
w  |  wall  |  watch  |  wc  |  wget  |  whatis  |  whereis  |  which  |  who  |  whoami
X
xargs
Y
yes  |  youtube-dl
Z
zcmp  |  zdiff  |  zip  |  zz
Sharing is Caring
Scroll to Top