Linux Command – (apt-get)(Shutdown)(tree)(which-where)

Linux Command – (apt-get)(Shutdown)(tree)(which-where)

Linux Command

In this course of Linux commands, we will introduce four Linux Command – (apt-get)(Shutdown)(tree)(which-where):

  • apt-get
  • Shutdown
  • tree
  • which-where
(apt-get):

The apt-get update command updates the list of available packages (programs) that can be downloaded.
*If you type this command as a non-root user, the system will refuse to execute the command because the user does not have the necessary privileges.

> apt-get update -y

> sudo apt-get update -y

let’s to see video from our YouTube channel

(Shutdown):

• The shutdown command allows you to schedule device shutdowns and restarts, sends a warning message, and prevents other users from connecting.
• To use this command, you must have root rights: if you are not logged in as superuser, use Sudo.

To quickly turn off the computer

> Shutting down -h now

• To restart the computer immediately

> Shutdown -r now

• To shut down the system in 30 minutes and notify other users of the action

> shutdown -h -t 30 “Scheduled shut down for maintenance”

 

(tree):

Sometimes it is useful to have an overview of the tree structure of the file system to facilitate navigation between files. We can use the command tree. This command does not install by default. To install it:

> sudo apt-get install tree

> tree

 

To display only directories without the list of filenames:

> tree -d

let’s to see video from our YouTube channel

(which-where):

In this course of Linux commands, we will introduce the command (which-where). We start tutorial by mentioning the structure and example.

In general, executable programs are in one of the following directories: /bin, /usr/bin, /sbin, /usr/sbin, /opt
To locate an application, we use command “which” or “where

> which is “app_name”

> where is “app_name”

let’s to see video from our YouTube channel

 

 

You can find other learning for Linux by clicking here.

WHILE in Python

WHILE in Python

WHILE in Python

WHILE loop is especially useful in Python programming, and we use it many times. In the WHILE loop, we start a loop until the condition in the loop becomes True and the loop stops.

In this loop, while first evaluates the desired condition, if the condition is correct, the command inside the loop is executed. After that, the condition is reevaluated and this process continues until the desired condition is violated and when the condition becomes False, the loop will stop.

Syntax:

while condition:

statement

In WHILE loop, we need a condition to stop loop, if we don’t write a condition to stop, loop will continue without stop. here are some examples:

while a > X:

print(‘Y’)
a=a-1


while a >= X:

print(a)
a-=1


Example : 

  • a=1
  • while a <= 5:
  •    print (a)
  •    a=a+1

Output:

1

2

3

4

5

Example : 

  • a=1
  • while True:
  •    print (a)
  •    if a==5:
  •       break
  •    a=a+1

Output :

The output for this example is same as the last one, I just wanted to teach you the same result in two ways.

Infinite while Loop in Python:

In this model of the loop, if the condition is True, the loop will run for infinity. In Python, to prevent this model of infinite loops, a workaround has been considered that if the compiler detects that the loop is not able to stop, it stops automatically. To avoid such infinite loops, we need a condition in the loop to stop.

while True:

statement

while True :

print(a)
a-=1

if a==X:

break

Example : 

  • a=1
  • while True:
  •    print (a)
  •    a=a+1

Output :

This loop will continue with non-stop

Python While loop with else:

while condition:

statement

else:

statement

Example : 

a = 1

while a <= 5:

print(a)

a = a + 1

else:

print(‘a is over‘)

Output :

1
2
3
4
5
a is over

let’s to see video from our YouTube channel

If you want to learn more Python, please click here.

FOR in Python

FOR in Python

FOR in Python

Loops are used for sequential traversal, that’s mean used for repeating variables such as numbers, strings, lists or sets. The loop continues until it is terminated by the variable or by terminating the loop with the Break command. In this section, we want to learn how to use loops. loop in programming languages is an iterative method and is also found in other object-oriented languages. With a loop, we can execute a set of commands, once for each item. Loops in every programming language start with a set of rules, but they may be slightly different in structure. Python also has statements and conditional loops.

In the first part, we will introduce the FOR-loop Python. With this loop, we can iterate through instructions based on the number considered in the loop. First, we examine its structure:

for <var> in <iterable>:

<statement(s)>

In this structure, the “statement” repeats i times

let’s to see some example

for i in “Hello”:

print(i)

The output of this command: in five lines it prints Hello, line 1 first character, line 2 second character and … 

for i in “Hello”:

print(1)

The output of this command: in five lines it prints 1, line 1 print 1, line 2 print 1 and … 

for i in “55”:

print(i)

The output of this command: in two lines it prints 55, line 1 print 5, line 2 print 5 and … 

if we want to print for example from 1 to 50, we can use command range(): in this command we can make [start,stop,step] 

