Tech in T: depth + breadth‎ > ‎OS‎ > ‎Linux‎ > ‎


As per dpkg -L tmux which shows you what files the package installed, 

you can use fakeroot to run a command in an environment wherein it appears to have root privileges for file manipulation. This is useful for allowing users to create archives (tar, ar, .deb etc.) with files in  them with root permissions/ownership.

sudo apt-get install SOFTWARE_NAME
sudo apt-get remove SOFTWARE_NAME

To set environment variables

$ sudo vim /etc/environment
$ source !$
$ sudo vim /etc/environment
$ source /etc/environment   # in every shell where you want the variables to be updated
 To set for a specific user:
$ vim ~/.bash_profile         # append the following at the end.
export JAVA_HOME

export PATH


/etc/environment    =>    /etc/profile      =>      ~/.bash_profile (login)   => ~/.bashrc (non-login)

login or non-login shell

.bash_profile is executed for login shells, while .bashrc is executed for interactive non-login shells. When you login (type username and password) via console, either sitting at the machine, or remotely via ssh: .bash_profile is executed to configure your shell before the initial command prompt.

But, if you’ve already logged into your machine and open a new terminal window (xterm) inside Gnome or KDE, then .bashrc is executed before the window command prompt. .bashrc is also run when you start a new bash instance by typing /bin/bash in a terminal.

intro link    Next intro link

/etc/environment file

The first file that the operating system uses at login time is the /etc/environment file. The /etc/environment file contains variables specifying the basic environment for all processes.

When a new process begins, the exec subroutine makes an array of strings available that have the form Name=Value. This array of strings is called the environment. Each name defined by one of the strings is called an environment variable or shell variable. The exec subroutine allows the entire environment to be set at one time.

When you log in, the system sets environment variables from the /etc/environment file before reading your login profile, named .profile. The following variables make up the basic environment:

/etc/profile file

The second file that the operating system uses at login time is the /etc/profile file.       

      •  shell invocation normally reads /etc/profile and its private equivalent ~/.bash_profile upon startup.

 The /etc/profile file controls system-wide default variables, such as:                   $ source /etc/profile

  • Export variables
  • File creation mask (umask)
  • Terminal types
  • Mail messages to indicate when new mail has arrived
#Set file creation mask
unmask 022
#Tell me when new mail arrives
#Add my /bin directory to the shell search sequence
#Set terminal type
#Make some environment variables global


Install an Archive File (Tarbal)

Extract the filebased on the extension (untar)
$ tar zxf file.tar.gz -C other_directory
$ tar zxf file.tgz
$ tar jxf file.tar.bz2
$ tar jxf file.tbz2

$ cd path-to-software/
$  ./configure  

$   make
Note: depending on the content of the make file or the documentation you might need to check if the make has been performed completely. this can be done by calling make test (as in XML-NamespaceSupport) or make check (as in kchmViewer)
$   make install

    or >sudo ./file.bin
    or >chmode +x file.bin
    and >./file.bin

You could find a default java available (open jdk) at /usr/lib/jvm/
-------install java_ee_sdk-5_07-jdk-6u16-linux.bin :
    chmode +x file.bin
    sudo ./file.bin   -->halted

-->new terminal

Environment Variables
        command prints the names and values of all currently defined environment variables:
    $PATH initial value            /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
    /etc/environment  --> this file contains system variables   --  to apply changes without restart $source /etc/environment
        For java

            -------adjust JAVA_HOME and PATH (local, instance and session dependent)
            export JAVA_HOME=/home/morteza/SDK/jdk
            PATH=$JAVA_HOME/bin:$PATH;export PATH
        For tomcat


Apache Tomcat
        be sure to check licenses for redistribution rights for any third party libraries you utilize),
    $CATALINA_HOME/conf/tomcat-users.xml  -->  <user name="morteza" password="pass" roles="standard,manager" />

javac -classpath ./javax.servlet_2.5.0.v200806031605.jar   --> compile a servlet

    $ sudo apt-get install mysql-server
    check if it is running    $ sudo netstat -tap | grep mysql

    sudo apt-get install mysql-query-browser

Install rpm

We need alien to install rpm in ubuntu:
$ sudo apt-get update
$ sudo apt-get install alien

$ alien -k package_file.rpm   //this makes the .deb file
$ sudo dpkg -i package_file.deb

To list files and directories created by a package

$ dpkg-query --listfiles packagename