Senin, 31 Agustus 2020

From Terminal Master to Grandmaster: Play Chess in Linux Terminal

You know Linux terminals can be fun too!

You can run some funny Linux commands for amusement. You can also play games in Linux terminal.

Yes! You heard it right. You can play games in the terminal and in this #TerminalTuesday series, I’ll show you how to play chess in Linux terminal.

You might be thinking, “why would anyone want to play chess in the terminal ?!”. I say, it’s a lot of fun. It is also challenging if you play against Stockfish.

Yes, there’s GNU Chess available, but it is not visually appealing and the chess engine “keeps thinking” for a long time.

I’m talking about an alternative to GNU Chess. Here are a few reasons you might enjoy this one better.

  • You get to play against one of the strongest chess engine, Stockfish. Here are the rankings for all the computer chess engines.
  • Visually looks way better than GNU Chess and is relatively faster as well.
  • You’ll learn how to describe chess moves in algebraic notation.
  • I figured that a pretty good chunk of It’s FOSS readers are geeks/nerds and that you guys would enjoy it.

To install terminal chess you need two components, the Stockfish chess engine and chs which is the UI which plugs into the chess engine.

Installing Chess in Linux terminal with Stockfish and chs

Play Chess Linux Terminal

The terminal commands here are for Ubuntu or Ubuntu based distributions since a lot of people use them. These commands were tested on Ubuntu 20.04.

You can use your distribution’s package manager for installing the mentioned software.

sudo apt install stockfish

Running the above command will install the latest version of the Stockfish chess engine.

chs is the UI which plugs into the chess engine. It is written in python3 and you can install it using pip3 the python package manager.

First, install PIP on Ubuntu with this command:

sudo apt install python3-pip

Once you have pip3 installed, run the below command to install chs.

pip3 install chs

Cofiguring chs

After installing chs, you’ll see an error message saying chs is not on PATH. At this point if you try to launch chs, the terminal won’t know where to launch it from.

PATH warning

You can use the following command to fix the problem

export PATH="$PATH:$HOME/ .local/bin"

If you try to launch chs from the terminal, you’ll see a “FileNotFoundError”. This is a known bug in chs, it is not able to find the Stockfish chess engine to launch it.

To fix this issue we need to make a small edit in the chs python code. The file we are interested in will be located at /.local/lib/python3.X/site-packages/chs/engine/stockfish.py

Make sure to replace the the 3.X in the python version with the one installed on your computer. You can check the python version using the below command.

python3 -V

For me, it was Python 3.8. You can use Nano editor or your choice of text editor and open up the file.

sudo nano ~/.local/lib/python3.8/site-packages/chs/engine/stockfish.py
stockfish code before

In the line 13 of the code you’ll see engine_path = ‘stockfish_10_x64_linux’, you have to replace ‘stockfish_10_x64_linux’ like this

engine_path = "/usr/games/stockfish"
stockfish code after

Now you’re finally done with all the setup. Type chs in the terminal to launch the game. This launches chs at level 1 difficulty.

You can specify the level of difficulty of the while launching the game as shown below.

chs level=8
Terminal chess

Playing chess in Linux terminal

You play terminal chess using the algebraic notation (the name sounds complicated but it is quite simple) to describe the moves.

I’ll summarize a short version of how to play using algebraic notation, for detailed information you can check out this article. Chess pieces are represented by a single letter.

  • Knight – N
  • Rook – R
  • Queen – Q
  • King – K
  • Bishop – B
  • Pawns – blank, they don’t have an associated letter.

The chess board columns are represented by letters a to h and rows are represented by numbers 18. To move your pawn in the position a2 to a4 you just write a4.

Playing chess in Linux terminal

To move your knight(N) from g1 to h3 you would write Nh3.

Playing chess in Linux terminal

To capture a pawn you have to add an x in the command. Here I’m trying to capture the bishop(B) which is in the position c4 using my knight(N). The command for this is Nxc4.

Playing chess in Linux terminal

The Stockfish engine also gives you suggestions when you type an invalid command or when there are multiple possibilities for a command. You can use the command hint and the chess engine will give you a hint for the next move.

