How VPS - How to use/setup VPS
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
How VPS - How to use/setup VPS
No Result
View All Result
Home Operating System Linux

7 Quirky ‘ls’ Command Tricks Every Linux User Should Know

How VPS by How VPS
November 2, 2018
in Linux, Operating System
0
0
SHARES
26
VIEWS
Share on FacebookShare on Twitter

Contents

  1. 1. List the contents of a directory with time using various time styles.
  2. 2. Output the contents of a directory in various formats such as separated by commas, horizontal, long, vertical, across, etc.
  3. 3. Use ls command to append indicators like (/[email protected]|) in output to the contents of the directory.
  4. 4. Sort the contents of directory on the basis of extension, size, time and version.
  5. 5. Print numeric UID and GID for every contents of a directory using ls command.
  6. 6. Print the contents of a directory on standard output in more columns than specified by default.
  7. 7. Include manual tab size at the contents of directory listed by ls command instead of default 8.

We have covered most of the things on ‘ls’ command in last two articles of our Interview series. This article is the last part of the ‘ls command‘ series. If you have not gone through last two articles of this series you may visit the links below.

  1. 15 Basic ‘ls’ Command Examples in Linux
  2. Sort Output of ‘ls’ Command By Last Modified Date and Time
  3. 15 Interview Questions on Linux “ls” Command – Part 1
  4. 10 Useful ‘ls’ Command Interview Questions – Part 2
7 Quirky ‘ls’ Command Tricks Every Linux User Should Know

7 Quirky ls Command Tricks

1. List the contents of a directory with time using various time styles.

To list the contents of a directory with times using style, we need to choose any of the below two methods.

# ls -l –time-style=[STYLE]               (Method A)

Note – The above switch (--time style must be run with switch -l, else it won’t serve the purpose).

# ls –full-time                           (Method B)

Replace [STYLE] with any of the below option.

full-iso
long-iso
iso
locale
+%H:%M:%S:%D

Note – In the above line H(Hour), M(Minute), S(Second), D(Date) can be used in any order.

Moreover you just choose those relevant and not all options. E.g., ls -l --time-style=+%H will show only hour.

ls -l --time-style=+%H:%M:%D will show Hour, Minute and date.

# ls -l --time-style=full-iso
7 Quirky ‘ls’ Command Tricks Every Linux User Should Know

ls Command Full Time Style

# ls -l --time-style=long-iso
7 Quirky ‘ls’ Command Tricks Every Linux User Should Know

Long Time Style Listing

# ls -l --time-style=iso
7 Quirky ‘ls’ Command Tricks Every Linux User Should Know

Time Style Listing

# ls -l --time-style=locale
7 Quirky ‘ls’ Command Tricks Every Linux User Should Know

Locale Time Style Listing

# ls -l --time-style=+%H:%M:%S:%D
7 Quirky ‘ls’ Command Tricks Every Linux User Should Know

Date and Time Style Listing

# ls --full-time
7 Quirky ‘ls’ Command Tricks Every Linux User Should Know

Full Style Time Listing

2. Output the contents of a directory in various formats such as separated by commas, horizontal, long, vertical, across, etc.

Contents of directory can be listed using ls command in various format as suggested below.

  1. across
  2. comma
  3. horizontal
  4. long
  5. single-column
  6. verbose
  7. vertical
# ls –-format=across
# ls --format=comma
# ls --format=horizontal
# ls --format=long
# ls --format=single-column
# ls --format=verbose
# ls --format=vertical
7 Quirky ‘ls’ Command Tricks Every Linux User Should Know

Listing Formats of ls Command

3. Use ls command to append indicators like (/[email protected]|) in output to the contents of the directory.

The option -p with ‘ls‘ command will server the purpose. It will append one of the above indicator, based upon the type of file.

# ls -p
7 Quirky ‘ls’ Command Tricks Every Linux User Should Know

Append Indicators to Content

4. Sort the contents of directory on the basis of extension, size, time and version.

We can use options like --extension to sort the output by extension, size by extension --size, time by using extension -t and version using extension -v.

Also we can use option --none which will output in general way without any sorting in actual.

# ls --sort=extension
# ls --sort=size
# ls --sort=time
# ls --sort=version
# ls --sort=none
7 Quirky ‘ls’ Command Tricks Every Linux User Should Know

Sort Listing of Content by Options

5. Print numeric UID and GID for every contents of a directory using ls command.

The above scenario can be achieved using flag -n (Numeric-uid-gid) along with ls command.

# ls -n
7 Quirky ‘ls’ Command Tricks Every Linux User Should Know

Print Listing of Content by UID and GID

6. Print the contents of a directory on standard output in more columns than specified by default.

Well ls command output the contents of a directory according to the size of the screen automatically.

We can however manually assign the value of screen width and control number of columns appearing. It can be done using switch ‘--width‘.

# ls --width 80
# ls --width 100
# ls --width 150
7 Quirky ‘ls’ Command Tricks Every Linux User Should Know

List Content Based on Window Sizes

Note: You can experiment what value you should pass with width flag.

