dirname

The dirname command will give you the path of the file that you provide as parameter, up to its parent directory. If the parameter is an absolute path, the absolute containing directory will be returned, otherwise it will be the relative path.

For example, for the file /home/marios/.bash_aliases:

{% highlight bash %} [email protected]:~$ dirname /home/marios/.bashaliases /home/marios [email protected]:~$ dirname ~/.bashaliases /home/marios [email protected]:~$ dirname .bash_aliases . {% endhighlight %}

See also

/etc/shadow

The fields, delimited by : are:

  1. Username
  2. Password (hashed)
  3. Last password change (in days since 1970-01-01)

Fields

Notes on specific fields.

Username

Fairly straightforward. The lenght used to be restricted to 8 characters maximum in very old distributions, now it's 32 characters on most distributions.

Password

An empty field, will allow the user to login without providing a password, whereas a field that starts with, or only contains an asterisk * indicates a disabled account.

The first characters of this field define the hashing algorithm, one of:

  1. MD5 - password starts with $1$
  2. Blowfish - password starts with $2a$
  3. SHA-256 - password starts with $5$
  4. SHA-512 - password starts with $6$

tail

tail can display the last lines of a text file, and can optionally follow the file and display new lines as they are appended to it.

See also

  • tailf: a utility that does the same as tail -f, but consumes less resources on the system.

Set up an HTTP Repository from RHEL DVD

RHEL can be installed from various different sources. One of them is over the network, from an HTTP accessible repository. Here's how to create such a repository:

  1. You will first need to install httpd from the RHEL DVD. See Install packages from RHEL DVD with yum on how to do that.

  2. After you have installed httpd, enable it and start it:

    chkconfig httpd on
    service httpd start
    

    At this point, you should be able to open http://localhost/ from the same system on which you are working.

  3. Create a directory for the repository:

    mkdir /var/www/html/rhel
    
  4. Copy all the files from the DVD to the repository. Assuming that either the DVD or the .iso image is mounted at /media/rhel:

    cp --recursive --archive /media/rhel/. /var/www/html/rhel/
    
  5. Change the SELinux context of the files in the repository:

    chcon --recursive --reference=/var/www/html/ /var/www/html/rhel/
    
  6. At this point the repository is only accessible from the system on which it runs, since iptables by default does not allow HTTP traffic from other hosts. To open this access, edit your /etc/sysconfig/iptables and add this line before the COMMIT command:

    -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
    

    ...and reload the firewall:

    service iptables reload
    

    Alternatively, you can do from the command line:

    iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
    service iptables save
    

Bash Scripting

Functions

Install packages from RHEL DVD with yum

There are a lot of packages available on the RedHat Enterprise Linux Installation DVD (I count 3764 .rpm files on version 6.5 Beta), and you can mount the DVD on your system and then use it as a repository to install them with yum. To do that:

  1. First you need access to the files on the DVD. If the disk is inserted in a physical DVD drive on your system, or if you are working in a virtual machine and you have the DVD attached to the VM's virtual optical drive, you can mount it with:

    mkdir /media/rhel
    mount /dev/cdrom /media/rhel
    

    Otherwise, if you have the .iso image locally on the system, you can mount that one instead:

    mkdir /media/rhel
    mount -o loop /root/rhel.iso /media/rhel
    
  2. Next, you need to create a Yum repository pointing to the mounted disk. To do that, create a new .repo file in the /etc/yum.repos.d/ directory:

    vi /etc/yum.repos.d/rhel-media.repo
    

    ...and populate it with the following lines:

    [rhel-media]
    name=rhel-media
    baseurl=file:///media/rhel
    gpgcheck=1
    enabled=1
    gpgfile=file:///media/rhel/RPM-GPG-KEY-redhat-release
    

    If you don't remember the configuration lines listed above, you can peak at other .repo files in /etc/yum.repos.d/.

You can then install packages, for example httpd with simply doing:

yum install httpd

You can also verify that the DVD is the source for that package with:

yum info  httpd | grep Repo
Repo        : rhel-media

/etc/filesystems

On RedHat, CentOS, and probably other RPM-based distributions, the /etc/filesystems file lists the filesystems that are known to the system, i.e. those filesystems that can be mounted without specifying the filesystem type. The contents of that file in a minimal CentOS installation are:

[[email protected] ~]# cat /etc/filesystems
ext4
ext3
ext2
nodev proc
nodev devpts
iso9660
vfat
hfs
hfsplus

How to get Google search suggestions in Firefox on Linux Mint

The Google search feature is not offered as an option in the version of Firefox that comes installed in Linux Mint. You can add it with the Manage Search Engines feature, but when you do, you will notice that there are no search suggestions when you start typing a search term.

To add Google search suggestions, you need to edit the file google.xml, located in the searchplugins directory, inside your Firefox user profile. In my case, the full path for this file is:

/home/marios/.mozilla/firefox/mwad0hks.default/searchplugins/google.xml

Yours should be similar, and the command locate google.xml can help you find the path.

Edit that file, and add the following line:

<Url type="application/x-suggestions+json" method="GET" template="https://www.google.com/complete/search?client=firefox&amp;q={searchTerms}"/>

...somewhere before the closing </SearchPlugin> tag. Restart your Firefox, and suggestions should now work.

About

Hello, I'm Marios Zindilis and this is my website. Opinions are my own. You also find me on LinkedIn and GitHub.

Unless otherwise specified, content is licensed under CC0.

Search