Andromeda Computer - Blog

BANNERGnulinuxrocks

 

Linux is fully capable of running not weeks, but years, without a reboot. In some industries, that’s exactly what Linux does, thanks to advances like kpatch and kgraph.

For laptop and desktop users, though, that metric is a little extreme. While it may not be a day-to-day reality, it’s at least a weekly reality that sometimes you have a good reason to reboot your machine. And for a system that doesn’t need rebooting often, Linux offers plenty of choices for when it’s time to start over.

 

 

Understand your options

Before continuing though, a note on rebooting. Rebooting is a unique process on each operating system. Even within POSIX systems, the commands to power down and reboot may behave differently due to different initialization systems or command designs.

Despite this factor, two concepts are vital. First, rebooting is rarely requisite on a POSIX system. Your Linux machine can operate for weeks or months at a time without a reboot if that’s what you need. There’s no need to "freshen up" your computer with a reboot unless specifically advised to do so by a software installer or updater. Then again, it doesn’t hurt to reboot, either, so it’s up to you.

Second, rebooting is meant to be a friendly process, allowing time for programs to exit, files to be saved, temporary files to be removed, filesystem journals updated, and so on. Whenever possible, reboot using the intended interfaces, whether in a GUI or a terminal. If you force your computer to shut down or reboot, you risk losing unsaved and even recently-saved data, and even corrupting important system information; you should only ever force your computer off when there’s no other option.

 

 

Click the button

The first way to reboot or shut down Linux is the most common one, and the most intuitive for most desktop users regardless of their OS: It’s the power button in the GUI. Since powering down and rebooting are common tasks on a workstation, you can usually find the power button (typically with reboot and shut down options) in a few different places. On the GNOME desktop, it's in the system tray: 

gnome-menu-power.jpg

It’s also in the GNOME Activities menu:

gnome-screen-power.jpg

On the KDE desktop, the power buttons can be found in the Applications menu:

kde-menu-power.jpg

You can also access the KDE power controls by right-clicking on the desktop and selecting the Leave option, which opens the window you see here:

kde-screen-power.jpg

Other desktops provide variations on these themes, but the general idea is the same: use your mouse to locate the power button, and then click it. You may have to select between rebooting and powering down, but in the end, the result is nearly identical: Processes are stopped, nicely, so that data is saved and temporary files are removed, then data is synchronized to drives, and then the system is powered down.

 

 

Push the physical button

Most computers have a physical power button. If you press that button, your Linux desktop may display a power menu with options to shut down or reboot. This feature is provided by the Advanced Configuration and Power Interface (ACPI) subsystem, which communicates with your motherboard’s firmware to control your computer’s state.

ACPI is important but it’s limited in scope, so there’s not much to configure from the user’s perspective. Usually, ACPI options are generically called Power and are set to a sane default. If you want to change this setup, you can do so in your system settings.

On GNOME, open the system tray menu and select Activities, and then Settings. Next, select the Power category in the left column, which opens the following menu:

gnome-settings-power.jpg

In the Suspend & Power Button section, select what you want the physical power button to do.

The process is similar across desktops. For instance, on KDE, the Power Management panel in System Settings contains an option for Button Event Handling.

 

kde-power-management.jpg

After you configure how the button event is handled, pressing your computer’s physical power button follows whatever option you chose. Depending on your computer vendor (or parts vendors, if you build your own), a button press might be a light tap, or it may require a slightly longer push, so you might have to do some tests before you get the hang of it.

Beware of an over-long press, though, since it may shut your computer down without warning.

 

 

Run the systemctl command

If you operate more in a terminal than in a GUI desktop, you might prefer to reboot with a command. Broadly speaking, rebooting and powering down are processes of the init system—the sequence of programs that bring a computer up or down after a power signal (either on or off, respectively) is received.

On most modern Linux distributions, systemd is the init system, so both rebooting and powering down can be performed through the systemd user interface, systemctl. The systemctl command accepts, among many other options, halt (halts disk activity but does not cut power) reboot (halts disk activity and sends a reset signal to the motherboard) and poweroff (halts disk acitivity, and then cut power). These commands are mostly equivalent to starting the target file of the same name.

For instance, to trigger a reboot:

sudo systemctl start reboot.target

 

Run the shutdown command

Traditional UNIX, before the days of systemd (and for some Linux distributions, like Slackware, that’s now), there were commands specific to stopping a system. The shutdown command, for instance, can power down your machine, but it has several options to control exactly what that means.

This command requires a time argument, in minutes, so that shutdown knows when to execute. To reboot immediately, append the -r flag:

sudo shutdown -r now

To power down immediately:

sudo shutdown -P now

Or you can use the poweroff command:

poweroff

To reboot after 10 minutes:

sudo shutdown -r 10

The shutdown command is a safe way to power off or reboot your computer, allowing disks to sync and processes to end. This command prevents new logins within the final 5 minutes of shutdown commencing, which is particularly useful on multi-user systems.

On many systems today, the shutdown command is actually just a call to systemctl with the appropriate reboot or power off option.

 

Run the reboot command

The reboot command, on its own, is basically a shortcut to shutdown -r now. From a terminal, this is the easiest and quickest reboot command:

sudo reboot

If your system is being blocked from shutting down (perhaps due to a runaway process), you can use the --force flag to make the system shut down anyway. However, this option skips the actual shutting down process, which can be abrupt for running processes, so it should only be used when the shutdowncommand is blocking you from powering down.

On many systems, reboot is actually a call to systemctl with the appropriate reboot or power off option.

 

Init

On Linux distributions without systemd, there are up to 7 runlevels your computer understands. Different distributions can assign each mode uniquely, but generally, 0 initiates a halt state, and 6 initiates a reboot (the numbers in between denote states such as single-user mode, multi-user mode, a GUI prompt, and a text prompt).

These modes are defined in /etc/inittab on systems without systemd. On distributions using systemd as the init system, the /etc/inittab file is either missing, or it’s just a placeholder.

The telinit command is the front-end to your init system. If you’re using systemd, then this command is a link to systemctl with the appropriate options.

To power off your computer by sending it into runlevel 0:

sudo telinit 0

To reboot using the same method:

sudo telinit 6

How unsafe this command is for your data depends entirely on your init configuration. Most distributions try to protect you from pulling the plug (or the digital equivalent of that) by mapping runlevels to friendly commands.

You can see for yourself what happens at each runlevel by reading the init scripts found in /etc/rc.d or /etc/init.d, or by reading the systemd targets in /lib/systemd/system/.

 

Apply brute force

So far I’ve covered all the right ways to reboot or shut down your Linux computer. To be thorough, I include here additional methods of bringing down a Linux computer, but by no means are these methods recommended. They aren’t designed as a daily reboot or shut down command (reboot and shutdown exist for that), but they’re valid means to accomplish the task.

If you try these methods, try them in a virtual machine. Otherwise, use them only in emergencies.

 

 

Proc

A step lower than the init system is the /proc filesystem, which is a virtual representation of nearly everything happening on your computer. For instance, you can view your CPUs as though they were text files (with cat /proc/cpuinfo), view how much power is left in your laptop’s battery, or, after a fashion, reboot your system.

There’s a provision in the Linux kernel for system requests (Sysrq on most keyboards). You can communicate directly with this subsystem using key combinations, ideally regardless of what state your computer is in; it gets complex on some keyboards because the Sysrq key can be a special function key that requires a different key to access (such as Fn on many laptops).

An option less likely to fail is using echo to insert information into /proc, manually. First, make sure that the Sysrq system is enabled:

sudo echo 1 > /proc/sys/kernel/sysrq

To reboot, you can use either Alt+Sysrq+B or type:

sudo echo b > /proc/sysrq-trigger

This method is not a reasonable way to reboot your machine on a regular basis, but it gets the job done in a pinch.

 

Sysctl

Kernel parameters can be managed during runtime with sysctl. There are lots of kernel parameters, and you can see them all with sysctl --all. Most probably don’t mean much to you until you know what to look for, and in this case, you’re looking for kernel.panic.

You can query kernel parameters using the -–value option:

sudo sysctl --value kernel.panic

 

If you get a 0 back, then the kernel you’re running has no special setting, at least by default, to reboot upon a kernel panic. That situation is fairly typical since rebooting immediately on a catastrophic system crash makes it difficult to diagnose the cause of the crash. Then again, systems that need to stay on no matter what might benefit from an automatic restart after a kernel failure, so it’s an option that does get switched on in some cases.

You can activate this feature as an experiment (if you’re following along, try this in a virtual machine rather than on your actual computer

 

sudo sysctl kernel.reboot=1

 

Now, should your computer experience a kernel panic, it is set to reboot instead of waiting patiently for you to diagnose the problem. You can test this by simulating a catastrophic crash with sysrq. First, make sure that Sysrq is enabled:

 

sudo echo 1 > /proc/sys/kernel/sysrq

And then simulate a kernel panic:

sudo echo c > /proc/sysrq-trigger

Your computer reboots immediately.

 

Reboot responsibly

Knowing all of these options doesn't mean that you should use them all. Give careful thought to what you're trying to accomplish, and what the command you've selected will do. You don't want to damage your system by being reckless. That's what virtual machines are for. However, having so many options means that you're ready for most situations.

Have I left out your favorite method of rebooting or powering down a system? List what I’ve missed in the comments!

 

BOTONFACEBOOK COMMUNITY BOTONTELEGRAMCHANNEL

 Source: opensource.com Please visit and support the linux project.

BANNERLINUXFINALESPAOL

Published in GNU/Linux Rules!

BANNERGnulinuxrocks

 

What is a multi-user Operating system ? When the OS allows multiple people to use the computer at the same time without affecting other's stuff, it becomes a multi-user OS. Like wise Linux is also belongs to above mentioned category. There can be having multiple users, groups with their own personal files and preferences. So, this article will be helpful for you in below actions.

 

  • Managing Users ( Create/Edit/Delete accounts, Suspend accounts )
  • Manage User's Passwords ( Set Password policies, Expiration, further modifications )
  • Manage Groups ( Create/Delete user groups )

 

From this article we will discuss mostly useful Linux commands with their syntax's.


How to create a user

 

1) useradd : Add a user

 

