Life of a Geek Admin

The Daily adventures of a true geek administrator

Life of a Geek Admin - The Daily adventures of a true geek administrator

Useful RPM and YUM Commands

RPM and YUM commands are used daily by RHEL/CentOS/Fedora Administrators and sometimes having a few more tricks up you sleeve for getting information from the command line are always handy to have.  Listed in this post are 14 useful commands for RPM and YUM.

1. Getting rpm to display architecture

This one is a pretty simple tip, and very useful especially for people using x86_64 systems. Just one line in ~/.rpmmacros will save all sorts of trouble later.

$ echo "%_query_all_fmt %%{name}-%%{version}-%%{release}.%%{arch}" >> ~/.rpmmacros

2. Query packages not from Redhat

Want to query all those packages installed from 3rd party repositories, not Redhat?

$ rpm -qa --qf '%{NAME} %{VENDOR}\n' | grep -v -i redhat

3. Reset File Permissions

Have you managed to completely mess up file permissions for a given package? Not a problem, because RPM has you covered.

$ rpm --setperms <packagename>

4. View the Changelog

Because Redhat and the upstream vendor have backported security patches, the version numbers can often be misleading when you look for CVE fixes. Checking the changelog of a package is a good way to see if the fix has been implemented. Once again, rpm comes to the rescue.

$ rpm -q --changelog <packagename>

5. Where’s the Documentation?

To quickly list documentation relating to a package, you can use the following two options:

$ rpm -qd <packagename>

This will show you the documentation contained in that rpm, or if you only have a filename you can do:

$ rpm -qdf /path/to/file

and rpm will show you the documentation in the package that owns the file.

6. Package Origin

Occasionally it’s nice to know where you got certain packages, or how many packages you have on your system from a particular repository or vendor. There are a couple of search options that you can use which are not in the rpm man pages to help you out here. While they’re not 100% perfect, they certainly help out. Most package repositories tag their packages with an identifier in the Release string. For example rpmforge uses rf as their identifier. You can use this to see what you have of theirs installed with

$ rpm -qa release="*rf*"

or if you want to see just how many packages you have installed built by Fred you could use

$ rpm -qa packager="Fred*"

This trick works for most categories visible in rpm -qi <packagename>.

Another approach is to use the keychecker package available in the EPEL repository, which lists rpm packages based on the GPG key they were signed with.

7. Extract just one File

If you need to extract just one file from an rpm without reinstalling the whole package, you can do this with rpm2cpio. For example, to extract just the config file from the logrotate rpm you would use the following statement:

$ rpm2cpio logrotate-1.0-1.i386.rpm |cpio -ivd etc/logrotate.conf

8. Query Package Install Order and Dates

Useful after an upgrade to find old packages that were not upgraded.

$ rpm -qa --last >~/RPMS_by_Install_Date

Review the end of the output file in “less” to find all RPMS older than the install date. Can also grep for specific packages and see when they were installed.

9. Query Available Packages from a Repo

Find all packages available from a specific repository, e.g. RPMfusion. This does not show the already installed packages from this repository.

$ yum --disablerepo "*" --enablerepo "rpmfusion" list available

10. Search yum repositories for a string

Find packages containing a string in package name or description.

$ yum search buildrpmtree | less

11. Using yum with a proxy server

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 through 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.

12. Use yum to install a local package, automatically checking/satisfying dependencies

$ yum --nogpgcheck localinstall packagename.arch.rpm

13. Display priority scores for all repositories

You can list all repositories set up on your system by a yum repolist all. However, this does not show priority scores. Here’s a one liner for that. If no number is defined, the default is the lowest priority (99).

