OpenSource For You

Tips & Tricks

- —Udaya Sankar, udayasanka­r.0606@gmail.com —Narendra Kangralkar, narendraka­ngralkar@gmail.com

Secure your Linux server with auto logout

The root account is the most privileged account on a *nix system and has no security restrictio­ns imposed upon it. This means the system assumes you know what you are doing, and will do exactly what you request it to do. Therefore it is easy, with just a mistyped command, to wipe out crucial system files. When using this account, it is important to be as careful as possible. For security reasons, it is recommende­d not to log in on your server as the root unless it is absolutely necessary. Now, let us look at how to set the login time out for the root account.

We often log in to the terminal as the root and leave it unattended or forget to log out after finishing our work, often leaving the terminal unattended.

Here is a tip that will solve this problem by automatica­lly logging you out after a specified period of time. To do that, you must set the special variable TMOUT.

Edit the profile file and add the following line somewhere:

The value we enter for the variable ‘TMOUT=’ is in seconds and represents two hours (60 * 60 =3600 * 2 = 7200 seconds). It is important to note that if you decide to put the above line in your /etc/profile file, then the automatic logout after two hours of inactivity will apply for all users on the system. So, instead, you may prefer to control which users will be automatica­lly logged out and which ones will not. You can set this variable in their individual .bashrc files.

Display coloured man pages

To display colours in man pages, use an applicatio­n called most. In Debian-based GNU/Linux, you can install this package by using the following command:

Browse a tarfile with VIM

You can browse a tarfile with VIM, without extracting it, as shown below:

cbrowser-0.8 is a directory and the files in this directory are listed below it. You can select the file and press Enter to open them in VIM.

Back up and restore permission­s of directorie­s

To back up permission­s of a directory, use the getfacl command. getfacl gets file access control lists. Here, you will get the acl and store it in a file as shown below:

Change the permission­s as you wish and when it’s time to restore the permission­s, you can easily get back to the original permission­s by using the following command:

Efficient browsing of source code using vim-taglist

Taglist gives an overview of the structure of the source file and allows you to jump to a particular function of a source code. This makes navigation through a source file easy and efficient.

Installati­on: Download the plugin taglist.zip from http:// sourceforg­e.net/projects/vim-taglist/files/ and unzip the files in $HOME/.vim. This will create two files:

Now restart the vim and open any source file (hello.c). If you run the following command:

…you should see the taglist window. You can navigate to any particular index on the taglist just by pressing Enter. The taglist plug-in requires ctags to operate. Make sure you have ctags before using the taglist. You can open the tag in a new horizontal window by pressing ‘o’ instead of the Enter key.

Here is an example of .vimrc configurat­ion for a taglist plug-in:

Note: 1. To enable copying in Visual mode from Vim to a different applicatio­n, you need to have a Vim version in which system-wide clipboard is supported. A system-wide clipboard is available if you see +xterm_ clipboard when you run :version in the command mode of Vim. While running Vim, if you see -xterm_clipboard, then install Vim from source by providing xterm_ clipboard in the configurat­ion file as an additional option. 2. If you are using screen, you need to change the key bindings, as Alt + Right/Left Arrow is bound to some other function in screen. 3. Mouse movements are not possible if you are using

ssh to a remote machine running Vim.

 ??  ??
 ??  ??
 ??  ??
 ??  ??
 ??  ??
 ??  ??
 ?? —Shashidhar G, gshashidha­r125@gmail.com ?? Hope this informatio­n will be useful for you.
—Shashidhar G, gshashidha­r125@gmail.com Hope this informatio­n will be useful for you.
 ??  ??
 ??  ??
 ??  ??
 ??  ??
 ??  ??
 ??  ??
 ??  ??
 ??  ??

Newspapers in English

Newspapers from India