Create shortcut commands with aliases and functions in Bash

Shortcut commands are very handy, they can reduce typing and increase productivity, we can create these commands with aliases and functions. The alias command is built into shells like bash, sh, ksh, zsh and dash, in this tutorial we will use bash, the most popular shell in Linux. Functions can be used when more powerful operations and logic is needed, let’s test them and see how they work!

Aliases

Show all defined aliases

Also I would like to share my favorite ones, feel free to post in the comments your favorite. Thanks!

alias
alias cp='cp -i'
alias mv='mv -i'
alias t='telnet'
alias s='ssh'
alias p='ping'
alias v='vim'
alias h='history'
alias ls='ls --color=auto'
alias ll='ls -alh'
alias grep='grep --color'
alias pinf='ping -i 0.2'
alias pinb='ping -s 9000'
alias p10='sudo ping -c 10 -i 0.02'
alias p100='sudo ping -c 100 -i 0.02'
alias update='sudo apt-get update'
alias upgrade='sudo apt-get upgrade'
alias install='sudo apt-get install'
alias cache='sudo apt-cache'

Can be found at: https://github.com/oueta/linux.bashrc.git

Create aliases

alias ls='ls --color=auto'

Remove alias

unalias ls

Note

If you add or remove an alias by command it will be available only for the current session, to make them permanent you need to add them to ~/.bashrc for the current user or /etc/bash.bashrc (Debian) , /etc/bashrc (CentOS) for all users. Also to load the bashrc file you need to start a new session or run the source command: source ~/.bashrc.

Run a command directly

If the command has the same name as the alias, you can run the command by using ‘\’ ( backslash ).

\ls

Functions

If you need to do something more complicated then an alias, you can use functions. To make them permanent you need to add them to bashrc, see the note from above.

Example

function print_param {
      if [ ! -z "$1" ]
        then
          echo "The parameter nr. 1 is $1"
          if [ ! -z "$2" ]
            then
              echo "The parameter nr. 2 is $2"
            fi
        fi
}

How to identify unknown devices in Microsoft Windows

If you have a device that Microsoft Windows doesn’t recognize, an “Unknown device” will show up in your Device Manager with an exclamation mark, this device cannot be used by the operating system. In this tutorial we will learn how to identify and install unknown devices, in a general way.

1. Identifying

a.) Double click on the “Unknown device”, go to the “Details” tab and select the “Hardware Ids” property.
My example device is VEN_10EC&DEV_8168 which means vendor ID is 10EC and device ID is 8168.

Windows Hardware Ids
b.) Go to https://www.oueta.com/pci-database/ and enter the values.

c.) If the device is not found in the database, try Google.

2. Installing

If you successfully identified the “Unknown device” you can search, download and install the drivers.

My recommendation:
a.) Check out the vendors website.
b.) Google is your best friend, search by device name or vendor and device id.
c.) Download clean drivers, only from trusted sources.