Unaliasing in BASH
How can we unalias a command temporarily without using unalias command ?
just put the escape character before the command i.e. "\"e.g. :-
$\ls
It will show the without alias.
A unique blog for Unix, Linux based Tips, tricks and Shell Scripts. This is intended to be one-stop Information Center for all your Unix, Linux needs.
Unaliasing in BASH
How can we unalias a command temporarily without using unalias command ?
just put the escape character before the command i.e. "\"e.g. :-
$\ls
It will show the without alias.
Whether you are a newbie to Linux or you are a seasoned guru, you are bound to find some scripts or programs which just make your life on the computer exponentially easier. The following is a list of them and explains what they do.
1. tac
tac is a command similar to cat, except that it reverses the output of the specified file.
tac
2. Multiple X-Sessions
Using multiple X-Sessions allows a user to have open more than just one instance of XFree, so multiple desktop environments can be used at a time.
startx -- :
terminal name is simply which terminal X should start on. By default it starts on
0:0. If you want two open, you may want it open on 0:1, which can be run by:
startx -- :1
The resulting desktops will exist on F7 - F12.
3. links
links is a text based browser which has full support for tables
links
To encrypt and decrypt files with a password, use gpg command. It is an encryption and signing tool for Linux/UNIX like operating system such as FreeBSD/Solaris.
GnuPG stands for GNU Privacy Guard and is GNU's tool for secure communication and data storage. It can be used to encrypt data and to create digital signatures. It includes an advanced key management facility.
Encrypting a file in linux
To encrypt single file, use command gpg as follows:
$ gpg -c filename
To encrypt myfinancial.info file, type the command:$ gpg -c myfinancial.info
Output:
Enter passphrase:
Repeat passphrase:
Option:
-c : Encrypt with symmetric cipher
Caution if you ever forgot your password aka passphrase, you cannot recover the data as it use very strong encryption.
1. Lost bash history
If you have a terminal open and are typing commands, then open another one and use that for a while, the new terminal won’t remember any of the commands typed in the first one. In addition, closing the first terminal, and then the second will overwrite any of the commands typed in the first terminal. Doubly annoying! This happens because the bash history is only saved when you close the terminal, not after each command. To fix it:
Edit your .bashrc (for beginners, any file starting with a . is hidden - they contain user preferences.)
nano ~/.bashrc
No need for a sudo here Ubuntuers, this is your own file, not a system setting. I like nano, but it’s up to you, choose gedit, kate, mousepad, vi or emacs as you wish.add the lines
shopt -s histappend
PROMPT_COMMAND=history -a;
And save. (control - O to write out. ^ means control in nano and other software, so the bottom of the editor does actually make sense to beginners! ^X to exit.) This makes bash append history instead of overwriting it, and makes it so that each time the prompt is shown it writes out all the history.
2. Stupid spelling mistakes
Add
shopt -s cdspell
to your .bashrc again. This will make sure that spelling mistakes such as ect instead of etc are ignored.
3. Duplicate entries in bash history
I often type cd .. multiple times in a row, when I then press UP to go back to earlier commands I don’t want to be reminded of my earlier inelegant excursions around the file system.
Add
export HISTCONTROL="ignoredups"
export HISTIGNORE="&:ls:[bf]g:exit”
This will ignore duplicates, as well as ls, bg, fg and exit as well, making for a cleaner bash history.
4. Multiple line commands split up in history
shopt -s cmdhist
to .bashrc, this will change multiple line commands into single lines for easy editing.
5. A couple of neat extras suggested by commenters
history grep "foo"
cd -
goes to the last directory you were in - useful if you want to go somewhere to change something, then need to quickly flip back again.
Conclusion So, there are a few tips to get your bash history more manageable - if you have any extra tips, add them to the comments and I’ll add them to the main article!