About the linux environment

Unix / Linux — Environment

In this chapter, we will discuss in detail about the Unix environment. An important Unix concept is the environment, which is defined by environment variables. Some are set by the system, others by you, yet others by the shell, or any program that loads another program.

A variable is a character string to which we assign a value. The value assigned could be a number, text, filename, device, or any other type of data.

For example, first we set a variable TEST and then we access its value using the echo command −

It produces the following result.

Note that the environment variables are set without using the $ sign but while accessing them we use the $ sign as prefix. These variables retain their values until we come out of the shell.

When you log in to the system, the shell undergoes a phase called initialization to set up the environment. This is usually a two-step process that involves the shell reading the following files −

The process is as follows −

The shell checks to see whether the file /etc/profile exists.

If it exists, the shell reads it. Otherwise, this file is skipped. No error message is displayed.

The shell checks to see whether the file .profile exists in your home directory. Your home directory is the directory that you start out in after you log in.

If it exists, the shell reads it; otherwise, the shell skips it. No error message is displayed.

As soon as both of these files have been read, the shell displays a prompt −

This is the prompt where you can enter commands in order to have them executed.

Note − The shell initialization process detailed here applies to all Bourne type shells, but some additional files are used by bash and ksh.

The .profile File

The file /etc/profile is maintained by the system administrator of your Unix machine and contains shell initialization information required by all users on a system.

The file .profile is under your control. You can add as much shell customization information as you want to this file. The minimum set of information that you need to configure includes −

  • The type of terminal you are using.
  • A list of directories in which to locate the commands.
  • A list of variables affecting the look and feel of your terminal.

You can check your .profile available in your home directory. Open it using the vi editor and check all the variables set for your environment.

Setting the Terminal Type

Usually, the type of terminal you are using is automatically configured by either the login or getty programs. Sometimes, the auto configuration process guesses your terminal incorrectly.

If your terminal is set incorrectly, the output of the commands might look strange, or you might not be able to interact with the shell properly.

To make sure that this is not the case, most users set their terminal to the lowest common denominator in the following way −

Setting the PATH

When you type any command on the command prompt, the shell has to locate the command before it can be executed.

The PATH variable specifies the locations in which the shell should look for commands. Usually the Path variable is set as follows −

Here, each of the individual entries separated by the colon character (:) are directories. If you request the shell to execute a command and it cannot find it in any of the directories given in the PATH variable, a message similar to the following appears −

There are variables like PS1 and PS2 which are discussed in the next section.

PS1 and PS2 Variables

The characters that the shell displays as your command prompt are stored in the variable PS1. You can change this variable to be anything you want. As soon as you change it, it’ll be used by the shell from that point on.

For example, if you issued the command −

Читайте также:  Центр лицензирования windows server 2019

Your prompt will become =>. To set the value of PS1 so that it shows the working directory, issue the command −

The result of this command is that the prompt displays the user’s username, the machine’s name (hostname), and the working directory.

There are quite a few escape sequences that can be used as value arguments for PS1; try to limit yourself to the most critical so that the prompt does not overwhelm you with information.

Current time, expressed as HH:MM:SS

Current date, expressed as Weekday Month Date

Источник

Linux Environment Variables: How to Read and Set on a Linux VPS

In this tutorial, we’ll explain in-depth what Linux environment variables are, and teach you basic modification and read commands on your VPS to get you started! Let’s jump in!

What is a Variable

In computer science, a variable is a location for storing a value that can be changed depending on conditions or information passed to the program. Variables play an important role in programming, they enable developers to write flexible programs related to the operating system they work on!

What are Linux Environment Variables

Environment variables are dynamic values that affect the programs or processes running on a server. They exist on every operating system, and their type may vary. Environment variables can be created, edited, saved and deleted.

Linux environment variables are placeholders for information stored within the system that passes data to programs launched in shells or sub-shells.

Linux Environment Variable Commands

Let’s look at some common Linux environment variable commands that you might want to know. Remember, before modifying any variables, you need to access your VPS using SSH.

How to View Linux Environment Variables

You can see the entire list of environment variables on your Linux distribution by using the printenv command. The simple use of it on Ubuntu will provide a large output displaying the variables.

You can get a more manageable output by adding piping in a modifier:

Every line contains the name of the Linux environment variable followed by = and the value. For instance:

HOME is a Linux environment variable that has the value set as the /home/edward directory.

Environment variables are typically upper case, though you can create lower case environment variables as well. The output of printenv displays all environment variables in uppercase.

An important thing to note is that Linux environment variables are case sensitive. If you want to view the value of a specific environment variable, you can do so by passing the name of that variable as an argument to the printenv command. The entire string would look like this in the command line:

Another way to display the value of an environment variable is by using the echo command like this:

How to Create a New Linux Environment Variable

