![]() |
![]() |
![]() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
![]() |
![]() |
To access the contents, click the chapter and section titles.
Complete Idiot's Guide to Linux
Listing FilesThe next thing youll want to do is list the files found in your current directory. This is done with the help of the ls command, which stands for list: [alberto@digital alberto]$ ls Desktop images linkToImages test.txt Mail kde nsmail test.txt∼ html lg test.rc todo.txt As you can see, the plain invocation of ls doesnt provide much distinction between directories (folders) and files. To tell ls to provide you with more information about the files it finds, you need to specify the -F flag. This option makes ls append a character to the filenames that indicates what it is. The file type indicators are
[alberto@digital alberto]$ ls -F Desktop/ images/ linkToImages@ test.txt Mail/ kde/ nsmail/ test.txt∼ html/ lg/ test.rc todo.txt Now you can tell the basic types apart. ls offers many more options. The more useful are listed in the following table.
You can combine multiple flags together, as in ls -Flai. This is the same as saying: ls -F -l -a i, except that you save a few keystrokes. Heres what that option would list: [alberto@digital alberto]$ ls -Flai total 9 157289 drwxrwxr-x 9 alberto alberto 1024 Sep 1 10:25 ./ 169675 drwxrwxr-x 16 alberto alberto 1024 Sep 1 10:24 ../ 157290 drwxrwxr-x 2 alberto alberto 1024 Sep 1 10:24 Desktop/ 157291 drwxrwxr-x 2 alberto alberto 1024 Sep 1 10:24 Mail/ 157292 drwxrwxr-x 2 alberto alberto 1024 Sep 1 10:24 html/ 157293 drwxrwxr-x 2 alberto alberto 1024 Sep 1 10:24 images/ 157294 drwxrwxr-x 2 alberto alberto 1024 Sep 1 10:24 kde/ 157295 drwxrwxr-x 2 alberto alberto 1024 Sep 1 10:24 lg/ 157296 lrwxrwxrwx 1 alberto alberto 6 Sep 1 10:24 linkToImages -> images/ 157297 drwxrwxr-x 2 alberto alberto 1024 Sep 1 10:24 nsmail/ 157298 -rw-rw-r-- 1 alberto alberto 0 Sep 1 10:25 test.rc 157299 -rw-rw-r-- 1 alberto alberto 0 Sep 1 10:25 test.txt 157300 -rw-rw-r-- 1 alberto alberto 0 Sep 1 10:25 test.txt∼ 157301 -rw-rw-r-- 1 alberto alberto 0 Sep 1 10:25 todo.txt This listing has a lot of information that Ill cover in bits and pieces throughout this and other chapters. For sake of being complete, the items listed in the listing are as follows (from left to right):
Listing Directories RemotelyYou dont need to go to a directory in order to list it. If you provide a pathname to a file or a directory to ls, ls will list the file or directory requested: [alberto@digital alberto]$ ls /opt bin/ kde/ man/ netscape/ [alberto@digital alberto]$ pwd /home/alberto ls in TechnicolorThe version of ls shipped with Linux has the capability to display different file types in different colors. This capability is very useful, as it makes it easy to discern among files, directories, and programs. To enable this behavior, you can type ls --color, and things will happen. The colors for the most popular file types are listed in the following table.
Pretty nifty, eh? Its so nice you might like to have the file types appear in color all the time. Fortunately, you can. Read on to learn how to change the default options of certain shell commands.
|
![]() |
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement. |