Linux Commands Examples - Running the Linux ls Command with Directory Names As Command Examples
Running the Linux ls Command with Directory Names As Examples of Running the Linux ls Command
As described in a previous "Linux Commands Training Examples" blog post, the Linux ls command shows (lists) the files and folders in a directory.
Linux ls Command Examples with Directory Names - The / (root) Directory and Directories Off of the root
Now we're going to do examples of running the ls command with various directory names - such as the root directory, represented by a / (slash) and also run the ls command with the names of directories "off of the root" directory (a.k.a. "below the root" directory).
Type in the Linux command examples below, as shown at the right of the Linux command line prompt
(the $ symbol shown below). You may see a different prompt, such as a # (pound or number symbol).
Be sure not to type in the prompt (the $ dollar sign) or any other prompt when you run the Linux command examples you see below.
Also, Linux commands are "case sensitive". Always type lower case letters when shown and upper case letters when shown.
For each Linux command example, be sure to press the Enter key after typing in the Linux commands.
Linux Commands Training Tips: When type in a command at the Linux command line prompt and then press Enter, you are "running" a Linux command.
Running the Linux ls Command - Linux ls Command Examples with Directory Names
The first Linux command example below shows running the ls command with the -l option (the -l is for long list) to show the files and folders off of the / (root) directory.
Remember: The -l option (uses an l pronounced "el") and not the number 1 (one).
Don't type in the $ prompt when you run the command below.
$ ls -l /
After you run a command, you see the "output" of the command on the screen.
In the above Linux command example, the ls command is being run "on" the / (root) directory to show the contents (directories and files) in the / directory.
The root directory of a Linux system is represented by a / (forward slash). The / directory contains all the directories and files on a Linux system. And there are many directories off of the root that have the same names on all versions (distributions) of Linux.
The output of the above command shows that the / (root) directory contains several directories that are "off of" or "below" the / (root), and some of these are: sbin, tmp, usr, and var. The directory names (sbin, tmp, usr, and var - and others) are some of the names that are common to all Linux versions.
The output and directory names you see may be different from what is described here, but they are likely to be the same, depending on the Linux version (distribution, distro) that you are using.
Linux Commands Training Tips: In the Windows world, directories are called "folders". And directories are the same as folders. They are used to contain files and other directories.
For example, the directory (folder) named usr is below the / (root) and contains other directories (folders).
Now run the ls command to list the contents of the usr directory, below the / directory.
$ ls -l /usr
The "/usr" above is the "path" to the directory. The "path" to the usr directory is: the / (root) and then the usr directory, which is "off of" the root directory. The full path to the usr directory is /usr (slash usr).
The output of the above command shows a directory named sbin, that is "in" (or "below") the usr directory, which is below the / directory. The full path to the sbin directory is: /usr/sbin
Now get a listing of the contents of the sbin directory, which is below the usr directory, which is "off of" or "below" the / directory.
The path in the Linux command below is: / (slash, for the root directory, then the usr directory, and then the sbin directory - the slash between usr and sbin is used to separate the two directory names.
$ ls -l /usr/sbin
The output of the above command shows the contents (directories and files) in the sbin directory.
Linux Command Examples Training Tips: You've just seen the "text" version of how to run some Linux commands with examples. Imagine how much easier it would be to also watch these steps and then do them yourself!
With the "Linux Admin & Commands Training Videos" CD, you can watch every step of hundreds of Linux command examples as they are shown to you and carefully narrated in detail.
For example, these Linux training videos show using the Linux ls command with lots more examples than the few shown above. And you can watch and hear how to user them very quickly and then try them yourself!
Or - You can order the "Linux Admin & Commands Training Videos" below.
Learn how to use Linux in General - Featuring Ubuntu Linux - NOW - Click Here to Order Now
Click Here to Watch Free Sample General Linux Training Videos - Featuring Ubuntu Linux
Learn Linux Commands Now with Linux Commands Videos - Click Here to Order
Click Here to Watch Free Sample Linux Commands Training Videos
Get Updates to this Linux Training Blog. FREE! |
| Privacy Notice: We will not distribute your email address to anyone. Period! |
What do you need to learn about using Linux?
Do you need to know how to run Linux Commands to do Linux System Administration?
Do you need to learn how to use LInux - Featuring Ubuntu Linux, including working at the Linux desktop, using Linux menus and icons?
How about learning how to install the Linux OS on an existing Windows system - or a new computer system - or running Linux from a "Live" CD?
Do you need to know how to run Linux software programs - change between Linux software programs - work in Linux software program windows?
Or do you need to learn how to use Linux training videos and Linux video tutorials to get real practical hands-on Linux Training?
You can find out more about using Linux - and find out what YOU need to know by clicking on "Comment" below asking your "burning Linux training question" - or you could give us make a suggestion - or just post a comment to let us know what you think!
Thanks for visiting this "Linux Commands Book Blog"!
Clyde Boom, http://www.iLearnLinux.com





Leave a Comment