You Got A Question? Ask    GNOME Community!


Fedora: Some basic tips with Yum

This post was made with an older stylesheet

fedora’s yum stands for..

..Yellowdog Updater, Modifier developed by Seth Vidal and is an open-source command-line package-management utility for RPM-compatible Linux operating systems and has been released under the GNU General Public License.


Fedora 18, new Grub Theme

Next, I will refer some common operations with yum, common to most of us, but not to everyone.


add a new user

Because I normally use Fedora’s minimal installation, I haven’t a either a user or a graphical interface at first. Luckily we have a root account, so lets create a new user first.

# useradd alex

and set a password so we actually can use this account.

# passwd alex

There is also a “adduser” command. The “adduser” in Fedora is just a link to “useradd” where in Ubuntu is a script that uses “useradd” and adds some more functionality. I am not going to cover the options of “useradd” but running it without options is exactly the same as make a new account within user interface, so you can use safely the terminal to add new users.

If you want to remove a user you can use the “userdel” command that without options doesn’t remove the home and mail directories.

# userdel alex

add users to sudo-ers

It is strongly recommended to don’t use our root account in a Linux Desktop. Indeed we have to avoid it, mostly because we forget to close terminals with a root logged in, and then we might re-use them, supposing we have a normal user logged in.

But how we can use Yum to install new things without a root account? Well, there is a “sudo” command for terminal or “gksudo” for GUIs. Sudo (SuperUser Do) is a program that allows users to run programs with the security privileges of another user (normally root).

Before we can use “sudo” we have to add our user to  /etc/sudoers config file. Although it is common to use “visudo” to edit this file we can use another (and simpler) text editor like nano. Visudo checks the sudoers file for errors. So if you make any error here, you might lockout from your system :)

# nano /etc/sudoers

And we add our user “alex”.

##Allow root to run any commands anywhere
root ALL = (ALL) ALL
alex ALL = (ALL) ALL

Sudoers configuration can get much complicated, but here is small trick: We have a single user box, so why should sudo asks us for a password? Lets remove this. Just edit your sudoers like this:

##Allow root to run any commands anywhere
root ALL = (ALL) ALL
alex ALL = (ALL) NOPASSWD: ALL

It isn’t really smart to mess up with our sudoers configuration if haven’t read some docs first, and besides Fedora places by default the first user in sudoers group in a typical installation.

I repeat that editing this file and make a typo, will lock you out of your system (and we have to repair with a liveCD), so it is needed to use the visudo to edit it :)


yum groupinstall

Ok, now that I can use “sudo yum” to install software, I want to install Gnome (I have currently not a GUI installed). I can install one by one Gnome modules as  yum will take care the dependencies.

$ sudo yum install gdm gnome-control-center nautilus ..etc

..but how I can know all the possible Gnome Modules that Gnome uses? Fedora makes it easy to install whole environments with a single command. To find out the available options run:

$ yum grouplist

and you get this response

Available Environment Groups:
   GNOME Desktop
   KDE Desktop
   Xfce Desktop
   LXDE Desktop
   Cinnamon Desktop
   MATE Desktop
   Sugar Desktop Environment
   Development and Creative Workstation
   Web Server
   Infrastructure Server
   Basic X windows
   Minimal install
Installed Groups:
   Administration Tools
   Authoring and Publishing
   Design Suite
   Development Tools
   Electronic Lab
   Milkymist
   Network Servers
   Office/Productivity
   Robotics
   Sound and Video
   System Tools
   Text-based Internet
Available Groups:
   Books and Guides
   Cloud Infrastructure
   Editors
   Educational Software
   Engineering and Scientific
   Fedora Eclipse
   Games and Entertainment
   LibreOffice
   Medical Applications
   Web Development
   Window Managers

We can also search for a specif group by using

$ yum grouplist gnome\*

 

Now install Gnome simply:

$ sudo yum groupinstall "GNOME Desktop"

or

$ sudo yum groupinstall gnome-desktop

or

$ sudo yum install @gnome-desktop

Obviously you can replace “GNOME Desktop” with any of the available groups.

Now I want, to check what packages the @gnome-desktop will install:

 $ yum groupinfo gnome-desktop
Environment Group: GNOME Desktop


Environment-Id:gnome-desktop


Description:GNOME is a highly intuitive and user friendly desktop environment.


Mandatory Groups:
base-x
core
dial-up
firefox
fonts
gnome-desktop
hardware-support
input-methods
multimedia
printing
standard
Optional Groups:
epiphany
gnome-apps
gnome-media
libreoffice
Group: GNOME Desktop Environment


Group-Id: gnome-desktop


Description:GNOME is a powerful graphical user interface which includes a panel, desktop, system icons, and a graphical file manager