$ sed -n -e "/^\[/h; /priority *=/{ G; s/\n/ /; s/ity=/ity = /; p }" /etc/yum.repos.d/*.repo | sort -k3n

14. Show all installed GPG keys

Shows all GPG keys along with the corresponding repo information.

 rpm -q gpg-pubkey --qf '%{name}-%{version}-%{release} --> %{summary}\n'

 

Hope this has added a few more ticks up your sleeve as it has mine!

How To Install Bluefish 2.2.4 on Fedora 18

Bluefish is a great Web Development IDE for Linux / Windows and Mac OSX. Having the latest and greatest on Fedora 18 is always a plus and sadly in the repositories it is at 2.2.3 and not 2.2.4, but great news we can take care of that in short order.

If you have installed Fedora’s supplied Bluefish you will need to uninstall it.

$ sudo rpm -e bluefish bluefish-shared-data

Now let’s download the lateste and install it. First download 2.2.4 from http://www.bennewitz.com/bluefish/stable/binaries/Fedora18/.

and now the really difficult part, open a terminal and type.

$ sudo rpm -ivh bluefish-2.2.4-3.fc18.x86_64.rpm

and that’s all there is to it. You can start it using the link in the menu or from a prompt.

bluefish1

How to Install Tiny Tiny RSS on Fedora 18

If you are an avid reader of RSS feeds then you are aware of Google Reader and Google’s decision to remove the service, leaving users scrambling for a replacement. One such solution is a standalone system so you do not have to rely on a service that may go away. With Linux there are many open sourced options available. One such option is Tiny Tiny RSS which runs using the standard LAMP stack on your distribution.

Install some dependencies.

 $ sudo yum install php-theseer-fDOMDocument php-mbstring php-mysql msql-server httpd php perl-DBD-MySQL

UntarTiny Tiny RSS into /var/www/html

$ tar zxfv Tiny-Tiny-RSS-1.7.9.tar.gz
 $ sudo mv Tiny-Tiny-RSS-1.7.9 /var/www/html/tt-rss
 $ cd /var/www/html
 $ sudo chown -R root:root tt-rss/
 $ cd tt-rss/
 $ sudo chmod -R 777 cache/images
 $ sudo chmod -R 777 cache/upload
 $ sudo chmod -R 777 cache/export
 $ sudo chmod -R 777 cache/js
 $ sudo chmod -R 777 feed-icons
 $ sudo chmod -R 777 lock

Login to MySQL and create user and database fo the app to use.

$ mysql -u root -p
 mysql> CREATE DATABASE `ttrss` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
 mysql> CREATE USER 'ttrss'@'localhost' IDENTIFIED BY 'ttRss1';
 mysql> CREATE USER 'ttrss'@'%' IDENTIFIED BY 'ttRss1';
 mysql> GRANT ALL ON `ttrss` . * TO 'ttrss'@'localhost';
 mysql> GRANT ALL ON `ttrss` . * TO 'ttrss'@'%';
 mysql> exit

 

Open browser and go to http://localhost/tt-rss/install

Enter in credentials for MySQL db

After finishing with the installer, open your Tiny Tiny RSS installation at http://localhost/tt-rss/ and login with default credentials (username: admin, password: password)

Now you are ready to customize Tiny Tiny RSS!

How To setup FreeNX-Server on Fedora 18 x64

Admit it, sometimes you need to have the GUI when accessing your Linux system, most times SSH access is all you need. A good option is NoMachine’s NX server with FreeNX running on your Fedora system.

Here is a way to successfully install.

Become root

$ sudo su -

Now install freenx-server

# yum install freenx-server

This will install any dependent programs it needs.

freenx1

After the installation has completed we need to configure freenx-server
# nxsetup –install –setup-nomachine-key

freenx2

Now we need to make a few changes to node.conf file

# vi /etc/nxserver/node.conf
Un-comment ENABLE_USERMODE_AUTHENTICATION=”0″
Un-comment ENABLE_SSH_AUTHENTICATION=”1″

Un-comment and Change DISPLAY_BASE=1000 to DISPLAY_BASE=1001
Un-comment ENABLE_CLIPBOARD=”both”
Un-comment and change NX_LOG_LEVEL=0 to NX_LOG_LEVEL=4
Un-comment NX_LOGFILE=/var/log/nx/nxserver.log

Depending on your window manager you will have to un-comment
For KDE
COMMAND_START_KDE=startkde
for Gnome
COMMAND_START_GNOME=gnome-session

Un-comment and change COMMAND_MD5SUM=”openssl md5″ to COMMAND_MD5SUM=”md5sum”

Save the changes to the file

start freenx-server when booting up Fedora
# systemctl enable freenx-server.service

start freenx-server
# systemctl start freenx-server.service
# systemctl status freenx-server.service

freenx3

Copy the generated client.id_dsa.key to a location for import on your client, Windows or Linux. For this post I will be using a Windows client.

$ sudo cp /var/lib/nxserver/home/.ssh/client.id_dsa.key ~/

Next part of the process is to download and install the NoMachine NX client. Download the Windows client from http://www.nomachine.com/download-package.php?Prod_Id=3835. Download NX Client for Windows and nxfonts-75dpi-3.5.0-1.exe

You can optionally download

  • nxfonts-100dpi-3.5.0-1.exe
  • nxfonts-misc-3.5.0-1.exe
  • nxfonts-others-3.5.0-1.exe

Double click to install the packages. Once installed you will need to start the client and configure it. Make sure to import the client.id_dsa.key from the server.

freenx6

After a successful login.

freenx7

On the Fedora system you can grep for nx (ps -ef | grep -i nx) and should now see the server running and a connection.

freenx4

How To Install Skype on Fedora 18 x64

Skype is a widely used application and running Skype is easy to do on Fedora 18 x64, so how do we install it? First we need to install the 32 bit libraries.

$ sudo yum -y install libXv.i686 libXScrnSaver.i686 qt.i686 qt-x11.i686 pulseaudio-libs.i686 pulseaudio-libs-glib2.i686 alsa-plugins-pulseaudio.i686 qtwebkit.i686

Download  the  Skype  rpm  from the  website http://www.skype.com/go/linux. The current download is for Fedora 16 32 bit and will work just fine. Now install it.

$ sudo rpm  -ivh  skype-4.1.0.20-fedora.i586.rpm

And that’s all there is to it. Open Skype and sign in or sign up!

How To Install LibreOffice 4.0 on Fedora 18

Today is the big day, LibreOffice 4.0 has been released and there many new features. We are going to show how to install LibreOffice 4.0 on Fedora 18. Ever since the fork I have been using LibreOffice and it has never disappointed me, so I had to see what 4.0 has and get it on Fedora 18. So here is how it is done.

First we need to remove the LibreOffice install and remove them. Using the handy rpm command it is easy to find.

$ sudo rpm -qa | grep -i libreoffice
libreoffice-math-3.6.3.2-8.fc18.x86_64
libreoffice-writer-3.6.3.2-8.fc18.x86_64
libreoffice-ure-3.6.3.2-8.fc18.x86_64
libreoffice-opensymbol-fonts-3.6.3.2-8.fc18.noarch
libreoffice-pdfimport-3.6.3.2-8.fc18.x86_64
libreoffice-presenter-screen-3.6.3.2-8.fc18.x86_64
libreoffice-kde-3.6.3.2-8.fc18.x86_64
libreoffice-xsltfilter-3.6.3.2-8.fc18.x86_64
libreoffice-calc-3.6.3.2-8.fc18.x86_64
libreoffice-core-3.6.3.2-8.fc18x6_64
libreoffice-draw-3.6.3.2-8.fc18.x86_64
libreoffice-langpack-en-3.6.3.2-8.fc18.x86_64
libreoffice-graphicfilter-3.6.3.2-8.fc18.x86_64
libreoffice-impress-3.6.3.2-8.fc18.x86_64

As we can see we have a few packages to remove. So in one line we type them (copy paste is must quicker).

$ sudo yum remove libreoffice-writer-3.6.3.2-8.fc18.x86_64 libreoffice-ure-3.6.3.2-8.fc18.x86_64 libreoffice-opensymbol-fonts-3.6.3.2-8.fc18.noarch libreoffice-pdfimport-3.6.3.2-8.fc18.x86_64 libreoffice-presenter-screen-3.6.3.2-8.fc18.x86_64 libreoffice-kde-3.6.3.2-8.fc18.x86_64 libreoffice-xsltfilter-3.6.3.2-8.fc18.x86_64 libreoffice-calc-3.6.3.2-8.fc18.x86_64 libreoffice-core-3.6.3.2-8.fc18.x86_64 libreoffice-draw-3.6.3.2-8.fc18.x86_64 libreoffice-langpack-en-3.6.3.2-8.fc18.x86_64 libreoffice-graphicfilter-3.6.3.2-8.fc18.x86_64 libreoffice-impress-3.6.3.2-8.fc18.x86_64 libreoffice-math.x86_64 1:3.6.3.2-8.fc18

Next download lastest LibreOffice 4.0 from http://www.libreoffice.org/download

Extract the downloaded file.

$ tar -xzvf LibreOffice_4.0.0_Linux_x86-64_rpm.tar.gz

Change to the directory

$ cd LibreOffice_4.0.0_Linux_x86-64_rpm/RPMS

Install the new rpm’s

$ su -c 'yum install *.rpm'

Now we need to install the menu entries on the system, the files are under the desktop-integration folder.

$ cd desktop-integration
$ su -c 'yum install libreoffice4.0-freedesktop-menus-4.0.0-103.noarch.rpm'

Give the system a bit to refresh he menus and the shortcuts will be in the same place as the old ones and you are ready to go!

 

LibreOffice 4.0

LibreOffice 4.0

How To Disable ipv6 Fedora 17/18

IPV6 is coming, but it is not here yet, so say you want to disable it on your Fedora 18 system. Pretty simple to do. First let’s edit the /etc/sysctl.conf file.

$ sudo vi /etc/sysctl.conf

Add and save the changes

net.ipv6.conf.all.disable_ipv6=1
net.ipv6.conf.default.disable_ipv6=1

To eliminate the default ipv6 addresses still appear on the interfaces open a terminal and type

Type ifconfig to get the inet6 info and the adapter

$ ifconfig
lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 0  (Local Loopback)
        RX packets 84  bytes 7100 (6.9 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 84  bytes 7100 (6.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

p2p1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.20  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::a00:27ff:fedc:5b71  prefixlen 64  scopeid 0x20<link>
        ether 08:00:27:dc:5b:71  txqueuelen 1000  (Ethernet)
        RX packets 234990  bytes 115274228 (109.9 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 210670  bytes 40730873 (38.8 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        
$ sudo ip addr del ::1/128 dev lo
$ sudo ip addr del fe80::a00:27ff:fedc:5b71/64 dev p2p1

$ ifconfig
lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        loop  txqueuelen 0  (Local Loopback)
        RX packets 84  bytes 7100 (6.9 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 84  bytes 7100 (6.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

p2p1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.20  netmask 255.255.255.0  broadcast 192.168.1.255
        ether 08:00:27:dc:5b:71  txqueuelen 1000  (Ethernet)
        RX packets 235487  bytes 115320518 (109.9 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 210678  bytes 40731473 (38.8 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

Comment out ::1 in /etc/hosts

$ sudo vi /etc/hosts

# ::1 localhost

Save the file and reboot the system

How To Connect to a Local Directory on a Windows Host with a Linux Guest in VirtualBox

Recently I felt the need to retrieve files from my Windows host on my Linux guest in VirtualBox 4.2.6. This is an easy task with the VBoxAdditions installed on the guest OS and a simple change in the shared folders in VirtualBox.

If VBoxAdditions are not installed on the guest host you must first get them installed. If you are running Fedora 17 or 18 look here for the instructions.

Next make sure to power off the guest VM and once powered off open the Settings for the VM and click on Shared folders.

shared1

Click on the add folder icon on the right side and a dialog box will open asking for the folder to add, you can type in the path ex: c:\Download or browse for it by selecting the drop down and select Other.

shared2

Insert a Folder Name and select Auto-mount. Click OK to accept the changes and restart the guest VM.

shared3

Once you have logged into your Linux VM you are ready to create a directory to mount and then mount the shared folder. In this example I have created the /mnt/share folder. Now all that is needed is to execute.

$ sudo mount -t vboxsf Download /mnt/share

Now we can get to the files but this command will have to be run every time, so why not create a shell script called mntshare.sh and just populate it with the exact command you ran. Now each time you start the VM you just run ./mntshare.sh.

Note that with this, the default mount options are used and all files are owned by root. This can be changed by adding some mount options. Options are passed on with the -o parameter. You can use multiple options with one parameter, separate the values with a comma.

$ sudo mount -t vboxsf -o uid=1000,gid=1000 Download /mnt/share

And that is all there is to creating and accessing a shared folder in VirtualBox.

How To Install VBoxAdditions on Fedora 18

With the latest Fedora release now out it is time to get it installed as a VM in VirtualBox and get the VBoxAdditions installed. First make sure you have VirtualBox 4.2.6 installed and then install Fedora as a VM as you usually do. Once you have all the latest updates installed and a few added programs, you are ready to install the VBoxAdditions.

First you will need to install gcc kernel-devel kernel-headers dkms make bzip2

$ sudo yum -y install gcc kernel-devel kernel-headers dkms make bzip2

Now lets mount the VBoxAdditions, click Devices > Install Guest Additions.

vbox-guest-additions

VirtualBox will mount it to /run/media/<userid>/VBOXADDITIONS_4.2.6_82870. Open a terminal and change to the directory. Substitute <userid> with your login id.

$ cd /run/media/<userid>/VBOXADDITIONS_4.2.6_82870
$ sudo ./VBoxLinuxAdditions.run
Verifying archive integrity... All good.
Uncompressing VirtualBox 4.2.6 Guest Additions for Linux.........
VirtualBox Guest Additions installer
Removing installed version 4.2.6 of VirtualBox Guest Additions...
Removing existing VirtualBox DKMS kernel modules           [  OK  ]
Removing existing VirtualBox non-DKMS kernel modules       [  OK  ]
Building the VirtualBox Guest Additions kernel modules
Building the main Guest Additions module                   [  OK  ]
Building the shared folder support module                  [  OK  ]
Building the OpenGL support module                         [  OK  ]
Doing non-kernel setup of the Guest Additions              [  OK  ]
You should restart your guest to make sure the new modules are actually used

Installing the Window System drivers
Installing X.Org Server 1.11 modules                       [  OK  ]
Setting up the Window System to use the Guest Additions    [  OK  ]
You may need to restart the hal service and the Window System (or just restart
the guest system) to enable the Guest Additions.

Installing graphics libraries and desktop services component[  OK  ]

Now all that is left is to reboot.

 

How To Enable Encrypted DVD Playback Fedora 18

Just installed Fedora 18 and can’t wait to watch Starship Troopers or Matrix? Well no worries here, just need to install a few packages. First we need to install libdvdnav and libdvdread which will allow us to play non-encrypted DVD’s.

$ sudo yum install libdvdread libdvdnav

To read encrypted DVD’s we need libdvdcss2, which in this case is available from atrpms.

For 32-bit systems:

$ sudo rpm -ivh http://dl.atrpms.net/f18-i386/atrpms/stable/libdvdcss2-1.2.11-6.fc18.i686.rpm

For 64-bit systems:

$ sudo rpm -ivh http://dl.atrpms.net/f18-x86_64/atrpms/stable/libdvdcss2-1.2.11-6.fc18.x86_64.rpm

Now we need something to play them so lets go with VLC.

$ sudo yum install vlc

That’s all we need and we are ready to start watching our favorite DVD’s.

Switch to our mobile site