Linux with Operating System Concepts


partially) so that programmers can more easily contribute



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


partially) so that programmers can more easily contribute.
• Root—a special account in Linux for the system administrator(s).
• Shell—a user-tailored environment to permit easier usage of the OS. In a GUI, the 
user can tailor the desktop and menus. From the command line, the user can specify 
his or her own definitions for functions, aliases, variables, and more. In Linux, a shell 
includes an interpreter to handle commands entered in the shell.
• System administrator—a special type of user who is in charge of administering a 
computer system who has access to all system software and resources.
• Terminal window—in Linux, this opens a shell and provides the user with a com-
mand line prompt from which the user can enter commands.
• Unix—an older operating system which looks similar to Linux in many ways. 
Although the Linux kernel was not modeled on Unix itself, the interface (commands, 
directory structure) and much of the functionality is the same or similar.
• User account—the means by which a user is able to log in and access a computer. 
User accounts come with a username, a password, and user resources such as a home 
directory space.
• Virtual machine—using software to create the illusion of a separate computer. The 
VM allows us to run other computer platforms on a given computer for experimenta-
tion or safety.
REVIEW QUESTIONS
1. On what type(s) of devices can Linux run?
2. Do handheld devices running a Linux OS, such as Android, count toward Linux’ 
market share?
3. Rank these operating system platforms in order of most to least commonly used in 
today’s computing market: Linux, Windows, IBM System i, Mac OS.


Introduction to Linux

35
4. Define open source software.
5. How does Linux offer the user greater control over the Windows OS?
6. List two reasons why you might want to learn Linux.
7. All computers have and have always had operating systems. True or false. Explain.
8. What is a resident monitor?
9. What is an operating system kernel? At what point is the kernel loaded into memory? 
How long does it stay in memory?
10. Order the following layers of a computer system from top (user) to bottom (hard-
ware): OS kernel, device drivers, application software, OS services, shells, ROM BIOS, 
OS utilities.
11. In order to log into a Linux system, you must know your username and your _______.
12. A user’s account will often come with access to what resource(s)?
13. What is a login screen?
14. What is Gnome? What is KDE?
15. Both Gnome and KDE are based on what older GUI?
16. From the Gnome desktop, list two ways to open a terminal window.
17. From the Gnome desktop, which menu would you look under to open a window list-
ing your user home directory?
18. From the Gnome desktop, which menu would you look under to find commands to 
access system administration programs like the Linux firewall and adding users and 
groups?
19. What is a workspace?
20. What does the Linux interpreter do?
21. What are the components that make up a Linux shell?
22. What types of definitions can you place inside an interpreted environment in Linux?
23. Which interface, the GUI or command-line requires more memorization and skill to 
use?
24. Which interface, the GUI or command-line requires more system resources to use?
25. Provide three reasons for why a user might want to use the CLI rather than a GUI in 
Linux.
26. How does emulation differ from virtualization?
27. What is a VM?


36

Linux with Operating System Concepts
28. In what way could using a VM make your computer safer?
29. Provide three reasons (aside from what was asked in 28) for why you might want to 
create a VM.
30. What operating system looks similar to Linux?
31. What was the original name for the Unix operating system?
32. What is BSD Unix?
33. How did the development of Linux differ from that of Unix?
34. Which dialect of Linux does CentOS derive from?
35. Why do operating systems have (at least) two types of accounts, normal users and 
administrators?
36. As a user of a Linux computer system, what documentation do you feel a system 
administrator should produce for you, if any?
37. Why would an organization want separate network administrators from system 
administrators?
38. It is important for a system administrator to understand general computer concepts 
such as how the operating system functions, virtual memory, process management, 
computer networks, and so forth. Why do you suppose this is true?
39. Research the role of a computer security specialist and enumerate some of the duties 
involved.
40. What is the IPOS cycle?
41. Define a computer.
42. How does hardware differ from software?
43. What is the memory hierarchy? List these types of memories in order from the fastest 
to slowest: on-chip cache, DRAM, hard disk storage, off-chip cache, registers.
44. What are the components of a computer system?
45. Rank these computing devices in terms of speed from fastest to slowest: mainframe, 
server, smart phone, supercomputer, desktop computer.
46. What does the term PetaFLOPS mean? What type(s) of computer achieves this?
47. You can find Linux or Unix running on which of the following types of computers? 
Mainframe, server, smart phone, supercomputer, desktop computer.


37
C h a p t e r
2
The Bash Shell
T
his chapter’s learning objects are
• To understand the role of the shell in Linux
• To be able to enter commands via the command line prompt in Linux
• To understand what options and parameters are in Linux commands
• To be able to apply aliases, history, command-line editing, brace expansion, tilde 
expansion, and wildcards in Bash
• To be able to use variables from the command line prompt and understand the roles 
of the common environment variables
• To understand the Linux commands ls and man
• To be able to apply redirection in Linux commands
• To be able to tailor a shell using .bashrc, .bash_profile
2.1 INTRODUCTION
A shell is a user interface. Recall from Chapter 1, there are different types of user interfaces. 
In Linux, we use the graphical user interface (GUI) and the command line interface (CLI). 
The CLI is older, and in many users minds, better. See Figure 2.1 for reasons why a Linux 
user might want to use the command line rather than the graphical interface. Of course, 
there are disadvantages as well with ease of use and the learning curve to understand how 
to issue commands from the command line being the top two.
A shell runs an interpreter. The interpreter is a program which accepts user input and 
determines how to execute that input. The original Unix shell was the Bourne shell with 
a built-in Bourne interpreter. This shell was named after the program’s author, Stephen 
Bourne. The intention of a shell was to provide the user with a command-line interpreter 
(a program which would interpret commands and execute them), but to also provide the 
user with an environment to work in. Today, the Bourne shell is not used, but in its place 


38

Linux with Operating System Concepts
is the popular Bourne-again Shell, or BASH (or Bash). The Bash shell
*
is the default shell 
for most Linux users. There are other shells, and at the end of this chapter, we will compare 
Bash to a few of those.
The shell environment can be tailored. The idea is one of the user “filling in” the envi-
ronment through definitions of different kinds. The different types of definitions include 
short cuts to existing commands, defining new commands, defining variables, and entering 
commands. The power of a Linux shell goes beyond the ability to fill in your own pieces 
though. A shell also offers very powerful command-line editing features and a variety of 
typing short cuts.
In this chapter, we examine the Bash shell. To see how to use some of these features, we 
also introduce some of the more basic Linux commands. Topics include methods of obtain-
ing help, Bash-specific features, comparison to other shells, and details on how the Bash 
interpreter works. Although we introduce some basic Linux commands, keep in mind that 
we will continue to introduce Linux commands throughout the textbook. Those covered
in this chapter will include the ls command to view contents of the Linux file system, but 
we concentrate on the Linux file system in later chapters.
2.2 ENTERING LINUX COMMANDS
So you have logged into Linux and opened your first shell (see Section 2.4.2). You see a 
prompt awaiting your command. Perhaps it looks like this:
[foxr@localhost ~]$
*
Note that “Bash shell” is redundant because the “sh” portion of Bash means shell. However, most people will still refer 
to it as the Bash shell.
1. Control—the command line permits users to include options that provide both 
flexibility and power over the defaults when issuing commands by GUI.
2. Speed—many programs issued at the command line are text-based and 
therefore will start faster and run faster than GUI-based programs.
3. Resources—as with speed, a text-based program uses fewer system resources.
4. Remote access—if you are using a program like ssh to reach a computer, you 
may be limited to a text–based interface, so learning it is important and once 
learned, you gain the other benefits.
5. Reduced health risk—yes, this one sounds odd, but mouse usage is one of the 
most harmful aspects of using a computer as it strains numerous muscles 
in your hand and wrist, while typing is less of a strain (although poor hand 
placement can also damage your wrist).
FIGURE 2.1 
Advantages of the Command Line over a GUI.


The Bash Shell

39
The prompt is telling you who you are, where you are, who you are, and where you are. 
The first “who you are” is your user name (foxr in this case). The first “where you are” is the 
machine you are on. Localhost means that the shell you have opened is on 
this
computer. 
Had you logged in remotely to another computer, you would receive a different value. The 
second “where you are” is provided by the ~ (tilde) character. The ~ means “user’s home 
directory.” This tells you that your current working directory is ~, which for this user is 
probably /home/foxr. The second “who you are” is provided by the $. The $ represents your 
prompt. This will precede any input you type.
Generally in Linux, we see two types of prompts. The $ indicates that you are a normal 
user whereas a # would indicate that you have logged in to this shell as root (the system 
administrator).
So we see by the prompt several pieces of information. As you will probably know 
who you are and which machine you are on, the most useful piece of information in the 
prompt is the current working directory. We will discuss later how you can modify your 
prompt.
The Bash interpreter awaits your command. To use the interpreter, you enter a com-
mand and press the
<
enter
>
key. Whatever was typed is now interpreted.
You can also type multiple commands at the prompt. You would do this by separating 
each individual Linux command with the semicolon character. You press 
<
enter
>
at the 
end of the last command.
2.2.1 Simple Linux Commands
Although the prompt tells you a lot of information, there are several simple Linux com-
mands that can tell you who you are, where you are, and what can be found at your current 
location. These commands are:
• whoami—output the user’s username
• pwd—output the current working directory
• hostname—output the name of the host (this will either be localhost.localdomain or 
the IP address or IP alias of the machine logged in to)
• ls—list the contents of the current working directory
If you are following along in a Bash shell, try each of them. You will see that whoami, 
pwd, and hostname respond with information that you will find in your prompt. If 
you are logged in as root, whoami returns root. Note that if the user prompt tells you 
that you are currently at ~, pwd would still return the full directory path, /home/foxr 
in this case. Most users’ directories are typically found under the /home directory and 
their home directory name will be the same as their user name. This may not always be 
the case. For instance, you might find that /home has subdirectories to divide up the 
user space into groupings, so for instance pwd might return /home/a/foxr or /home/b/
zappaf.


40

Linux with Operating System Concepts
Some other useful, simple Linux commands are:
• passwd—used to change your password. You are first prompted to input your current 
password and then your new password (twice). If the password you enter is not suf-
ficiently strong, you are warned.
• uname—output basic information about your operating system.
• arch—output basic information about your computer’s hardware (architecture).
• who—list the users currently logged in to the computer you are operating on, includ-
ing their terminal (which terminal window they have opened or whether they are on 
console).
• bash—start a new Bash shell (if in a shell, this starts a new session so that the outer 
shell session is hidden). A variation is sh, to start a new shell. The sh program may not 
start a Bash shell however depending on which version of Linux you are using.
• exit—leave the current Bash shell and if this is the outermost Bash shell, close the 
window.
As stated earlier, you can enter multiple commands from the prompt by separating each 
with a semicolon. What follows is what you would expect to see in response to entering the 
three commands uname, arch and who individually and then combined. These responses 
would vary computer to computer and session to session based on who is logged in.
[foxr@localhost ~]$ uname
Linux
[foxr@localhost ~]$ arch
x86_64
[foxr@localhost ~]$ who
foxr
tty7
2013-10-11 09:42 (:0)
foxr
pts/0
2013-10-11 15:14 (:0)
[foxr@localhost ~]$ uname; arch; who
Linux
x86_64
foxr
tty7
2013-10-11 09:42 (:0)
foxr
pts/0
2013-10-11 15:14 (:0)
2.2.2 Commands with Options and Parameters
Most Linux commands expect arguments. Arguments come in two basic forms, options 
and parameters. Options are user-specified variations to the command so that the com-
mand performs differently. As a simple example, the ls command has numerous options 
that provide the user with different information than just a list of the entities in the current 
directory. One option is 
–l
(hyphen lower-case L). This provides a “long” listing of the enti-
ties. That is, it provides more details than just the name of each item.


The Bash Shell

41
Parameters are commonly either file names or directories (or both). A filename or direc-
tory name specifies to the command what entity to operate on. The format of a Linux com-
mand is
command [

Download 5,65 Mb.

Do'stlaringiz bilan baham:
1   ...   9   10   11   12   13   14   15   16   ...   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