You can also use the back which takes back your last move(s), this will help you cheat or revise the game depending on how you see it.

Closing thoughts

If you find the chessboard to be very tiny, you can scale it up and play around with different fonts. Both Stockfish and chs are open source and you can easily get your hands dirty and mess around with the code for your own projects (if you want).

If you want to try out the good old GNU Chess, you can install it using the command below.

sudo apt install gnuchess

Let me know how your game went in the comment section :)



from It's FOSS https://ift.tt/3hPSPay
via IFTTT

How to Set Up Facial Recognition to Sign into Ubuntu and Other Linux Distributions

Despite all the concern, facial recognition is getting popular among consumers. Most recent Android and iOS devices have the feature to unlock the device with facial authentication.

Once you get used to the face unlock or fingerprint unlock, typing password feels like a tedious, boring task.

On Windows operating system, Microsoft provides the Windows Hello that allows instant authentication based on your face.

On Linux, face unlock is not a built-in feature. No Linux distribution, as far as I know, provides face unlock feature out of the box.

But as the saying goes, there is a shell, there is a way. In Linux, you’ll often find alternative things and tools that you can configure for a certain task. Remember the tutorial I wrote for sharing mouse and keyboard between Linux and Raspberry Pi devices?

In this tutorial, I’ll show you how to set up face unlock in Ubuntu. You can use the tutorial for other Linux distributions as well.

You need to be comfortable with the terminal and Linux commands because you’ll be using Linux command line tool.

Howdy: A Windows Hello Styled Facial Recognition Authentication System for Linux

Face Unlock In Linux

Howdy is an open source software that gives you the ability to login to your Linux system with face recognition. Consider it an open source Windows Hello alternative for Linux. Here, your data is stored locally on your computer.

Howdy uses the built-in IR emitters and webcam combination to recognize your face. It is built using OpenCV and Python.

Howdy uses the PAM authentication system which means not only you can login to your system with your face, you can also use it for sudo, su and in most other situations where you need to use your account password. However, in my testing, it could not unlock the keyring in Ubuntu.

In this tutorial, I’ll show you how to install Howdy and how to set it up for facial recognition. The process is not too complicated but you should not be too uncomfortable using the terminal here.

Installing Howdy on Ubuntu and other Linux distributions

The developer of Howdy provides a handy PPA that makes installing Howdy easier to install on Ubuntu-based distributions.

Open a terminal and use the following commands on Ubuntu:

sudo add-apt-repository ppa:boltgolt/howdy
sudo apt update
sudo apt install howdy

Howdy is a big software and it installs a huge number of software libraries. For me, it showed around 140 MB of download size and 600 MB of disk size requirement after installation.

During the installation, it asks you to choose from Fast, Balanced and Secure authentication type. I chose Balanced at this step because I don’t want to wait too long but don’t want it to be less secure as well.

Select Face Unlock Level Ubuntu

During the installation, it complains about adding /usr/local/bin in the PATH but for me it was already there. You may verify it for your system.

Installing Howdy on other Linux distributions

For Debian, you can download the DEB file. Arch/Manjaro users can install it from AUR.

Fedora users have the option to use COPR repository:

sudo dnf copr enable luya/howdy
sudo dnf install howdy

openSUSE users can find the installation instructions here.

As the last resort, you can get the source code on its GitHub repository.

Since I am using Ubuntu 20.04 in this tutorial, some steps may use apt command but I believe you can use your distribution’s package manager in those steps.

Setting up face unlock on Ubuntu and other Linux with Howdy

Let’s see how to set it up for facial recognition.

Change config file

Before you use Howdy, you should change the configuration file to specify your webcam device.

On most Linux systems, /dev/video0 should be the device for webcam but you should make sure of it using v4l2-ctl command.

Install v4l-utils first:

sudo apt install v4l-utils

Now use the v4l2-ctl command to list your devices

abhishek@itsfoss:~$ v4l2-ctl --list-devices
Integrated_Webcam_HD: Integrate (usb-0000:00:14.0-5):
        /dev/video0
        /dev/video1