7. Include manual tab size at the contents of directory listed by ls command instead of default 8.
# ls --tabsize=[value]
7 Quirky ‘ls’ Command Tricks Every Linux User Should Know

List Content by Table Size

Note: Specify the [Value]= Numeric value.

That’s all for now. Stay tuned to Tecmint till we come up with next article. Do not forget to provide us with your valuable feedback in the comments below. Like and share us and help us get spread.

Source: tecmint.com

Tags: Linux Commandslinux guidelinux vps setup guide
How VPS

How VPS

Related Posts

Failed to download metadata for repo 'appstream' on Centos 8
CentOS

How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

February 25, 2022
How to Install Apache Tomcat 8 on CentOS 7
Linux

How to Install Apache Tomcat 8 on CentOS 7?

February 11, 2020
Install Arch Linux With Btrfs Snapshotting
Uncategorized

Install Arch Linux With Btrfs Snapshotting

February 13, 2020
Next Post

Easily Correct a Typo of Previous Command Using Carat (^) Symbol

How to Manage a Web Server and Install the IIS WWW Service Module

How to Manage a Web Server and Install the IIS WWW Service Module

How To Install Selfoss On A CentOS 7 Linux VPS

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Follow Us

  • 121 Followers
  • 87.2k Followers

Recommended

How to Install FFmpeg on Debian 8 or Debian 9

3 years ago

6 Interesting Funny Commands of Linux (Fun in Terminal) – Part II

4 years ago

Exa – A Modern Replacement for “ls Command” Written in Rust

4 years ago

How to Count Number of Files and Subdirectories inside a Given Directory

4 years ago

Instagram

    Please install/update and activate JNews Instagram plugin.

Categories

  • Arch
  • Authentication
  • Backups
  • BSD
  • Centmin Mod
  • CentOS
  • Control Panels
  • CoreOS
  • CWP
  • Debian
  • Directadmin
  • Encryption
  • Fedora
  • Firewalls
  • Hocvps Script
  • Hosting providers
  • Kloxo-MR
  • Linux
  • Mitigations
  • Operating System
  • Plesk
  • Reviews
  • Securing VPS/Servers
  • Security Patches
  • SSL Certificates
  • Uncategorized
  • Upgrading
  • VPS/Servers management guides
  • Vulnerability Detection
  • Web servers software
  • Webhosting Control Panel

Topics

Apache Web Server Bluehost Review 2019 Bluehost Review 2020 Bluehost Review 2021 Centmin Mod CentminMod centos install htop fsck htop install HTTP DoS attack Install Snort on an Ubuntu install Zabbix on CentOS install Zabbix on CentOS 7 Linux Commands linux guide linux install htop linux vps setup guide MariaDB MariaDB Error Mysql mysqld error optimize MariaDB optimize Mysql snort Ubuntu
No Result
View All Result

Highlights

Top Free Web Hosting Control Panels To Manage VPS/Dedicated Servers

Webmin Reviews

Virtualmin Reviews

CentOS Web Panel Reviews

Ajenti Reviews

ISPConfig Reviews

Trending

Failed to download metadata for repo 'appstream' on Centos 8
CentOS

How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

by How VPS
February 25, 2022
0

I tried to update some extensions by use yum on centOs which I specified in Dockerfile. After...

How to Fix MySQL Error "Plugin 'InnoDB' registration as a STORAGE ENGINE failed"?

How to Fix MySQL Error “Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed”?

November 17, 2020
How to optimize Mysql or MariaDB

How to optimize Mysql or MariaDB

November 3, 2020
Top Free Web Hosting Control Panels To Manage VPS/Dedicated Servers

Top Free Web Hosting Control Panels To Manage VPS/Dedicated Servers

February 17, 2020
Webmin Reviews

Webmin Reviews

February 17, 2020
How VPS – How to use/setup VPS

We bring you the best Premium WordPress Themes that perfect for news, magazine, personal blog, etc. Visit our landing page to see all features & demos.
LEARN MORE »

Recent News

  • How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8 February 25, 2022
  • How to Fix MySQL Error “Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed”? November 17, 2020
  • How to optimize Mysql or MariaDB November 3, 2020

Categories

  • Arch
  • Authentication
  • Backups
  • BSD
  • Centmin Mod
  • CentOS
  • Control Panels
  • CoreOS
  • CWP
  • Debian
  • Directadmin
  • Encryption
  • Fedora
  • Firewalls
  • Hocvps Script
  • Hosting providers
  • Kloxo-MR
  • Linux
  • Mitigations
  • Operating System
  • Plesk
  • Reviews
  • Securing VPS/Servers
  • Security Patches
  • SSL Certificates
  • Uncategorized
  • Upgrading
  • VPS/Servers management guides
  • Vulnerability Detection
  • Web servers software
  • Webhosting Control Panel

[mc4wp_form]

© 2018 JNews - City News Magazine WordPress theme. All rights belong to their respective owners.
JNews is a top selling 2018 WordPress News, Blog, Newspaper & Magazine Theme.

No Result
View All Result
  • Home

© 2023 JNews - Premium WordPress news & magazine theme by Jegtheme.