Linux From Scratch 9.0-rc1 Duyuruldu

Kullanıcıya kendi zevki ve ihtiyacına göre özelleştirilmiş bir GNU/Linux sistem yükleme olanağı sunmak amacıyla geliştirilen Kanada kökenli dağıtım Linux From Scratch‘in (LFS) 9.0 sürümünün ilk sürüm adayı, Bruce Dubbs tarafından duyuruldu. Linux From Scratch topluluğunun LFS’nin yeni sürümünü duyurmaktan memnuniyet duyduğunu söyleyen Dubbs; LFS’nin sıfırdan temel bir GNU/Linux sistemin nasıl inşa edileceği konusunda adım adım yönergeler sunan bir kitap olduğunu belirtti. gcc 9.2.0 ve glibc 2.30’daki takım zinciri güncellemelerini içeren yeni sürüm, 5.2.8 Linux çekirdeği üzerine yapılandırılmış bulunuyor. Linux From Scratch 9.0-rc1 hakkında ayrıntılı bilgi edinmek için sürüm duyurusunu inceleyebilirsiniz.

Continue Reading →

Linux From Scratch 9.0-rc1 edinmek için aşağıdaki linkten yararlanabilirsiniz.

0

Python sürümü nasıl belirlenir?

Dünyanın en popüler programlama dillerinden birisi olan Python; web siteleri geliştirmek, script yazmak, veri analizi ve daha pek çok şey için kullanılmaktadır. Python, çoğu GNU/Linux dağıtımında ve hatta macOS’ta önceden yüklenmiş olarak gelir. Hatta çoğu GNU/Linux dağıtımı, Python’un hem 2.x hem de 3x sürümünü içerir. Ama GNU/Linux dağıtımlarında öntanımlı Python sürümü ağırlıklı olarak Python2’dir. Bu çalışmamızda, sistemimizde hangi Python sürümünün bulunduğunu anlamak için terminali kullanacağız. Sistemimizde hangi Python sürümünün yüklü olduğunu bulmak için python --version veya python -V komutunu çalıştırabiliriz. Burada, sanırım dikkatinizi çekmiştir, her iki komut da 2.x sürümüne yönelik değerlendirme yapmaktadır.

Continue Reading →

Kuşkusuz, sisteminizde kurulu python 3 sürümünü de öğrenmek isteyeceksinizdir. Bu durumda, python3 --version veya python3 -V komutunu vermeniz gerekiyor.

Bunun dışında, siz, daha güncel bir Python 3 sürümünü yüklemiş de olabilirsiniz. O halde, yukarıda gördüğünüz gibi, vereceğiniz komutu bu sürüme özgü hale getirmelisiniz. Mesela: python3.7 --version veya python3.7 -V. İşte, sizin yüklediğiniz sürüm de karşınızda.

Şimdi olağan şartlarda, Python’u başlatmak için şu komutu vermeniz yeterlidir:

python

Ancak, hem Python2 hem de Python3 zaten kurulu durumdaysa, ihtimal Python2 başlayacaktır.

 

Bu nedenle başlat konutu olarak;

python3

kullanmalısınız. Ancak daha yeni bir sürüm yüklediyseniz, ona göre özelleştirmelisiniz:

python3.7

Kolaylık açısından /usr/bin/ dizini altına py3 adında bir sembolik bağ yerleştirmeniz durumunda, yalnızca py3 komutunu vererek kendi yüklediğiniz son sürümü kullanabilirsiniz. Bunun için /usr/local/bin/ dizini içindeki python 3.7 adlı dosyaya /usr/bin dizini altından, py3 adlı bir sembolik bağ oluşturacaksınız. Şöyle bir komut verebiliriz:

ln -s /usr/local/bin/python3.7 /usr/bin/py3

Tabii bu komutu yetkili kullanıcı olarak vermeniz gerektiğini söylemeye herhalde gerek yoktur. Bu komutu verdikten sonra artık sadece py3 komutu ile Python programlama dilini kendi sürümünüzle başlatabilirsiniz. Kolay gelsin.

0

Bash Scripting Part6 – Create and Use Bash Functions

Before we talk about bash functions, let’s discuss this situation. When writing bash scripts, you’ll find yourself that you are using the same code in multiple places. If you get tired of writing the same lines of code again and again in your bash script, it would be nice to write the block of code once and call it anywhere in your bash script. The bash shell allows you to do just that with Functions. Bash functions are blocks of code that you can reuse them anywhere in your code. Anytime you want to use this block of code in your script, you simply type the function name given to it. We are going to talk about how to create your own bash functions and how to use them in shell scripts.

Continue Reading →

Creating a function

You can define a function like this:

functionName() {

}

The brackets () is required to define the function.

Also, you can define the function using the function keyword, but this keyword is deprecated for POSIX portability.

