LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Bourne Shell aliases (https://www.linuxquestions.org/questions/linux-newbie-8/bourne-shell-aliases-4175610612/)

expplane 07-25-2017 10:18 PM

Bourne Shell aliases
 
I am familiar with the Bash shell, however I have begun learning to program in Raspbian linux which is specifically for the Raspberry Pi micro computer.
I want to put some aliases in what is the .bashrc file in bash shell distros however the only file similar in the Bourne shell is the /etc/profile. There are no entries in this text file with the alias command and when I enter in my home directory the alias command it returns 'no such command'.
So how are aliases entered in a Bourne shell?

aragorn2101 07-26-2017 01:12 AM

Hi and welcome to LQ,

You add aliases by specifying them in either the /etc/profile (for global system config, i.e. for all users) or in your local HOME/.bashrc (for your own environment config only). They are defined as in Bash, e.g.
Code:

alias l='/usr/bin/ls --color=auto -F'
alias ll='/usr/bin/ls --color=auto -l -h'
alias df='/usr/bin/df -h --output=source,fstype,itotal,ipcent,iused,iavail,size,pcent,used,avail,target'

But use aliases carefully. Try to avoid conflicts with existing commands or existing aliases. Use the alias command to see all aliases already defined in the environment.

RockDoctor 07-26-2017 09:44 AM

Not sure if Raspbian works like Ubuntu, but in Ubuntu 17.10 on my desktop, I've placed aliases for all users in /etc/bash.bashrc
Code:

cat /mnt/GU1710/etc/bash.bashrc | grep alias
alias ls="ls --color"
alias dir="ls -al"
alias md=mkdir
alias rd=rmdir


expplane 07-26-2017 10:25 AM

Bourne shell aliases
 
Thanks for the reply; found the /home/.bashrc file and sure enough it has the alias commands. Put my favorite alias ll='ls -al | more' in and it works. As I remember the .bashrc file in a bash shell distro is in the root directory structure. It's been awhile .

pan64 07-26-2017 11:24 AM

in general Raspbian is a debian release for Raspberry Pi, and the bash is almost the same as on any other release.
By the way bash means Bourne-Again SHell.The original bourne shell is named sh, not bash. You can read about .bashrc and related files on the man page of bash.

lazydog 07-26-2017 02:27 PM

Check my Blog I have a large list of aliases I use and how I call them.


All times are GMT -5. The time now is 06:52 PM.