Why two (or more) video devices? You’ll have to check the capabilities of the device. The device should have Video Capture capability, not just Metadata Capture.

You can check it with a command like v4l2-ctl –device=/dev/video0 –all and then look under the capability section. Most of the time, it should be the first device i.e. /dev/video0.

Now, you need to set the device path in the Howdy config. You can do that by mnually opening the /lib/security/howdy/config.ini file for editing or use the command below to open the config file for edit in your default terminal-based text editor:

sudo howdy config

Look for the line starting with device_path. Change its value to /dev/video0 or whatever is the path for your webcam device.

Setup Howdy For Face Unlock In Ubuntu

Save and exit the file. You are ready to go now.

Add your face for facial recognition

Howdy is a command line tool. You have to do everything in the terminal.

Now that you have the correct device path set, it is time to add some face in its database for the recognition.

Use the following command to associate a face to the currently logged in user i.e. you.

sudo howdy add

It doesn’t show how your face looks like by opening a camera so you should look into the webcam to get your face captured properly.

It will ask you to add an identifier to the face. You can name it anything you want. I used terms like glasses, with-headphones etc.

Add New Face For Facial Recognition Linux

I suggest adding a few more variants of your face specially if you wear glasses. Just run the sudo howdy add command each time you want to add a face.

Howdy is ready to use as soon as you add a face. To test it, open a new terminal and run a command with sudo. You’ll notice that your webcam blinks and it tries to detect a face. If the face is not recognized, it will show an error message and ask you to use your password.

Use Sudo With Face Unlock

To add a face for some other user, you should provide the username as well:

sudo howdy -U username add 

You don’t need to worry about starting Howdy after reboot. Howdy starts automatically at each boot.

List all the known face models for a user

You can see what face models are associated to a user with the list option. If you don’t specify the username, it shows the output for the current user.

sudo howdy list
Howdy List Face Models

Clear some or all face models

When you list all the face models for a user, you can use the remove option to delete a certain face model. You’ll have to provide the ID of the face model, not the label.

sudo howdy remove face_ID
Remove Face Model Linux

You can remove all the face models with the following command:

sudo howdy clear

Disable and re-enable Howdy

You can temporarily disable Howdy using this command:

sudo howdy disable 1

You can re-enable it using the same disable option but with 0 as argument:

sudo howdy disable 0

Removing Howdy from your system

You can use your distribution’s package manager to remove Howdy.

On Ubuntu, use the following command:

sudo apt remove howdy

You should also delete the PPA:

sudo add-apt-repository -r ppa:boltgolt/howdy

For other distributions, use the uninstallation method that corresponds to the installation method you used.

Conclusion

It’s fun to setup face unlock on Linux. I think this could provide base for some good Raspberry Pi projects. It’s a fun weekend exercise to do a thing like this.

However, I won’t recommend setting up it on critical infrastructure or servers. Facial recognition is not very secure.

Using face unlock on your personal Linux system is one thing but please don’t use it on servers or work machines.

I hope you liked this DIY (if I may call it) tutorial. Let me know if you would like to see more such tutorials on It’s FOSS in the future.



from It's FOSS https://ift.tt/2EJuJjl
via IFTTT

Jumat, 28 Agustus 2020

What is a Display Server in Linux? What is it Used for?

In Linux related articles, news and discussions, you’ll often come across the term display server, Xorg, Wayland etc.

In this explainer article, I’ll discuss display servers in Linux.

What is display server in Linux?

A display server is a program which is responsible for the input and output coordination of its clients, to and from the rest of the operating system, and among the hardware and the operating system. Basically, thanks to a display server, you can use your computer graphically (GUI). Without the display server, you would only be restricted to a command line interface (TTY).

The display server provides the framework for a graphical environment so that you can use mouse and keyboard to interact with applications.

The display server communicates with its clients over the display server protocol, like X11. The display server is a key component in any graphical user interface, specifically the windowing system.

Don’t confuse display server with desktop environment. The desktop environment uses display server underneath it.

Sounds familiar but it is not fully clear? Let me explain.

Display server communications protocols in Linux

Display Server Linux