function functionName() {

# Deprecated definition but still used and working

}

In the second definition, the brackets are not required.

Using Functions

#!/bin/bash

myfunc() {

echo "Using functions"

}

total=1

while [ $total -le 3 ]; do

myfunc

total=$(($total + 1))

done

echo "Loop finished"

myfunc

echo "End of the script"

Here we’ve created a function called myfunc and in order to call it, we just typed its name.

bash functions

The function can be called many times as you want.

Notice: If you try to use a function which is not defined, what will happen?

#!/bin/bash

total=1

while [ $total -le 3 ]; do

myfunc

total=$(($total + 1))

done

echo "Loop End"

myfunc() {

echo "Using function ..."

}

echo "End of the script"

call before declare

Oh, it’s an error because there no such function.

Another notice: bash function name must be unique. Otherwise, the new function will cancel the old function without any errors.

#!/bin/bash

myfunc() {

echo "The first function definition"

}

myfunc

function myfunc() {

echo "The second function definition"

}

myfunc

echo "End of the script"

override definition

As you can see, the second function definition takes control from the first one without any error so take care when defining functions.

Using the return Command

The return command returns an integer from the function.

There are two ways of using the return command; the first way is like this:

#!/bin/bash

myfunc() {

read -p "Enter a value: " value

echo "adding value"

return $(($value + 10))

}

myfunc

echo "The new value is $?"

return command

The myfunc function adds 10 to the  $value variable then show the sum using the $? Variable.

Don’t execute any commands before getting the value of the function, because the variable $? returns the status of the last line.

This return method returns integers. what about returning strings?

Using Function Output

The second way of returning a value from a bash function is command substitution. This way, you can return anything from the function.

#!/bin/bash

myfunc() {

read -p "Enter a value: " value

echo $(($value + 10))

}

result=$(myfunc)

echo "The value is $result"

bash functions output

Passing Parameters

We can deal with bash functions like small snippets that can be reused and that’s OK, but we need to make the function like an engine, we give it something and it returns a result based on what we provide.

You can use the environment variables to process the passed parameters to the function. The function name is declared as $0 variable, and the passed parameters are $1, $2, $3, etc.