syntax : useradd 

eg : We will create a user named ""Jesica". The command is useradd jesica . First i switch to root user with sudo su command as i am a sudo user.

UGLINUX1.png

You can see when we created the user in root account, it just added the user without asking the password for the newly created user. So now we will create a password for the user jesica.

 

 

2) passwd : set a password for users

 

syntax : passwd 

UGLINUX2.png

Here, i set a password for jesica. I set the password also as "jesica".You can use your own. The password you are writing will not be displayed for security reasons. As my password only having 6 characters, we get a message saying password is shorter than 8 characters. Those are password policies. We will discuss later in this article.

 

* Now we have created a new user with command useradd and set a password with passwd command. This is done in CentOS. But in some other linux distributions, adduser command will be used instead of useradd.

 * If you are a normal user, you have to be a super user to add a new user. So you have to use the commands as sudo useradd and sudo passwd .

 

Where all of these users are residing ?

We discussed these stuff in "Linux File System Hierarchy" article. As /root directory is root user's home directory, normal user's home directory is /home. Inside of /home directory all the user's profiles are stored. You can use the command ls /home to check who are currently in your OS. Check the below image, which shows my users in my OS.

 UGLINUX3.png

 

 

What is /etc/passwd file ?

 

When you created a user with command useradd without any options, there are some configuration file which are changing. Those are as below

 

  1. /etc/passwd
  2. /etc/shadow
  3. /etc/groups
  4. /etc/gshadow

 

Output of the above files are as below according to my OS.

 

1. /etc/passwd file

UGLINUX4.png

 

 

2. /etc/shadow file

UGLINUX5.png 

 

3. /etc/group file

UGLINUX6.png

 

When we created a new user with useradd command without any options, /etc/passwd file sets reasonable defaults for all field in that file for the new user. It is just a text file which contains useful information about the users like username, user id, group id, user's home directory path, shell and etc.

 

If we discuss about the fields in /etc/passwd file, eg : student:x:1000:1000:student:/home/student:/bin/bash

 

1. student : This is the username. To login we use this name.

 

2. x : This is the password. This is an encrypted password stored in /etc/shadow file. You can see the password record in /etc/shadow file for user student in the above image.

 

3. 1000 : This is the user id. Each an every user should have UID. This is zero for root user and 1-99 is for predefined user accounts and 100-999 is for system administrative accounts. Normal users are having User IDs starting from 1000. Extra - Also you can use command id for viewing user details.

 

4. 1000 : Primary group ID ( GID ). see /etc/group file on left side.

5. student : Comment field

6. /home/student : User's home directory

7. /bin/bash : The shell used by the user

 

 

* Summary of the above

 

  • When a user created, new profile will be created in /home/username by default
  • Hidden files like .bashrc , .bash_profile , .bash_logout will be copied to user's home directory. Environmental variables for the user is set by those hidden files and they will be covered in future articles.
  • A separate groups will be created for each user with their name.

 

Useradd command with some options

 

1.) If accidentally user's home directory is not created with useradd command.

 UGLINUX7.png

 

If you want to create a user without the home directory, useradd -M panda.

 

2.) If you want to move your home directory to a separate directory

UGLINUX8.png 

 

In the above command you have to use useradd command and then -d option for changing the default home directory path and /boo is the new home directory. Last put the username. You can see the below image. /etc/passwd file has a different home directory entry for user boo, Because we changed it's home directory.

UGLINUX9.png 

 

3.) Add a comment for the user when adding

UGLINUX10.png 

 

In /etc/passwd file :

UGLINUX11.png 

 

 

4.) Create a user by your own UID, useradd -u

5.) Create a user by your own UID and GID, useradd -u -g

6.) Create a user adding to a different groups, useradd -G There groups can be one or more and should be separated with a comma (,) the groups.

7.) To create a user, but disable shell login useradd -s /sbin/nologin With the above command, we can disable shell interaction with the user. But the account is active.


 

How to remove an account

 

3. userdel : Remove a user

 

syntax : userdel

 

eg : userdel -r

 

* When deleting the user, go with option -r. Why is it ? With -r option, it removes user with it's home directory. If removed without -r option, user's home directory will not be deleted.


 

How to modify an user account

 

4. usermod : Modify a user

 

syntax : usermod

 

* Here we can use all the options used in useradd command. Below are some options which is not discussed above.


 

1.) How to change the user's name

 

usermod -l

 

2.) To lock a user

 

usermod -L

 

3.) To unlock a user

 

usermod -U

 

4.) To change the group of a user

 

usermod -G

 

5.) To append a group to a user

 

usermod -aG

 

* Here appending means adding groups without removing the already existing groups. But if we use without -a, it removes the existing groups and join to new groups. This is relevant under primary groups and supplementary groups.

 

What is a group ?

 

Group is a collection of one or more users in Linux OS. Same as users, groups also have a group name and a id ( GID ). The group details can be found in /etc/group file. There are two types of main groups in Linux OS. Those are Primary groups and Supplementary groups. Every user once created is getting a new groups with the user's account name. That is the primary group and Supplementary groups are groups having one or more users inside.


 

How to create a group

 

4. groupadd : create a linux group

 

syntax : groupadd

 

Few examples

 

1.) To create a group named "student"

 

groupadd student

 

2.) Define a different group id ( GID )

 

groupadd -g 5000 student


 

How to modify an existing group

 

5. groupmod : modify a group

 

syntax : groupmod <options> <group name>

 

To change the name of the group, groupmod -n To change the group if, groupmod -g

 


 

How to delete an existing group

 

6. groupdel : delete a group

 

syntax : groupdel <group name>


 

How to manage user passwords using password policy ?

 

As we discussed above, while /etc/passwd file stores user details, /etc/shadow file stores user's password details. I attached an image of /etc/shadow file in the above. Here we use a term named Password aging. From that we use command chage edit the password aging policy. Look at the below image.

 UGLINUX12.png

Refer the above image and the options are as below.

 

  • chage -d 0 : Forcefully request the user to change the password in the next login.
  • chage -E Year-Month-Date : To expire an user account ( It should be in format YYYY-MM-DD ) 
  • chage -M 90 : Set password policy for requesting password should be renewed in every 90 days
  • chage -m 7 : Minimum days should be 7 to wait for changing the password again.

 

* Inactive days are set to define from how many days the account will be kept inactive after password expiration. If the user didn't change the password within inactive period, the account will be expired. 

 

chage -l : To display user's current settings for password policy.

 

The default values for all of the above values ( password expiration days, inactive days and etc ) will be in the configuration file, /etc/login.defs text file. Including User account ID , Group Account ID configurations also can be seen there. You can change the values in the /etc/login.defs file as your requirement.

UGLINUX13.png 

 

Now you have learned mostly needed stuff in Linux Users and Groups. This is not a small topic. There are a lots of commands you need to refer under this topic.

 

 You can see our previous posts with related topics

 

 

 

 

 

BannerFinalGNULINUZROCKS

Published in GNU/Linux Rules!

BANNERGnulinuxrocks

Gaming in Linux has evolved a lot in the past few years. Now, you have dozens of distros pre-optimized for gaming and gamers. We tested all of them and hand-picked the best. There are a few other articles and lists of this type out there, but they don’t really go into detail and they are pretty outdated. This is an up-to-date list with any info you’d need.

How to choose the best Linux distro for gaming

Before we start listing out the best distros, you’d still need to choose one of them. Here are a few guidelines you can use to help you choose the right one for you:

  • Any Linux distro can be used for gaming. You can install Linux games on any distro or you can use tools like PlayOnLinuxWineSteam and a bunch of other emulators. At the end of the day, it all boils down to which one you personally prefer. Try them out. Use a live CD (flash drive) image and test it out without even installing it. Watch some videos, check some screenshots, read some reviews…
  • The main feature that matters when choosing a distro for gaming is support for drivers. Most distros support the latest (and even oldest) hardware out of the box. Even if they don’t, you can still manually find and install the driver yourself on any distro. If you’re really unsure, you can just google some info for your hardware and see if the distro supports it out of the box.
  • Second most important feature is update frequency. Is it a rolling release distro like Manjaro (very frequent updates without a schedule, always the latest software)? Or is it a point release distro like Ubuntu (scheduled updates, not always the latest software). If you prefer to always use the latest versions of any software and apps, go with a rolling release distro. That way, you’ll always get the latest driver updates and you’ll most likely already have the latest drivers for your new GPU/CPU. If you’d like to stick with what you know and use a more stable OS, go with a point release distro.
  • Previous Linux experience should also be a deciding factor. Have you used a Linux VPS before? Which distro did you use for your server? If it was Ubuntu, then you should choose the desktop version of Ubuntu since you’ll be more familiar with it. If you’ve used CentOS for your server, go with a Fedora-based distro for gaming. Did you use an LXDE distro? Go with a gaming distro that uses LXDE.

Now, let’s move on to the main part.

Best Linux Distro for Gaming

Here’s a 8 examples to help you choose the best Linux distro for you:

1. SteamOS

There’s a reason why SteamOS is always the first on every Linux gaming distro list. It’s designed with gaming in mind. It comes pre-installed with Steam and it’s based on Debian. SteamOS is built, designed and maintained by Valve. By default, SteamOS only has Steam installed, but you can activate the “desktop mode” and you’ll get a fully-featured desktop OS where you can run other applications besides Steam and games. It has everything set up out of the box, so you don’t need to install or configure anything to play on Steam, which is why this is the most recommended distro for beginners and Linux gamers.

SteamOS hardware requirements