There are three display protocols available in Linux, the X11, Wayland and Mir. I’ll give you a brief introduction for these display servers.

X11

The X11 (also refer as X) is the legacy display server that has been existed for years. It is the most common display server used in Linux distributions.

X Architecture 1
X Architecture

The X11 communication protocol, uses the X.org Server display server. It receives input events from device drivers and makes them available to one of its clients.

The display server also receives data from its clients, it processes the data and does the compositing and on Linux it passes the data to one of three kernel components – the DRM, gem or KMS driver.

The X.Org Server is a display server that relies on a second program, the compositing window manager, to do the compositing. Examples are Mutter or KWin. GNOME uses Mutter.

Wayland

As per its website, Wayland is “intended as a simpler replacement for X, easier to develop and maintain”.

And indeed Wayland is the modern display server that is supposed to replace the legacy X display server.

Its adoption is still a work in progress. Ubuntu tried to switch to Wayland as the default display server with version 17.10 but the experiment met with negative feedback.

A lot of GUI applications and their frameworks depend on the X server. These applications didn’t work as intended on Wayland.

This forced Ubuntu to stay on X as default display server. It still provides the option to use Wayland but it is not default anymore.

An overwhelming majority of distributions use X display server by default even today.

Wayland display server architecture
Wayland Architecture

Display servers that put into effect the Wayland display server protocol, are called Wayland compositors. Like any X11, a Wayland compositor is responsible for handling input and output for its clients but also does the compositing – in contrast to X11.

A few Wayland compositors are Weston, Mutter, KWin or Enlightenment.

Mir

The Mir display server comes with its own Mir display server protocol which differs to those used by X11 and Wayland. It was developed by Canonical, as part of the development of Unity, and was intended to be the display server of choice for Ubuntu.

As of 2017, it has been replaced with the Wayland display server for desktop editions of Ubuntu, although Mir’s development continued for Internet of Things (IoT) applications.

Why are we still using Xorg?

Wayland as it is relatively new, is not very stable yet, compared to Xorg. The programs, which act as clients, in order to communicate with a display server, must know how to do it.

For this reason, many programs might not run when using Wayland. Ubuntu’s experiment to switch to Wayland by default confirmed this.

Conclusion

I hope you have a bit better understanding of display server concept in Linux. I have tried to not go into too much technical details but I could not avoid them altogether.

Your feedback and suggestion is welcome.



from It's FOSS https://ift.tt/3hFVNOy
via IFTTT

Kamis, 27 Agustus 2020

Best Free Online Markdown Editors That Are Also Open Source

Markdown is a useful lightweight markup language and a lot of people prefer for writing documentation or web publishing. Many of us at It’s FOSS use markdown for writing our articles.

There are several Markdown editors available for Linux that you can install and use.

But, what if you don’t want to install another program on your system? Perhaps you are using a system temporarily and cannot install an application? Maybe you just want a markdown editor that lets you collaborate in real-time?

No matter what you require, online markdown editors makes a lot of things easy by providing collaboration features, publishing integration, notes synchronization, and some online-only features.

Hence, I’ve compiled a list of the best online markdown editors.

Free Online Markdown Editors

I have tried to keep the focus on online markdown editor with open source code. You may use the official website or deploy them on your server.

Note: The list is in no particular order of ranking.

1. StackEdit

Stackedit Screenshot

StackEdit is one of the most popular open-source online Markdown editors available.

It provides a great user interface and offers a bunch of useful features. The ability to collaborate, synchronizing capability, and being able to publish/save your files to Blogger, WordPress, GitHub, and a couple other services are some key features that you get with StackEdit.

Not to forget, you also get an extended markdown support some extensions available to support LaTeX mathematical expressions, UML diagrams, and more. It presents a WYSIWYG editor that makes it easy for you to work with Markdown. It also works offline and offers a chrome app and extension — if that’s your requirement.

It’s easy to import/export files on StackEdit as well. You can take a look at its source code on GitHub for more details if you need to host it on your server.

2. Dillinger

Dillinger Screenshot

