Blog literacki, portal erotyczny - seks i humor nie z tej ziemi
Keyword
Title
Author
ISBN
Publisher
Imprint
Brief
Full
Please Select
-----------
Components
Content Mgt
Certification
Databases
Enterprise Mgt
Fun/Games
Groupware
Hardware
IBM Redbooks
Intranet Dev
Middleware
Multimedia
Networks
OS
Prod Apps
Programming
Security
UI
Web Services
Webmaster
Y2K
-----------
New Titles
-----------
Free Archive
To access the contents, click the chapter and section titles.
Complete Idiot's Guide to Linux
(Publisher: Macmillan Computer Publishing)
Author(s): Manuel Ricart
ISBN: 078971826x
Publication Date: 12/22/98
Search this book:
Previous
Table of Contents
Next
Listing Files
The 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
* for programs or executable scripts
/ for directories
@ for symbolic links
| for pipes
= for sockets
nothing for regular files
[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.
Useful ls Options
Option
Action
-F
Mark files with characters designating their type
-l
Display long listings
-a
List all files including any hidden files
-s
Print the size of files
-t
Sort listing by file time, with new files first
-R
List files recursively including contents of other directories
-i
List file inode
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):
The inode of the file
The permissions for the file
The number of hard links to the file
The owner of the file
The group owning the file
The size of the file
The last modification date for the file
The name of the file
Techno Talk: Links, Sockets, and Inodes???
Whats this link stuff? A symbolic link (also called an alias or shortcut in other OSs) is a file that points to another file, and is a commonly used tool. A hard link rarely created by the user, is a filename that points to a block of data that has several other filenames as well.
Whats this pipe and socket stuff? Pipes and sockets are special files that programs create to communicate with one another. They are rarely seen, but you might be able to see a socket or two in the /dev directory.
Whats this inode stuff? An inode is the address of a disk block. When you ask to see inode information through ls, ls prints the address of the first block in the file. You can use this information to tell if two files are really the same file with different names. Well talk a little more about this when we talk about links.
Listing Directories Remotely
You 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 Technicolor
The 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.
Typical File Colors (ls --color)
File Type
Color
Regular Files
White
Programs
Green
Directories
Blue
Links
Aqua
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.
Previous
Table of Contents
Next
| | | | |
Use of this site is subject to certain ,
All rights reserved. Reproduction whole or in part in any form or medium without express written of EarthWeb is prohibited.