However, if you have an older machine, SteamOS is not recommended, as it has quite a lot of hardware requirements:

  • Intel or AMD 64-bit capable processor
  • 4GB or more RAM
  • 250GB or larger disk
  • NVIDIA, Intel, or AMD graphics card

SteamOS facts and features

Linux and Steam for gamers.

  • Steam is preinstalled out of the box
  • Ready to play games without needing to install any additional software
  • Free and open source (apart from Steam itself, which is proprietary)
  • Support for many graphic cards, controllers and other gaming-related hardware

Visit their official website for download/installation instructions and FAQ:
Download SteamOS


Let’s move on to the next distro on our list:

2. Ubuntu GamePack

t’s not the default Ubuntu, but it’s a distro based on Ubuntu. You can still use the default Ubuntu and install Play on Linux, Wine and Steam or any other game you’d want to, but it would not be as optimized for gaming as Ubuntu GamePack is.

Ubuntu GamePack hardware requirements

Quite similar to the default Ubuntu, this distro requires:

  • 2 GHz or more processor (64-bit recommended)
  • 1GB RAM or more
  • 9GB disk (the more the better)
  • VGA capable of 1024×768 screen resolution. Intel HD graphics/AMD Radeon 8500 for Steam games and any other GPU for other games.

Ubuntu GamePack facts and features

Ubuntu for gamers.

  • Pre-installed with Lutris, PlayOnLinux, Wine, and Steam
  • Great hardware drivers support
  • Low(er) hardware requirements
  • Free and open source OS
  • Supports Flash and Java (great for online, browser-based games)

If you’re already familiar with Ubuntu, go with this distro.

Visit their official website for download/installation instructions and FAQ:
Download Ubuntu GamePack


 

The second most popular Linux distro used for desktop computers is Fedora. Luckily, Fedora also has a gaming flavor (spin):

3. Fedora – Games Spin

Fedora – Games Spin has thousands of games already pre-installed and ready to play. It doesn’t support as much hardware as some other distros, and it doesn’t come with Wine/Steam pre-installed, which is why this is not recommended for anyone. However, if you’re already familiar with Fedora or if you like the XFCE desktop environment, this distro would be perfect for you.

Fedora Games Spin hardware requirements

Similar to the Fedora desktop distro:

  • 2 GHz or more processor (64-bit recommended)
  • 1GB RAM or more
  • 10GB disk (the more the better)
  • Intel HD graphics/AMD Radeon 8500 for Steam games and any other GPU for other games.

Fedora Games Spin facts and features

For Fedora users.

  • Has thousands of games already pre-installed
  • Stable, but not with the latest software and doesn’t have pre-installed drivers for all hardware
  • Steam and Wine are not pre-installed
  • Free and open source
  • Uses the XFCE Desktop Environment

If you’ve used Fedora (or CentOS) before, either for a server or for your desktop computer, try this Fedora spin.

Visit their official website for download/installation instructions and FAQ:
Download Fedora – Games Spin


 

Moving on to the next one:

4. SparkyLinux – GameOver Edition

SparkyLinux is a Linux distribution created on the “testing” branch of Debian. It uses the LXDEdesktop environment and it has everything you’d need already pre-installed.

SparkyLinux – GameOver Edition hardware requirements

A very lightweight distro.

  • CPU i586 / amd64
  • 256 MB of RAM memory (some games need more than that – 500-1000MB recommended)
  • 20 GB of space for installation on a hard drive (30GB recommended)

So just about any old PC/laptop can run it without any issues.

SparkyLinux – GameOver Edition facts and features

Ready out of the box.

  • Has everything you’d need pre-installed out of the box. Wine, Play On Linux, Steam etc.
  • Many open source Linux games pre-installed
  • Emulators and tools for easily installing emulators
  • Free and open source

If you’ve used an LXDE Linux distro before and you want everything pre-installed, go with SparkyLinux – GameOver Edition.

Visit their official website for download/installation instructions and FAQ:

Download SparkyLinux – GameOver Edition


 

Gaming doesn’t have to be all 2019 and bleeding-edge. You may be into retro games, which is where this distro comes to play:

 

5. Lakka

Although it’s based on Linux (kernel), it doesn’t have any desktop environment and you can’t really use it for anything other than turning a computer into a retro gaming console.

Lakka hardware requirements

You can turn any computer into a console since Lakka doesn’t have a lot of requirements. You can even use a Raspberry Pi to run Lakka. It’s a very lightweight OS that can run on just about anything.

Lakka facts and features

For retro gamers.

  • Pre-installed and optimized with various emulators
  • Very lightweight with minimum hardware requirements
  • Beautiful, easy-to-use UI
  • Free and open source with various retro games to choose from

Visit their official website for download/installation instructions and FAQ:
Download Lakka


Game Drift Linux is no longer being maintained. Though you can still use it, we wouldn’t recommend using it. We’ll leave their spot here for archive purposes, but there are other actively maintained alternatives if you’re looking for a gaming distro.

Want to play Windows games on a Linux distro without too many configurations?

6. Game Drift Linux

Based on Ubuntu, this distro would be perfect for beginners that previously used Ubuntu. Easy to install and everything works out of the box.

Game Drift Linux hardware requirements

Although not the most lightweight Linux distro for gaming, it doesn’t require much. At least not as much as SteamOS.

  • 1-2 GHz processor (32 or 64 bit)
  • 1-2 GB RAM
  • 4 GB hard disk drive for Game Drift Linux (excluding games)
  • ATI, NVidia or Intel graphics adapter suitable for games

If you can run Ubuntu desktop, you can run Game Drift Linux.

Game Drift Linux facts and features

You can play A LOT of Windows games on Game Drift Linux. It has all the tools you need pre-installed.

  • Has a game store with free and premium games – all run perfectly on Game Drift Linux. High-quality games only
  • You can play more than 1200 Windows games (due to CrossOver Games technology)
  • The distro itself is free, but you need to purchase an activation key for CrossOver Games in order to play more than 1200 Windows games
  • Based on Ubuntu

The game store is great – a wide choice of quality games that you can install with a single click.

Visit their official website for download/installation instructions and FAQ:

Download Game Drift Linux


Need a full-featured Linux distro for gaming, media, browsing and general use?

7. Solus

Recently this year, Solus became a rolling release distro, which means that you’ll get the latest software with all the latest updates. Solus looks great, especially with the Budgie desktop environment. It has all the features you need for an OS for gaming/media playback/browsing/general use. There’s an official Steam integration for Solus which will greatly help you with installing and configuring steam on your Linux system. It’s based on the Linux kernel, but it’s independent of any other distro like Ubuntu or Fedora.

Solus hardware requirements

Although not the most lightweight Linux distro for gaming, it doesn’t require much. At least not as much as SteamOS.

  • Intel/AMD CPU (64 bit recommended). ARM-based processors won’t work
  • 2GB RAM Minimum, 4GB+ recommended
  • 10GB+ storage
  • ATI, NVidia or Intel GPU suitable for games

Requires a more powerful machine.

Solus facts and features

Everything built into one modern system.

  • Has different desktop environments to choose from: Budgie, Mate, and GNOME
  • Modern – has notification features
  • Free and open source
  • Can be used for everything – including gaming, browsing, general home use etc. Everything’s set up out of the box
  • Rolling release – you’ll get the latest updates and latest software all the time.

Solus looks great. One of the best looking Linux distros out there today, especially with its flagship desktop environment Budgie.

Visit their official website for download/installation instructions and FAQ:

Download Solus


Want to use the Manjaro (rolling release) distro?

8. Manjaro Gaming Edition (mGAMe)

mGAMe, which is based on Manjaro, which is based on Arch Linux, is a rolling-release gaming distro with everything you need pre-installed. Steam, PlayOnLinux, Lutris, Minecraft, Editing Tools, and a bunch of other emulators are already installed. You can easily enable the “living room mode” in which case you won’t need a mouse – you can do everything with your controller or keyboard.

mGAMe hardware requirements

Although not the most lightweight Linux distro for gaming, it doesn’t require much. At least not as much as SteamOS.

  • At least 1GHz processor
  • At least 1GB RAM
  • At Least 30GB storage
  • ATI, NVidia or Intel GPU suitable for games and HD

If you don’t have enough hardware requirements to run Solus, but still need a rolling-release distro, go with mGAMe.

mGAMe facts and features

Everything’s pre-installed and ready to play.

  • Pre-installed Software and Emulators list: Audacity, KdenLIVE, Lutris, Minecraft, Minetest, Mumble, OBS Studio, OpenShot, PlayOnLinux, Wine, DeSmuME, Dolphin Emulator (64-Bit only), DOSBox, Fceux, Kega Fusion, PCSXR, PCSX2, PPSSPP, RetroArch, Stella, VBA-M, Yabause, ZSNES…
  • Steam is not pre-installed, you’ll have to install it manually.
  • XFCE desktop environment
  • Rolling release – you’ll get the latest updates and latest software all the time.

A great, more lightweight rolling-release distro for gaming.

Visit their official website for download/installation instructions and FAQ:

Download mGAMe


Wanna turn any computer into a Linux gaming machine?

9. SuperGamer

The new v4 of SuperGamer was recently released and no longer includes some open source games pre-installed, but you can easily install them, or install an app like Steam. The distro is optimized for gaming and ready to use via a live DVD/USB. It’s a great distro for testing out a machine.

SuperGamer hardware requirements

The distro is based on Ubuntu 16.04 and Linux Lite and only works with 64bit.

  • Intel/AMD CPU (64 bit recommended). ARM-based processors won’t work
  • 1.5GB RAM Minimum
  • 2GB+ DVD/Flash Drive
  • ATI, NVidia or Intel GPU suitable for games

Ready to use, no installation needed.

SuperGamer facts and features

A live Linux gaming distro.

  • Based on Ubuntu 18.04 and Linux Lite.
  • Free and open source.
  • Optimized for gaming.

