Linux with Operating System Concepts



Download 5,65 Mb.
Pdf ko'rish
bet14/254
Sana22.07.2022
Hajmi5,65 Mb.
#840170
1   ...   10   11   12   13   14   15   16   17   ...   254
Bog'liq
Linux-with-Operating-System-Concepts-Fox-Richard-CRC-Press-2014

option(s)
] [
parameter(s)
]
where the [] indicate that the item is optional.
For instance, if you wish to see the long listing of a single file called file1.txt you would 
issue the command
ls –l file1.txt
Many Linux commands permit 
any number
of parameters. The above instruction could 
just as easily have operated on several files. This would be the case if the command were
ls –l file1.txt file2.txt file3.txt file4.txt
We will explore an easier way to specify a list of files later in this chapter by using 
wildcards.
Through options, you are able to take greater control of Linux. In fact, it is through 
options that you will find the real power behind the command line. One of the problems 
with using options is remembering them. Fortunately, we can view all of the options of 
a command easily through the command’s man page (discussed later) or by issuing the 
command followed by the option --
help
(not all Linux commands have this option but 
many do).
Let us explore the ls command in more detail. The ls command lists the current direc-
tory’s contents. Typing ls will display for you the 
visible
files and subdirectories in the cur-
rent directory. The term visible indicates entries whose names do not start with a period (.). 
For instance, file1.txt is a visible file while .file1 is not visible. To view all entries through ls
the option 
–a
is used. This option specifies that ls should “list all” entries. The –a option 
will not only list the hidden, or dot, files (those that start with a dot), it will also list . and .. 
which are the current directory and the parent directory, respectively. We explore . and .. 
in more detail in the next chapter.
As already mentioned, the option 
–l
(a lower case “L”) provides a 
long
listing. The long 
listing provides several properties of each item:
• The type of object (file, directory, symbolic link, etc. where a hyphen means a regular 
file)
• The permissions of the object (who can read, write, and execute it, which appear 
using r, w, and x, with a hyphen indicating no permission, we examine permissions 
in detail in Chapter 3)
• The number of names linked to the object


42

Linux with Operating System Concepts
• The user owner and group owner of the object
• The size of the object
• The last modification (or creation) date and time of the object
• The name of the object (and if a symbolic link, the item it is linked to)
Figure 2.2 shows an example of an 
ls –l
operation applied to a portion of a user’s 
home space.
An instruction can receive any combination of options. If you wish to provide a long 
listing of all files, you would use 
ls –al
(or 
ls –la
). You could separate these to be 
ls 
–a –l
or 
ls –l –a
but it is more common to combine all options as desired to save 
typing.
You might notice the period that appears after the first series of characters (the hyphens, 
r and w entries). The period indicates that the given item (file, directory) has an SELinux 
context. SELinux is security-enhanced Linux and provides a greater degree of protection 
over those available through ordinary Linux permissions. We cover Linux permissions in 
Chapter 3 and briefly overview SELinux in Chapter 8.
While ls has a number of options, there are only a few options that you would typically 
use. Table 2.1 describes these (omitting 
–a
and 
–l
from earlier).
As mentioned at the beginning of this section, commands receive options and param-
eters. For ls, the parameters are a listing of files and directories. These names are the enti-
ties that are listed. If no such argument(s) is provided, the ls command lists all entries in 
the current directory. If parameters are provided, they can consist of one or several files 
and/or directories.
Consider the following instruction:
ls file.txt
FIGURE 2.2 
A long listing.


The Bash Shell

43
If this file exists, the ls command responds by listing it. Otherwise, ls returns the response
ls: file.txt: No such file or directory
This instruction is not a very informative instruction as it only tells you if the file exists 
or not.
A user more commonly will want to see what is in the directory. Therefore, there seems 
little value to supply such an argument. However, when used with options such as 
–l
, it 
becomes far more meaningful. For instance, when issuing 
ls –l file.txt
, we might see
-rwxr--r--. 1 
foxr foxr 183 
Jul 23 2011 file.txt
If we use ls in conjunction with a directory name, then the command displays all of the 
contents of the given directory (rather than the current working directory). We can use 
wildcards to indicate possible variations in name. The * wildcard is used to match any-
thing. Thus, 
ls *.txt
will list all files in the current working directory whose names end 
with .txt no matter what appears on the left-hand side of the period. We explore wildcards 
in Chapter 3.
2.3 MAN PAGES
How do you learn about the options available for a command? Another command avail-
able in Linux is called 
man
, which is short for manual page. This command displays the 
manual contents for a given Linux command. These contents explain the intention of the 
TABLE 2.1 
Common ls Options

Download 5,65 Mb.

Do'stlaringiz bilan baham:
1   ...   10   11   12   13   14   15   16   17   ...   254




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish