Blog

03/06/2019

Unix / Linux: Initialize Dot Files Without Restarting The Current Shell Session



I‘m a new Linux, OS X or Unix-like system users. I’m using bash shell. I made changes to my $HOME/.profile ($HOME/.bash_profile) file. How can I restart my session without doing logout and login again?

You can always initialize your shell startup files without restarting a Unix or Linux based session. The command and input file name depends upon your shell you are using. You can use the following command to find out your shell name:[donotprint][/donotprint]

echo $SHELL

Sample outputs:

/bin/csh

Restart a Unix/Linux session based on ksh or bash shell

The syntax is:

. $HOME/.profile  
. $HOME/.bash_profile  
 
## or Use source command ##
source $HOME/.profile  
source $HOME/.bash_profile

The source or . is a shell builtin commands to read and execute commands from given FILENAM. If you have created a $HOME/.bashrc file, type:

. $HOME/.bashrc
 
## or 
 
source $HOME/.bashrc

Restart a Unix/Linux session based on csh or tcsh shell

The syntax is as follows for csh/tcsh based shell:

source .cshrc
source .login

For more info see your shell man pages – ksh(1) or type the following command:

help source
help .

Posted by: SXI ADMIN

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

14/08/2019

How to KVM, QEMU start or stop virtual machine from command line (CLI)

KVM or Kernel Based Virtual Machine is a popular virtualization technology. It allows you to run virtual guest machines over a host machine. To start...
14/08/2019

How to Docker backup Saving and restoring your volumes

Running a Docker volume backup First, we spin up a temporary container, and we mount the backup folder and the target Docker volume to this container....
12/08/2019

How to Start and Enable Firewalld on CentOS 7

In this article, we discuss how to start and enable firewalld. It is highly recommended that you have a firewall protecting your server.Pre-Flight CheckThese...