≡ Menu

environment variable

Linux: TMOUT To Automatically Log Users Out

How do I auto Logout my shell user in Linux after certain minutes of inactivity?
[click to continue…]

Unix / Linux: TCSH / CSH Shell Set Variable

How do I set environment variables using c shell (tcsh or csh) under FreeBSD UNIX or Linux operating systems? How do I save variable using csh shell under Unix like operating systems?
[click to continue…]

Bash History: Display Date And Time For Each Command

How do I display shell command history with date and time under UNIX or Linux operating systems?
[click to continue…]

Edit a File When You Are Viewing It Using more / less Command Pager

I can use less or more pagers to view a file. How do I start an editor (such as vi or other text editor) to edit the current file without leaving the less or more pager command?
[click to continue…]

I'm behind a squid proxy server. How do I access internet via proxy server when I use wget, lynx and other utilities from a shell prompt on a Linux or Unix-like systems?
[click to continue…]

How to: Recompiling / Rebuild Debian / Ubuntu Linux Binary Source File Packages

Q. I'd like to rebuild a Debian / Ubuntu package called foo with additional option. How do I recompile .deb packages?
[click to continue…]

How To Read / Print $PATH Shell Variable

Q. I'm new to Unix / Linux and I'd like to print current values of $PATH variable. How do I read $PATH from a shell prompt?
[click to continue…]

Linux logged out a user automatically

Q. We have a few users who frequently forget to log out and I'd like to force them or automatically log out a user in case of inactivity detected. How do I force user to be logged out automatically?

A. BASH provides TMOUT variable. It is necessary for security reasons to have an inactive user logged out after a period of inactivity from Linux / UNIX ssh / telnet session. This can be accomplished by setting an environment variable TMOUT.

Automatically log out a user

Add the TMOUT variable to your /etc/bashrc file:
# vi /etc/bashrc
Set TMOUT to 300 seconds (5 minuets):
Save an close the file. Above config would automatically logout users after 300 seconds of inactivity. Please note that this hack only works with run level 2, 3 i.e. it will not work with GUI sessions.

Display or print UNIX / Linux path ~ $PATH variable

Q. How do I print current path settings under BASH shell? I’m using Debian Linux.

A. In UNIX / Linux file systems, the human-readable address of a resource is defined by PATH. On Unix / Linux like operating systems, (as well as on DOS / Windows and its descendants), PATH is an environment variable listing a set of paths to directories where executables may be found.

Display current PATH

Use echo command:
$ echo $PATH


Modify current PATH

Use export command to add /opt/games to PATH, enter:
export PATH=$PATH:/opt/games

To format your PATH variable for easy viewing, add following code to your bash startup file (such as ~/.bashrc or ~/.bash_profile) :

function path(){
    printf "%s\n" $PATH

(Function credit: usenet archive)

Now just run path:
$ path


Linux / UNIX: Set The Time Zone On a Per User Basis

We are developing Linux based application and we would like to set the time zone on a per user basis for individual user. How do I configure Fedora Linux or any Unix like oses to set the time zone on a per user basis using bash shell?
[click to continue…]