Arch Linux Core Post-Installation

Welcome to my Arch Linux post-installation tutorial! Here, I’m going to teach you how to setup and build your own personalized desktop with Arch Linux. And also, in this tutorial we are going to setup Arch Linux Core (on a desktop) with:

LXDE: A lightweight desktop environment for Linux. There are other DEs to choose from (e.g. Gnome, KDE, XFCE, etc.) but for this tutorial we are going to use LXDE.

Openbox: Openbox is an opensource and light-weight window manager for Unix/Linux system.

SLiM: Or Simple Login Manager, is also a lightweight login manager for Linux.

This is quite a long process so please bear with me. I’ve grouped the whole installation process into 3 stages, provided 1 stage for the configuration, and I’ve also provided some sample configuration files at the end of the tutorial.


STAGE 1: Modifying Mirrorlist and Installing Input Drivers

Before we go any further, first we need to make sure that we are connected to the Internet. To do that we are going to use the ping command. In TTY just type:

# ping -c 3 yahoo.com

This should return 3 ping results with 0% packet lost.

NOTE: In case ping did not return any result, you can fix this problem and make a connection by simply typing this command:

# dhcpcd eth0 

After we’ve made sure that we are connected to the Internet, we will now refresh and sync our Arch repository and then update the system. To do that, just type this simple command:

# pacman -Syu

Initialize Pacman Keyring

Pacman-Key is a new tool available with pacman 4.0. Based on Arch Linux wiki, “Package signing in pacman uses the “web of trust” model to ensure that packages come from the developers and not from someone impersonating them. Package developers and TUs have individual PGP keys which they use to sign their packages. This signature means they vouch for the contents of the package. You also have a unique PGP key which is generated when you set up pacman-key.”

To initialize and setup pacman keyring, simply type:

# pacman-key –init

You may want to move to another TTY and run:

# cat /dev/urandom

This would help generate more random bytes for generating pacman keychain.

Modify Mirrorlist File

Now, we need to make some simple modifications with our mirrorlist file (/etc/pacman.d/mirrorlist). This is very important since a little misconfiguration on this file may slow down the entire installation process, or worst, keep us from installing anything.
Be default, the mirrorlist file consists of dozens of links to the mirrors available for Arch Linux repository. What we’re going to do here is modify this list, select the fastest in terms of download speed and make it more cleaner, so to speak. Before we do that we need to install a very important tool for this job called reflector. In your TTY, just type:

# pacman -S reflector

After you have installed reflector, backup your mirrorlist file by running this command:

# cd /etc/pacman.d
# cp mirrorlist mirrorlist.backup

Then using reflector, modify your mirrorlist by typing:

# reflector -c %own% -f 6 > mirrorlist

The ‘-f 6‘ option means to get the 6 fastest mirrors close to your country (-c %own%). Again, don’t forget to sync and update your system after you finished modifying your mirrorlist:

# pacman -Syu

I strongly suggest you reboot after this second update. Just type:

# reboot

Install Input Drivers

Now we are going to install important input drivers along with othe important tools. Please note that installing drivers varies from system to system. In case you are installing on a laptop, there may be some other different drivers that you need to install. Same is true for so many different types of hardware installed in your computer. And since we are installing Arch on a desktop, basically, these are the drivers that need to install – just all the simple stuff.

To install input drivers, just type:

# pacman -S xf86-input-evdev alsa-plugins alsa-utils pulseaudio mesa mesa-demos libgl dbus consolekit

STAGE 2: Creating a Sudoer and Installing X

Now here in the second stage of the installation process, we are going to create a sudoer or a regular user. This adds up to your security since running your system as root may cause some security risk. And by the end of this stage we are also going to install X.

Before we can start creating a sudoer, first we need to install sudo. By using the sudo command, a regular user can run programs that needs root priviledges as if he is root.

To install sudo, just type:

# pacman -S sudo

Creating A Sudoer
Creating a sudoer or regular user in Linux is very simple. We can do this by using the useradd command. Simply type:
# useradd -m -g users -G audio,lp,optical,storage,power,video,games, network,wheel -s /bin/bash pedro
After you’re done creating a sudoer, in this case, the sudoer’s username is ‘pedro‘ we will now create a password for pedro. And we’re going to do that using the passwd command. To add a password to pedro, just type:
# passwd pedro
(You will be asked to enter the password twice to confirm it)

