среда, 20 апреля 2016 г.

Browse WWW from terminal

Preface

With FreeBSD (and *nix in general) you can browse the WWW from your text terminal. There is a several text based WWW browsers (elinks based on links based on lynx, Edbrowse, W3M). All of them are not require you to buy expensive hardware to run them. They even work without graphical subsystem.

I am going to show you how to install the ELinks browser.

Installation

Just enter the next command and confirm downloading the package and installing the software.
% sudo pkg install elinks
To run the browser execute, for example, the next command.
% elinks ddg.gg




The ddg.gg is a shortcut link to the DuckDuckGo search engine page.

The greeting screen looks as shown below.


Usage of ELinks is pretty simple and intuitive. Just follow on-screen tips.







ELinks works without graphics (X11) from terminals and terminal emulators.






So you can search something in the Internet, and even use FTP, IRC and a few other protocols with ELinks. Enjoy!

Bibliography

1. Хабрахабр. Обзор текстовых вeб браузеров, date: 2016-04-20.

пятница, 15 апреля 2016 г.

Build a custom kernel

Build a custom kernel

Today I will show you how to build your custom kernel based on the standard GENERIC kernel.

Why?

Let me explain a situation when the custom kernel is useful. I love the MATE desktop environment with the classic GNOME2ish design. The MATE contains the libmatemixer package which provides, for example, possibility to adjust volume level using the according volume panel applet. The libmatemixer's package built with 4FRONT OSS support. Every time I upgrade software packages I have to make libmatemixer with ALSA support from the port.

This is not good. I think so. But I can't merely do `pkg remove alsa ; pkg install oss` because the 4FRONT OSS conflicts with NewPCM OSS built in FreeBSD 10's kernel by default. So before I will be able to install and use OSS from 4FRONT Technologies, I have to cut off all the audio drivers from the default GENERIC kernel.

To do this...

Create a new kernel configuration

Log in to the system as root. Go to the /usr/src/sys/i386/conf directory (where i386 is the architecture of your machine). Then create (if not exists) a directory where you are going to work with your kernels (/root/kernels for example). Then copy an existing kernel configuration to start from and open it in your favorite editor.

cd /usr/src/sys/i386/conf
mkdir /root/kernels
cp GENERIC /root/kernels/F1
ln -s /root/kernels/F1
vi F1

I started from the supplied GENERIC kernel. The first screen of its configuration looks like on the next screenshot.


Configure new kernel

Do not hesitate changing the title and the description of the new kernel in its configuration file.

I recommend you to save the kernel configuration after typing the comment to avoid a possible data lost. If you use vi, just press ESC, type the :w command and press ^j.

I am too lazy to make long description of kernels, so I just noted that my custom kernel called F1 (like the first generation in the biology/genetics) and that it does not contain any sound driver.

To configure (cut off) sound drivers, find the Sound support section in the kernel configuration file using the /Sound vi command.

In vi: press ESC, type /Sound and then press ^j.

This command will toggle you to at about 340 line.


To remove all sound devices drivers, commend out all the lines in the "sound support" section.


Comment all the lines in the "Sound support" section. In vi you may use the next command:
:342,349s/^/#

In vi you may use the :342,349s/^/# command to add the # sign to the beginning of all lines from 342 to 349 (in your configuration file sound support section may be located in the different lines interval!).

vi says that 8 sound devices drivers was excluded from the kernel

Save changes in the kernel configuration file.

Use :wq command of vi to save changes in the kernel configuration file and exit the editor.

Build the kernel

After the kernel is configured, you can build it. Go to the /usr/src directory and start build process.

cd /usr/src
make buildkernel KERNCONF=
F1
# where F1 is the name of the kernel you want to build

The kernel build process takes several minutes and looks like this


On my system it took ten or even twenty minutes.

After the kernel is built you will see the according message on the screen. Now it is possible to...

Install the kernel

To do this just enter the next command


make installkernel KERNCONF=F1

and wait several minutes.

The kernel installation process

Reboot the machine after kernel installation complete.

shutdown -r now
or simple
reboot

Check your work

Look at the output of the uname -a command after reboot. The output should contain the name of the newly installed kernel.

uname -a

To ensure that my new kernel does not support my audio card I started the MPlayer and noticed that there is no sound now. Also I noticed the error message from OSS about missing audio device file.


Advanced. Configuration including

