Posts Tagged ‘Linux ls command’

Red Hat Linux Commands – How to Understand Linux Directory and File Listings 

Interpreting Linux Directory and File Listings – From the Output of the Linux ls Command

In this linux tutorial we will learn how to running the Linux ls command at the Linux command line prompt shows a listing of directories and files.

The following is an example of a listing at the shell prompt of a directory named bin:

  • drwxr-x— 22 root root 4096 May 22 16:14 bin

The name of the directory (bin) appears at the far right.

At the left of this name is the time (16:14). If the directory were not created this year, the year would appear in place of the time. Next at the left is the date (May 22). At the left is the size of the directory, which is 4,096 bytes (4 K).

At the far left is a “d” and this indicates that the item is a directory.

The other items shown above, such as “rwxr-x— 22 root root”, are permissions.

The following is a Linux ls command output example of a file named grep.1.gz:

  • -rw-r–r– 1 root root 5907 Jul 17 2007 grep.1.gzThe name of the file appears at the far right (grep.1.gz).

At the left of the name is the date that the file was created (July 17, 2007). At the left of that is the size of the file, which is 5,907 bytes (approximately 5.9 K).

At the far left is a “-“. This indicates that the item is a file.

The above file was created in 2,007. If the file was created this year, then the time that the file was created, in the form of hh:mm, would appear in place of the year.

When you run ls command and use the -l option, you see a series of characters at the left of each item in the directory listing. The table below shows the meaning of the far left character in a directory listing.

The Leftmost Characters in a Listing from the Output of the Linux ls Command

When using the -l option of the ls command, the - (dash) for file and the d for directory appear most often in the list that is output when the ls command is run.

Remember that directory names have a “d” at the far left of them and files have a “-“.

The Linux concepts shown above apply to Slackware, Red Hat, Ubuntu, Fedora, and Debian Linux – and also ALL Linux distributions.

By the way…do you want to learn exactly how to use Linux and run Linux commands for Linux System Administration and get real, practical Linux training experience by running hundreds of examples of Linux commands? Stay tuned as more linux commands training tips will coming. speak soon.

Other related articles:

Technorati Tags: , , ,

Linux Mount: Quickie

SUSE Linux distributions
Image via Wikipedia

The Linux mount command is used to mount a filesystem by assigning a mount point (such as a directory below the /mnt directory) to a hard disk partition or other disk device, such as a CD-ROM drive.

After the partition or device has been mounted, it can be accessed by application Linux software programs, utilities and commands.

Example of Using the Linux mount Command

For example, the following command:

$ mount /dev/cdrom /mnt/cdrom causes the device file named cdrom in the /dev directory to be mounted “onto” the cdrom directory below /mnt.

The cdrom directory becomes the “mount point” for the CD and this allows you to access the filesystem of the CD.

The files in the / (root) directory of the CD become accessible below the full path of /mnt/cdrom.

Listing the Contents of the Linux /dev System Directory Below The / (Root) Directory

Many of the important Linux system directories, such as the /dev directory, are located directly below the / (root) directory.

Now look at the contents of the /dev directory and find out what Linux uses it for.

Examples of Using the Linux ls Command to the List System Directories and the /dev Directory

The following command lists the contents of the / directory – from any directory. The “-l” option of the ls command is not required here.

$ ls / Notice the dev directory, which is below the / (root) directory in the full path of /dev.

Viewing the Contents (Directories and Files) in the /dev Directory Path

Now run the following command to see the contents of the /dev directory, without having to change directory.

$ ls /dev Example of Using the Linux nl Command To Number Lines of Output

The Linux nl (number line) command can be used to count and display the number of lines in a file or the output of a command.

In the folloinwg example, the output of the ls command is “piped” (with the vertical bar symbol) to the nl command to display a count of the output of the command.

$ ls -l /dev | nl This shows the device driver files for many different types of Linux hardware devices that are located in /dev and a count of the number of them.

Linux Commands Training Tips: On more current Linux systems, the mount command may not be required and your devices may automatically mount below the /media directory. For example, if you put a CD in your drive and it automatically appears on your Linux desktop, you do not need to use the mount command to do the steps in the command example above. The Linux ls command and dev system directory concepts covered here apply to ALL Linux distributions and versions, including Ubuntu, openSUSE, Debian, SUSE, Fedora, Slackware and Red Hat Linux.

By the way…do you want to learn exactly how to use Linux and run Linux commands for Linux System Administration and get real, practical Linux training experience by running hundreds of examples of Linux commands? Stay tune as I add more about Linux.

Other related articles:

Enhanced by Zemanta

Technorati Tags: , , , ,