How to Use the alias Command
Let us say you execute the command ‘ls –alh’ every time you need a long listing of files and directories. Now you want a shortcut to do this. Fortunately, you can do so by using the command alias.
The alias command is useful for creating shortcuts for long commands or for correcting typing mistakes.
To create a shortcut for ls, you can do this:
$ alias ls=”ls -alh”
Now, everytime you execute ls command, it will be run as if you are executing the whole ls –alh command. Be reminded that this will replace the existing ls command. You may use a different name for the new shortcut like so:
$ alias ll=”ls -alh”
However, once you exit the current terminal, the alias will not be saved. To make the alias permanent, you may edit the .bashrc file in user’s home directory:
$ vi ~rai/.bashrc
Then insert the alias command after the line that says #system wide functions and aliases. Save and exit.
That should do it!
How to Fix the Terminal After Viewing Binary File
Every now and then, I open up a file only to realize that it is a binary file (yes, I keep ignoring the warning that I am about to view a binary file, not text). Then the terminal ends up messy, or in other words, wonky. The characters have turned out in various colors, the lines are indented, and you can’t see what you are typing.
To fix it, run this command:
$ reset
As the name implies, this will reset the terminal back to its normal state.
Using Perl to Replace Text in Multiple Files
You can search and replace text inside multiple files using Perl. This is how you do it:
$ perl -i -pe 's/Windows/Linux/;' test*
This command will search for the word ‘Windows’ inside all files that begin with ‘test’. When it finds one, it will substitute it with the word ‘Linux’. This is useful if you have multiple files that contain the same text. Remember that you can use regular expressions to make searching flexible.
VIM Trick: How to Comment Multiple Lines
If you need to comment out lines of text inside VIM, you can try this trick:
(Enter command mode in VIM)
:40,105s/^/#/g
This will insert the # character at the beginning of each line starting from line number 40 to line number 105.
If you cannot see the line numbers, do this:
(Enter command mode in VIM)
:set number
To remove the lines:
:set nonumber
This is quite handy if you need to comment out lines of codes in a script.
Backspace Key Not Working in PuTTY
If you access your Linux machines from a Windows workstations by SSH, most probably you are using PuTTY. My new job requires me to work with SUSE Enterprise servers and to my surprise, the VIM on SLES is somewhat different from that of RHEL.
One example is the backspace key. It just won’t work in PuTTY connecting to SUSE server. I have to put the cursor before the character I want to delete and press the DELETE key. If you have this issue with PuTTY/SUSE too, this tip might help you.
Go to your PuTTY configuration -> Terminal -> Keyboard
Look for Change Sequences Sent By -> The Backspace Key
From there, select Control-H. Save your session and try it.
This one worked for me, hope this works for you too.
Search PinoyTux
Subscribe to Email Feeds
Blog Lounge
Popular Posts
Recent Posts
Drop your Card Here
Recent Comments
- mega-mind.net , , Dien Dan,Forums,Blog,CMS,php,cgi,asp,software,serial,hardware,game,games,choi game,Thuong mai dien tu, hoc tap, mua ban, download,choi nhac, xem phim, dien anh,cac van de khac,nokia,hp.vaio,iphone,ipad,itune,gmail,yahoo,chat,crack,an nic on President of United States of America: Barack Obama
- Belarus Hava Yolları, Belarus airlines, Uçak Bileti, Air tickets, Belarus uçak on Cebu Pacific Sucks
- Cezayir Hava Yolları, Cezayir airlines, Uçak Bileti, Air tickets, Cezayir uçak on Cebu Pacific Airlines is Evil!
- Lambchop on Cebu Pacific Airlines is Evil!
- rabat on Linux Comics of the Day