Visit their official website for download/installation instructions and support via their forums:

Download SuperGamer


Feeling nostalgic for the good old games? Play them without installing a distro.

10. batocera.linux

batocera.linux is another live Linux gaming distro similar to Lakka.tv that you can use for retro gaming. Easy to install, easy to set up, and comes pre-installed with everything you need. A great way to go back in time and play the good old retro games.

batocera.linux hardware requirements

A live Linux distro ready for retro gaming with an active community.

  • Any supported CPU, at least 2.4GHz for some games.
  • 512MB RAM
  • 2GB+ DVD/Flash Drive
  • ATI, NVidia or Intel GPU supported by Linux

Ready to play retro games, no installation needed.

batocera.linux facts and features

A live Linux gaming distro.

  • Can run on a Raspberry Pi or any other nano PC
  • Free
  • Optimized for retro gaming (more than 50 consoles, including Dreamcast. Wii, PS2)
  • Fully controllable from a pad
  • You don’t need to stop it and shut it down properly, it behaves like a real console
  • You can use an USB flash drive or SD card
  • Pre-installed with Kodi
  • Has exclusive builds for Odroid devices

Visit their official website for download/installation instructions and support via their forums:

Download batocera.linux


Honorable mentions

Here’s something extra you can explore when it comes to Linux gaming:

  • live.linuX-gamers.net – a live Linux gaming distro – hasn’t been updated since 2011
  • LinuxConsole – lightweight gaming distro with a few games pre-installed
  • RetroArch – a frontend for emulators, game engines, and media players. Great for retro games and nano PCs.
  • RetroPie – turns your nano PC into a retro gaming machine

Which distro do you use? What kind of a Linux gaming setup do you have? Did we miss something? Leave a comment below!

BannerFinalGNULINUZROCKS

Published in GNU/Linux Rules!

BANNERGnulinuxrocks

Linux-based operating systems (often called Linux Distributions, or just Distros) are quite popular among programmers and developers since their announcement in the 90s. The Linux kernel itself is designed to be flexible and open for modifications and contributions, thus it can run on any hardware. The same principle is applied to almost the whole software stack above the kernel that constitutes the Linux Distribution as a complete product. In general, it is designed from programmers for programmers and freely available to everyone.

 

 

All of the Linux-based distributions share common code – the Linux Kernel itself, but many different methods of software distribution to the end users appeared. Some of them tend to provide a stable environment while others tend to provide the very latest software available all the time.

Stable vs Rolling Distros for Development

Linux-based distributions that are focused on stability achieve it by freezing the software as much as possible. An updated version of some software will be distributed to end users only in critical situations. Most of the time those are security updates and bug fixes but for sure no new features are being added until the end of life for that release is reached. In short, if it is not broken don’t fix it.

There are Linux distributions that tend to offer the latest of everything. “Latest must be greatest” is in their genes. Usually, the term rolling distribution is used as a description for these distros. It is very common to receive an update every hour or two. Although this looks like an awesome concept, in practice it is shown to bring some sort of instability with it and in some cases, even breaking the system.

There are pros and cons in both. Stable distributions prefer safety rather than features. This is important if you are working on a product that must be running 24/7 and must be error-free. They are often used for servers, data centers, and home users. Developers choose this type of distribution when they need to provide long-term support for the product or if the developing of the product requires an extended amount of time, like 5 or more years.

For programmers, each of their programs relies on features offered by some other program. Those are called dependencies. A stable environment can guarantee that no bugs will appear overnight due to changes in some of the dependencies. In other words, if there is a bug, don’t waste time trying to find it somewhere else rather than in your own code. This saves a lot of time and frustration.

The cons of the stable environment is that most of the time they are lacking all the cool new features. Sometimes this forces developers to utilize a harder route to achieve the desired point and nothing else. But sometimes this means that end product will run slower in production due to missing optimizations in some of the dependencies, or it will be less secure due to unpatched exploits etc.

Rolling Distributions prefer and lean towards new features and bleeding-edge software as compared to stable ones. Those are preferred among programmers and developers working on continuous integration. For example, if a program is tightly coupled with many dependencies.

Being informed of every change in your dependencies forces developers to resolve minor conflicts on a daily basis. This opens an opportunity to immediately inform third parties that they are breaking your code. Sometimes it is much easier to release a fix on their side instead in your own. Asking them to undo all the patches released in the last few years because just now you are aware of having a problem with them is a no-go. Simply, they won’t accept the undo request, so everything must be fixed on your side.

Also, you have a chance to develop your product with the latest and greatest tools available at the time. This can improve the performance, reduce the cost, can introduce a new and easier way of doing things (new API) etc.

It’s worth noting that constantly throwing updates can break things. Most of the time it is about not simultaneously updating to a new release when needed. Some apps are intended to work with the exact version of another app so breaking this creates undesired behavior. In this case, both apps must be updated at the same time which is not the case in a rolling release model.

Best Linux Distros for Programming Compared



Now, to the main part, choosing the best Linux distro for you. This is an overview and comparison of the best Linux distros for programming.

 

1. Ubuntuubuntu.jpg

 

Ubuntu is the most popular Linux Distribution among all of them. It is used by programmers and most of the home users too.

There is one major release every two years. This is called an LTS (Long Term Support) release. Those are stable thus receiving only bug fixes and security updates in next 5 years. As the release model prefers stability its underlying layers are mostly stable (unchanged) during this 5 years period. The latest LTS release as of writing is Ubuntu 18.04 LTS.

There is one non-LTS release every 6 months supported for a period of 9 months. Those releases are not considered as stable. Big and significant changes can occur in every release. Sometimes those releases are caring packages that break dependencies with a previous release. It is like a playground for merging software and continuously searching for incompatibilities in a desire to provide the best fit solution for the next LTS release. Developing software in this kind of unpredictable environment is not clever. But in real life, it is not so frightening.  Even non-LTS releases offer a crash-prone environment. Many home users are using them as a daily driver with no issues at all. They see a benefit from having more recent software than what is available in the latest LTS release for example.

As you can see it is a mix of everything. You can have 5 years or stability, or stability for 9 months depending on what fits the best. Even mixing packages is possible but not recommended. A user of an LTS release can obtain a newer version of the same software from a more recent non-LTS release. This is handy as a one-time workaround but it is like a tempered bomb waiting to break the system. Pooling recent packages will continue until some incompatibility occurs. It is better to switch to a non-LTS version instead.

It is worth mentioning that Ubuntu is the place where developers and home users meat each other. Therefore, Ubuntu is the starting point for a company offering a product or a service on a Linux-based operating system. Here they find an environment that is stable and familiar to the developers but also many target users. In addition, it is best to develop the software in the native environment as the product or service that’s going to be deployed and used in production. Sounds like a perfect balance.

Ubuntu is one of the most popular Linux distro for servers, and most people use it as their main distro with their Cloud hosting.

Some of the companies that love Ubuntu and that are offering their products or services on Ubuntu as a first choice are: Nvidia, Google, Dell, STMicroelectronics etc. Most companies that sell Linux laptops offer Ubuntu as the first choice for a pre-installed distro.

  • Nvidia is offering the CUDA toolkit natively on Ubuntu as a first choice. Only the LTS releases are officially tested and supported, thus Ubuntu is the best fit if you rely on CUDA for your project. But it is not exclusive. The CUDA toolkit is available on non-LTS releases and many other Linux-based distributions, but without support or guarantees that things will behave as expected.
  • Google is the company behind Android. They offer developing Android applications on Windows, Mac OS, and Linux-based distributions. Ubuntu is their first choice. Android Studio (IDE) and all other tools are tested on LTS releases of Ubuntu before distribution to end users.
  • STMicroelectronics is a company producing ARM-based CPUs for embedded devices. Developing software for their CPUs is possible on Windows, Mac OS and Linux-based distributions. They support Open STM 32 for developing a free and cross-platform IDE, System WorkBench. Again, LTS releases of Ubuntu is their first choice for a Linux Distribution.
  • Dell is known for their laptops, ultra-books, PCs and monitors. Their products are mostly offered with Windows preinstalled and Ubuntu for some of them. The Dell XPS 13 Developer Edition is a small, light, fast, and beautiful, and runs an Ubuntu LTS release by default.

There are more companies that offer and use Ubuntu, but this should give you an idea of how software and development companies incorporate Ubuntu.

 

 

2. Arch Linux

arch-linux-gn.jpg

 

Arch Linux is just the opposite of Ubuntu. It is a rolling release Linux Distribution. There are constantly new updates. Every hour or two something new arrives in your system. It is a perfect working environment for some. As we mentioned earlier this type of software distribution is best suitable for developers working on software that is highly coupled with some or many dependencies. They will receive an updated version of their dependencies with almost no delay. But this comes at a price for sure. The instability of the system offers no guarantees for the origins of the new bugs.

Also, Arch Linux is hard to install. An advanced user can do it in no more than 15 minutes, but it is almost impossible for a newcomer to succeed. It requires a lot of knowledge because there is nothing preconfigured, there is no default, everything is custom instead. A pure mechanism for distributing software and nothing more, it is up to the user to install and configure things according to their personal requirements. This is why many people use Arch Linux as a lightweight Linux distro, by installing a lightweight window manager/desktop environment, and only the essential software. As you can already see Arch Linux provides a perfectly configured environment for every developer that knows how to utilize it.

Every Arch Linux is unique thus each of them encounters unique obstacles. This is what makes it special and loved among programmers. Just by using it on daily basis you grow. There is a giant and thorough wiki page. It’s one of the best wikis you can find with very detailed and strict explanations and guides for configuring stuff and encouraging the use of what is said to be good practice. Its necessity can be seen just when you try to install it (as we mentioned earlier, it is hard if not following the wiki the first time). Reading documentation may seem like wasting time but it is an essential skill for every programmer. Just by reading good documentation developers also learn how to write good documentation.

