General:Introduction |Explanations |Why Unix-like
Platforms:Linux |BSD
Quick Reference:Commands |Environment Variables |Files |License
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 ofsync is to update your superblock information.
Thesync 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 thatsync was successful.
Links:
echo outputs its parameters to the standard output.
Examples:
$echo "hello world"hello world
Tips:Some common echo usage:
Check a shell variable:
$echo $EDITORemacs
Check the parameters passed in the previous command:
$ls -l .........$echo $_-l
Check the current parent process:
$echo $0bash
Check the exit code of the last command:
$echo $?0
Create a empty file (same astouch /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:
Produces formatted output, richer thanecho.
Examples:
Links:
Outputs a calendar, per default for the current month. If followed by a year, outputs calendar for that year; if followed by a month and a year, outputs a calendar for that period. POSIX supports no options: all options are extensions. The options of linux-util cal, GNU gcal and FreeBSD cal are generally incompatible.
Introductory examples, covered by POSIX:
$cal April 2004Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8 9 1011 12 13 14 15 16 1718 19 20 21 22 23 2425 26 27 28 29 30
$cal 01 2007 January 2007Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8 9 10 11 12 1314 15 16 17 18 19 2021 22 23 24 25 26 2728 29 30 31
More examples for POSIX cal:
Examples for util-linux cal:
Examples for GNU gcal:
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:
$cal 9 1752 September 1752 Su Mo Tu We Th Fr Sa 1 2 14 15 1617 18 19 20 21 22 2324 25 26 27 28 29 30
Links:
date displays the current date and time.
Example:
$ dateMon Jun 26 12:34:56 CDT 2006
Links:
time time a program
Example:
$ time real 0m1.818s user 0m0.770s sys 0m0.210s
Links:
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 -cThere are 2 messages in your incoming mailbox.
Links:
mail allows you to read and write emails.
Example:
$mailNo mail for user.$mail user2Subject: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.
$mailMail 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:
Clears the screen of the terminal. Takes no arguments. Keywords: cls.
Links:
Outputs sequences of numbers, even floating point numbers. Seems not covered by POSIX.
Examples:
Links:
Randomly shuffles file or input lines. Not covered by POSIX.
Examples:
Links:
Writes the input stream into a file while at the same time passing it to standard output.
Examples:
Links:
Pauses for a period of time.
Examples:
Links:
Outputs an indefinite stream of newline-separated strings "y", or other strings as specified. One of the uses is feeding the output into a command that requires user confirmation.
Examples:
Links:
Does nothing and finishes with zero exit code, indicating success.
Links:
Does nothing and finishes with non-zero exit code (often 1), indicating failure.
Links:
Sets the environment for a command or outputs all environment variables. See alsoEnvironment Variables.
Examples:
Links:
Outputs values of one or more environment variables or all variables if none are passed. Not covered by POSIX. Alternatives are#env to output all variables and "echo $HOME" to output a single variable, here HOME. See alsoEnvironment Variables.
Examples:
Links: