Birmingham mumbai



Download 15,21 Mb.
Pdf ko'rish
bet203/482
Sana13.01.2022
Hajmi15,21 Mb.
#355107
1   ...   199   200   201   202   203   204   205   206   ...   482
Bog'liq
Mastering Ubuntu Server Gain expertise in the art of deploying, configuring, managing, and troubleshooting Ubuntu Server by Jay LaCroix (z-lib.org)

[
 150 
]
Automation is a subject we'll explore multiple times throughout the remainder of the 
book, which will include more advanced subjects such as configuration management. 
Writing scripts is the simplest form of automation, which gives you the ability to type 
commands in a text file and have them all execute. That's what we'll explore next.
Writing simple scripts
This is the section where everything we've talked about so far starts to come 
together. Scripting can be very fun and rewarding, as they allow you to automate 
large jobs or just simplify something that you find yourself doing over and over. The 
most important point about scripting is this: if it's something you'll be doing more 
than once, you really should be making it into a script. This is a great habit to get 
into.
A script is a very simple concept; it's a just a text file that contains commands for 
your shell to execute one by one. A script written to be executed by Bash is known as 
a Bash script, and that's what we'll work on creating in this section.
At this point, I'm assuming that you've practiced a bit with a text editor in Linux. It 
doesn't matter if you use Vim or Nano. Since we've edited text files before (we went 
over that in 
Chapter 5

Managing Files and Directories
), I'm under the assumption that 
you already know how to create and edit files. We'll be using a text editor to create a 
simple script as an example, using the following command:
nano ~/myscript.sh
Inside the file, type the following:
#!/bin/bash
echo "My name is $USER"
echo "My home directory is $HOME"
echo "My default text editor is $EDITOR"
If you weren't already aware, a tilde (
~
) is just a shortcut for a 
user's home directory. Therefore, on my system, the previous 
command would be the same as if I had typed:
nano /home/jay/myscript.sh


Chapter 6

Download 15,21 Mb.

Do'stlaringiz bilan baham:
1   ...   199   200   201   202   203   204   205   206   ...   482




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