Tinkering here and there with the operating system itself will teach you how one works so you can build your own later. It’s an important skill to have, especially if you end up working with embedded devices in your career. Every day you can read about some unexpected issues on the forum and very clever workarounds for each of them. Just being aware of what might go wrong makes a developer produce code with better quality if paying attention.

The best thing about Arch Linux is its huge repository of available software. Personally, I can’t think of something that I need that is unavailable. Although the software is there, because of the very different configurations among users, the quality of provided software can be lower than expected. It is not unusual if users need to get their hands dirty doing some minor manual intervention. It’s brilliant for improving skills but some can struggle with the maintenance at the beginning.

It’s worth to be mentioned that there are no devices that come with Arch Linux preinstalled. It is painful to do so since until the device reaches the customer, the software is out of date and performing one giant update is very likely to break the system (while constant minor updates don’t). Even if some vendors do, advanced users will find it uncomfortable and will change it anyway.

 

3. Fedora

fedora548401.jpg

Fedora is another popular Linux Distribution among programmers. It is just in the middle between Ubuntu and Arch Linux. It is more stable than Arch Linux, but it is rolling faster than what Ubuntu does.

There is one major release every 6 months supported for 13 months. Basically, 13 months of a stable environment is just fine. Also, 6 months of delay between the next big update is fine too. No software is growing so fast so it is good even for those who want to experience and work with the latest stuff in a stable environment while still doing their integration job without issues. Excellent balance as Ubuntu does but with a smaller amount of home users.

In terms of software availability, there is no such broader range as in Ubuntu or Arch Linux. If you are looking for proprietary software the situation is even worse. There isn’t any official support for it. But if you are working with open source software instead Fedora is excellent.

The people behind Fedora embrace free and open software and do the best for it but it is a big no go for any proprietary stuff. You can’t find Java, DVD codecs, Flash Player etc. Of course, all those are available in some private repositories with weaker license policies but they are not officially supported so no guarantees for any incompatibilities or misbehavior. It is a big issue if you are working on a project that costs money or that is expected to have a big impact because you don’t want to rely on unreliable sources. You want support instead. On Ubuntu for example, companies do offer support for their proprietary software.

There are several Fedora “Spins”, which are similar to Ubuntu flavors. It’s basically Fedora with software pre-installed for a specific purpose, but the main difference is the desktop environment. We featured the Games Spin of Fedora in our Best Linux Gaming Distros list.

Do not forget that the Fedora project is founded by Red Hat Linux distribution which is targeting the enterprise sector and offer paid support for it. Fedora is like a playground but a good one. At some point, the Fedora release will become a Red Hat release. Everybody has some benefits. Big companies receive a rock solid and stable system with years-long support (from Red Hat) while casual users receive a big amount of free software and a stable environment that is more recent than Ubuntu (from Fedora).

Just like Arch Linux, there are no devices with Fedora preinstalled because of very short time between major releases. In 6 months there is no time for manufacturers to produce and sell the device.

There are hundreds of Linux distros out there, each more different than the other. Though the 3 distros we mentioned are great for developers, you may find a better fit in a different distro. For example, if you’re developing an application that’s supposed to run on a server, you may need to use a server distro like Ubuntu or CentOS. So do your research and you may find a better one for you.

 

Overview of The Best Tools for Programmers on Linux

Out of the box, no distro comes with IDEs and toolkits pre-installed, neither Windows nor Mac OS do, so developers have to install them manually. Only a simple text editor like gedit or nano (command line text editor) can be found preinstalled. Some popular IDEs are: Eclipse, QT Creator, NetBeans etc. but many developers dislike IDEs in general and use simpler text editors like Sublime, Atom or Vim instead.

Eclipse is the most commonly used IDE. It supports multiple programming languages like C, C++, Java etc. Its basic features can be extended by various plugins. This allows a company to develop a complete IDE for their product just by writing a small plugin and relying on Eclipse for everything else.

Until 2016, Eclipse was actively supported by Google as the recommended IDE for Android applications development. Later Google migrated to InteliJ IDE and abandoned Eclipse, but users continued developing plugins like gradile-android-eclipse and still providing easy to use Android IDE based on Eclipse.

Eclipse is the recommended IDE for CUDA development on Linux-based operating systems (Visual Studio for Windows). Nvidia is distributing a slightly customized version of Eclipse called Eclipse Nsight. For them, It is much easier to provide an IDE by reusing components, but also it is even easier for developers when they don’t have to endure the hassle of building custom toolchains even for simple “Hello World” examples.

System Workbench is an IDE for programming ARM-based CPUs.  This IDE is free and built by the community but also supported and recommended by STMicroelectronic, a company that produces ARM-based CPUs. The IDE can be downloaded standalone, or by adding a plugin on top of existing Eclipse installation.

The latest stable version of Eclipse is 4.7, named Oxygen. As Arch Linux tends to have the latest of everything, version 4.7 is available in the repositories. On Ubuntu 16.04, which is latest stable release at the moment. version 3.18 of Eclipse is available while Fedora offers version 4.7 just like Arch Linux.

QT Creator is another very popular IDE. It is developed by the QT Company as an IDE for the QT framework. Although targeting a single C++ framework, because the nature of the language it is commonly used for developing non-QT applications with plain C or C++. It cannot be extended like Eclipse but it is much faster because it is written in C++. Also, it provides better theming options than Eclipse that blends well with the native desktop environment.

On Arch Linux users can obtain the very latest version 4.6 but on Ubuntu, we are stuck with version 3.5 while on Fedora it’s version 4.5.

Netbeans is an IDE for developing in C, C++, Java, PHP, Node JS, Angular JS etc. It is most popular among PHP developers and Web developers. Also, some tend to use it for Android application development with the NBAndroid plugin. There are many other plugins that enable a better integration with various technologies like WordPress, Ruby, Ruby on rails etc. Much like Eclipse.

The latest stable version of Netbeans is 8.2 and the same is available in the Arch Linux repositories. Ubuntu users can obtain version 8.1 while Fedora users must do a manual installation by downloading Netbeans from the website and eventually manually resolving conflicts and dependency issues if any. Just a warning than officially supported software is always of a better quality.

Sublime is one of the most famous text editors available. Sublime is mature, supports extensions and has autocomplete and code highlight for almost any kind of programming. Even though it is just a text editor, its extensions can easily add every feature that is expected from a modern IDE. Those are the main selling points. Once you get familiar with it, you are going to use it for everything.

Ubuntu doesn’t ship Sublime in their repositories, but Sublime developers offer a packaged version in their private repository, just follow the instructions and obtain the very latest version available from their website. Arch Linux also doesn’t distribute it in the official repositories but it is available from the AUR (packaged from users, also unofficially). Fedora requires manual installation too, see their website for instructions.

Atom text editor is an alternative to Sublime. It is free as in freedom and it is based on Electron. Although it has the very same features set and capabilities it tends to be heavier than Sublime so some developers are simply rejecting it.

As with Sublime, Atom on Ubuntu and Fedora can be installed manually by following instructions on the website while on Arch Linux they distribute version 1.25.

Developers who are doing most of the work in a terminal use the Vim text editor, especially on servers. It is a free and extensible command line text editor. It is an improved version of the older Vi text editor. One can use Vim for developing in any programming language or toolkit. Vim is the most customizable of them all by adding additional plugins. It is the most keyboard-friendly text editor available too. Some developers find using the mouse hurting their shoulders and muscles thus being able to do anything with only a keyboard is like being blessed.

Vim behaves like a person. Stand-alone is nothing, but plugins make It evolve to anything. Many actions are just like having a conversation with the editor. For example, to delete next three words after the cursor you just type “d3w” (Delete 3 words) and done, or to move the cursor 4 rows down type “4j” and done. There are many many more similar shortcuts that allow developers to do things faster and easier compared to other text editors or IDEs.

Both Arch Linux and Fedora distribute version 8.0 of Vim, while Ubuntu version 7.6.

 

Introduction to the Linux Shell for Development

Beside IDEs and text editors, Linux-based operating systems are popular because of the Shell. Ba Shell, known as bash, is most commonly found preinstalled on every major Linux distribution but it’s not the only one available. There are zsh, tcsh, ksh etc. They all do the same job but with minor differences that are not part of this introduction. The thing about shells is that they are an environment for interaction with the system. Often shells are used for automating things.

Some tasks through the development lifecycle are repetitive and require time synchronization in terms of executing the next task when the previous is done. Very common in embedded development like build kernel, then waiting until it is done to start building the image, then again waiting to start the transferring the image to the device, and waiting one more time until transfer complete to boot finally boot the device.

The point is that no one wants to sit in front of the PC or sever waiting for a job to finish then manually executing the next one. It is nicer for developers if they can just write the code and let someone or something else to manage task execution in the right order. It’s about not hurting your eyes while paying attention to the execution status. A simple five-line shell script can automate all of this. In addition, the shell can even send a notification to your smartphone when all the jobs are done or if there is a crash.

Another use case when the shell is important is automating the crashes. Knowing that each build generates text output and that the output can be redirected to shell script we can automate the crash handling process. Thus, if compiling fails due to a missing header, a shell script can search the file system to find the location of the header and check if that location is included in our build. If not, then alter the content of a single file and add the path to the header. Now the shell script can simply inform the developer of the crash, what actions were taken if any and retry to compile. This is handy for long-lasting projects.

 

Windows vs Linux for Programmers

Nevertheless, developing on Windows requires installing more additional software. For example, for Android development, device drivers are required. Sometimes drivers might crash or cannot be installed or don’t work on recent versions of Windows (if it is an older device). But a good programmer must have many devices around and test the program on each one of them. This can complicate the setup of the working environment quite a bit.

On Linux distros, this is a very smooth process. All the drivers are already present in the Linux kernel (with just a few exceptions) so no additional installation is required beside the IDE. Just plug in a device and you are ready to go. As smooth as that.