Dillinger is yet another interesting open-source online Markdown editor. Similar to StackEdit, you also get the ability to link and save the documents with Dropbox, GitHub, Medium, Google Drive, Bitbucket, and OneDrive.

You can also choose to simply import/export files when needed. The user interface for Dillinger is simpler than what you get on StackEdit — but it gets the job intended. Unlike StackEdit, you may not get extended Markdown support with LaTeX expressions or diagrams but if you just need simple online Markdown editor, this is a good pick.

If you need, you can choose to deploy it in a Docker container on your server. For more technical details on it, you might want to check out its GitHub page.

3. Write.as

Write As Screenshot

Write.as is based on the free and open source software WriteFreely, developed by the same team. So you can simply host it on your own server and start using it for free if you want.

You can also use Write.as service as a free online Markdown editor with basic features. To make the most out of it, you may want to choose a subscription. Some paid features include custom themes, newsletters, photo hosting, and multiple blogs.

It supports Markdown and also lets anyone on Mastodon, ActivityPub, and Pleroma to follow and share your blog posts easily.

You can explore more about WriteFreely on its GitHub page or get started using Write.as.

4. Editor.md

Editor Md Screenshot

An interesting open-source Markdown editor that you can also embed on your own web pages if you require.

It supports real-time preview, GitHub flavored markdown, and also presents a WYSIWYG editor along with a bunch of useful features. In addition to the basic Markdown support, it also supports emojis, LaTeX expressions, Flowchart, and more.

You can choose to configure your own by hosting it yourself as well. Take a look at its GitHub page for more information.

5. CodiMD

Codimd

CodiMD isn’t available as a full-fledged online service from the get-go. But, it is an open-source project that lets you collaborate on documentations or notes in real-time by giving you the ability to host it on your server.

It’s based on HackMD‘s source code and offers a demo instance to test it out. Personally, I like the fact that it also offers a dark mode and it’s easy to use.

For its future release (at the time of writing this), it will be renamed as “HedgeDoc“.

You can find all the relevant information on deploying it on your server through Docker/Kubernetes and other manual configuration options on its GitHub page.

6. Wri.pe

Wri Pe Screenshot

Wri.pe is a simple open-source online Markdown editor that’s no longer maintained but it is still active and usable.

It features real-time preview and the options to export or save your notes to Dropbox/Evernote. Considering that it’s not actively maintained — you may not rely on it but it works as expected when I tested it.

You can take a look at its GitHub page or the official site to learn more about it.

Honorable Mentions

Here are a few tools that provide markdown access.

Markdown Web Dingus

Markdown Web Dingus

A simple and free online Markdown editor by the creator of Markdown language. It’s not a full-fledged online editor with integrations or that supports import/export.

But, if you just want an online editor to get a preview for your Markdown source, this could be a great option to use. Not just limited to the editor, but you also get a syntax cheatsheet in the sidebar of the website. So, you can try and learn here as well.

Markdown Journal

Markdown Journal

Markdown Journal was an interesting open-source project on GitHub which has been discontinued. It gave you the ability to use its online editor to create journals using Markdown language and save them directly on your Dropbox account. I noticed Internal Server error when I tried to create a journal — but you can take a look at it.

Etherpad

Etherpad Public Instance

Etherpad is yet another impressive open-source online editor but it doesn’t come with Markdown support out of the box. You might notice some plugins available to enable Markdown editing on your server — but that’s not something that works flawlessly yet. So, you might want to keep an eye out for it. There’s a list of public instances to try it out as well.

Wrapping Up

Considering that a lot of online editors, CMSs, and note-taking services support Markdown, services/applications like WordPress can also be a good option if you want to publish it to the web.

Which one do you prefer to use as a Markdown editor? Did I miss any of your favorites? Let me know in the comments below!



from It's FOSS https://ift.tt/2Qx8Xl3
via IFTTT

Rabu, 26 Agustus 2020

How to Switch Users in Ubuntu and Other Linux Distributions [Quick Beginner Tip]

It is really simple to switch users in Ubuntu or any other Linux distribution using the terminal.

All you need to do is to know the unsername and its account password and you can switch users with su command:

