• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer

Mister PKI

SSL Certificates * SSL Tools * Certificate Decoder

  • PKI Training
  • OpenSSL
  • Keytool
  • PKI Tools
    • Apereo CAS
    • SAML
    • OpenID Connect
  • Get expert help

Linux ls human readable file size

February 9, 2023 by Mister PKI Leave a Comment

This article will demonstrate how to use the linux ls command to show a human readable file size in GB, MB, and K. The same command and set of options is used for showing each classification of size, but we have documented each of them separately for clarity.

ls in gigabytes

GB is short for gigabytes. A GB is equal to 1024 megabytes (MB) is equal to 1024 kilobytes (K or KB). If a file size is in upwards of gigabytes, it will show up with GB after the number.

To show results of the ls command in GB, run the following command.

ls -lah

The -h is key, which stands for human readable.

The other options are defined as:

  • -a – List all entries in the directory including the hidden files and sub directories
  • -l – Format into a long list

ls in megabytes

The command to show file size in megabytes with ls is the same as for gigabytes.

ls -lah

ls in kilobytes

The command to show file size in kilobytes with ls is the same as for gigabytes and megabytes.

ls -lah

ls shortcut alias

If you have a set of preferred options when using the ls command you can create an alias to automatically use those options each time. In our case, we simply want to override the ls command with the ls -lah options. The quickest way to do so is to run the following alias command:

alias ls='ls -lah'

The alias command is a temporary and not persistent command. The alias will only be created for the open terminal session. If you want the command to persist you will need to edit the .bashrc file.

vi ~/.bashrc

Conveniently, there is already a section with ls aliases. You should find the following section, at least for WSL2 on Windows using Ubuntu.

# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'

Simply add the previous alias to the list in the .bashrc file.

alias ls='ls -lah'

The change is saved, but you must either source the file or close and reopen your terminal.

source ~/.bashrc

With that, you’re on your way to quicker ls commands.

Conclusion – linux ls human readable

This article has demonstrated how to run ls to show human readable file sizes in gigabytes, megabytes, and kilobytes. Note that if no suffix is appended to the file size, it is less than a kilobyte and is being shown in the standard bytes format. Let us know in the comments if you have any questions or would like to see more examples of the ls command. Read our article on the du command for showing directory and file sizes or any other article.

linux,  Ubuntu

Reader Interactions

Leave a Reply Cancel reply

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

Primary Sidebar

Popular Posts

PKCS12

openssl s_client

Keytool

Keytool list

ECDSA vs RSA

OpenSSL

PKCS7

Certificate Decoder

PKI for DevOps Engineers – Free Training Series

PKI for DevOps Training Hub

Lesson 1 – How TLS and PKI Work

Lesson 2 – Understanding X.509 Certificates

Lesson 3 – Certificate Chains Explained

Lesson 4 – Debug TLS with OpenSSL

Lesson 5 – Verify Certificate Chains

Lesson 6 – Creating CSRs with OpenSSL

Lesson 7 – Working with PKCS12 Certificates

Lesson 8 – Java Keystores and keytool

Lesson 9 – Certificate Expiration Monitoring

Lesson 10 – Automating Certificate Renewal

Lesson 11 – Common TLS Errors

Lesson 12 – PKI Architecture for DevOps

Recent Posts

  • Apache mod_auth_cas: Protect Web Applications with Apereo CAS and Docker
  • Apache mod_auth_mellon: Configure SAML SSO & Docker
  • Configure OpenID Connect (OIDC) in Apereo CAS 7.3 and 8
  • Certificate Ownership Is an Operating Model Problem, Not a Tooling Problem
  • OpenSSL dgst: Create Checksums and Verify Digital Signatures

Footer

  • Twitter
  • YouTube
Mister PKI

Practical security engineering for the systems that establish trust.

Learn OpenSSL Keytool Free training
Work together PKI consulting CAS consulting Sponsored contributions
Site About Support Mister PKI Cookie policy Search
© 2026 Mister PKI Secure systems. Clear guidance.