for i in range (3):

print(i)

The output of this command: in three lines it prints: line 1 print 0, line 2 print 1 and line 3 print 2

We must know range (3), prints 0,1,2. If we want to print 1,2,3 = for i in range (1,3+1)

With [step] we can skip numbers, for example: this prints 1,3,5 = for i in range (1,5+1,2):

let’s to see video from our YouTube channel

If you want to learn more Python, please click here.

Condition IF in Python

Condition IF in Python

Condition IF in Python

We use the IF statement in programming to run a group of statements but only when a condition is met.

In this section, we want to introduce the syntax and examples of Condition IF in Python.

IF is one of the conditional commands that is very widely used in programming and learning it is recommended to everyone.

There are three forms of the IF In Python:

  1. if
  2. if  else
  3. if   elif   else

elif allows to check multiple statements for TRUE and if one the condition was True then it execute those statements.

else: if all conditions were False then the last condition in ‘else’ will execute at the end.

we must know the conditional elements and here there are some elements:

a==b              Is a equal to b?

a !=b              Is NOT a equal to b?

a < b              Is a smaller than b?

a > b              Is a greater than b?

 

for using IF we have three steps:

if condition1:

statement a

if it’s True then compiler run it and skip others condition

elif condition2:

statement b

and if last IF was False then compiler check this part and if it’s True then compiler execute it and skip other conditions

elif condition3:

statement c

we can have another IF and if last ELIF was False then compiler check this part and if it’s True then compiler execute it and skip other conditions

else:

statement d

All conditions were False, and compiler runs this.

 

For Example:

if a > b:

    print (‘Yes’)

elif a < b:

    print (‘No’)

else:

    print (‘Equal’)

 

Nested IF in Python:

We can merge several IF into a single IF statement and this is called Nesting in programming languages.

First Condition: if condition1:

Second Condition: if condition2:

Third Condition: if condition3:

statement a

elif condition3-1:

statement b

else:

statement c

 

let’s to see video from our YouTube channel

If you want to learn more Python, please click here.

Problems running Hyper-V & VirtualBox

Problems running Hyper-V & VirtualBox

Problems running Hyper-V & VirtualBox

 

The use of virtual machines is being used day by day. In companies, institutions and even at home for practice and learning. We can install virtual machines on personal computers that have minimal functionality. When we install these softwares on Windows 10 or 11, in some cases, problems arise to run it. One of them is, “Problems running Hyper-V & VirtualBox” at the same time. Here we are going to explain how to solve this problem.

If you installed Hyper-V and you want to install VirtualBox, you will have this issue:

mes you get error to run these two, together. In this tutorial we teach you how you can disable Hyper-V and use VirtualBox.

Here is the command to disable Hyper-V to solve this problem

  • bcdedit.exe /set hypervisor launch type off

After running this command, you must Restart the computer, and try after that.

Here is the command to enable Hyper-V
  • bcdedit.exe /set hypervisor launch type auto

note: you must restart the computer

 

You can find some learning for this topic here:

Backup and Recovery

Backup and Recovery

Backup and Recovery

In this part we want to know, what is Backup and Recovery? Backup refers to storing information in external memory to protect information from accidents and loss. Recovery refers to returning data from a saved copy to the original location or to an alternate location where information has been lost or damaged.
To store information, we use a separate system or media such as virtual hard drives, data storage servers or cloud storage space to protect them against the possibility of data damage.

Why do we need backups?

Why do we need backups? By making a backup copy, we make a copy of the information in a peripheral memory so that we can recover it in case of damage to the primary data. Primary data failures usually occur for the following reasons:

  • Hardware defect
  • Defect in the software
  • Corruption of information
  • Human error – accidental deletion of data
  • Attack of viruses or malware

by having a backup copy of the data, we can restore it from the initial point in time.

Having a copy of information in an external space is very vital and necessary to prevent information loss. This additional copy can be, for example, an external hard drive or a USB memory or a disk storage system or Cloud storage:

  • The source device (a workstation),
  • Your local backup device (External HDD),
  • Off-site location (Cloud backup solution).

 Backup solutions:

  • File-only backup,
  • Server backup,
  • Desktop backup

Backup methods:

There are two general methods for backup:

1. Field or traditional method:

Data is serially backed up using a backup server or software. The backend server retrieves the data and indexes, compresses, and encrypts the data for optimization and easy search before sending it.

2. Array-based method:

This backup method is based on array. The way this method works is based on Snapshots, which provides an alternative for data protection.

The advantages of this method include:

    • High performance on personal memories
    • Low pressure on memory
    • Higher service level to provide more backup copies
    • Productivity and high efficiency of stored data
    • Easier and faster use of data alignment

 

If you are interested in seeing some learning you can click here.