Python calculates expressions based on the below rules , these are generally the same as those in algebra.
Expression in Parenthesis
Parenthesis ( ) are evaluated first , any expression between the parenthesis will evaluate the value first and results will be further processed.
Exponentiation
are the second set of expression that are evaluated, if there are multiple expression then Python will evaluate each from right to left.
Multiplication , Division and Modulus
are on the same level of precedence. In case of multiple occurrence Python will evaluate each from left to right.
Addition and Substraction
are on the same level of precedence. these are evaluated last unless covered in parenthesis.In case of multiple occurrence these are evaluated from left to right.
Complete list of precedence is available at Python.org
Python is one of the most popular language today , it is dynamic, general purpose programming language, it has a long history of over few decades but in recent time it has gained enormous attention specially with cloud computing.
Python is not only used for cloud application but with huge module library it is used all sort of applications such as desktop application , scripting and automation , web application , machine learning , data analysis and many more.
One of the recent projects that has raised Python value is OpenStack Cloud , this project is written in Python and utilizes libraries to integrate different part of the Cloud. This has raised the value of Python in Enterprises such as Facebook , Microsoft , Google and Amazon to name a few.
Though Python is highly in demand there are some advantages and disadvantages of using Python and it is good to understand those before considering Python for your next project.
Pro’s
Easy Python Syntax
Python was designed keeping simplicity in mind , its code is simple and easy to read as compared to other high level languages such as Java , C++ etc.
Object Oriented
Python is Object oriented , one of the main concept that makes it is a great choice is concept of objects, everything is an object including all the basic data types such as strings and integers are considered object and developer can apply methods on these objects.
Libraries
Python has a huge collection of libraries that makes the life much more easier , many of the task can be performed with very few lines of code. There are two type of libraries , Python Standard Library and 3rd Party libraries developed by Vendors for there own products.
Python is extensible
Python code can integrate with C / C++ and that makes it very extensible language , basically Python was used mainly for system integration in the past but in recent years it has developed into a more robust platform.
Portable
Languages like C and C++ the code varies from platform to platform example libraries for Windows and Linux might differ but that is not the case with Python , here you code once and you can run it anywhere. This is called write once and run anywhere.
Interpreted
Python code get executed Line by Line and thus debugging is easier and simpler
Open Source , Community support
Python is an open source language and it has a huge community support , more and more people are using Python and its support is increasing as well , many Enterprises have jumped in to adopt Python and that is increasing community greatly.
Con’s
Speed
Python as compared to low level languages like C / C++ is slow due to the structure, Python code is compiled into byte code at runtime while the C / C++ code is compiled before run-time.
Memory Utilization
for memory intensive application Python is not a good choice , the flexibility of data-types brings overhead in form of memory consumption.
Threading Issues
Multi-threading is another area where Python does not really perform as compared to other High level languages like Java , this is due to Global interpreter lock (GIL) which allows only one thread to execute at a time. As a result, single-threaded application perform better with Python.
Mobile Development
As compared to Java , Python is not greatly used for Mobile applications and thus does not have great support for Mobile devices. It is easy to use Python for mobile purposes but configuring require some extra effort.
Python is not native to mobile environment and it is seen by some programmers as a weak language for mobile computing. Android and iOS don’t support Python as an official programming language. Still, Python can be easily used for mobile purposes, but it requires some additional effort.
Conclusion
Python is ideal for creating tools , automation and applications, it is getting more and more support at both community and enterprise level , it is the most in demand language for programming jobs currently available in the market.
Though SystemD will be compared to its predecessor SystemV for a long time , it has much more to offer in terms of System Management. It is a new way how Linux interact with the underline Objects such as hardware , sockets , application processes and many more.
Understand How SystemD works
systemd is a system and service manager for Linux, compatible with SysV and LSB init scripts.
Features
Contrary to its predecessor SystemD handles processes parallel
socket and D-Bus activation
traditionally services will be configured to start on boot, but with systemd it is more event driven and you can configure to start when something connects to a specific port or a device get connected , this is called socket and d-bus activation.
Offers on-demand starting of daemons, also keeps track of processes using Linux cgroups
Supports snapshot and restoring of the system state
Maintains mount and automount points
Implements an elaborate transactional dependency-based service control logic.
Concept of Units in SystemD
SystemD manages units, which are representations of system resources and services.
Type of Units in SystemD
Service
A Service unit is used to manage service, the unit file include instruction to start , stop , restart the service.
Socket A network socket associated with a service.
Device
Unit file related to Device is used to manage Device , start , stop , auto etc.
Mount Unit manages the Mount points via SystemD
Automount Unit file mounts the file system on system boot. This feature might replace traditional fstab files in the near future.
Swap Mounts swap space on the system
Target Targets are much like Runlevel used previously to manage different services to start and stop at different
Path
A path for path-based activation. For example, you can start services based on the state of a certain path, such as whether it exists or not.
Timer Timer unit is used similar to Crontab to schedule other units.
Snapshot
A snapshot of the current systemd state. Usually used to rollback after making temporary changes to systemd.
Slice Restriction of resources through Linux Control Group nodes (cgroups).
Scope Information from systemd bus interfaces. Usually used to manage external system processes.
systemctlcommand
is the primary tool to manage SystemD. It can be used for starting , stopping of services as well as enabling and disabling , this was previously performed with service and chkconfig commands in the previous versions.
Basic Service Management Syntax
Description:
Command
Start the Service
systemctl start foo
Stop the Service
systemctl stop foo
Restart the Service
systemctl restart foo
Status of the Service
systemctl status foo
Enable Service to start at bootime
systemctl enable foo
Disable the Service
systemctl disable foo
Check if service is enabled
?
systemctl is-enabled foo
Mask
the Service
systemctl mask foo
Reload the updated unit file
systemctl daemon-reload
Show Failed Services
systemctl -failed
Reset any failed service
systemctl reset-failed
Show properties of the Unit
systemctl show < service >
Edit the Service Unit
systemctl edit < service >
Edit the Full Service Unit
systemctl edit --full < service >
Run on remote host
systemctl -H < host_name > status network
Changing System State
Reboot host
systemctl reboot
Poweroff host
systemctl poweroff
Switch to Emergency mode
systemctl emergency
Log back to default mode (Multi-User)
systemctl default
Viewing Log Messages
Show all log messages
journalctl
Show only kernel log messages
journalctl -k
Show log for specific service
journalctl -u network.service
Follow messages as they appear
journalctl -f
Besides services, most systemd commands can work with these unit types: paths,
slices, snapshots, sockets, swaps, targets, and timers
Once the Hardware check POST “Power On Self Test” is completed and boot devices are identified , the last step by UEFI / BIOS was to identify the first boot device read the <abbr title=”Master boot record”>MBR</abbr>. Its a 512 byte in the storage device that stores boot loader information, this can be considered as an index location that refer to other sectors for loading the Operating System. In most of the Linux distributions GRUB V2 is used as a bootloader as of this writeup.
GRUB V2 stands for “Grand Unified Bootloader, version 2” , it is the program that identifies and loads system kernel. At this point we should be clear why we use GRUB2 / GRUB V2 rather then just simply calling it GRUB ? that is because GRUB V2 is the rewrite of a legacy bootloader GRUB2 with many new features and a modular design. It is designed for multi-OS boot running multiple Linux, Unix and other proprietary Operating systems such as MS Windows. It can even identify multiple kernel for the Same Linux distribution and allow to boot from older version if required.
The default configuration file is Ubuntu /boot/grub/grub.conf RHEL 7 /boot/grub/grub.conf
Grub in itself is a complete topic to be discussed along with its configuration and management options which is discussed in GRUB section.
Once the Kernel is selected, Kernel along with initramfs is loaded in main memory and root file system gets mounted, the first process in legacy SystemV was the init process which will initiate the OS processes , but this has changed with Canonical Upstart and more recently SystemD. Both these systems have been designed to overcome what was previously the shortcomings of SystemV INIT system, both of these have comparatively similar features but do differ in design and architecture. As of now SystemD seems to lead with many big distribution such as Redhat , Fedora , CentOS , Debian and last but not least Ubuntu have given up Upstart in favor of SystemD, one of the reason was both of these system were causing more confusion for the software developers community.
To keep things simple i have divided the working of these three system in separate links below.
Once you have installed docker its time to manage , pull , remove docker images.
What is an Image
Image is a file that comprise of multiple layers used to execute code in a docker. It is built from the instruction for a complete and executable version of an application.
Note it does rely on the OS kernel
There are more then 1500 images created by different application teams such as by apache , ngnix , mysql , mariadb , these are called official docker images. One of the biggest repositories for these official docker images is
https://hub.docker.com
.
Installing Images
Downloading and installing an image on docker in Linux is a very straight forward way with a single command,example ngnix
docker pull <package_name>
To pull a particular version of an image
docker pull <package_name>:package_version_detail
by default pull will grab the latest version of the package and same goes for removing the version with docker rmi <package_name>
To see all the images that are downloaded on your machine use the command
docker images
To delete an image you can type
docker rmi <package_name>:package_version_details
if no package version details are added it will delete the latest version of the package.