November 13, 2018

Bash (UNIX Shell) Commands Guide

I created this Bash basic Commands that will make the job easier on a daily basis.

There is a few needs in Linux, one of them is to increase History commands.

To do that, open Linux Terminal and edit ~./bash_profile.

Add these commands and save.

(It will set to save unlimited history commands)

vi ~/.bash_profile
export HISTSIZE=
export HISTFILESIZE=

Save the history command immediately

Force bash to save each command you type,
Edit .bash_profile that is located in ~/.bash.profile:

vi ~/.bash_profile
export PROMPT_COMMAND=’history -a’

Don’t store specific commands

Force bash not to save duplicate commands, edit .bash_profile that is located ~/.bash_profile:

vi ~/.bash_profile
export HISTCONTROL=ignoredups

Force bash not to save lines that start with a space, edit .bash_profile that is located <homeDir>/.bash_profile:

vi ~/.bash_profile
export HISTCONTROL=ignorespace

Force bash not to save both space and duplicates, edit .bash_profile that is located in <homeDir/.bash_profile:

vi ~/.bash_profile
export HISTCONTROL=ignoreboth

Setting the time – system time and hardware time

hwclock -r

Setting time and date:

date -s “24 SEP 2015 19:30:00”

Setting the hardware time using the system’s time:

hwclock -w

SSH autentication without Password

When you are trying to SSH to Linux server from terminal (ssh

You need to enter Password, use key-Gen authentication without password:

#Generating ssh key

root@hostname# ssh-keygen         

             Generating public/private rsa key pair.
             Enter file in which to save the key (/root/.ssh/id_rsa):
             Enter passphrase (empty for no passphrase):
             Enter same passphrase again:
             Your identification has been saved in /root/.ssh/id_rsa.
             Your public key has been saved in /root/.ssh/id_rsa.pub.
             The key fingerprint is: ab:bd:ef:fh:cv

#copy the key to ssh destination Linux server.

root@hostname# ssh-copy-id     

 

root@hostname’s password:

Now try logging into the machine, with “ssh ‘hostname'”, and check in:

~/.ssh/authorized_keys

to make sure we haven’t added extra keys that you weren’t expecting.

About The Author

Related posts

Leave a Reply

Your email address will not be published. Required fields are marked *