Another use case is when developers have to obtain support for multiple products at the same time. This is fine until two products enforce the existence of software that cannot coexist. For example, version 3.1 of a given program and version 4.2 of the same program but for the other project.

On Windows, installing a newer version often requires deleting the older version. Even if the older version is not automatically deleted, environmental variables are being automatically modified so pooling wrong dependencies or pooling a dependency twice might occur.

On Linux distros, this can be resolved quite easily. Just extract one version in one folder, extract another version in another folder and you are halfway done. Second part is either change the global environment variable to point to only one path, or alter the content of the variable but with a tighter scope. Thus, the same variable will have a different property for different compilations. Isn’t this great? Not just resolving the coexistence problem, in addition, a developer can even run two compiles at the same time without issues.

 

Conclusion – Best Linux Distro for Programmers

In general, Linux-based operating systems offer a more than excellent environment for developers. It just takes some time to learn the cool stuff. No matter which distribution you choose you won’t regret doing it. Just pay attention to the method of software distribution. Choose what suits you best and the projects you are working on. If not sure, just choose Ubuntu, overall it is the best-balanced Linux distribution.

 

BannerFinalGNULINUZROCKS

Published in GNU/Linux Rules!
Wednesday, 08 May 2019 23:04

Using rsync to back up your Linux system

Find out how to use rsync in a backup scenario.

Published in GNU/Linux Rules!

Basic rsync commands are usually enough to manage your Linux backups, but a few extra options add speed and power to large backup sets.

 

It seems clear that backups are always a hot topic in the Linux world. Back in 2017, David Both offered Opensource.com readers tips on "Using rsync to back up your Linux system," and earlier this year, he published a poll asking us, "What's your primary backup strategy for the /home directory in Linux?" In another poll this year, Don Watkins asked, "Which open source backup solution do you use?"

My response is rsync. I really like rsync! There are plenty of large and complex tools on the market that may be necessary for managing tape drives or storage library devices, but a simple open source command line tool may be all you need.

Basic rsync

I managed the binary repository system for a global organization that had roughly 35,000 developers with multiple terabytes of files. I regularly moved or archived hundreds of gigabytes of data at a time. Rsync was used. This experience gave me confidence in this simple tool. (So, yes, I use it at home to back up my Linux systems.)

 

The basic rsync command is simple.

rsync -av SRC DST

Indeed, the rsync commands taught in any tutorial will work fine for most general situations. However, suppose we need to back up a very large amount of data. Something like a directory with 2,000 sub-directories, each holding anywhere from 50GB to 700GB of data. Running rsync on this directory could take a tremendous amount of time, particularly if you're using the checksum option, which I prefer.

Performance is likely to suffer if we try to sync large amounts of data or sync across slow network connections. Let me show you some methods I use to ensure good performance and reliability.

 

Advanced rsync

One of the first lines that appears when rsync runs is: "sending incremental file list." If you do a search for this line, you'll see many questions asking things like: why is it taking forever? or why does it seem to hang up?

Here's an example based on this scenario. Let's say we have a directory called /storage that we want to back up to an external USB device mounted at /media/WDPassport.

If we want to back up /storage to a USB external drive, we could use this command:

rsync -cav /storage /media/WDPassport

 

The c option tells rsync to use file checksums instead of timestamps to determine changed files, and this usually takes longer. In order to break down the /storage directory, I sync by subdirectory, using the find command. Here's an example:

find /storage -type d -exec rsync -cav {} /media/WDPassport \;

 

This looks OK, but if there are any files in the /storage directory, they will not be copied. So, how can we sync the files in /storage? There is also a small nuance where certain options will cause rsync to sync the . directory, which is the root of the source directory; this means it will sync the subdirectories twice, and we don't want that.

Long story short, the solution I settled on is a "double-incremental" script. This allows me to break down a directory, for example, breaking /home into the individual users' home directories or in cases when you have multiple large directories, such as music or family photos.

Here is an example of my script:

HOMES="alan"
DRIVE="/media/WDPassport"

for HOME in $HOMES; do
     cd /home/$HOME
     rsync -cdlptgov --delete . /$DRIVE/$HOME
     find . -maxdepth 1 -type d -not -name "." -exec rsync -crlptgov --delete {} /$DRIVE/$HOME \;
done

 

The first rsync command copies the files and directories that it finds in the source directory. However, it leaves the directories empty so we can iterate through them using the find command. This is done by passing the d argument, which tells rsync not to recurse the directory.

-d, --dirs                  transfer directories without recursing

 

The find command then passes each directory to rsync individually. Rsync then copies the directories' contents. This is done by passing the r argument, which tells rsync to recurse the directory.

-r, --recursive             recurse into directories

 

This keeps the increment file that rsync uses to a manageable size.

Most rsync tutorials use the a (or archive) argument for convenience. This is actually a compound argument.

-a, --archive               archive mode; equals -rlptgoD (no -H,-A,-X)

 

The other arguments that I pass would have been included in the a; those are lptg, and o.

-l, --links                 copy symlinks as symlinks
-p, --perms                 preserve permissions
-t, --times                 preserve modification times
-g, --group                 preserve group
-o, --owner                 preserve owner (super-user only)

 

The --delete option tells rsync to remove any files on the destination that no longer exist on the source. This way, the result is an exact duplication. You can also add an exclude for the .Trash directories or perhaps the .DS_Store files created by MacOS.

-not -name ".Trash*" -not -name ".DS_Store"

 

Be careful

One final recommendation: rsync can be a destructive command. Luckily, its thoughtful creators provided the ability to do "dry runs." If we include the noption, rsync will display the expected output without writing any data.

rsync -cdlptgovn --delete . /$DRIVE/$HOME

This script is scalable to very large storage sizes and large latency or slow link situations. I'm sure there is still room for improvement, as there always is. If you have suggestions, please share them in the comments.

Source: opensource.com

 

 

 

Marielle Price 
Published in GNU/Linux Rules!

linux-icon-t.jpg

We all know that we use cd command to move from one directory to another. To return back to the previous directory, we use “cd ..” or “cd <location_of_previous_directory>” commands. This is how I mostly navigate between directories until I found these trio commands, namely pushdpopd, and dirs. These three commands provides a way faster navigation between directories. Unlike cd command, pushd and popd commands are used to manage a stack of directories. Just enter into a directory and do something you want to do, and “pop” back to the previous directory quickly without having to type the long path name. dirs command is used to show the current directory stack, just like “ls” command. These trio commands are extremely useful when you’re working in a deep directory structure and scripts.

Still confused? No worries! I am going to explain these commands in layman terms with some practical examples.

Use Pushd, Popd And Dirs For Faster Navigation Between Directories

Pushd, popd ,and dirs commands are comes pre-installed, so let us just forget about the installation, and go ahead to see how to use them in real time.

Right now, I am in /tmp directory.

1.png

I am going to create ten directories, namely test1test2, …. test10 in /tmp directory.

As may already know, We can easily create multiple directories at once using mkdir command as shown below.

mkdir test1 test2 test3 test4 test5 test6 test7 test8 test9 test10

Or,

mkdir test{1,2,3,4,5,6,7,8,9,10}

Now, let us move to test3 directory. To do so, just type:

pushd test3

2.png

To know where you are now, just type:

dirs

Sample output:

/tmp/test3 /tmp /tmp

3.png

As you see in the above output, dirs command shows we have two directories in the stack now. Do something you wish to do in this directory. Once done, you can go back to your previous working directory using command:

popd

4.png

No need to mention the full path of previous directory. If you use cd command, you should type “cd ..” or “cd <full_path_name>” to go back to the /tmp directory. But, using popd command we can instantly move back to the previous working directory. It’s simple as that.

Let us go again to test8 directory. To do so, run:

pushd test8

Sample output:

/tmp/test8 /tmp /tmp

5.png

Let us go deep in the stack.

pushd /tmp/test10

Sample output:

/tmp/test10 /tmp/test8 /tmp /tmp

6.png

We’re now in test10 directory, and we have totally 3 directories (test10, test8 and tmp) in our stack. Did you also notice the direction? Each new directory is getting added to the left. When we start poping directories off, they will come from the left as well.

Now, if you want to move to the previous working directory i.e test8 using cd command, the command would be like below.

cd /tmp/test8

But it is not necessary though. We can do it more quickly by running the popd command.

popd

Sample output:

/tmp/test8 /tmp /tmp

7.png

As you see in the above output, we moved to the previous working directory without having to type full path (i.e /tmp/test8).

Now, let us pop again?

popd

Sample output:

/tmp /tmp

8.png

Finally, We came back to the directory where we started.

In this example, I have used just ten directories. So, It may seem it is no big deal. Think about twenty or more directories? Would you type “cd <path_name>” or “cd ..” each time to move between directories? Nope. It would be time consuming. Just use pushd command to change to any directory in the stack and move back to your previous working directory using popd command. Also, you can use dirs command at any time to show the current directory stack at any time. You can add a series of paths onto your stack and then navigate to them in the reverse order. This will save you lot of time when you are navigating around stack of directories.


Also read:


You know now how to effectively navigate between directories without using cd command. These commands comes in handy when you’re working with large directory stack. You can quickly move back and forth through x amount of directories, and these commands are much useful working with scripts too.

That’s all for now. If you know any other methods, feel free to share them in the comment section below. I will be here with another interesting guide soon.

Marielle Price

Published in GNU/Linux Rules!

Today we are going to learn some command line productivity hacks. As you already know, we use “cd” command to move between a stack of directories in Unix-like operating systems. In this guide I am going to teach you how to navigate directories faster without having to use “cd” command often. There could be many ways, but I only know the following five methods right now! I will keep updating this guide when I came across any methods or utilities to achieve this task in the days to come.

Five Different Methods To Navigate Directories Faster In Linux

Method 1: Using “Pushd”, “Popd” And “Dirs” Commands