It is possible to include the one kernel configuration to the yours. Like "inheritance" in OOP. " This allows another configuration file to be included in the current one, making it easy to maintain small changes relative to an existing file" documentation says.

You are able to use the next self-descriptive options.
  • option
  • nooption
  • device
  • nodevice
Below is the example of the my kernel configuration based on the GENERIC kernel. My configuration just disables sound devices support from the kernel.
nodevice sound
nodevice snd_cmi
nodevice snd_csa
nodevice snd_emu10kx
nodevice snd_es137x
nodevice snd_hda
nodevice snd_ich
nodevice snd_via8233

Conclusion

So, I proud to say: the mission is complete. I removed audio support from the system. I am going to install the 4FRONT OSS sound system package next week or to. Thank you for your interest.

Bibliography

  1. Руководство FreeBSD. Глава 9. Настройка ядра FreeBSD, 9.5. Сборка и установка собственного ядра.
  2. Open Sound System for FreeBSD
  3. Configuring the FreeBSD Kernel. The Configuration File.


четверг, 14 апреля 2016 г.

Listening to the online radio with MPlayer

Install MPlayer

What if I want to listen to the online radio having got only base FreeBSD system? In this case I should only install the MPlayer package. MPlayer is a minimalist but powerful audio and video player, media encoder. It even can repair broken files.

To install it you should execute the next command.

The pkgng may ask you for the confirmation of updating itself. Don't disagree :)

After the pkg package is updated, confirm downloading and installing all packages required for MPlayer functioning.






As you can see MPlayer weights at about 60MB and requires you to download only 16MB over the network. You even needn't to find a [suspected] distributive over the Internet. And this works 'out of the box'. This is why I like UNIX.






Look! MPlayer is installed and you can now use it. But wait! You may ask "How can I use it if there is no graphics on the 'desktop'?". I'll ask: easy, MPlayer does not require video drivers and graphical X11 desktop. You can listen to the music or online radio from your terminal and do your work on the 2nd, 3rd, ..., 8th terminals. (This is the second reason I like UNIX: I have not to install tons of unnecessary software if I just want to listen to the radio.)

How yo use MPlayer

Easy (assuming you already have the a working Internet connection and integrated or discrete sound card, speakers). To listen to the radio you should use the command like this:
$ mplayer 'LOCATOR'
Where the LOCATOR is an media resource locator of the online radio stream (in simple words: URL of the stream you want to listen).

For example:
starts MPLayer and outputs the sound.

To sum up

I want to say that there is nothing impossible for modern operating systems. But FreeBSD (and many other *nix systems) really makes our life easy (compare to the heavy WMP with its horrible startup wizard). MPlayer is cool and easy to use. And you can quickly install it using the FreeBSD's pkgng manager in a seconds.






вторник, 5 апреля 2016 г.

The sudo primer

Introduction

To prevent spoiling your system you should avoid usage of dangerous su command. The sudo utility will help you with that. I am going to show you how to install it and perform its initial configuration.

Intallation

To install the sudo utility just run the next command (as super user)
pkg install sudo

Configuration

Using visudo edit the sudoers file. Add the next lines to the according sections

alias of your host


Host_Alias     LOCALHOST     =     fbsd.fbsd.gf4
where LOCALHOST is just host alias (like variable or named constant in programming) and fbsd.fbsd.gf4 is the name of your host (which you set during FreeBSD installation or configuration; you can find the value in the /etc/rc.conf file, under the hostname option)

user group alias

User_Alias     ADMINS     =     vasily
(you can use the whoami command to determine your user name)

enumerate commands to allow

Cmnd_Alias     PACKAGES     =     /usr/sbin/pkg
[use whereis pkg (pkg is just for example) to get the full path to the command you interested in]

specify the privilege

for example
ADMINS     LOCALHOST=(root)     PACKAGES

save changes and exit su

The picture for the example above

Usage

After you install and configure the sudo utility, you will be able to use the privileged commands from your regular user like this
sudo pkg update
First time sudo will show you the next message.

When sudo prompts the password, please type the password of the user you are working as!

Read the next

Install MPlayer and listen to the online radio.

Bootstrapping package manager

Afrer you installed FreeBSD it is necessary to initialize package manager: pkgng.
I do not know how simple is package management on linux, but I would have you believe that in FreeBSD it is very easy.

Just run the next command (as super user):
# pkg update
and then confirm bootstrapping.

Continue reading -> The sudo primer.