Ku xooji hagaha Linux iyadoo la adeegsanayo qoraalka Shell

Waxa jira dhawr ikhtiyaar oo lagu kaydinayo xogtaada Linux . Waxaad isticmaali kartaa qaar ka mid ah barnaamijyada software-ka ee si xorta ah loo heli karo, sida fwbackups iyo Sbackup . Si kastaba ha ahaatee, waxaa jira hab fudud oo lagu taageerayo tusaha iyada oo aan la rakibin wax software dheeraad ah.

Waxaan samayn doonaa qoraalka qolofka annagoo adeegsanayna doorsoomayaasha, taliska daamurka(tar) iyo amarka taariikhda(date) si aan u abuurno faylka kaydka ah ee hagaha, oo wata hage-hoosaadyadiisa.

Qoraalka qolofku asal ahaan waa fayl ka kooban liis amarro kuwaas oo si isdaba joog ah loo wado. Haddii aad haysato amarro taxane ah oo aad si joogto ah u maamusho, way caawinaysaa inaad abuurto qoraal qolof ah oo ka kooban amarradan. Kadib, kaliya waa inaad socodsiisaa faylka qoraalka si aad u socodsiiso amarrada.

Abuuritaanka Faylka Qoraalka Shell

Tusaalahan, waxaanu samayn doonaa qoraal qolof ah si aanu u kaydiyo hagaha ka kooban faylal hagaha isticmaale. Waxaan u isticmaaleynaa deegaanka Gnome ee Ubuntu .

Marka hore, gal hagaha gurigaaga, adiga oo ka dooranaya Folderka Guriga(Home Folder) ee liiska Goobaha(Places) . Faylka Browser(File Browser) wuxuu u furmayaa hagaha gurigaaga.

Furitaanka galka guriga

Waxaan sameyneynaa fayl cusub oo maran kaas oo aan geli doono amarrada lagu fulinayo kaydinta. Midig ku dhufo(Right-click) shayga midig oo dooro Create Document | Empty File ee ka menu-ka soo booda.

Abuuritaanka faylka qoraalka qolofka maran

Fayl ayaa lagu daray liiska oo wuxuu diyaar u yahay in dib loo magacaabo. Ku qor(Type) magaca faylka, adoo siinaya faylka kordhinta .sh .

Fayl cusub oo diyaar u ah in dib loo magacaabo

Tusaalahan, waxaanu u magacownay faylkayaga user_guide_backups.sh(user_guide_backups.sh) .

Faylka qoraalka Shell ayaa dib loo magacaabay

Hadda waxaan u baahanahay inaan amarrada ku darno faylka. Midig ku dhufo magaca faylka oo dooro Open with gedit menu pop-up ka.

Furitaanka faylka qoraalka qolofka leh gedit

Faylku wuxuu ku furmay gedit . Geli khadadka soo socda faylka oo guji Save . Ujeedada sadar kasta ayaa hoos ku taxan.

FIIRO GAAR AH:(NOTE:) Waxaad sidoo kale koobi kartaa qoraalka soo socda oo aad ku dhejin kartaa gedit . Hubi inaad u badasho <username> magacaaga isticmaale.

#!/bin/bash
 SRCDIR="/home/<username>/Documents/my_work/"
 DESTDIR="/home/<username>/Backups/"
 FILENAME=ug-$(date +%-Y%-m%-d)-$(date +%-T).tgz
 tar – create – gzip – file=$DESTDIR$FILENAME $SRCDIR

Tafatirka faylka qoraalka qolofka ee gedit

Sharaxaada khadka-line

Jadwalka soo socdaa waxa uu qeexayaa waxa xariiq kastaa ku jiro faylka qoraalka qolofka.

Line # Description
1 This line must be the first line in a bash shell script, which is the default type of script.
2 This line sets up a variable called SRCDIR and sets the value of it to the directory to be backed up.
NOTE: Be sure to replace <username> with your username.
3 This line sets up a variable called DESTDIR and sets the value of it to the directory into which the backup file will be written.
NOTE: Be sure to replace <username> with your username.
4 This line sets up a variable called FILENAME and sets the value using text and variables containing the date command to add the current date and time to the filename. For example, the filename might be ug-20100212-13:03:45.tgz.
NOTE: When using a variable, always start it with the dollar sign ($). If you use a command as part of a variable, enclose the command and the options for the command in parentheses.
5 This line is the tar command with the following function and options added.