This is the most frequent method that I use everyday to navigate between a stack of directories. The “Pushd”, “Popd”, and “Dirs” commands comes pre-installed in most Linux distributions, so don’t bother with installation. These trio commands are quite useful when you’re working in a deep directory structure and scripts. For more details, check our guide in the link given below.

Method 2: Using “bd” utility

The “bd” utility also helps you to quickly go back to a specific parent directory without having to repeatedly typing “cd ../../.” on your Bash.

Bd is also available in the Debian extra and Ubuntu universe repositories. So, you can install it using “apt-get” package manager in Debian, Ubuntu and other DEB based systems as shown below:

$ sudo apt-get update
$ sudo apt-get install bd

For other distributions, you can install as shown below.

$ sudo wget --no-check-certificate -O /usr/local/bin/bd https://raw.github.com/vigneshwaranr/bd/master/bd
$ sudo chmod +rx /usr/local/bin/bd
$ echo 'alias bd=". bd -si"' >> ~/.bashrc
$ source ~/.bashrc

To enable auto completion, run:

$ sudo wget -O /etc/bash_completion.d/bd https://raw.github.com/vigneshwaranr/bd/master/bash_completion.d/bd
$ source /etc/bash_completion.d/bd

The Bd utility has now been installed. Let us see few examples to understand how to quickly move through stack of directories using this tool.

Create some directories.

$ mkdir -p dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8/dir9/dir10

The above command will create a hierarchy of directories. Let us check directory structure using command:

$ tree dir1/
dir1/
└── dir2
 └── dir3
 └── dir4
 └── dir5
 └── dir6
 └── dir7
 └── dir8
 └── dir9
 └── dir10

9 directories, 0 files

Alright, we have now 10 directories. Let us say you’re currently in 7th directory i.e dir7.

$ pwd
/home/sk/dir1/dir2/dir3/dir4/dir5/dir6/dir7

You want to move to dir3. Normally you would type:

$ cd /home/sk/dir1/dir2/dir3

Right? yes! But it not necessary though! To go back to dir3, just type:

$ bd dir3

Now you will be in dir3.

1.png

Navigate Directories Faster In Linux Using “bd” Utility

Easy, isn’t it? It supports auto complete, so you can just type the partial name of a directory and hit the tab key to auto complete the full path.

To check the contents of a specific parent directory, you don’t need to inside that particular directory. Instead, just type:

$ ls `bd dir1`

The above command will display the contents of dir1 from your current working directory.

For more details, check out the following GitHub page.

Method 3: Using “Up” Shell script

The “Up” is a shell script allows you to move quickly to your parent directory. It works well on many popular shells such as Bash, Fish, and Zsh etc. Installation is absolutely easy too!

To install “Up” on Bash, run the following commands one bye:

$ curl --create-dirs -o ~/.config/up/up.sh https://raw.githubusercontent.com/shannonmoeller/up/master/up.sh
$ echo 'source ~/.config/up/up.sh' >> ~/.bashrc

The up script registers the “up” function and some completion functions via your “.bashrc” file.

Update the changes using command:

$ source ~/.bashrc

On zsh:

$ curl --create-dirs -o ~/.config/up/up.sh https://raw.githubusercontent.com/shannonmoeller/up/master/up.sh
$ echo 'source ~/.config/up/up.sh' >> ~/.zshrc

The up script registers the “up” function and some completion functions via your “.zshrc” file.

Update the changes using command:

$ source ~/.zshrc

On fish:

$ curl --create-dirs -o ~/.config/up/up.fish https://raw.githubusercontent.com/shannonmoeller/up/master/up.fish
$ source ~/.config/up/up.fish

The up script registers the “up” function and some completion functions via “funcsave”.

Now it is time to see some examples.

Let us create some directories.

$ mkdir -p dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8/dir9/dir10

Let us say you’re in 7th directory i.e dir7.

$ pwd
/home/sk/dir1/dir2/dir3/dir4/dir5/dir6/dir7

You want to move to dir3. Using “cd” command, we can do this by typing the following command:

$ cd /home/sk/dir1/dir2/dir3

But it is really easy to go back to dir3 using “up” script:

$ up dir3

That’s it. Now you will be in dir3. To go one directory up, just type:

$ up 1

To go back two directory type:

$ up 2

It’s that simple. Did I type the full path? Nope. Also it supports tab completion. So just type the partial directory name and hit the tab to complete the full path.

For more details, check out the GitHub page.

Please be mindful that “bd” and “up” tools can only help you to go backward i.e to the parent directory of the current working directory. You can’t move forward. If you want to switch to dir10 from dir5, you can’t! Instead, you need to use “cd” command to switch to dir10. These two utilities are meant for quickly moving you to the parent directory!

Method 4: Using “Shortcut” tool

This is yet another handy method to switch between different directories quickly and easily. This is somewhat similar to alias command. In this method, we create shortcuts to frequently used directories and use the shortcut name to go to that respective directory without having to type the path. If you’re working in deep directory structure and stack of directories, this method will greatly save some time. You can learn how it works in the guide given below.

Method 5: Using “CDPATH” Environment variable

This method doesn’t require any installation. CDPATH is an environment variable. It is somewhat similar to PATH variable which contains many different paths concatenated using ‘:’ (colon). The main difference between PATH and CDPATH variables is the PATH variable is usable with all commands whereas CDPATH works only for cd command.

I have the following directory structure.

2.png

Directory structure

As you see, there are four child directories under a parent directory named “ostechnix”.

Now add this parent directory to CDPATH using command:

$ export CDPATH=~/ostechnix

You now can instantly cd to the sub-directories of the parent directory (i.e ~/ostechnix in our case) from anywhere in the filesystem.

For instance, currently I am in /var/mail/ location.


3.pngTo cd into 
~/ostechnix/Linux/ directory, we don’t have to use the full path of the directory as shown below:

$ cd ~/ostechnix/Linux

Instead, just mention the name of the sub-directory you want to switch to:

$ cd Linux

It will automatically cd to ~/ostechnix/Linux directory instantly.

4.png

As you can see in the above output, I didn’t use “cd <full-path-of-subdir>”. Instead, I just used “cd <subdir-name>” command.

Please note that CDPATH will allow you to quickly navigate to only one child directory of the parent directory set in CDPATH variable. It doesn’t much help for navigating a stack of directories (directories inside sub-directories, of course).

To find the values of CDPATH variable, run:

$ echo $CDPATH

Sample output would be:

/home/sk/ostechnix

Set multiple values to CDPATH

Similar to PATH variable, we can also set multiple values (more than one directory) to CDPATH separated by colon (:).

$ export CDPATH=.:~/ostechnix:/etc:/var:/opt

Make the changes persistent

As you already know, the above command (export) will only keep the values of CDPATH until next reboot. To permanently set the values of CDPATH, just add them to your ~/.bashrc or ~/.bash_profile files.

$ vi ~/.bash_profile

Add the values:

export CDPATH=.:~/ostechnix:/etc:/var:/opt

Hit ESC key and type :wq to save and exit.

Apply the changes using command:

$ source ~/.bash_profile

Clear CDPATH

To clear the values of CDPATH, use export CDPATH=””. Or, simply delete the entire line from ~/.bashrc or ~/.bash_profile files.

In this article, you have learned the different ways to navigate directory stack faster and easier in Linux. As you can see, it’s not that difficult to browse a pile of directories faster. Now stop typing “cd ../../..” endlessly by using these tools. If you know any other worth trying tool or method to navigate directories faster, feel free to let us know in the comment section below. I will review and add them in this guide.

And, that’s all for now. Hope this helps. More good stuffs to come. Stay tuned!

Marielle Price

Published in GNU/Linux Rules!

This article explains how to list all the packages available in an Ubuntu, Linux Mint or Debian repository (installed and available for install), be it an official repository or a third-party source like a PPA, and so on.

Below you'll find 2 ways of listing packages from a repository: using a GUI or from the command line.

List all packages in a Debian, Ubuntu or Linux Mint repository using a GUI


If you want to list all the packages in a repository on your desktop, you can use Synaptic Package Manager. 

Synaptic is a graphical package management application for APT (APT being the main command line package manager for Debian and its derivatives).

If you don't have Synaptic installed, you can install it on Debian, Ubuntu, and any Debian or Ubuntu based Linux distribution, including elementary OS, Linux Mint and so on, by using this command:

sudo apt install synaptic


To list all the packages in a particular software repository using Synaptic, launch the application and click on Origin in the bottom left-hand side of its window. Next, select the repository for which you want to list all available packages (both installed and available for installation) from the list that's displayed in the left-hand side of Synaptic Package Manager.

For example, here's Synaptic showing all the packages available in the Google repository, listing Google Chrome stable, beta and unstable, as well as Google Earth Pro and EC:

Synaptic list all packages in a repository on Ubuntu or Debian


As you can see, all the software sources are listed here, including the official repositories. 

Launchpad PPA repositories are supported as well. Their name begins with LP-PPA, followed by the actual PPA name. Synaptic lists 2 entries for each PPA - make sure you select the PPA entry ending with /ubuntu-codename, for example /bionic/cosmic, etc. The entry ending in /now doesn't list all the available packages in the PPA.

This is a screenshot showing all the packages available in the Ubuntu Graphics Drivers PPA (for Ubuntu 18.10 Cosmic Cuttlefish, since that's what I'm using), including showing which are installed on my system:

Synaptic list all packages in a repository


I'm not sure why, but some packages are listed multiple times for PPA sources (and only for PPA repositories). That only a display thing, and it doesn't break any functionality.

List all packages in a repository in Ubuntu, Debian or Linux Mint from the command line


Listing all packages in a repository from the command line in Ubuntu, Debian or Linux Mint is a bit tricky, but still quite easy to do.

There are multiple ways of doing this from the command, but I'll only list one. The command to list all packages available in repository-name is the one that follows:

