Are you looking for a way to have the most common DOS commands available in your Bourne Again SHell?
There are some commands, like dir and similar ones that are easily available also in Bash.
For example, I hate when cd.. gives me an error on the console.
Fortunately, Bash provides the alias directive to create alternative names for whatever can be interpreted as a command by the Bash parser.
Bash reads some files when you open an interactive console (opening an interactive console means logging in a text based GNU/Linux system or equivalently opening a terminal on a Window manager like KDE and Gnome but also logging in a ssh tunnel) to serve as initialization scripts. Interactive shells are the prompts where you can type commands, so the shells created to run a script fall into non-interactive category. Several dialects exist according to the distribution you are using, but you can generally consider that the following files are read during Bash startup:
- /etc/profile : containing the system wide initialization file, read at every login in a shell
- ~/.bash_profile : that is the same file as above, but devoted to the single user owning that particular home directory
- ~/.bashrc : my favorite that is read in every interactive shell (means every console on a Desktop environment, ssh shells and the like)
Here the precise detailing of which file to use becomes excessively complicated as we should ascertain with no degree of uncertainty what is interactive and what not, what is profile based and what is not, etc.
To simplify everything I would just give you precooked compound to use: write all your customization into ~/.bashrc if you want it for your sole user and make sure that /etc/profile or whatever .profile file you have includes a statement to read bashrc file with a line like:
[[ -r ~/.bashrc ]] && . ~/.bashrc
Or in the CentOS/Red Hat form
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
Before the end of the file. If you don’t have bashrc in your home just create it.
Now that we know where to write, let us populate .bashrc with something useful to the nostalgic.
The dir command
Just add an alias to your chosen configuration file like
alias dir=’ls’
but if you want to have a output closer to what DOS wag delivering you may prefer
alias dir=’ls –lhr’m
The cd.. command
Every GNU/Linux shell expects that you step back one directory level with a command like cd .. (mind the space between cd and the dots).
If you consider that every character you avoid to type is a character less you likely have to debug the space before the dots shall be best avoided.
I like the monkish stiffness of GNU/Linux but cd.. is something transcending humanity so it is a must have.
Just add this at the bottom of your .bashrc file
Alias cd..=’cd ..’
No more and no less than this.
Do you need more hints to convert your Bash console into something more similar to what is engraved in your brain since the 80ies?
Just apply the same algorithm or subscribe for some idea sharing. I would love it.
Auf wiederluoege
Alex