Labels

Showing posts with label Z Other Command. Show all posts
Showing posts with label Z Other Command. Show all posts

Aliases are custom commands

Aliases are custom commands which can be used to make the work with the shell easier and faster. For example, if your current working directory is /usr/bin and you want to quickly go to /var/cache/apt/archives you can do a 'cd /var/cache/apt/archives'. If you want to save time, you may want to type only a command such as 'cache' or 'debs. Or you may want to update your Debian system in one command, so instead of typing 'su -c "apt-get update && apt-get upgrade"' you only type 'upgrade' or something of your choice. This is where aliases come to help.

In this How-To I will explain two ways of creating aliases.

Method 1
The first method is to add aliases directly into your ~/.bashrc file. The format should be:
alias name='command'
For example you can add something like:
alias ll='ls -l'
alias deb='cd /var/cache/apt/archives'
alias dld='cd ~/downloads'
alias upgrade='su -c "apt-get update && apt-get upgrade"'
Open a console and try your aliases. For example if you type 'deb', the current working directory will be changed to /var/cache/apt/archives.

Method 2
The second method lets you make a separate aliases file, so you won't have to put them in ~/.bashrc, but to a file of your choice. First, edit your ~/.bashrc file and add or uncomment the following lines:
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
Save it and close the file. After that, all you have to do is create a ~/.bash_aliases file and add your aliases there, with the same format specified at the first method.
READ MORE - Aliases are custom commands

Others useful commands on linux

# alias hh='history'
set an alias for a command - hh = history [man]

# apropos ...keyword
display a list of commands that pertain to keywords of a program , useful when you know what your program does, but you don't know the name of the command [man]

# chsh
change shell command [man]

# chsh --list-shells
nice command to know if you have to remote into another box [man]

# gpg -c file1
encrypt a file with GNU Privacy Guard [man]

# gpg file1.gpg
decrypt a file with GNU Privacy Guard [man]

# ldd /usr/bin/ssh
show shared libraries required by ssh program [man]

# man ping
display the on-line manual pages for example on ping command - use '-k' option to find any related commands [man]

# mkbootdisk --device /dev/fd0 `uname -r`
create a boot floppy [man]

# wget -r www.example.com
download an entire web site [man]

# wget -c www.example.com/file.iso
download a file with the ability to stop the download and resume later [man]

# echo 'wget -c www.example.com/files.iso' | at 09:00
start a download at any given time [man]

# whatis ...keyword
displays description of what a program does [man]

# who -a
show who is logged on, and print: time of last system boot, dead processes, system login processes, active processes spawned by init, current runlevel, last system clock change [man]
READ MORE - Others useful commands on linux