su another_username

You’ll be asked to enter the password of the user you want to switch to.

Switching Users in Ubuntu Linux

As you can see in the screenshot above, I changed to user prakash from user abhishek in the terminal.

There are some minor details with this method that I’ll share with you in a moment. I’ll also share the graphical way of switching users in Linux if you are using desktop Linux.

Switching to root user

If you want to switch to the root user in Ubuntu, you can use the following command:
sudo su
You’ll have to enter your own user password here.

Change user in Linux command line

Switch Users Linux

Let’s see things a bit in detail. To switch users, you need to first know the exact username because tab competition doesn’t work here. You can list all the users in Linux command line by viewing the content of the /etc/passwd file.

You’ll also need to know the password of the user account you want to switch to. This is for security reason, of course.

su another_username

If you are the admin user or have sudo access, you can change account password with passwd command.

You’ll notice that some people use a - between su and the username. There is a specific reason for that.

su - another_username

When you use -, -l or –login option, you start the shell as a login shell. This means that it will initialize the environment variables like PATH and changes to the home directory of the changed user. It will be as if you logged into the terminal as the second user.

Switch User Ubuntu Linux

Note: though -is more popular, it is advised to use –login option.

Change users in Linux graphically (for desktop Linux)

If you are using desktop Linux, the above method may not be sufficient for you. Why? Because you switch the user in the terminal only. It is confined to the terminal. Nothing is changed outside the terminal.

If you want to switch users so that you can log in as another user and use all the system (browser, applications etc) graphically, you’ll have to log out and then log back in.

Now the screenshots may look different but the steps remain the same. Here’s how to switch users in Ubuntu Linux.

Go to the top right corner and click the Power Off/Log out option to open the dropdown and you can choose either of Switch User or Log Out.

  • Switch User: You get to keep your session active (applications keep on running) for current user. Good for temporarily switching users as you won’t lose your work.
  • Log out: Current session ends (all applications are closed). Good when you want to switch to the other user for a long time.

You can choose whichever option is more suited for your need.

Switch User in Ubuntu

Now, you’ll be at the login screen with all the available users for your system. Choose the user account of your choice.

Clearly, you need to know the password of the user account you want to use.

That’s it. I hope you find this quick beginner tip helpful in changing users in Ubuntu and other Linux distributions. Questions and suggestions are always welcome.



from It's FOSS https://ift.tt/2EBzHOE
via IFTTT

How to Check Dependencies of a Package in Ubuntu/Debian-based Linux Distributions

Installing applications via command line is quite easy in Ubuntu/Debian. All you need to do is to use apt install package_name.

But what if you want to know the dependencies of a package before or after installing it?

In this tutorial, I’ll show you various ways to see the dependencies of a package in Ubuntu and other Debian-based Linux distributions that use APT package management system.

What is package dependency in Ubuntu?

If you didn’t know already, when you install a software package in Linux, sometimes, it needs other packages to function properly. These additional packages are called dependencies. If these dependency packages are not installed on the system, it is usually installed automatically with the package.

For example, the GUI tool HandBrake for converting video formats needs FFmpeg, GStreamer. So for HandBrake, FFmpeg and GStreamer are the dependencies.

If you don’t have these packages installed on your system, they will be automatically installed when you install HandBrake on Ubuntu.

Check dependencies of a package in Ubuntu and Debian based distributions

As it often happens in Linux, there are more than one way to achieve the same result. Let’s see various ways to see the dependencies of a package.

Checking dependencies with apt show

You can use the apt show command to display details of a package. Part of this information is dependencies and you can see it in the line starting with Depends.

For example, here’s what it shows for ubuntu-restricted-extras package.

