Writers' Community!
Home Page Two Columnists Q&A Submit an Article FAQs Contact Author Login
Article Submission
We Need YOUR Articles!
We'll Promote Them for FREE!

Author Login

New Authors
Register Here


Now Serving 8,188 Authors
71,887 Quality Articles
& 4,876 Current Users Online!
Featured Authors
Linda DeWitt (1,997)
Edward Rhymes (7,667)
Brianna Popsickle (2,495)
Teresa Ortiz (10,864)
Julian Price (13,927)
Stephany Springer (41,578)
Abigail Richards (9,835)
E. Raymond Rock (3,120)
Terry Mitchell (5,410)
Mark Parsec (16,584)
Nenita Wells (1,718)
Ira Coffin (12,151)
Krystal Kuehn (1,183)
Michael Ramzy (705)

View All Featured Authors
Most Recent
Was Ares I-X designed by NASAs own CAD-system?

How To Decide A Niche For Your Membership Software?

How to Remove the Vocals from a Song

Jazz Up and Organize Your Inbox with Color Categories

Preventing Malware While Browsing The Internet

Should A Cad Come With The Operation System?

How To Setup An Email Out of Office Auto Reply In Mircosoft Outlook

How can I open a 2007 Microsoft Office file in an earlier version of Office?

What are the Key Requirements for Privacy Control Software?

Wny Do You Need Open Source Audits

Home » Categories » Computers & Networking » Software » Linux Commands Tutorials - Using the ls Command with Examples of Options - A Hands-On Tutorial Help » Printer Friendly

Clyde Boom

Linux Commands Tutorials - Using the ls Command with Examples of Options - A Hands-On Tutorial Help

Rated 4 out of 5
No Reader Ratings Available ?
Rate It  /  View Comments  /  View All Articles submitted by Clyde Boom
Submitted Wednesday, May 09, 2007
Clyde Boom (3,318)
Clyde Boom

Lancom Technologies
Log in to become a member of Clyde Boom's Fan Club!


This Linux command tutorial shows you several examples of how to run the Linux ls command using popular, commonly used command options.

All of the Linux command examples shown below have been designed to work with all Linux distributions (versions).

So, if you run all of the Linux commands shown below yourself, you'll have a mini Linux command tutorial.

Try it - it's a great way to get Linux training!

The Linux ls Command

The Linux ls (list) command is a very popular Linux command that is used to show a listing of directories and files.

Linux ls Command Tutorial - Showing Examples of Using ls Command Options

Run the cd (change directory) command below to change into the etc directory (folder) so we have lots of directories and files for the ls command examples below.

     ]$   cd  /etc

Run the ls command without any options.

     ]$   ls

This shows a listing of all directories and files (items) in the current directory, which is the etc directory. There are a lot of items and only the end of the listing appears. You can't see the top of the listing because it has scrolled off the screen.

So, we will use the | (vertical bar - above the Enter key on many keyboards) to "pipe" the output of the ls command to the less command - and then see some options of the ls command.

Linux Tips: To type the | (vertical bar) on most keyboards, hold down the shift key and press the \ (backslash) key.

Linux Tips: The less command is used to pause the output of a command after the first "screenful", so the output doesn't scroll off the screen. The less command is a Linux command, and not an option of the ls command.

     ]$   ls  |  less

Now, because you piped the output of the ls command to the less command, you can use the Up Arrow, Down Arrow and Page Up and Page Down keys to scroll through the output of the ls command.

Press the Down Arrow key a few times; then the Up Arrow key and then Page Up and Page Down. A nice way to view the files in the Linux file system!

Notice that just the item (directory and file) names appear. You don't see any other information, such as the size and date.

Press the letter "q" (without the quotes) to quit out of the less command. Do this after running each of the command examples below.

Now run the ls command with the -l (for long) option to get a "long" and more detailed listing of the items in the etc directory.

     ]$   ls  -l  |  less

Now you get lots more info on each item! The size (in bytes) of the item appears at the left of the date. When a "d" appears at the far left of an item, this indicates that the item is a directory (folder).

Try scrolling down and then scrolling up.

The ls command below uses both the -l and -S options. The -S option causes the items to be sorted by size, with the largest item at the top.