Mandatory Packages:
NetworkManager-openconnect
NetworkManager-openvpn
NetworkManager-pptp
NetworkManager-vpnc
PackageKit-command-not-found
PackageKit-gtk-module
PackageKit-gtk3-module
abrt-desktop
aisleriot
at-spi2-atk
at-spi2-core
avahi
baobab
brasero
brasero-nautilus
caribou
cheese
control-center
dconf
deja-dup
desktop-backgrounds-basic
empathy
eog
evince
evince-nautilus
file-roller
file-roller-nautilus
firewall-config
firstboot
fprintd-pam
gcalctool
gdm
gedit
glib-networking
gnome-backgrounds
gnome-bluetooth
gnome-clocks
gnome-color-manager
gnome-contacts
gnome-dictionary
gnome-disk-utility
gnome-disk-utility-nautilus
gnome-documents
gnome-font-viewer
gnome-icon-theme
gnome-icon-theme-extras
gnome-icon-theme-symbolic
gnome-packagekit
gnome-panel
gnome-screensaver
gnome-screenshot
gnome-session
gnome-settings-daemon
gnome-shell
gnome-system-log
gnome-system-monitor
gnome-terminal
gnome-themes-standard
gnome-user-docs
gucharmap
gvfs-fuse
gvfs-gphoto2
gvfs-smb
libcanberra-gtk2
libcanberra-gtk3
libproxy-mozjs
librsvg2
libsane-hpaio
metacity
mousetweaks
nautilus
nautilus-sendto
network-manager-applet
nm-connection-editor
notification-daemon
orca
policycoreutils-restorecond
polkit-gnome
seahorse
setroubleshoot
sushi
totem
totem-mozplugin
totem-nautilus
xdg-user-dirs-gtk
yelp
Default Packages:
gnome-mplayer
gstreamer-ffmpeg
gstreamer-plugins-ugly
Optional Packages:
gstreamer-plugins-bad
gstreamer-plugins-bad-extras

These are the default packages in Fedora 18 for Gnome ..in case you are curious! And yes Epiphany is still an optional package in Fedora 18, pff…

We can search for a package in a grouplist

