What Are Linux File Aliases Used For?
Defining an alias is another way to minimize your work at the keyboard, and you can also eliminate the need to remember long, awkward commands by creating synonyms that are more meaningful to you. Here are some examples: alias dir='ls -l'
alias dogs='find . -name "*dog*"
-print'
In this example, the first alias tells bash that when you enter dir on the command line, it should actually execute the ls -l command instead. If you're a hard-core DOS user, you could use alias to create DOS-like synonyms for many Linux commands.
The second alias lets you enter dogs instead of that long, ugly find command shown above. Don't worry about the ls and find commands right now. Just keep in mind that the alias command can save you some keystrokes and make it easier to remember a command.
Undoubtedly you will find other clever things to do with the alias command and add them to your .profile file so they will be available each time you log in. Your .profile file contains a series of comm ands that bash executes automatically when you log in, similar to autoexec.bat the DOS world.
Previous Lesson: Command History
Next Lesson: Redirection
Comments - most recent first
(Please feel free to answer questions posted by others!)
Thanks.
Thank you.
Thank you.
or use
echo alias cls='clear' >> ~/.bashrc
and remember ">>" is very important if > is used you'l be totally f***ed up
When bash is invoked as an interactive login shell, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable.
For an interactive shell that is NOT a login shell, bash reads and executes commands from ~/.bashrc, if that file exists.
Clear as mud? :-)
Can u tell me whr i can find .profile (i mean wht is the path for this file).
Good stuff. What is the difference between .profile and bashrc? I created a bashrc file for my aliases which works fine but wondering if .profile is a better way for some reason.
I welcome your comments. However... I am puzzled by many people who say "Please send me the Linux tutorial." This website *is* your Linux Tutorial! Read everything here, learn all you can, ask questions if you like. But
don't ask me to send what you already have. :-) NO SPAM! If you post garbage, it will be deleted, and you will be banned.
Copyright © by -
All rights reserved - Redistribution is allowed only with permission.

