Basic UNIX Commands for Beginners: UNIX Command Alias
As its name implies, a command alias is just an alias for a command and its options and/or arguments. Defining command aliases are helpful for command and option combinations that are frequently used or difficult to remember. The alias command is used to create a command alias:
$ alias listfiles=lsRunning this command will create the alias listfiles that will run the ls command when invoked. To display a complete list of your alias definitions, you would use the alias command with no arguments. To display a specific alias, you would type the alias command followed by the name of the alias:
$ alias listfiles
[ If you are new to UNIX and need an overview of important UNIX commands and concepts, check out our Basic UNIX Commands and Concepts Tutorial for Beginners ]
The unalias command is used for deleting alias definitions:
$ unalias listfilesYou can verify the removal of an alias by attempting to display the alias, or by attempting to run the alias:
$ alias listfilesOR
listfiles alias not found
ksh: listfiles: not found
TIP: If you want to include one or more options with a command when defining an alias, the command and option(s) need to be enclosed with single quotes. For example, if you wanted to include the -l option with the ls command you would use the following syntax:
$ alias longlist='ls -l'
Do you need to learn UNIX or Linux, including how to read and write shell scripts...on a REAL SERVER?
If you are ready to move past the basics, either of these online courses is a good place to start...
UNIX and Linux Operating System Fundamentals contains a very good "Introduction to UNIX Shell Scripting" module, and should be taken if you are new to the UNIX and Linux operating system environments or need a refresher on key concepts.
UNIX Shell Scripting is a good option if you are already comfortable with UNIX or Linux and just need to sharpen your knowledge about shell scripting and the UNIX shell in general.
Both courses include access to an Internet Lab system for completing the course's hands-on exercises, which are used to re-enforce the key concepts presented in the course. Any questions you may have while taking the course are answered by an experienced UNIX technologist.