$ sudo yum groupinfo gnome/* | grep -i mplayer

or display it in more readable way

$ sudo yum groupinfo gnome/* | less

Of course we can remove our grouplist by:

$ sudo yum groupremove gnome-desktop

or update it

$ sudo yum groupupdate gnome-desktop

yum common operations

$ yum clean all

Clean all the cache and metadata in yum

$ yum check-update

Checking if there are available updates

$ sudo yum update

Checking and installs the available updates -if any.

$ sudo yum update --skip-broken

Many times in Fedora(!?) we have broken packages that prevent the installation of others. We can use the –skip-broken flag to overpass it.

$ sudo yum install package1 package2

Installs two packages, but it can also used with a regex

$ sudo yum install gnome-shell-ext*

Installs all the packages that the name starts from gnome-shell-ext. This will install all the available gnome-shell extensions.

$ sudo yum remove package1 package2

Removes these two packages

$ yum search package

Searches for a package, and is useful to use some regex here and filtering it with grep

$ yum provides package

Looking for a missing lib or a package and returns the package or the repo that contains it.

Yum and every other updating system are very complex programs with dozens of options, so there is no way to address all the capabilities of Yum.

$ man yum

You get all the available options of yum :)


rpm use

Sometimes yum ins’t enough to install or to remove packages. Suppose we want to install a package that lies somewhere in our hard drive and not in an online repository. To install it we will use rpm program.

$ sudo rpm -i /PATH_TO_FILE/package.rpm

or

$ sudo rpm -U /PATH_TO_FILE/package.rpm

to update it.

$ sudo rpm -e package

To erase a package that you had install with rpm

Another nice thing about rpm is that we can install or remove packages dropping any dependencies with the –nodeps flag

$ sudo rpm -i /PATH_TO_FILE/package.rpm --nodeps

Install package without calculating dependencies

$ sudo rpm -e package --nodeps

Erase the package without removing the dependencies.

Searching with rpm

$ rpm -q package

Look for a package if it is installed

$ rpm -qa

Returns all the installed packages

$ rpm -qa | grep -i gnome-do

Returns all the installed packages that contains “gnome-do” as part of their name.

rpm -q --changelog package | less

Returns the changelog of the package, really cool!

$ man rpm

Man is your best friend :)


Yum repositories

All the repositories in Fedora are stored in /etc/yum.repos.d/ The typical fedora.repo looks like that:

[fedora]
name=Fedora $releasever - $basearch
failovermethod=priority
#baseurl=http://download.fedoraproject.org/pub/fedora/linux/releases/$releasever/Everything/$basearch/os/
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=fedora-$releasever&arch=$basearch
enabled=1
#metadata_expire=7d
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$basearch

[fedora-debuginfo]
name=Fedora $releasever - $basearch - Debug
failovermethod=priority
#baseurl=http://download.fedoraproject.org/pub/fedora/linux/releases/$releasever/Everything/$basearch/debug/
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=fedora-debug-$releasever&arch=$basearch
enabled=0
metadata_expire=7d
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$basearch

[fedora-source]
name=Fedora $releasever - Source
failovermethod=priority
#baseurl=http://download.fedoraproject.org/pub/fedora/linux/releases/$releasever/Everything/source/SRPMS/
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=fedora-source-$releasever&arch=$basearch
enabled=0
metadata_expire=7d
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$basearch

Enable and GPGKey is the two variables that we can use to enable(1)/disable(0), the repositories and the gpg checks.

Fedora comes by default with 3 repositories, fedora.repo, fedora-updates.repo and fedora-updates-testing.repo. As their names suggest, the first is the stable and the only one that is enabled by default. Also we can add the Rawhide repository which is the next development version of Fedora.

$ sudo yum install fedora-release-rawhide

which is extremely unstable! If you enable Rawhide you must to disable the other three.


Yum Plugins

Yum in Fedora comes with some plugins enabled by default (like presto) but there are lots of plugins out there to install. One of the most common and highly recommended is Fastest Mirrors

The Fastest Mirror plugin is designed for use in repository configurations where you have more than 1 mirror in a repo configuration. It makes a connection to each mirror, timing the connection and then sorts the mirrors by fastest to slowest for use by yum. This won’t work behind a proxy!

sudo yum install yum-plugin-fastestmirror

Yum plugins configuration is stored in /etc/yum/pluginsconfig.d, and from there you can enable or disable them. But you can also disable a plugin instantly.

yum check-update --disableplugin=fastestmirror

Run Yum behind a proxy

To enable yum operations to use a proxy server you should first add the following parameter to /etc/yum.conf

proxy=http://yourproxy:8080/

where yourproxy is the name of the proxy server you want to access and 8080 is the proxy port. If the server requires authentication you can specify the login credentials like:

proxy=http://username:password@yourproxy:8080/

The rpm package manager makes use of the proxy environment variable. This can be set system wide in /etc/profile or user specific in ~/.bash_profile

export http_proxy=http://yourproxy:8080/ export ftp_proxy=http://yourproxy:8080/

To use wget throug a proxy server add the following lines to /etc/wgetrc

http_proxy = http://yourproxy:8080/  ftp_proxy = http://yourproxy:8080/

In both cases, login information can be set like in the example above.

source: CentOS wiki


Keep more than 3 kernels

In Fedora there are some special packages that are “installed only” and cannot be updated. These (as far as I know) are only the kernels. A default Fedora Yum configuration is set to keep the three latest kernels. However sometimes is critical to keep more kernels. We can easily manage the number of the kernels that yum installs by editing yum.config.

vi /etc/yum.config

[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=3

And obviously we need to change the installonly_limit variable to any number.


Packages installation Priorities

Sometimes we need to define a specific package (ie a kernel, Php etc) to be updated from a specific repo no matter if there is a more updated version in another repo. While many people using yum plugins like “Priorities”, it isn’t a very nice way to do things. I will try to make a detailed guide on this later, as I needed it recently :)


Notes

All the above “just works” but it is better if you read the documentation in Fedora and CentOS and always use the man program :)


 
  We can't watch comments unless G+ provides an API or if you send a notification, e.g +World Of Gnome
     Sometimes is better to place your questions on GNOME Community
  • katastrophal

    A very useful command to quickly undo a transaction is ‘yum history’. :-)

  • http://twitter.com/mimurrayy murrayy

    You can also use “EDITOR=nano visudo” to edit /etc/sudoers with nano and still have visudo check for errors afterwards.

    • alex285

      Nice one!

  • Enrico Bastelli

    @8e61bbdfadfcc12af4af5f4fb8fabd39:disqus

    # yum history undo last
    You can undo the last transaction of yum, it’s really MORE than useful :-D

  • Stiph

    Wow, *never* use rpm just for that, yum works perfectly with local files (you do not even need yum localinstall, just yum install ). Yum will not be able to track the install/removal, so you can not use the yum history and a lot of other nice things. That is why yum emits a warning when the rpm database has been changed by running rpm manually! rpm should only be used manually to really cope with a very hard issue.

    • Stiph

      I meant yum install *path to rpm*, my message was mangled somehow.

      • alex285

        Wow, I didn’t know that!

  • http://profiles.google.com/tshimulu Luya Tshimbalanga

    Like Stiph mentioned, rpm command should be use as last resort.
    Here is a list of yum search equivalent of rpm:
    rpm -q package yum list installed package or yum search
    rpm -qa yum list installed
    rpm -qa | grep -i gnome-do yum list installed | grep -i gnome-do or yum list installed gnome-do*

    Searching changelog is also possible with the additional plugins from yum (yum-plugin-changelog)

    yum distro-sync -> Synchronize installed packages to the latest available versions

    • alex285

      Thank you for these. I will re-write a post based on your comments; I have to read some in yum docs. Why rpm program should be use as last resort? There is a difference installing/removing packages with yum and rpm?

      • http://profiles.google.com/tshimulu Luya Tshimbalanga

        For these reasons, yum database and dependencies solver. Think rpm like dpkg which is not designed to resolve dependancy although rpm detailed a list of needed packages. As a packager myself, I use rpm only if there is no yum command equivalent.

  • http://varemenos.com/ Adonis K. (Varemenos)

    Does yum support ppa repos?

    • alex285

      Ofc not! Yum and Fedora have their own repos. Similar to Ubuntu, ok almost similar ..and not so many!

  • Pingback: Links 15/10/2012: New Btrfs Features In Linux 3.7, New E17 Snapshot | Techrights