Linux Command Line and Shell Scripting Bible. Christine Bresnahan

Читать онлайн книгу.

Linux Command Line and Shell Scripting Bible - Christine Bresnahan


Скачать книгу
be somewhat misleading. It shows the files and directories contained in the current directory, but not necessarily all of them. Linux often uses hidden files to store configuration information. In Linux, hidden files are files with filenames starting with a period (.). These files don't appear in the default ls listing. Thus, they are called hidden files.

      To display hidden files along with normal files and directories, use the – a parameter. Here is an example of using the – a parameter with the ls command.

      All the files beginning with a period, hidden files, are now shown. Notice that three files begin with .bash. These are hidden files that are used by the bash shell environment. These features are covered in detail in Chapter 6.

      The – R parameter is another option the ls command can use. Called the recursive option, it shows files that are contained within subdirectories in the current directory. If you have lots of subdirectories, this can be quite a long listing. Here's a simple example of what the – R parameter produces. The – F option was tacked on to help you see the file types:

      Notice that the – R parameter shows the contents of the current directory, which are the files from a user's home directory shown in earlier examples. It also shows each subdirectory in the user's home directory and their contents. The only subdirectory containing a file is the Music subdirectory, and it contains the executable file, ILoveLinux.mp3.

      Tip

      Option parameters don't have to be entered separately as shown in the nearby example: ls – F – R. They can often be combined as follows: ls – FR.

      In the previous example, there were no subdirectories within subdirectories. If there had been further subdirectories, the – R parameter would have continued to traverse those as well. As you can see, for large directory structures, this can become quite a large output listing.

Displaying a long listing

      In the basic listings, the ls command doesn't produce much information about each file. For listing additional information, another popular parameter is – l. The – l parameter produces a long listing format, providing more information about each file in the directory:

      The long listing format lists each file and subdirectory on a single line. In addition to the filename, the listing shows additional useful information. The first line in the output shows the total number of blocks contained within the directory. After that, each line contains the following information about each file (or directory):

      ● The file type – such as directory (d), file (-), linked file (l), character device (c), or block device (b)

      ● The file permissions (see Chapter 6)

      ● The number of file hard links (See the section “Linking Files” in Chapter 7.)

      ● The file owner username

      ● The file primary group name

      ● The file byte size

      ● The last time the file was modified

      ● The filename or directory name

      The – l parameter is a powerful tool to have. Armed with this parameter, you can see most of the information you need for any file or directory.

      The ls command has lots of parameters that can come in handy as you do file management. If you type at the shell prompt man ls, you see several pages of available parameters for you to use to modify the ls command output.

      Don't forget that you can also combine many of the parameters. You can often find a parameter combination that not only displays the desired output, but also is easy to remember, such as ls – alF.

      Конец ознакомительного фрагмента.

      Текст предоставлен ООО «ЛитРес».

      Прочитайте эту книгу целиком, купив полную легальную версию на ЛитРес.

      Безопасно оплатить книгу можно банковской картой Visa, MasterCard, Maestro, со счета мобильного телефона, с платежного терминала, в салоне МТС или Связной, через PayPal, WebMoney, Яндекс.Деньги, QIWI Кошелек, бонусными картами или другим удобным Вам способом.

iVBORw0KGgoAAAANSUhEUgAAAjYAAAG8CAIAAABCF3hBAAAABGdBTUEAALGOfPtRkwAAACBjSFJNAACHDwAAjA8AAP1SAACBQAAAfXkAAOmLAAA85QAAGcxzPIV3AAAKL2lDQ1BJQ0MgUHJvZmlsZQAASMedlndUVNcWh8+9d3qhzTACUobeu8AA0nuTXkVhmBlgKAMOMzSxIaICEUVEmiJIUMSA0VAkVkSxEBRUsAckCCgxGEVULG9G1ouurLz38vL746xv7bP3ufvsvc9aFwCSpy+XlwZLAZDKE/CDPJzpEZFRdOwAgAEeYIApAExWRrpfsHsIEMnLzYWeIXICXwQB8HpYvAJw09AzgE4H/5+kWel8geiYABGbszkZLBEXiDglS5Auts+KmBqXLGYYJWa+KEERy4k5YZENPvsssqOY2ak8tojFOaezU9li7hXxtkwhR8SIr4gLM7mcLBHfErFGijCVK+I34thU

Скачать книгу