Bash Tricks

Bash tricks

Bash completion

First we need to install the package if it is not present

 apt-get install bash-completion

Then edit either ~/.bashrc or /etc/profile

 if [ -f /etc/bash_completion ]; then  
  . /etc/bash_completion
 fi

Scripting

Given a list of users, executes the command taking each line of the file users.txt as a parameter

 #!/bin/bash 
 while read username 
 do 
         echo "useradd -m -d /home/$username $username" 
 done < users.txt

Shortcuts

Moving quickly is very important, here’s a list of the best shortcuts to move quickly in the command line

last updated on April 11, 2015, 7:42 p.m.
Back