GNU/Linux Tips, Tricks, and Techniques

Ernesto P. Adorio

With GNU/Linux, we have a combination of a free operating system kernel and software tools based on the solid commercial Unix. Companies, educational and government institutions and even students are discovering the economy, power and productivity gains in using GNU/Linux (shortened to Linux from hereon). Linux can be installed in old hardware and is fast, reliable and less susceptible to computer viruses. Students would be encouraged to study and use a 'real' operating system since the source codes are available.
Extensive help for doing work in the Linux environment is available from the web that we are encountering the unusual problem of information overload! Linux users should be trained to employ search engines intelligently to zeroin on relevant information.
In this article, we present a few useful tips, tricks, and techniques for productive work with Linux.

Help in Linux: info, man and apropos

Every Linux user should be familiar with the info and man commands. If you want detailed help on the ls command, type info ls and you will be presented with the documentation for that command.
Type 'q', without the quotes to quit, '/searchstring', again without the quotes, to find occurrence of searchstring in the current page. The following navigation keys maybe also be available when the info file is large: 'N' for next page, 'P' for previous page, 'U' for top page. There is usually a keyed menubar shown on top of the info page.
To find all man pages containing a word, type apropos word.

Bash shell commands

Here is a listing of some bash shell commands:

History/Readline for productive console work

Your system should have the readline/history package installed if you want to be productive with the command line interface. We list the following commands when readline is available.

Up arrow Previous stored command
Down arrow Next stored command
Ctrl-R Perform search for previous commands

Passwordless ssh

Assume that you are using a local machine and you wish to log-on to the remote machine where you have an account without being asked for your password. This is a necessity if you are doing parallel computing.
If you have not done so, type the following command:
  ssh-keygen -t rsa

This will generate your hidden key file id_rsa and public key file id_rsa.pub in your $HOME/.ssh directory.

Be sure to set the proper file permissions of the directory and files:
  chmod 0755   $HOME/.ssh
  chmod 0644   $HOME/.ssh/*

Next, copy the id_rsa.pub file to the remote machine:
  scp -p id\_rsa.pub remote:~/.ssh/authorized_keys

The next time you ssh to the remote machine, it will not ask for your password. If this does not work, ask your friendly SA (system administrator).

If you wish to log-in to the remote machine from other terminals, perform the same procedure except that instead of copying the id_rsa.pub file to the remote authorized_keys file, you append it.

C Programming

Compiling and running C programs

Assume we have the following input file named hello.c
#include <stdio.h>

int main(int argc, char **argv)
{
  printf("hello world.\n")
}


To compile to default executible file a.out:
gcc hello.c

To compile to named output file hello:
gcc -o hello hello.c

To compile only to object file:
gcc -c hello.c

To show all compilation warnings (Highly recommended!):
gcc -Wall -o hello hello.c

To generate an assembly file:
gcc -S hello.c

If a source file myc.c calls a function in the C standard math library, then the math library must be linked:
gcc -o myc myc.c -lm

If there are object files obj1.o, obj2.o to be linked:
gcc -o myc myc.c obj1.o obj2.o -lm




Last updated Jan 13, 2004.


File translated from TEX by TTM, version 3.38.
On 20 Jan 2004, 21:19.
Hosted by www.Geocities.ws

1