Linux Tips: Linux commands are case sensitive, so when you see an upper case "S", be sure to type in a capital "S" (without the quotes).

     ]$   ls  -lS  |  less

Press the Page Down key until you get to the bottom of the listing.

A Practical Linux ls Command Example - Listing Linux Text Configuration Files

Now let's say you need to look at some of the system configuration settings in a Linux text file. You know the file is in the current directory (etc) and that the file ends in ".conf", but you can't remember the full name of the file.

To see all possible file names, you use a Linux "pattern" of "*.conf" . This pattern uses the * (asterisk) wildcard character to show all files that end in ".conf".

     ]$   ls  -l  *.conf  |  less

Now you see the Linux text file you need and can check the settings in it.

Quit out of the less command.

The exit command is used to close a terminal emulation window and end a Linux bash shell "session".

     ]$   exit

Beyond This "Linux Commands Tutorials" Article

The Linux ls command is one of the most popular and commonly used Linux commands. There are lots of uses for the ls command and many other useful ls command options.

As part of your Linux training, you also need to learn how to use the ls command to: get a listing of "hidden" files, get a listing using an absolute path and relative path, get listings using several different "patterns" (with wildcard characters), and list directories and files recursively.

Now, imagine watching a clearly narrated Linux video tutorial that not only shows all of the examples above, but also shows you the full output of each command - you get to learn Linux live!

Then imagine pausing the Linux video after each example and trying the commands yourself - an excellent way to get Linux training!


Watch Free Sample I Learn Linux Video Tutorials now at http://www.iLearnLinux.com and get over the steep Linux learning curve.

Sign up for Free I Learn Linux News to receive technical tips, info on new video samples and important updates on Linux (swa).

Clyde Boom, Author and Expert Trainer with 20+ Years of Training Successes. Explains intricate technical matters in an easy-to-understand, non-technical manner, with tens of thousands of software and hardware learners into masters.






Reprint Rights

Log in to become a member of Clyde Boom's Fan Club!

Comments on this article:


» left by Anonymous (2 years 152 days ago.)
Reader Rating: 5 out of 5
very good
Respond to this comment

» left by prodip mallick from kolkata (2 years 136 days ago.)
Reader Rating: 4 out of 5
its very nice and usefull also,but not all commands are included
Respond to this comment

» left by Rukayat Ali from Nigeria (1 year 85 days ago.)
Reader Rating: 4.5 out of 5
This article really exceed my expectation. Clyde boom, thank you for sharing your knowledge.

Respond to this comment

» left by Arun.P from India (362 days 17 hours ago.)
Reader Rating: 4 out of 5
Thank You very much... For helping....

Respond to this comment

» left by Jeba from india (176 days 22 hours ago.)
Reader Rating: 3 out of 5
where are the commands?????????

Respond to this comment

Was this article helpful to you? Leave a Public Comment or Question:

This Article has been viewed 11,219 times.
Article added to SearchWarp.com on 5/9/2007 10:19:25 PM.
View other articles written by Clyde Boom (3,318)
Clyde Boom

Subscribe to 'I Learn Linux News'


If you found this article interesting, you may want to check out:

Disclaimer:  All information on this site is provided for informational purposes only! By no means is any information presented herein intended to substitute for the advice provided to you by any health care or other professional or organization.


Today's Most Popular
Introduction to DQL-Documentum Query Language

Linux Commands Tutorials - Using the ls Command with Examples of Options - A Hands-On Tutorial Help

Multiversion Concurrency Control (MVCC)- How PostgreSQL attain data consistency

Improve PC Performance - 6 Tips You Must Know.

Linux Command Tutorials - Opening a Linux Terminal / Console to Run Linux Commands - Tutorial Help

Explore the Earth from Home

Microsoft Outlook 2000 Tips – Easy Folder Maintenance

How to Save an Image in a SQL Server Database?

How To Export A Microsoft Access Report as a PDF

Microsoft Outlook 2000 Tips – I Can’t Send My Attachments!

Viewed from Cache. Load Time: 0.000.

Home  |  Page Two  |  FAQ's  |  Contact  |  Terms of Service  |  Article Submission Guidelines  |  Questions & Answers  |  Privacy  |  Mission / About
Copyright © 1999-2009 SearchWarp.com, All Rights Reserved - SearchWarp.com is an IcoLogic, Inc. Company