You can get the number of passed parameters to the function using the ($#) variable.

We pass parameters like this:

myfunc $val1 10 20

The following example shows how to use the ($#) variable:

#!/bin/bash

addnum() {

if [ $# -gt 2 ]; then

echo "Incorrect parameters passed" # If parameters no equal 2

else

echo $(($1 + $2)) # Otherwise add them

fi

}

echo -n "Adding 10 and 15: "

value=$(addnum 10 15)

echo $value

echo -n "Adding three numbers: "

value=$(addnum 10 15 20)

echo $value

pass parameters

The addnum function gets the passed parameters count. If greater than 2 passed, it returns -1.

If there’s one parameter, the addnum function adds this parameter twice. If 2 parameters passed, the addnum function adds them together, and if you try to add three parameters it will return -1.

If you try to use the passed parameters inside the function, it fails:

#!/bin/bash

myfunc() {

echo $(($1 + $2 + $3 + $4))

}

if [ $# -eq 4 ]; then

value=$(myfunc)

echo "Total= $value"

else

echo "Passed parameters like this: myfunc a b c d"

fi

unknown parameters

Instead, you have to send them to the function like this:

#!/bin/bash

myfunc() {

echo $(($1 + $2 + $3 + $4))

}

if [ $# -eq 4 ]; then

value=$(myfunc $1 $2 $3 $4)

echo "Total= $value"

else

echo "Passed parameters like this: myfunc a b c d"

fi

bash functions parameters

Now it works!!

Processing Variables in Bash Functions

Every variable we use has a scope, the scope is variable visibility to your script.

You can define two types of variables:

  • Global
  • Local

Global Variables

They are visible and valid anywhere in the bash script. You can even get its value from inside the function.

If you declare a global variable within a function, you can get its value from outside the function.

Any variable you declare is a global variable by default. If you define a variable outside the function, you call it inside the function without problems:

#!/bin/bash

myfunc() {

input=$(($input + 10))

}

read -p "Enter a number: " input

myfunc

echo "The new value is: $input"

global variables

If you change the variable value inside the function, the value will be changed outside of the function.

So how to overcome something like this? Use local variables.

Local Variables

If you will use the variable inside the function only, you can declare it as a local variable using the local keyword  like this:

local tmp=$(( $val + 10 ))

So if you have two variables, one inside the function and the other is outside the function and they have the identical name, they won’t affect each other.

#!/bin/bash

myfunc() {

local tmp=$(($val + 10))

echo "The Temp from inside function is $tmp"

}

tmp=4

myfunc

echo "The temp from outside is $tmp"

local variables

When you use the $tmp variable inside the myfunc function, it doesn’t change the value of the $tmp which is outside the function.

Passing Arrays As Parameters

What will happen if you pass an array as a parameter to a function:

#!/bin/bash

myfunc() {

echo "The parameters are: $@"

arr=$1

echo "The received array is ${arr[*]}"

}

my_arr=(5 10 15)

echo "The old array is: ${my_arr[*]}"

myfunc ${my_arr[*]}

pass arrays

The function only takes the first value of the array variable.

You should disassemble the array into its single values, then use these values as function parameters. Finally, pack them into an array in the function like this:

#!/bin/bash

myfunc() {

local new_arr

new_arr=("$@")

echo "Updated value is: ${new_arr[*]}"

}

my_arr=(4 5 6)

echo "Old array is ${my_arr[*]}"

myfunc ${my_arr[*]}

pass arrays solution

The array variable was rebuilt thanks to the function.

Recursive Function

This feature enables the function to call itself from within the function itself.

The classic example of a recursive function is calculating factorials. To calculate the factorial of 3, use the following equation:

3! = 1 * 2 * 3

Instead, we can use the recursive function like this:

x! = x * (x-1)!

So to write the factorial function using bash scripting, it will be like this:

#!/bin/bash

fac_func() {

if [ $1 -eq 1 ]; then

echo 1

else

local tmp=$(($1 - 1))

local res=$(fac_func $tmp)

echo $(($res * $1))

fi

}

read -p "Enter value: " val

res=$(fac_func $val)

echo "The factorial of $val is: $res"

bash recursive function

Using recursive bash functions is so easy!

Creating Libraries

Now we know how to write functions and how to call them, but what if you want to use these bash functions or blocks of code on different bash script files without copying and pasting it on your files.

You can create a library for your functions and point to that library from any file as you need.

By using the source command, you can embed the library file script inside your shell script.

The source command has an alias which is the dot. To source a file in a shell script, write the following line:

. ./myscript

Let’s assume that we have a file called myfuncs that contains the following:

addnum() {

echo $(($1 + $2 + $3 + $4))

}

Now, we will use it in another bash script file like this:

#!/bin/bash

. ./myfuncs

result=$(addnum 10 10 5 5)

echo "Total = $result"

source command

Awesome!! We’ve used the bash functions inside our bash script file, we can also use them in our shell directly.

Use Bash Functions From Command Line

Well, that is easy, if you read the previous post which was about the signals and jobs you will have an idea about how to source our functions file in the bashrc file and hence we can use the functions directly from the bash shell. Cool

Edit the bashrc file at /home/username and add this line:

. /home/likegeeks/Desktop/myfuncs

Make sure you type the correct path.

Now the function is available for us to use in the command line directly:

addnum 10 20

use from shell

Note: you may need to log out and log in to use the bash functions from the shell.

Another note: if you make your function name like any of the built-in commands you will overwrite the default command so you should take care of that.

I hope you like the post. Keep coming back.

Thank you.

0

MX Linux 19 Beta 1 duyuruldu

antiX ile MEPIS Linux topluluğu arasında bir işbirliği girişimi olarak doğan, Debian “stable” versiyonu üzerine yapılandırılan ve varsayılan masaüstü ortamı olarak Xfce kullanan MX Linux‘un 19 sürümünün ilk betası duyuruldu. Bunun bir test sürümü olduğunun unutulmaması ve yalnızca test etmek amacıyla kullanılması gerektiği vurgulanıyor ve test eden kullanıcıların tespit ettikleri hataları rapor etmeleri rica ediliyor. Debian 10 ‘Buster’a dayalı olarak gelen sistem; Xfce 4.14 masaüstü ortamını içeriyor ve antiX ile MX depolarından son güncellemelerle geliyor. 4.19.5 Linux çekirdeği üzerine yapılandırılan sistem; GIMP 2.10.12, MESA 18.3.6, Firefox 68, VLC 3.0.8, Clementine 1.3.1, Thunderbird 60.8.0, LibreOffice 6.1.5 gibi pek çok güncel yazılımı kullanıma sunuyor. DistroWatch’ın listesinde 4701 günlük ziyaret ile “bir numaralı” dağıtım olan MX Linux’un yeni sürümü, Hyper-V ve KVM için geliştirilmiş desteği yanında, NTFS cihazlarında verimli kurulumlar için geliştirilmiş destek içeriyor. MX Linux 19 Beta 1 hakkında ayrıntılı bilgi edinmek için sürüm duyurusunu inceleyebilirsiniz.

Continue Reading →

MX Linux 19 Beta 1 edinmek için aşağıdaki linklerden yararlanabilirsiniz.

0

LibreOffice 6.3.1 RC1 çıktı

LibreOffice 6.3.1’in ilk sürüm adayı, sürüm takviminde belirtilen tarihe göre, yaklaşık iki haftalık bir gecikmeyle The Document Foundation (TDF) tarafından çıkarılarak test edilmek üzere kullanıma sunuldu. Çeşitli hata düzeltmeleri ve iyileştirmelerle gelen sürümün bir test sürümü olduğunun unutulmaması ve yalnızca test etmek amacıyla kullanılması gerektiği hatırlatılırken, test eden kullanıcıların tespit ettikleri hataları rapor etmeleri rica ediliyor. LibreOffice 6.3.1 RC1’i var olan LibreOffice kurulumuna paralel kurabilirsiniz. Farklı dağıtımlar için ayrıntılı kurulum yönergelerini incelemeniz önerilir. Sürüme ilişkin hataları Bugzilla üzerinden bildirebilirsiniz. LibreOffice 6.3.1 RC1 hakkında bilgi edinmek için yayımlandıktan sonra sürüm notlarını inceleyebileceksiniz.

Continue Reading →

LibreOffice 6.3.1 RC1 edinmek için aşağıdaki linklerden yararlanabilirsiniz. Resmi duyuru yapılana kadar:

Resmi duyuru yapıldıktan sonra:

0

Huawei yola şimdilik Android ile devam etmeyi düşünüyor

ABD tarafından casuslukla suçlanan Çinli şirket Huawei, yola şimdilik Android ile devam etmeyi düşünüyor. Huawei’nin Kıdemli Başkan Yardımcısı Vincent Yang’a göre, şirketin şu an için bir HarmonyOS yüklü bir akıllı telefonla ortaya çıkma planları bulunmuyor. Standart bir ekosistemi korumak istediklerini söyleyen Yang; HarmonyOS’un Huawei için B planı olarak hizmet edeceğini sözlerine ekledi. Yang, bu nedenle, yaklaşmakta olan amiral gemisi akıllı telefonun Android ile kullanıma sunulacağını söyledi. Bununla birlikte, ABD hükümeti, Huawei’nin Google Play Store da dahil olmak üzere önemli Android bileşenlerine erişmesini engelleyecek yasağı uygularsa, işler değişebilir. Ticaret Bakanlığı kısa bir süre önce Çinli bir şirketin ABD şirketleriyle iş yapmaya devam etmesine izin vermek için geçici bir lisans verdi, ancak yasağın onaylanması durumunda, Huawei bir HarmonyOS yüklü bir akıllı telefonu ortaya çıkarmak zorunda kalabilir.

Continue Reading →

Huawei’nin HarmonyOS işletim sistemi şu an için uygulama desteği almadı. Şirketin Android kullanması yasaklanırsa, Huawei Mate 30 gibi akıllı telefonlar, ABD müşterileri için büyük bir fırsat yaratan Google Play Store’a erişimini kaybedecek. Şirketin yakın zamanda çıkaracağı  modellerin Huawei Mate 30 ve Huawei Mate 30 Pro olacağı sanılıyor. Anlaşılan o ki, firma, bu ürünleri Android yüklü olarak çıkarmayı planlıyor. HarmonyOS’un yakında bir televizyon ile kullanıma sunulacağı, ayrıca bir akıllı saatte kullanılacağı söyleniyor.

0

Linux Kodachi 6.2 duyuruldu

Debian GNU/Linux tabanlı bir dağıtım olan, DVD veya USB üzerinden başlatılabilen, VPN ve Tor ağı üzerinden tüm ağ trafiğini filtreleyen Linux Kodachi‘nin 6.2 sürümü , Warith Al Maawali tarafından duyuruldu. Bunun Xbuntu 18.04 LTS üzerine kurulu bir sürüm olduğunu söyleyen Al Maawali; güncellenmiş taban sistem yanı sıra, yeni sürümün çeşitli özellikler ile birlikte geldiğini ifade etti. Özel DNS betiği eklenen yeni sürüme, ayrıca, Wicd ağ yöneticisi de eklenmiş bulunuyor. Tam sistem güncellemesi ile gelen sistemde, dokunmatik yüzey güncellemesi gerçekleştirilmiş. 5.0.0-27 Linux çekirdeği üzerine yapılandırılan sistem, anonimliği kolaylaştırmak üzerine odaklanmış ve Electrom BTC Wallet, Gimp, Thermald, Qalculate gibi pek çok yazılım eklenmiş olarak geliyor. Sphere anonim tarayıcı eklenen sistem, Riot ve Tox chat araçlarını da içeriyor. Linux Kodachi 6.2 hakkında ayrıntılı bilgi edinmek için sürüm duyurusunu ve değişiklikler sayfasını inceleyebilirsiniz.

Continue Reading →

Linux Kodachi 6.2 edinmek için aşağıdaki linklerden yararlanabilirsiniz.

0