Friday, August 5, 2011
5:34 AM

Commands_Part_2


Head

Syntax: command                  -args                                    source
Head displays the first 10 lines of any file in the terminal.
# head  /etc/passwd
Displays the first 10 lines of /etc/passwd on the terminal
# head  -n  20  /etc/passwd
Displays the first 20 lines of /etc/passwd on the terminal

Tail

Syntax: command                  -args                                    source
Head displays the last 10 lines of any file in the terminal.
# tail  /etc/passwd
Displays the last 10 lines of /etc/passwd on the terminal
# tail  -n  20  /etc/passwd
Displays the last 20 lines of /etc/passwd on the terminal
# tail –f  /var/log/messages
  OR
# tailf  /var/log/messages
Dynamically displays the last portion of the log file /var/log/messages

Echo

Syntax: command                  destination
The string after the command echo would be displayed at the terminal.
# echo  hello. how are you?
Displays the text ‘hello. how are you?’ on the terminal
# echo  this is easy
Displays the text ‘this is easy’ in the terminal

Date

Time in any Linux system can be changed in the following methods.
# system-config-date
 OR
# system-config-time

Change the time/date in GUI
# date MMddhhmmyyyy

Example:# date 051117372011
This is a universal command that would work on all UNIX systems. Here MM = Month (1~12), dd = date (1~31), hh = hour (00~23), mm = minute (00~59), yyyy = year

# hwclock  --systohc
Required if time is changed using the command ‘date’. This command synchronizes hardware clock with operating system clock.

History

Whenever a user executes a command, it is saved to history. Each user has a separate history as a reference of the commands that were executed. History is stored in the file .bash_history which is located in the home directory of the user i.e. /root/.bash_history, /home/sarmed/.bash_history.
# history
Displays history
# history –c
Clears history temporarily.

To delete history permanently, open the file .bash_history and delete its contents.

0 comments:

Post a Comment