3 - Weber State University
3 - Weber State University
3 - Weber State University
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
94 Chapter 3 Exploring Linux Filesystems<br />
[root@server1 ~]# pwd<br />
/root<br />
[root@server1 ~]# ls /home/bob<br />
assignment1 file1 letter letter2 project1<br />
[root@server1 ~]#_<br />
When running the ls command, notice that files of different types<br />
are often represented as different colors. However, the specific colors<br />
used to represent files of certain types might vary from terminal to<br />
terminal and distribution to distribution. As a result, do not assume<br />
color alone indicates the file type.<br />
Windows uses the dir command to list files and directories. To simplify<br />
the learning of Linux for Windows users, there is a dir command in<br />
Linux, which is simply a pointer or shortcut to the ls command.<br />
Recall from the previous chapter that you can use switches to alter the behavior of commands.<br />
To view a list of files and their types, use the –F switch to the ls command:<br />
[root@server1 ~]# pwd<br />
/root<br />
[root@server1 ~]# ls -F<br />
current@ myprogram* project project12 project2 project4<br />
Desktop/ myscript* project1 project13 project3 project5<br />
[root@server1 ~]#_<br />
The ls –F command appends a special character at the end of each filename displayed to<br />
indicate the type of file. In the preceding output, note that the filenames current, Desktop,<br />
myprogram, and myscript have special characters appended to their names. The @ symbol<br />
indicates a linked file, the * symbol indicates an executable file, the / indicates a subdirectory,<br />
the ¼ character indicates a socket, and the | character indicates a named pipe. All other file<br />
types do not have a special character appended to them and could be text files, binary data<br />
files, or special device files.<br />
It is common convention to name directories starting with an uppercase<br />
letter, such as the D in the Desktop directory shown in the<br />
preceding output. This ensures that directories are listed at the<br />
beginning of the ls command output and allows you to quickly<br />
determine which names refer to directories when running the ls<br />
command without any options that specify file type.<br />
Although the ls –F command is a quick way of getting file type information in an<br />
easy-to-read format, at times you need to obtain more detailed information about each<br />
file. The ls –l command can be used to provide a long listing for each file in a certain<br />
directory.<br />
[root@server1 ~]# pwd<br />
/root<br />
[root@server1 ~]# ls -l<br />
total 548<br />
© Cengage Learning. All rights reserved. No distribution allowed without express authorization.