–create This function creates a new archive (or truncates an old one if the filename specified already exists) and writes the named files or directory to it.
–gzip This option tells tar to compress the files in the archive using the gzip utility.
–file This option gives tar the filename to use. In this case, we assembled the filename using the DESTDIR, FILENAME, and SRCDIR variables.

Tafatirka Ogolaanshaha(Permissions) Faylka Qoraalka Shell(Shell Script File)

Kahor intaadan socodsiin qoraalkaaga, waxaad u baahan tahay inaad hubiso in faylka uu haysto ogolaanshaha saxda ah. Si aad tan u samayso, fur galka gurigaaga sida(Home Folder) kor ku xusan oo midig-guji faylka qoraalka qolofka. Ka dooro Properties menu pop-up ka.

Helitaanka sifooyinka faylka qoraalka qolofka

Sanduuqa wada hadalka Properties ayaa soo bandhigaya. Hubi(Make) in sanduuqa(Execute) calaamadaynta la doortay.

Oggolaanshaha faylka qoraalka Shell

Guji Xir(Close) _

Ku socodsiinta qoraalka Shell

Si aad u socodsiiso qoraalka qolofka, fur daaqad terminal ah adiga oo dooranaya Accessories | Terminal ka yimid liiska Codsiyada(Applications) .

Furitaanka daaqadda Terminalka

Marka uu daaqadda Terminalku(Terminal) furmo, waa in aad ku jirtaa galka Gurigaaga(Home Folder) si caadi ah. Ku qorida pwd(pwd) khadka taliska oo aad riixdo geli waxay xaqiijinaysaa xaqiiqadan. Isla markiiba, ku qor ./user_guide_backups.sh oo tabo Gelida(Enter) .

Ku socodsiinta qoraalka qolofka

Waa inaad ku haysaa faylka .tgz galka Backups ee ku jira Foltarka Gurigaaga(Home Folder) . Haddii aad midig-gujiso magaca faylka, waxaad arkaysaa dhawr fursadood oo aad ku furto kaydka mid ka mid ah barnaamijyada kaydinta ee jira, ama aad si toos ah ugu soosaarto faylalka galka Backups adigoo isticmaalaya amarka Soosaar Halkan(Extract Here ) .

Ikhtiyaarada menu-ka-soo-baxa ee faylka .tgz

Macluumaad dheeraad ah

Xidhiidhada hoose ayaa bixiya macluumaad dheeraad ah oo ku saabsan qoraalada qolofka, amarrada daamurka(tar) iyo taariikhda(date) , iyo amarada Linux kale .

Qorista

Hage degdeg ah oo lagu qoro qoraallada la isticmaalayo qolofka bash(A quick guide to writing scripts using the bash shell)

Bash Shell Scripting – 10 Seconds Guide | All about Linux

Buugga Tixraaca Bash(Bash Reference Manual)

Amarada Linux

daamur MAN Page(tar MAN Page)

taariikhda MAN Page(date MAN Page)

amarrada bash - Linux MAN Pages(bash commands – Linux MAN Pages)

Sahaminta boggagan waxay kaa caawin doontaa inaad dhisto qoraaladaada bash shell ee waxtarka leh.



About the author

Waxaan ahay khabiir kombuyuutar, waxaanan ku takhasusay aaladaha iOS. Waxaan dadka caawinayay tan iyo 2009, waayo-aragnimadayda wax-soo-saarka Apple ayaa iga dhigaysa qofka ugu habboon ee ka caawinaya baahiyahooda tignoolajiyada. Xirfadeyda waxaa ka mid ah: - Dayactirka iyo cusboonaysiinta iPhones iyo iPod-yada -Rakida iyo isticmaalka software Apple - Ka caawinta dadka inay helaan apps-ka ugu fiican ee iPhones iyo iPod-yada - Ka shaqaynta mashaariicda onlaynka ah



Related posts