Guide to Unix/Commands/Miscellaneous

< Guide to Unix < Commands

sync

sync write memory buffers to disk

Example: Sync has no options, doesn't display any messages

$ sync 

Tips:

It is always good to type sync a couple of times, one the important functions of sync is to update your superblock information.

The sync calls sync Unix system call and exits with success code '0' or '1' if it fails. These exit codes stored in $? variable.

$ sync
$ echo $?
 0 

The above example shows that sync was successful.

Links:

echo

echo outputs its parameters to the standard output.

Examples:

$ echo "hello world"
hello world

Tips: Some common echo usage:

Check a shell variable:

$ echo $EDITOR
emacs

Check the parameters passed in the previous command:

$ ls -l 
 .........
$ echo $_
-l

Check the current parent process:

$ echo $0
bash

Check the exit code of the last command:

$ echo $?
0

Create a empty file (same as touch /tmp/newfile):

$ echo "" > /tmp/newfile

Create a new file with some text:

$ echo "exec fluxbox" > ~/.xinitrc

Add (append) a new line to end of file:

$ echo "A New Line" >> /tmp/newfile

Links:

cal

cal displays a calender for the current month. If the command is followed by a date (a month or a year) it will return a calender for that period.

Examples:

$ cal 
     April 2004
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
$ cal 01 2007
    January 2007
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 31
$ cal -3
Shows current, previous and next month (default on some implementations)
$ cal -3 04 2004
Shows April 2004, as well as the previous (March) and following (May) month
$ cal -1
Shows the current month (default on some implementations)
$ cal 2004
Shows a calendar for the whole year 2004
$ cal -j
Shows this months calendar with day-of-year number (counted from January 1st) rather than the date

Tips: The Gregorian Calendar was adopted in the British Empire in 1752. The 2nd day of September 1752 was immediately followed by the 14th day of September, as shown by the example below.

$ cal 9 1752
  September 1752   
Su Mo Tu We Th Fr Sa
       1  2 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30

Links:

date

date displays the current date and time.

Example:

$ date
Mon Jun 26 12:34:56 CDT 2006

Links:

time

time time a program

Example:

$ time

 real    0m1.818s
 user    0m0.770s
 sys     0m0.210s

Links:

from

from display the names of those who sent you mail recently

Example:

$ from
  From andy@box.po Sat Feb 05 08:52:37 2005
  From andy@box.po Sat Feb 05 08:53:52 2005

Count the number of mail in your mailbox

$ from -c
There are 2 messages in your incoming mailbox.

Links:

mail

mail allows you to read and write emails.

Example:

$ mail
No mail for user.
$ mail user2
Subject: What's up?
Hi user2, you can delete this rubbish by pressing 'd'.
Cc: user

Tips: Note that you need to press enter then ctrl+d to confirm.

$ mail
Mail version 8.1 6/6/93. Type ? for help.
"/var/spool/mail/user": 1 message 1 new
>N 1 user@unix.com Tue Jun 27 12:34 16/674 "What's up?"
&

Tips: Press enter to read.

Links:

clear

clear clears the screen.

Example:

$

Links:

This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.