palazzini
asked on
Command Line Shortcuts
Greetings:
How would I create command line shortcuts in Linux. For example I would be in a shell at the command line and to view my directories and files in /home/user(user being me) I would type in ls -al which would list all files in alphabetical order. Now what I would like to do is type in l(lower case L) and receive the same output as ls -al.
MikeP
How would I create command line shortcuts in Linux. For example I would be in a shell at the command line and to view my directories and files in /home/user(user being me) I would type in ls -al which would list all files in alphabetical order. Now what I would like to do is type in l(lower case L) and receive the same output as ls -al.
MikeP
Do this exactly
vi /usr/bin l
ls -al
save file
chmod 777 l
Now when u type l it will work as ls -al
vi /usr/bin l
ls -al
save file
chmod 777 l
Now when u type l it will work as ls -al
Agree with periwinkle. To make it permanent save the alias command to $HOME/.bashrc file. I assume You are using bash as Your shell... Also remember that aliases are not recursive, so following is wrong
alias ll='ls -la'
alias lf='ll -F' # will not work, ll is unknown here
alias ll='ls -la'
alias lf='ll -F' # will not work, ll is unknown here
ibu1
I assume you meant to write
vi /usr/bin/l
That's not a good idea, as you should not pollute /usr/bin with your own scripts. Also doing a chmod 777 is a bad idea as it means anyone can delete,edit the file.
aliases or functions are the way to go.
I assume you meant to write
vi /usr/bin/l
That's not a good idea, as you should not pollute /usr/bin with your own scripts. Also doing a chmod 777 is a bad idea as it means anyone can delete,edit the file.
aliases or functions are the way to go.
ASKER
Thanks for the quick response everyone. I am talking about the bash shell. I'm using Ubuntu 6.06. What I'm looking for are step by step instructions to do this request. For example to create the aliases script or function do this:
Step 1-Start at the command line here.
Step 2-Open text editor(vi, pico) and type the following.
Step 3-Save to this path.
Step 4-etc, etc, etc,
This way I will create the command line short-cut without making any mistakes. The idea is if I can create this command line short cut there are alot more I would like to do. I just need to be instructed on how to correctly create the commands.
Once again thanks for being there. This is my favorite site for getting IT help.
MikeP
Step 1-Start at the command line here.
Step 2-Open text editor(vi, pico) and type the following.
Step 3-Save to this path.
Step 4-etc, etc, etc,
This way I will create the command line short-cut without making any mistakes. The idea is if I can create this command line short cut there are alot more I would like to do. I just need to be instructed on how to correctly create the commands.
Once again thanks for being there. This is my favorite site for getting IT help.
MikeP
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Yes, start the command line terminal
echo "alias l='ls -la'" >> $HOME/.bashrc
every newly opened shell should have the alias set
Alternative: if You can handle editing files, open .bashrc (in Your home directory) and add following line
alias l='ls -la'
echo "alias l='ls -la'" >> $HOME/.bashrc
every newly opened shell should have the alias set
Alternative: if You can handle editing files, open .bashrc (in Your home directory) and add following line
alias l='ls -la'
ASKER
That's what I needed. Thanks everyone for the input.
glad to have helped - ravenpl's solution to add the line via echo and redirection is simple and elegant, too...
alias l 'ls -al'