Technology blog::Life hacks::Linux::Hardware::Gaming

Linux Tips for Beginners

Getting started with Linux

By , 20th July 2010 in Linux

This post is going to contain a list of tips and tricks used to the beginner Linux user. It covers lots of tasks which are second nature to Linux veterans, but hard to grasp for new users.

Creating a Symbolic Link

A symbolic link is a pointer to another file or directory, like a shortcut in Windows. Unlike shortcuts however, the symbolic link can be used just like the original file or directory. Symbolic links are very good if you need to have multiple copies of the same file in different locations.

You can use the command below to create a symbolic link to a file.

ln -s {/path/to/file-name} {link-name}

Example below will create a link to /home/timtrott/public_html and create a "false" folder called /www. When you change directory to /www, you will really be in /home/timtrott/public_html.

ln -s /home/timtrott/public_html/www /www

Creating Shell Scripts

A shell script is a Linux version of a MS-DOS batch file, only a bit more flexible and powerful. They can be created using any text editor. I'm going to create a sample shell script that will mount a network drive.

All shell scripts start with #!/bin/bash. The following lines are executed line by line.

sudo mount -t cifs // /usr/www

The script must have it's permissions changed to allow execute.

chmod +x scriptname

I like to keep my scripts in my home folder /home/tim/ That way I can call them using ~/scriptname.

Creating Multiple IP Addresses

I will be working on multiple websites at a time and as such I need to allocate an IP address to each one. I can do this by using IP alias. This is done easily enough by adding some entries to /etc/network/interfaces.

sudo pico /etc/network/interfaces

And add the following block of code. Repeat as required.

auto eth0:0
iface eth0:0 inet static
name Ethernet alias LAN card

Once complete you need to restart the network interfaces.

sudo /etc/init.d/networking restart

Host Tables

A host table is a simple text file that associates IP addresses with host names, one line per IP address. It isn't normally necessary to change this, however I have a situation in which I need to redirect a host name for my database server to my local host.

sudo pico /etc/hosts

The format for the file is ip_address hostname alias. My hosts file looks like this:       localhost   ubuntu
# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

Modifications to this file normally take effect immediately, except in cases where the file is cached by applications.

Enable the Power Button

By default on my installations, the power button does not function, except to immediately power off. Instead I'd rather send a power down message to the OS so that my server can gracefully close and power off.

First we need to install the Advanced Configuration and Power Interface (ACPI) package

sudo apt-get install acpid

And edit the config file if required

sudo pico /etc/acpi/

When the power button is pressed, the system no goes down with a message stating the power button has been pressed.

/sbin/shutdown -h now "Power button pressed"

Linux Cheat Sheets

Here are a few very handy Cheat sheets for Linux which will introduce you to the basic commands.

Above all, the best way to learn Linux is to use it. Use it a lot.

Whenever you run into a problem with a command, do some online searching. Almost any time you run into a wall, you're going to find that a lot of people have run into it before you and a number of them will have written something about how they got over it.

Further Reading

There are no comments for this post. Be the first!

Leave a Reply

Your email address will not be published.