Skip to main content
Drupal 8

Main navigation

  • Home
    • Question And Answer
    • NEWS
    • Projects
  • Tutorials - Drupal
    • Android
    • Other
User account menu
  • Log in

Breadcrumb

  1. Home

.bashrc File - Configure bash aliases functions commands... on Linux Unix and MacOSX

By editor , 13 June, 2016
Question

What is the .bashrc file and what does it do ?

How to add bash custom shortcuts on Linux , MacOSX and other Unix based operating systems?

The .bashrc file is a script that is executed whenever a new terminal session is started in interactive mode. It is just the shortcut to the commands allows the user to launch any command or group of commands.

The bashrc file is located in user's directory ( /home/$USER/.bashrc)

Examples:

alias name=value
alias name='command'
alias name='command arg1 arg2'
alias name='/path/to/script'
alias name='/path/to/script.pl arg1'

#Export Options
export LS_OPTIONS='--color=auto'
eval "`dircolors`"

#Create the alias ll = ls -alh
alias ll='ls $LS_OPTIONS -al'

#Change user/group for few commands (Set group = www-data for drush, git, svn, ssh)
alias drush='sudo -u www-data drush'
alias svn='sudo -u www-data svn'
alias git='sudo -u www-data git'
alias ssh='sudo -u www-data ssh'

 

Add alias for all users

/home/$USER/.bashrc is an override of /etc/bash.bashrc or /etc/profile, If you want to add your custom shortcuts for all users, just add your custom alias to /etc/bash.bashrc file (Tested on debian based distributions).

Tutorials:

http://www.cyberciti.biz/tips/bash-aliases-mac-centos-linux-unix.html
https://www.digitalocean.com/community/tutorials/an-introduction-to-useful-bash-aliases-and-functions

 

Tags

  • Linux
  • Shell

Comments

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.

Links

  • Drupal.org
  • Drupal core release cycle
  • Drupal events with ease
  • Unit test with Drupal using PHPUnit (Drupal 10)
  • Tokens for file upload url
  • Tips for Docker
  • CKEditor inline image files usage for custom forms.
  • Install Docker on Linux Mint
  • Install PHP 8.1
  • Drupal Security Best Practices
  • Order and sort items with tabledrag
  • Add a custom service YAML container
  • Apply a patch with composer