grep ^Package /var/lib/apt/lists/repository-name*_Packages | awk '{print $2}' | sort -u


I'll explain later on how to find out the repository name from /var/list/apt/lists and how to use it. Before that I'll explain what this command does:

  • grep ^Package ... searches for lines beginning with ^Package in the /var/lib/apt/lists/*_Packagesfile
  • awk '{print $2}' prints the second column for each line (so it filters out everything but the package name)
  • sort -u sorts the lines and outputs only unique lines (removes duplicates)


The first thing you need to do is find the name of the repository *_Packages file from /var/lib/apt/lists/. You can list all the repository _Packages files available in /var/lib/apt/lists/ by using a simple ls:

ls /var/lib/apt/lists/*_Packages


Since the results may be very long, you can run the command output through more for easier reading:

ls /var/lib/apt/lists/*_Packages | more


If you know part of the repository name (I'm using KEYWORD in the command below as the name), you can filter the ls results using grep, like this:

ls /var/lib/apt/lists/*_Packages | grep KEYWORD


For example, let's say you want to list all the packages in the official Tor repository, and you know the repository name must contain tor. In this case, you'd use this command to find out the _Packages filename from /var/lib/apt/lists/

ls /var/lib/apt/lists/*_Packages | grep tor


For short queries, some unrelated repositories might be displayed, but it's still easier to see what you're looking for using grep than listing all the repositories _Packages files.

Now that you know the _Packages filename, you can list all the packages available in that repository by issuing this command:

grep ^Package /var/lib/apt/lists/some-repository-amd64_Packages | awk '{print $2}' | sort -u


Use the file containing the architecture for which you want to list all available packages in that repository. The example above is for 64bit (amd64), but you could use i386 for 32bit, etc.

You don't need the complete repository _Packages filename. Back to my Tor repository example, the _Packages filename for Tor is deb.torproject.org_torproject.org_dists_cosmic_main_binary-amd64_Packages. In this case, you could use deb.torproject followed by *_Packages to simplify things, like this:

grep ^Package /var/lib/apt/lists/deb.torproject*_Packages | awk '{print $2}' | sort -u


Which outputs the following:

deb.torproject.org-keyring
tor
tor-geoipdb


Another example. Let's say you want to see all packages available in the Linux Uprising Oracle Java 11 PPA(ppa:linuxuprising/java). You can list them by using:

grep ^Package /var/lib/apt/lists/ppa.launchpad.net_linuxuprising_java*_Packages | awk '{print $2}' | sort -u


Which outputs this:

oracle-java11-installer
oracle-java11-set-default


To use this with other PPA repositories, replace linuxuprising with the first part of the PPA name, and java with the second part of the PPA name, and the command will list all the packages from that PPA (both installed and not installed).

You can also list all the packages available in all the PPA repositories you have added on your system, by using:

grep ^Package /var/lib/apt/lists/ppa.launchpad.net*_Packages | awk '{print $2}' | sort -u


For easy access, you could bookmark this command using Marker commands bookmark manager (while used primarily for searching, HSTR can bookmark commands as well).

Published in GNU/Linux Rules!

There are multiple ways of searching for packages available in the Debian, Ubuntu or Linux Mint from the command line, and in this article I'll cover aptapt-cache and aptitude. Use this to search in both package names and package descriptions, useful if either you're looking for a specific package but you don't know the exact package name, or if you need a tool for a particular purpose / task but you don't know the available options.

The major differences between using aptapt-cache and aptitude to search for available packages is their output and the sort order, as you'll see in the examples below. Also, aptitude may not be installed by default on your Debian-based Linux distribution.

I personally prefer apt-cache because of the easier to read output (and I don't need extra info usually - to see installed/available versions I can use apt-cache policy package-name); it also tends to display the results I'm looking for near the top.

Another thing to note is that apt and apt-cache search the apt software package cache, so they return both packages available in the repositories as well as DEB packages installed manually (not available in the repos), while aptitude only returns packages that are available in the repositories.

I. Search available packages using aptitude

aptitude is a Ncurses-based front-end for apt. This tool is usually not installed by default but you can install it in Debian, Ubuntu, Linux Mint and other Debian-based Linux distributions using this command:

sudo apt install aptitude


You can use aptitude to search for packages from the command line, like this:

aptitude search KEYWORD


Example:

$ aptitude search openssh

p   libconfig-model-openssh-perl                           - configuration editor for OpenSsh                                
p   libghc-crypto-pubkey-openssh-dev                       - OpenSSH key codec  
p   libghc-crypto-pubkey-openssh-dev:i386                  - OpenSSH key codec  
v   libghc-crypto-pubkey-openssh-dev-0.2.7-6af0a           -                    
v   libghc-crypto-pubkey-openssh-dev-0.2.7-6af0a:i386      -                    
p   libghc-crypto-pubkey-openssh-doc                       - OpenSSH key codec; documentation                                
p   libghc-crypto-pubkey-openssh-prof                      - OpenSSH key codec; profiling libraries                          
p   libghc-crypto-pubkey-openssh-prof:i386                 - OpenSSH key codec; profiling libraries                          
v   libghc-crypto-pubkey-openssh-prof-0.2.7-6af0a          -                    
v   libghc-crypto-pubkey-openssh-prof-0.2.7-6af0a:i386     -                    
p   libnet-openssh-compat-perl                             - collection of compatibility modules for Net::OpenSSH            
p   libnet-openssh-parallel-perl                           - run SSH jobs in parallel                                        
p   libnet-openssh-perl                                    - Perl SSH client package implemented on top of OpenSSH           
p   lxqt-openssh-askpass                                   - OpenSSH user/password GUI dialog for LXQt                       
p   lxqt-openssh-askpass:i386                              - OpenSSH user/password GUI dialog for LXQt                       
p   lxqt-openssh-askpass-l10n                              - Language package for lxqt-openssh-askpass                       
v   lxqt-openssh-askpass-l10n:i386                         -                    
i   openssh-client                                         - secure shell (SSH) client, for secure access to remote machines 
p   openssh-client:i386                                    - secure shell (SSH) client, for secure access to remote machines 
p   openssh-client-ssh1                                    - secure shell (SSH) client for legacy SSH1 protocol              
p   openssh-client-ssh1:i386                               - secure shell (SSH) client for legacy SSH1 protocol              
p   openssh-known-hosts                                    - download, filter and merge known_hosts for OpenSSH
p   openssh-server                                         - secure shell (SSH) server, for secure access from remote machines
p   openssh-server:i386                                    - secure shell (SSH) server, for secure access from remote machines 
p   openssh-sftp-server                                    - secure shell (SSH) sftp server module, for SFTP access from remote machines
p   openssh-sftp-server:i386                               - secure shell (SSH) sftp server module, for SFTP access from remote machines


You can also use the aptitude Ncurses UI if you wish. Type aptitude to start it:

Aptitude ncurses interface


You can search packages by pressing / and then start typing the keyword.

II. Search available packages using apt-cache

Use apt-cache to to search for packages available in the Debian, Ubuntu or Linux Mint repositories (and installed DEB packages that aren't in the repositories) like this:

apt-cache search KEYWORD


Example:

$ apt-cache search openssh

openssh-client - secure shell (SSH) client, for secure access to remote machines
openssh-server - secure shell (SSH) server, for secure access from remote machines
openssh-sftp-server - secure shell (SSH) sftp server module, for SFTP access from remote machines
python-setproctitle - Setproctitle implementation for Python 2
python3-setproctitle - Setproctitle implementation for Python 3
ssh - secure shell client and server (metapackage)
agent-transfer - copy a secret key from GnuPG's gpg-agent to OpenSSH's ssh-agent

...

ssh-askpass-gnome - interactive X program to prompt users for a passphrase for ssh-add
ssh-audit - tool for ssh server auditing
sshpass - Non-interactive ssh password authentication


I removed some of the output because it can get very long. The visible results order was not changed though.

III. Search available packages using apt

Using apt you can search for available packages from the command line as follows:

apt search KEYWORD


Replace KEYWORD with the keyword you want to search for (you can add multiple keywords in quotes).

Here is an example search for "openssh" together with its output:

$ apt search openssh

Sorting... Done
Full Text Search... Done
agent-transfer/bionic 0.41-1ubuntu1 amd64
  copy a secret key from GnuPG's gpg-agent to OpenSSH's ssh-agent

cme/bionic,bionic 1.026-1 all
  Check or edit configuration data with Config::Model

connect-proxy/bionic 1.105-1 amd64
  Establish TCP connection using SOCKS4/5 or HTTP tunnel

...

openssh-client/bionic,now 1:7.6p1-4 amd64 [installed]
  secure shell (SSH) client, for secure access to remote machines

openssh-client-ssh1/bionic 1:7.5p1-10 amd64
  secure shell (SSH) client for legacy SSH1 protocol

openssh-known-hosts/bionic,bionic 0.6.2-1 all
  download, filter and merge known_hosts for OpenSSH

openssh-server/bionic 1:7.6p1-4 amd64
  secure shell (SSH) server, for secure access from remote machines

openssh-sftp-server/bionic 1:7.6p1-4 amd64
  secure shell (SSH) sftp server module, for SFTP access from remote machines

putty-tools/bionic 0.70-4 amd64
  command-line tools for SSH, SCP, and SFTP

python-scp/bionic,bionic 0.10.2-1 all
  scp module for paramiko


Once again, I removed some of the results because the results list is quite long. The results order was not changed though.


For all three, the search results may be very long. In such cases, you can run them through more, for easier reading, like this:

apt-cache search KEYWORD | more


You can also exclude results that don't include a particular keyword (KEYWORD2 in this example) by using grep:

apt-cache search KEYWORD | grep KEYWORD2


grep is case sensitive by default. Add -i (grep -i KEYWORD2) to ignore case.

Published in GNU/Linux Rules!
Page 1 of 2
Our website is protected by DMC Firewall!