After we have created a sudoer, we need to edit the sudoer file, so that a regular user would be able to run programs that needs root priviledge. If you did not edit the sudoer file, running programs as root, would be virtually impossible. And since the sudoer file is a very sensitive file. We are going to edit it using the visudo command, which would lock the sudoer file for simultaneous edit providing basic sanity check, and preventing parse error. This way we can edit the sudoer file in a safer way.

To use and run the command, just type:

# EDITOR=nano visudo

Now, we can edit the sudoer file – with the help of visudo – using the nano editor.

NOTE: As you can see with the useradd command above, we have also added our username pedro to the wheel group, which group we can see inside the sudoer file.

To enable regulars users to run programs as root using sudo, simply uncommenting the ‘wheel‘ group would do the trick. After uncommenting, the line should now look like this:

%wheel ALL=(ALL) ALL

Optionally, you can also uncomment the line ‘# %wheel ALL=(ALL) NOPASSWD: ALL‘, if you don’t want to enter you password everytime you use sudo. I personally prefer uncommenting this line as well 🙂

Installing X (Xorg Server)

Now, we are going to install X. For more information about X, please visit this link.

To install X, simply type and run this command:

# pacman -S xorg xorg-server xorg-xinit xorg-utils xorg-server-utils xorg-twm xterm xorg-xclock

When asked to enter a selection, just enter all for default.

After you have installed X, we can now run a simple test to see if we have installed it successfully. To do that just type in this simple command:

# startx

If you see something like the image below, then you have successfully installed X Server, which means we can now continue and install some graphical interface to our system. Just type ‘exit‘ to the xterms you below to exit X.

STAGE 3: Installing A Graphical Environment (GUI) and Other Important Plugins

Now we’ve come to the fun part – installing graphical user interface such as LXDE or Linux X11 Desktop Environment.

Please note that by installing LXDE, we also install other programs that’s part of the LXDE package such as, gpicview, lxappearance, lxpanel, lxtask, lxterminal, openbox, pcmanfm and some others. For more information about LXDE, you can visit their website at http://lxde.org/lxde.

To install LXDE, along with other tools that we needed to setup our desktop environment, simply type and run this command:

# pacman -S lxde tint2 nitrogen volwheel xcompmgr networkmanager network-manager-applet gvfs gfvs-afc autofs

After you have successfully installed the LXDE package and the other tools, it’s time to test our new desktop environment, but first we need to switch form root to pedro, which is our regular user, to do that, just type:

# su – pedro

Since you are root before you switch to pedro, you dont have to enter you password to do this.

Now, to go to your LXDE desktop, just type:

$ xinit startlxde

If you have installed LXDE successfully, you should be able to see something like the image below:

The image above is currently the default LXDE interface. LXDE desktop itself is lightweight but there is one interface that’s even more lightweight and fortunately, it’s part of the LXDE package – the Openbox.

To see and experience the Openbox interface, you need to run the openbox-session, but first you need to logout from the LXDE desktop interface. Then in your TTY type:

$ xinit /usr/bin/openbox-session

You should be able to see the empty darkgray canvass-like Openbox desktop with nothing but a simple openbox menu template that you can see when you right-click on it.

Congratulations! You have successfully setup and built your very own Arch Linux with Openbox running the LXDE desktop environment 🙂

SYSTEM CONFIGURATION

Since our newly build openbox desktop is nothing but an empty canvas at the moment, we are going to perform some configuration to make it look more elegant. Just like an artist painting to a blank canvas. We are going install and automate some tools and we are also going to install a login manager called SLiM a little later at the end.
And since we are building for an Openbox desktop, we are going to install some tools that we need to properly configure openbox. In your empty desktop, right-click to open the default openbox menu. Most of the items listed on this menu could only take you to a dead end. But that’s alright, for now, we’re also going to fix that later.
Before we start our system configuration, we need to prepare some config files for openbox and for pcmanfm, which is the default file manager for LXDE. Right-click your Openbox desktop to see the menu, then click Terminals → Xterm to launch the Xterm terminal emulator.
For the Openbox configs, simply run the following commands (please note that the following command lines should be run as a regular user and NOT as root, or else you might end up experiencing some permission issues):

