Friday, 11 April 2014

Basic - Commands beginner's should know

clear

The clear command is one of the most handy command used to clear your terminal screen. The clear command does not affect files or jobs, it simply clears the clutter from your terminal screen. Another nice thing about `CLEAR` is that it doesn't erase your terminal scroll buffer, so if you need to see something that was on your screen a while ago, you can still use your mouse wheel to scroll back.

# clear
or CTRL + L

date

The date command is used to display the current date and time or set the system date/time

 # date
Fri Apr 11 11:50:40 GMT 2014


- To set a new date and time
   # date -s "Fri Apr 11 11:00:00 GMT 2014"
or # date -s "11 APR 2014 16:00:00"
or # date --set="11 APR 2014 16:00:00"

- To set date only
# date +%Y%m%d -s "YYYYMMDD"
# date +%Y%m%d -s "20131120"

- To set time only
# date +%T -s "HH:MM:SS"
# date +%T -s "16:24:30"


cal

The cal command is used to print the current month's calender. With this command also we can see any year/month's calender.

# cal
     April 2014
Su Mo Tu We Th Fr Sa
       1  2  3  4  5
 6  7  8  9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30


- To see a particular year's calender (e.g. 1995)
# cal 1995

- To see a particular month's calender of a year ( e.g. Feb 2005)
 # cal 2 2005

- To see last few months calender
# cal -3

uname

The uname command reports basic information about a computer's software and hardware. It privides the information about the name, version and other details about the current machine and the operating system running on it.

# uname
Linux

uname without any ooption prints the kernel name


- To get all the inrforamtion about the system  

# uname -a
Linux ip-10-132-73-9.ap-southeast-1.compute.internal 2.6.32-431.1.2.el6.x86_64 #1 SMP Sun Nov 24 09:37:37 EST 2013 x86_64 x86_64 x86_64 GNU/Linux


- To get the operationg system name
# uname -o
GNU/Linux

- To get the kernel name
# uname -s
Linux

- To get the hostname
# uname -n
ap-southeast-1.compute.internal

- To get the kernel release information
# uname -r
2.6.32-431.1.2.el6.x86_64


- To get the kernel version name
# uname -v
#1 SMP Sun Nov 24 09:37:37 EST 2013

- To get the machine hardware name
# uname -m
x86_64
- To get the processor type
# uname -p
x86_64


- To get the informaiton about hardware platform information
# uname -i
x86_64 
 


hostname

The hostname command is used to view or change the hostname of the system.

- To view the hostname of the system
# hostname

- To change the hostname
# hostname subrat.com
# hostname
subrat.com


- To see the IP of the host
# hostname -i

-To see the Fully Qualified Domain Name of the host
# hostname -f

history

The history command is used to see the command line history i.e. lists the executed commands.

- To display the command line history
# history | more
- To display the Time stamp with commands

# export HISTTIMEFORMAT='%F %T  '
# history | more
 127  2014-04-11 08:31:16  vim /etc/sysctl.conf
  128  2014-04-11 08:31:16  sysctl -p
  129  2014-04-11 08:31:16  vim /etc/sysctl.conf
  130  2014-04-11 08:31:16  cat /proc/self/mapped_base
  131  2014-04-11 08:31:16  history
  132  2014-04-11 08:31:16  vim /etc/sysctl.conf
  133  2014-04-11 08:31:16  sysctl -p
  134  2014-04-11 08:31:16  byobu
  135  2014-04-11 08:31:16  aws help

- To clear command line history
# history -c

alias

The alias command allows a user to create simple names or abbreviations (even consisting of just a single character) for commands regardless of how complex the original commands are and then use them in the same way that ordinary commands are used.

Syntax: alias name='command'

- To set an alias
# alias p="pwd"

- To see a list of aliases set up on your system
# alias
alias cp='cp -i'
alias l.='ls -d .* --color=auto'
alias ll='ls -l --color=auto'
alias ls='ls --color=auto'
alias mv='mv -i'
alias rm='rm -i'

alias p='pwd'

unalias

The unalias command is used to remove entries from the current user's list of aliases.

# unalias p

# alias
alias cp='cp -i'
alias l.='ls -d .* --color=auto'
alias ll='ls -l --color=auto'
alias ls='ls --color=auto'
alias mv='mv -i'
alias rm='rm -i'





No comments:

Post a Comment