abhishek@itsfoss:~$ apt show ubuntu-restricted-extras 
Package: ubuntu-restricted-extras
Version: 67
Priority: optional
Section: multiverse/metapackages
Origin: Ubuntu
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 14.3 kB
Depends: ubuntu-restricted-addons
Recommends: libavcodec-extra, ttf-mscorefonts-installer, unrar
Download-Size: 3,200 B
APT-Manual-Installed: yes
APT-Sources: http://us.archive.ubuntu.com/ubuntu focal/multiverse amd64 Packages
Description: Commonly used media codecs and fonts for Ubuntu
 This collection of packages includes:
  - MP3 and other audio codec software to play various audio formats
    (GStreamer plugins)
  - software to install the Microsoft Web fonts
  - the Adobe Flash plugin
  - LAME, software to create compressed audio files.
 .
 This software does not include libdvdcss2, and will not let you play
 encrypted DVDs. For more information, see
 https://help.ubuntu.com/community/RestrictedFormats/PlayingDVDs
 .
 These software packages are from the Multiverse channel, restricted by
 copyright or legal issues in some countries. For more information, see
 http://www.ubuntu.com/ubuntu/licensing

As you can see, ubuntu-restricted-extras package depends on ubuntu-restricted-addons package.

Here’s a catch! The dependency package may also depend on some other package and the chain could go on. Thankfully, the APT package manager handles this for you by automatically installing all the dependencies (most of the time).

What is recommended package?

Did you notice the line starting with Recommends in the above output?

Recommended packages are not direct dependencies for the package but they enable additional features.

As you can see, ubuntu-restricted-extras has ttf-mscorefonts-installer as recommended package for installing Microsoft Fonts on Ubuntu.

The recommended packages are also installed by default and if you explicitly want to forbid the installation of recommended package, use the –no-install-recommends flag like this:

sudo apt install –no-install-recommends package_name

Use apt-cache for getting just the dependencies information

The apt show has way too many information. If you want to get the dependencies in a script, the apt-cache command gives you a better and clean output.

apt-cache depends package_name

The output looks much clean, does it not?

Apt Check Dependencies Ubuntu

Check the dependencies of a DEB file using dpkg

Both apt and apt-cache command works on the packages that are available from the repositories. But if you download a DEB file, these command won’t work.

In this case, you can use the dpkg command with -I or –info option.

dpkg -I path_to_deb_file

The dependencies can be seen in the line starting with Depends.

Check Dpendencies Of Deb Package

Checking dependencies and reverse dependencies with apt-rdepends

If you want more details on the dependencies, you can use the apt-rdepends tool. This tool creates the complete dependency tree. So, you get the dependency of a package and the dependencies of the dependencies as well.

It is not a regular apt command and you’ll have to install it from the universe repository:

sudo apt install apt-rdepends

The output is usually quite large depending on the dependency tree.

Reading package lists... Done
Building dependency tree       
Reading state information... Done
shutter  
  Depends: procps
  Depends: xdg-utils
imagemagick
  Depends: imagemagick-6.q16 (>= 8:6.9.2.10+dfsg-2~)
imagemagick-6.q16
  Depends: hicolor-icon-theme
  Depends: libc6 (>= 2.4)
  Depends: libmagickcore-6.q16-6 (>= 8:6.9.10.2)
  Depends: libmagickwand-6.q16-6 (>= 8:6.9.10.2)
hicolor-icon-theme
libc6
  Depends: libcrypt1 (>= 1:4.4.10-10ubuntu4)
  Depends: libgcc-s1
libcrypt1
  Depends: libc6 (>= 2.25)

The apt-rdepends tool is quite versatile. It can also calculate the reverse dependencies. Which means, you can see what other packages depend on a certain package.

apt-rdepends -r package_name

The output could be pretty big because it will print the reverse dependency tree.

abhishek@itsfoss:~$ apt-rdepends -r ffmpeg
Reading package lists... Done
Building dependency tree       
Reading state information... Done
ffmpeg
  Reverse Depends: ardour-video-timeline (>= 1:5.12.0-3ubuntu4)
  Reverse Depends: deepin-screen-recorder (5.0.0-1build2)
  Reverse Depends: devede (4.15.0-2)
  Reverse Depends: dvd-slideshow (0.8.6.1-1)
  Reverse Depends: green-recorder (>= 3.2.3)

I hope this quick tutorial was helpful in improving your command line knowledge a bit. Stay tuned for more such tips.



from It's FOSS https://ift.tt/3hI8sAR
via IFTTT