$ mkdir -p ~/.config/openbox
$ cp /etc/xdg/openbox/* ~/.config/openbox

And for the pcmanfm file manager config:

$ sudo mkdir -p /usr/share/lxde/pcmanfm
$ sudo cp -a /etc/xdg/pcmanfm/default/pcmanfm.conf /usr/share/lxde/pcmanfm/pcmanfm.conf

Now, we are going to install some openbox tools that we need. Just type:

$ sudo pacman -S obmenu obconf openbox-themes obtheme pyxdg

This would install the obmenu, which is the GUI menu editor for Openbox, obconf, which is the openbox GUI configuration tool, also some openbox themes package and pyxdg, which is an xdg python library.

After you have installed these tools, we can now start by configuring your openbox menu. Again in Xterm, just type:

$ obmenu

This would launch the openbox GUI menu editor (just like your see in the image below).

Openbox GUI menu editor interface is actually very simple. What it does is, instead of manually coding and editing your openbox menu.xml file inside ~/.config/openbox folder – we use obmenu.

Now, what we’re going to do here, is basically, remove all the default menu items listed in our menu.xml file, and then recreate menu items from scratch. This way we can create menu items, that’s really needed for our setup – nothing more.

Here we have added one item in the openbox menu, and we named it Terminal, which would execute a more configurable terminal emulator that is also part of the LXDE package. So next time, instead of using Xterm, we are going to use LXDE’s default terminal emulator – lxterminal.
Now right-click and open your very own openbox menu, then click Terminal to launch lxterminal.  Here we are going to install some plugins and codecs for mp3, dvd, other multimedia, etc. To do that, just type:

$ sudo pacman -S alsa-oss libdvdread libdvdcss gecko-mediaplayer xine-lib xine-ui flashplugin java-runtime leafpad

Then after that, install some descent looking fonts:

$ sudo pacman -S ttf-dejavu ttf-ubuntu-font-family

Now, you can further more edit your openbox menu by refering to the image reference below:

Now, so much for the menu. We are now going to throw some of the basic stuff we need in our empty desktop, such as some background image, taskbar panel, some system tray icons, etc. We start with the taskbar – tint2.

tint2

tint2 is a very simple, very configurable and lightweight system panel for Linux. To  enable tint2 via terminal, just type:

$ tint2 &

You can automatically run tint2 at startup by adding this line:

tint2 &

to your autostart (~/.config/openbox/autostart) file. Please refer below for the complete initial configuration for our openbox autostart file.

nitrogen

Nitrogen is a fast and lightweight desktop background browser and setter for X windows. To start nitrogen and place a good looking background for your desktop using your terminal just type:

$ nitrogen

For this, you may want to download some images first using a web browser. To install firefox browser, just type:

$ sudo pacman -S firefox

After you have created a desktop background, you can automatically run nitrogen at startup and restore your background image by adding this line to your autostart file:

nitrogen –restore &

VolWheel

VolWheel is a simple tool that place an icon in your system tray. It’s used to adjust the sound of your default sound server. Before we can start volwheel, first we need to start alsa which is currently disable. To enable alsa, just type in your terminal:

$ sudo rc.d start alsa

Then include alsa in the daemons line of your rc.conf file (/etc/rc.conf) to automatically run alsa at startup.

Then setup your asound.state file using the alsactl command. To do that, just run this simple command:

$ sudo alsactl -f /var/lib/alsa/asound.start store

This command will generate a file called asound.state file, which will restore your previous sound settings at startup.

After that, we can now start and run volwheel in your system tray. In your terminal, just type:

$ volwheel &

You can also add this same line of command (without the $ sign of course) in your autostart file to automatically run volwheel at start-up.

nm-applet (Network Manager Applet)

nm-applet is the simple tray icon that indicates your network connections. Before we start nm-applet, first we need to start network manager. To do that just type:

$ sudo rc.d start networkmanager 

You also need to include networkmanager right before network, in the daemons line of your rc.conf file.

Then you can start nm-applet by typing:

$ nm-applet &

Running this command my not run your network icon the way it should right away. It’s alright, to fix that and to automate nm-applet at startup, simply add this line at the top of your autostart file:

(sleep 3 && /usr/bin/nm-applet –sm-disable) &

On your next startup, network manager icon should now run the way it should.

xcompmgr

Xcompmgr is a simple composite manager, capable of rendering dropdown shadows and window transparency. You can start xcompmgr using the terminal by typing:

$ xcompmgr -CcfF &

or adding the exact same line (without the $ sign) to your autostart file to automate dropdown shadows and transparency at start up.

Installing SLiM

SLiM or Simple Login Manager is a simple and lightweight login manager for Linux. To install SLiM, along with some slim theme packages, just type:

$ sudo pacman -S slim archlinux-themes-slim slim-themes

Before you can run slim, you need to edit the slim.conf config file (/etc/slim.conf). Please refer to the final slim.conf file below. You can automate SLiM by adding it to your rc.conf‘s daemons line.

NOTE: Make sure the your login manager, such as SLiM, is located at the end of your daemons line, to prevent some unnecessary boot-up problems.

After you have finished configuring your slim.conf file and adding it to your rc.conf‘s daemons line – reboot!
After you reboot, you should be able to SLiM automatically.

SAMPLE CONFIGURATION FILES

autostart (~/.config/openbox/autostart)

(sleep 3 && /usr/bin/nm-applet –sm-disable) &
nitrogen –restore &
if which tint2 >/dev/null 2>&1; then
    (sleep 2 && xcompmgr -CcfF) &
    (sleep 2 && tint2) &
fi
volwheel &

.xinitrc (~/.xinitrc)

#!/bash/sh
import DE=lxde
exec ck-launch-session dbus-launch
exec lxsession -e LXDE -d openbox-session -a

rc.conf (/etc/rc.conf)

By default your rc.conf’s file DAEMONS line looks like this:

DAEMONS=(hwclock syslog-ng network netfs crond)

After we have setup up everything, your DEAMONS line should now look exactly like this:

DAEMONS=(dbus hwclock syslog-ng networkmanager !network netfs crond autofs @alsa slim)

The apostrophe (!) before the network means it’s been disabled, we do this because since we already have put networkmanager there which now would handle all the network stuff. The at-sign by the way before alsa means alsa would be run at the background.

slim.conf (/etc/slim.conf)

The following is the configured slim.conf file. Highlighted in red are the lines I’ve edited and uncommented.

# Path, X server and arguments (if needed)
# Note: -xauth $authfile is automatically appended
default_path     /usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/bin/vendor_perl:/usr/bin/core_perl
default_xserver     /usr/bin/X
xserver_arguments -nolisten tcp vt07
# Commands for halt, login, etc.
halt_cmd            /sbin/shutdown -h 0
reboot_cmd          /sbin/reboot
console_cmd         /usr/bin/xterm -C -fg white -bg black +sb -T “Console login” -e /bin/sh -c “/bin/cat /etc/issue; exec /bin/login”
#suspend_cmd        /usr/sbin/suspend

# Full path to the xauth binary
xauth_path         /usr/bin/xauth 

# Xauth file for server
authfile           /var/run/slim.auth

# Activate numlock when slim starts. Valid values: on|off
numlock             on

# Hide the mouse cursor (note: does not work with some WMs).
# Valid values: true|false
hidecursor          false

# This command is executed after a succesful login.
# you can place the %session and %theme variables
# to handle launching of specific commands in .xinitrc
# depending of chosen session and slim theme
#
# NOTE: if your system does not have bash you need
# to adjust the command according to your preferred shell,
# i.e. for freebsd use:
# login_cmd           exec /bin/sh – ~/.xinitrc %session
#login_cmd           exec /bin/bash -login ~/.xinitrc %session

login_cmd exec ck-launch-session dbus-launch openbox-session

# Commands executed when starting and exiting a session.
# They can be used for registering a X11 session with
# sessreg. You can use the %user variable
#
# sessionstart_cmd some command
# sessionstop_cmd some command

# Start in daemon mode. Valid values: yes | no
# Note that this can be overriden by the command line
# options “-d” and “-nodaemon”
#daemon yes

# Available sessions (first one is the default).
# The current chosen session name is replaced in the login_cmd
# above, so your login command can handle different sessions.
# see the xinitrc.sample file shipped with slim sources
sessions            openbox

# Executed when pressing F11 (requires imagemagick)
screenshot_cmd      import -window root /slim.png

# welcome message. Available variables: %host, %domain
welcome_msg         Welcome to %host

# Session message. Prepended to the session name when pressing F1
# session_msg         Session: 

# shutdown / reboot messages
shutdown_msg       The system is halting…
reboot_msg         The system is rebooting…

# default user, leave blank or remove this line
# for avoid pre-loading the username.
default_user        pedro

# Focus the password field on start when default_user is set
# Set to “yes” to enable this feature
#focus_password      no

# Automatically login the default user (without entering
# the password. Set to “yes” to enable this feature
#auto_login          no

# current theme, use comma separated list to specify a set to 
# randomly choose from
current_theme       lake

# Lock file
lockfile            /var/lock/slim.lock

# Log file
logfile             /var/log/slim.log

That’s about it! If you have any questions about this tutorial, you can send me  a message at goldenfinch.net(at)gmail(dot)com

.

Automatically Start X with GDM in BackTrack 5



I’ve heard about BT5 a while ago, but since it’s also a Debian-based distro and I’ve been using Debian-based Linux distributions for like one-third of my life, I was reluctant. Until a couple of weeks ago, after a friend told me that it comes out-of-the-box with tons of InfoSec tools I’ve decided to give it a try just to see what it really can do. So I downloaded and install it in VirtualBox to give it a test-run.

My first impression was it’s like Arch Linux. By default, you’d be booted up on a Tty and you have to manually login as ‘root,’ with ‘toor’ as the default root password Then you have to run ‘startx’ so you can have a graphical interface – the BT5 way. It’s pretty simple actually, but I don’t think it’s a very good idea for any smart Linux user to run it’s entire system as root all the time. You might destroy your important system files before you know it.
So in this tutorial let me share to you how I created a sudoer (regular user) account in a fresh installed BT5. And then we will try and install Gnome Desktop Manager (GDM) because Gnome is the default desktop environment pre-installed in BT5.
OK, first we need to make a sudoer. It’s actually very simple. Simply fire up your Terminal and then run the following command (assuming that you don’t have a user account yet, so we’re doing the entire process as root):
For this example, we are going to use ‘homer125‘ as our test username.

# useradd -m -g users -G admin,video,disk,games,cdrom -s /bin/bash homer125
Then we need to add a password to your username:
# passwd homer125
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
After we have created a sudoer, we’re going to install GDM, so we can boot up and login directly using the username (homer125) we’ve just created. To install GDM simply run this command in your Terminal:

# apt-get install gdm

Now we need to test GDM and see if it’s working the way it should. To run GDM simply run this command:
# gdm
If GDM is working the way it should, you should see the good old Gnome login screen. Let me remind you , the default login screen is quite ugly so you gonna have to be patient about it, you can change it though if you want to. Now, try to login using your new username. If you see no problem, restart your computer and then login again as root in Tty. This time we’re going to automate GDM so you won’t have to login as root everytime you boot up before you can go the the graphical interface.
To do just that, you have to edit /etc/init/gdm.conf using vim (or nano). I suggest you create a backup of your gdm.conf file first, just in case you run into trouble along the way.
# cp /etc/init/gdm.conf /etc/init/gdm.conf.backup
# cd vim /etc/init/gdm.conf
By default this is what gdm.conf file in BT5 looks like:
# gdm – GNOME Display Manager
#
# The display manager service manages the X servers running on the
# system, providing login and auto-login services
description “GNOME Display Manager”
author “William Jon McCann “
start on (filesystem
and started dbus
and (drm-device-added card0 PRIMARY_DEVICE_FOR_DISPLAY=1
or stopped udevtrigger))
stop on runlevel [016]
emits starting-dm
env XORGCONFIG=/etc/X11/xorg.conf
script
if [ -n “$UPSTART_EVENTS” ]
then
[ ! -f /etc/X11/default-display-manager -o “$(cat /etc/X11/default-display-manager 2>/dev/null)” = “/usr/sbin/gdm” ] || { stop; exit 0; }
# Check kernel command-line for inhibitors
for ARG in $(cat /proc/cmdline)
do
case “${ARG}” in
text|-s|s|S|single)
plymouth quit || : # We have the ball here
exit 0
;;
esac
done
fi
if [ -r /etc/default/locale ]; then
. /etc/default/locale
export LANG LANGUAGE
elif [ -r /etc/environment ]; then
. /etc/environment
export LANG LANGUAGE
fi
export XORGCONFIG
exec gdm-binary $CONFIG_FILE
end script
Highlighted in orange are the codes that you need to remove for you to be able to automate GDM at bootup. Once you have trimmed the code, your gdm.conf file should now look exactly like this:
# gdm – GNOME Display Manager
#
# The display manager service manages the X servers running on the
# system, providing login and auto-login services
description “GNOME Display Manager”
author “William Jon McCann “
start on (filesystem
and started dbus
and (drm-device-added card0 PRIMARY_DEVICE_FOR_DISPLAY=1
or stopped udevtrigger))
stop on runlevel [016]
emits starting-dm
env XORGCONFIG=/etc/X11/xorg.conf
script
export XORGCONFIG
exec gdm-binary $CONFIG_FILE
end script
Now, restart your computer.

You should now be able to run X and login with your new username via GDM automatically. I’ve only used BT5 for like 2 days, but I think I’m going to like it.
Happy BackTracking! Cheers 🙂

.

Send Gmail Message at the Command-line via sSMTP

Well, I must admit, I’m a proud console guy. And one of the so many things that I love to do at the command-line is sending simple email messages using sSMTP with my free Gmail account.
sSMTP, or Secure Simple Mail Transfer Protocol, is a simple program that effectively gets mail off the system to your mail hub. It does not contain any suid-binaries, or other dangerous stuff – no mail spool to poke around in, and no daemons running in the background. Mail is simply send to the configured mail host.
To start sending simple email messages via sSMTP, first we need to install it by opening Terminal and running this command:


$ sudo apt-get install ssmtp mailutils

You can omit mailutils if you think it is already installed in your system.

After you finished the installation, you can now edit and configure your sSMTP settings, simply run:

$ sudo gedit /etc/ssmtp/ssmtp.conf

Now, add the following lines of codes at the bottom of your ssmtp.conf file replacing the bold letters with your Gmail account credentials.

root=accountname@gmail.com
mailhub=smtp.gmail.com:465
rewriteDomain=gmail.com
AuthUser=accountname # (without @gmail.com)
AuthPass=yourGmailPassword
FromLineOverride=YES
UseTLS=YES

Save your ssmtp.conf file and then exit gedit.

Now you can start sending email messages using sSMTP. There are also some other ways to do it, but this time I would like to share the easiest way around it at the command-line. First, you need to create a text file that would contain the information of the recipient and the main content of the message you would like to send.
For this tutorial I will call the text file, MailMe.txt. Open gedit and write your content with exactly this same format:

To: recipientmail@address.com
From: accountname@gmail.com
Subject: Greetings
Hello,
The quick brown fox jumps over the lazy dog. This is a test
email message. Please do not reply.
Best regards,

Vintarah

…save it as MailMe.txt in your home directory. The From address in this text file should be the same address in your ssmtp.conf file.

To send MailMe.txt file using sSMTP, simply type this command in your Terminal:

$ ssmtp recipientmail@address.com < ~/MailMe.txt

If you know Vim (I will talk more about Vim in my upcoming posts), you can use it in creating your email messages at the command-line which is what I always do because it’s faster and resource friendly.

Your email should now be in your friends mail box.

EDIT: There was a reported bug in SSMTP which gave this error message:
ssmtp: Cannot open mailhub:25 or
ssmtp: Fails to send any mail with send-mail: Cannot open mailhub:25

For more information about this bug please follow this link and the suggested fix:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=500454

.