Where technology and gadgets come together and play

Linux Tips for Beginners

By on in Linux

680 words, estimated reading time 4 minutes.

Introduction to Linux Series
  1. Linux Tips for Beginners
  2. Beginners guide to Reading and Finding Files in Linux
  3. Using Grep to Search for Text in Linux
  4. Understanding Linux File Permissions
  5. How to Archive, Compress and Extract files in Linux
  6. Linux Piping and Redirection
  7. Linux Hardlinks and Softlinks
  8. Basic Data Recovery in Linux
  9. Essential Guide to Working with Files in Linux
  10. Apache Administration on Linux
  11. MySql Administration on 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.

This is my collection of Linux tips beginners, which I am adding to as I learn more about using Linux. This page serves as my notepad and reminders for commands and is published online in the hopes it helps others starting out with Linux.

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     mydomain.com   ubuntu       my.databaseserver1.com       my.databaseserver2.com
# 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/powerbtn.sh

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.

Last updated on: Monday 31st July 2017



Have a question or suggestion? Please leave a comment to start the discussion.


Leave a Reply

Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

Your email address will not be published.