The basic syntax of this command would look like this:

Let’s break it down:

  • export – the command used to create the variable
  • VAR – the name of the variable
  • = – indicates that the following section is the value
  • “value” – the actual value

In a real world scenario the command could look like this:

Let’s see how we could change the value of the TZ – timezone – variable:

First, let’s view the time:

The command will output the current time.

Then we can use the export command to alter the timezone:

Now that the variable’s value was changed, we can check the time again by using the date command, that would output a different time appropriate to the changes made to the Linux environment variable.

Unsetting the Value of a Linux Environment Variable

We’ll be using the unset command. Let’s see how the command’s syntax looks, and break it down:

The parts of the command are:

  • unset – the command itself
  • VAR – the variable we want to unset

Simple, right? We’ll unset the timezone variable as a test:

This will take time zone to its default value, which we can check by using the date command once more.

Setting and unsetting a Linux environmental variable from the command line effects only your current running sessions. If you want to make your settings persist between logins you have to define the environment variables in your personal initialization file – i.e. .bash_profile.

Local and Global Linux Environment Variable

In computer programming, a global variable is one that can be used anywhere in the program. While a local variable is one that is defined in a function and can only be used in that function. Here’s an example – Global_var and local_var are the global and local variables:

Linux environment variables can be global or local. The global environment variables are visible from a shell session and any child processes that the shell spawns. While local variables can be available in the shell only in which they are created.

System environment variables use all uppercase letters to distinguish them from normal user environment variables.

How to Set a Local Linux Environment Variable

In the following example, local_var is only visible in the current shell:

We can create a global environment variable using the export command:

Finally the output will be:

Conclusion

Congratulations, now you know all the Linux environment variable basics! Remember to always be careful, research what you’re modifying and keep advancing your skills! We hope this tutorial helped you do just that!

Edward is an expert communicator with years of experience in IT as a writer, marketer, and Linux enthusiast. IT is a core pillar of his life, personal and professional. Edward’s goal is to encourage millions to achieve an impactful online presence. He also really loves dogs, guitars, and everything related to space.

Источник

The Best Desktop Environments For Linux (We Tested Them So That You Don’t Have To)

Last updated August 24, 2021 By Ankush Das 313 Comments

The desktop environment is usually the core of your Linux desktop system for how it looks/feels. If you don’t get a good user experience, it will be difficult to use a Linux distro on your desktop, right?

So, which is the best desktop environment available?

Trying out each and every desktop environment is a very time-consuming and tiring task.

So, here, we’ve created a list of the best desktop environments available for Linux distros along with their pros and cons for you. We tried them so that you don’t have to.

Best desktop environments for Linux distributions

Just to mention, this list is in no particular order of ranking.

1. KDE

KDE is one of the most popular desktop environments out there. You may also refer it as the “Plasma” desktop. Even though it’s not my primary choice, it is highly customizable and extremely lightweight.

Yes, it looks like KDE has managed to beat XFCE as one of the lightest desktop environments. Not just limited to Jason’s test, you will find numerous benchmark comparisons and tests that point to the same result.

KDE also makes it easier to connect your phone with your Linux system using KDE Connect. You will also find Plasma’s browser integration that connects your phone directly to your browser for establishing quick communication.

Overall, it looks like KDE is an incredibly lightweight desktop environment while being one of the most flexible as well.

Some Linux distros using KDE as the default are openSUSE, Kubuntu and KDE Neon. You may also refer to one of our tutorials to install KDE on Ubuntu, if that’s what you want.

  • Modern and polished user interface
  • Highly customizable and flexible experience
  • Several useful tools built-in
  • Extremely lightweight
  • The customization options and tools might be a little too overwhelming for newbies, leading to potential confusion.

2. MATE

MATE Desktop Environment is based on GNOME 2. MATE was initially developed for the users who were disappointed with the latest iteration of GNOME shell — GNOME 3.

Even though it’s based on the good-old GNOME 2, the MATE team has improved the desktop environment on a lot of grounds. To get some idea, you might want to check out what Ubuntu MATE 20.04 has to offer.

If we take the example of Ubuntu MATE 20.04, MATE desktop is suitable for almost everyone. And, of course, especially for the ones who loved GNOME 2 but hate the new GNOME. In addition to the user experience, it is also worth noting that it is a lightweight desktop environment as well.

MATE comes with a collection of basic applications and includes a number of built-in useful tools.

Ubuntu MATE is one of the official flavors of Ubuntu that utilizes the MATE desktop. Some other popular Linux distributions like Linux Mint, Manjaro, etc, also offer MATE editions of their distributions.

  • Easy to use and robust experience
  • Lightweight
  • Simple yet Customizable
  • May not offer the most intuitive user experience

3. GNOME

GNOME is arguably the most popular desktop environment out there. Many of the popular Linux distros use GNOME as their default desktop environment and it has some popular forks, such as Cinnamon.

GNOME is designed to be easy to use and customizable. The user interface aims to provide a unique experience (kind of tailored for both mobile and desktops).

Unfortunately, GNOME isn’t a lightweight desktop environment. So, it’s not a great choice to go with if you are looking to install a Linux distribution on older computers or systems with less than 4 Gigs of RAM.

It’s good to see that GNOME is also focusing on the performance side of things with their recent GNOME 3.36 release.

So, if you want a good user experience with something that looks different from the likes of a traditional Windows layout, GNOME should be the perfect pick.

Some major distros using GNOME are Debian, Fedora, openSUSE and Ubuntu. Not to forget Pop OS 20.04 also features many good things along with GNOME desktop environment.

  • Modern and touch-friendly UI
  • Can extend functionalities through GNOME Shell Extensions
  • Customizable
  • Not suitable for older computers
  • User Interface isn’t tailored for a Windows user

4. Cinnamon

Cinnamon, a fork of GNOME 3, was initially developed to be and is the default desktop environment for Linux Mint. It is known for its similarities with the Windows user interface which helps new Linux users get comfortable using easily.

Cinnamon tries to present itself as a modern desktop environment while offering a traditional user interface. And, being somewhat light on resources makes Cinnamon a balanced choice for many Linux users.

  • Sleek and polished look
  • Familiar interface
  • Pretty customizable
  • May not offer the most intuitive user experience

5. Budgie

Budgie desktop has been developed by the Solus project. In case you didn’t know, Solus is an independently developed Linux distro where they utilize GNOME technologies such as GTK to develop the Budgie desktop environment.

It’s a mixed bag of modern UI and a traditional user interface. It’s not exactly resource heavy but not a complete lightweight desktop environment either.

Ubuntu Budgie — an official Ubuntu flavour features the Budgie desktop as the default. Not a lot of major distributions support Budgie desktop environment out of the box. So, you’d be better off using Solus or Ubuntu Budgie for the most part.

  • Solid and intuitive
  • Modern UI, elegant looks
  • Seamless desktop experience
  • Available only on few distributions (can be installed on your own manually)

6. LXQt

LXQt is a lightweight Qt desktop environment. When compared to LXDE, it’s safe to say that LXQt is indeed a lightweight desktop environment while providing a better user experience than LXDE (in terms of its look and feel).

Not just theoretically, but we also found it to be a great replacement to LXDE on Lubuntu 20.04.

Even though LXQt tries to present a modern look without comprising the performance, it is still not the most intuitive experience out there. Of course, if you need performance over the look and feel, LXQt is an impressive choice.

  • Extremely fast performing and lightweight
  • Decent UI for a lightweight desktop environment
  • User interface may seem unappealing
  • Not much customizable
  • Available only on few distributions (can be installed on your own manually)

7. Xfce

Xfce is one of the most lightweight desktop environments out there. Unlike LXQt, you will find a lot of major Linux distributions support XFCE editions.

Xfce is light on resources but proves to provide a feature-rich user experience. If you need a performance-centric desktop environment without needing advanced customizations, Xfce is a great choice to go with.

To give you an example, I’d recommend you check out our initial impressions on Zorin OS 15 Lite which includes Xfce desktop environment as the default.

Major Linux distributions like Manjaro Linux, Xubuntu, MX Linux, Zorin OS Lite, and several others feature Xfce as the default desktop environment.

  • Lightweight and adaptable to old hardware
  • Modern and visually appealing
  • Windows-like familiar UI

8. Deepin

Sometimes it’s not enough to offer customization options or being light on resources. There’s a lot of users who prefer an eye candy user interface by compromising the performance of the desktop environment.

That’s when the Deepin desktop environment comes to the scene. It may offer a macOS-ish interface in a way but because of the animations and the layout, the looks and feel of Deepin desktop environment is something to appreciate.

Originally, it was only available on Deepin OS, but it is now gradually being added to some other distributions as well. Recently an interesting project (UbuntuDDE) has managed to incorporate it on top of Ubuntu. It isn’t fairly new but it is being slowly adopted by other Linux distributions.

Pros

  • Eye candy user interface
  • Sleek animations

Cons

  • Heavy on resource usage and sluggish at times

So, which is the best desktop environment?

The reason why different desktop environment exists because there’s no ultimate desktop environment. Every user has a different set of requirements. Some look for a fast experience while some drool over an eye candy UI.

Even though we’ve already mentioned the best available in this article, there are a few other desktop environments that deserve the mention. Some of them are:

What desktop environment do you prefer and why? Feel free to let me know your thoughts in the comments below.

Like what you read? Please share it with others.

Источник

Читайте также:  Windows server radeon driver
Оцените статью
Sr.No. Escape Sequence & Description
1