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.
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.
Fayl ayaa lagu daray liiska oo wuxuu diyaar u yahay in dib loo magacaabo. Ku qor(Type) magaca faylka, adoo siinaya faylka kordhinta .sh .
Tusaalahan, waxaanu u magacownay faylkayaga user_guide_backups.sh(user_guide_backups.sh) .
Hadda waxaan u baahanahay inaan amarrada ku darno faylka. Midig ku dhufo magaca faylka oo dooro Open with gedit menu pop-up ka.
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
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.
|
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.
Sanduuqa wada hadalka Properties ayaa soo bandhigaya. Hubi(Make) in sanduuqa(Execute) calaamadaynta la doortay.
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) .
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) .
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 ) .
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.
Related posts
Sida Loo Socodo & Isticmaalka Qaabdhismeedka Hagaha Linux
Linux Hel Taliska Tusaalooyinka
5 Sababood oo Wanaagsan oo loogu talagalay Daaqadaha Linux
HDG wuxuu sharxayaa: Waa maxay UNIX?
9-ka ugu Wanaagsan Linux Distros ee loogu talagalay jabsiga
Habka ugu fudud ee meel fog looga xidhi karo Linux Mint ka OS kasta
Khiyaamooyinka Gawaarida: Isticmaal Terminalka sida saacada digniinta
U beddelo Sawirrada u dhexeeya Qaababka iyada oo loo marayo khadka taliska ee Ubuntu
Ku dar Jid-gaabyada menu-ka-midig ee macnaha guud ee Ubuntu
Xir oo dib uga bilow Kumbuyuutarkaaga Terminalka Ubuntu
5-ta Cayaarood ee ugu Wanaagsan Linux
Ku rakib Adobe Digital Editions gudaha Ubuntu Linux
Sida loo Sameeyo Qayb Disk Linux ah
Ku samee Linux Live Live Custom oo leh Kit Linux Live
10ka ugu sarreeya ee Raspberry Pi Linux amarada ay tahay inaad ogaato
10-ka ugu fiican ee duubayaasha shaashada ee Linux
Sida loo rakibo oo loo dejiyo Kali Linux
9 Waxyaabo Faa'iido Leh Linux Waxay Qaban Kartaa Daaqadaha Aysan Qaban Karin
BSD vs Linux: Farqiga Aasaasiga ah
Sida loo rakibo Ku dhawaad Printer kasta Ubuntu