Unix Commands

Here is a page I created using html and inline CSS to sample some simple unix commands.

 

These are useful UNIX commands. The commands can be used in most flavors of UNIX including Mac OS X (via the terminal), Linux, and Solaris. These commands are known to be accessible in Mac OS X (as that was my testing environment.)

Table of Contents

 


 

UNIX COMMANDS:

echo

$ echo Hello World
Hello World
$ exit

whoami

$ whoami
johndoe
$ exit

cal

$ cal
    August 2008
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
$ exit

date

$ date
Sun 31 Aug 2008 20:18:42 ADT
$ exit

ls

$ ls
Desktop			Movies			Sites
Documents		Music			javademoapp
Downloads		Pictures		test-video
Library			Public			twit_fail_whale.jpg
$ vexit

diff filename1 filename2

$ diff readme1.txt readme2.txt
< This is readme 1.txt...
3,13c2,20
< This is a test file and is the first file used in this demo... this file is awesome
< 1
< 2
< 3
< 4
< 5
< 6
< 7
< 8
< 9
< 10
---
>
> FILE 2:
> THIS IS THE SECOND FILE IN THIS DEMONSTRATION
>
> 88
> 89
> 90
> 91
> 92
> 93
> 94
> 95
> 96
> 97
> 98
> 99
> 100
>
> FILE #2
\ No newline at end of file
$ exit

gzip filename

$ls
readme1.txt
readme2.txt
$ gzip readme1.txt
$ls
readme1.txt.gz
readme2.txt
$ exit

gunzip filename

$ls
readme1.txt.gz
readme2.txt
$gunzip readme1.txt.gz
$ls
readme1.txt
readme2.txt
$ exit

gzcat filename

$ gzip readme1.txt
$ gzcat readme1.txt.gz
This is readme 1.txt...

This is a test file and is the first file used in this demo... this file is awesome
1
2
3
4
5
6
7
8
9
10
$ exit

wc

$ wc readme1.txt
      13      32     130 readme1.txt
$ wc readme2.txt
      19      25     105 readme2.txt
$ exit

w

$w
20:42  up 9 days, 20:01, 2 users, load averages: 0.51 0.55 0.54
USER     TTY      FROM              LOGIN@  IDLE WHAT
johndoe console  -                22Aug08 9days -
johndoe s001     -                20:24       - w
$ exit

ftp

''$ ftp brad-zone.com''
Connected to brad-zone.com.
220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------
220-You are user number 4 of 50 allowed.
220-Local time is now 16:56. Server port: 21.
220-This is a private system - No anonymous login
220 You will be disconnected after 3 minutes of inactivity.
''Name (brad-zone.com:bradleyarsenault): bradzone''
331 User bradzone OK. Password required
''Password: ''
230-User bradzone has group access to:  516
230 OK. Current directory is /
Remote system type is UNIX.
Using binary mode to transfer files.
[[''ftp> put readme1.txt'']]
local: readme1.txt remote: readme1.txt
500 Unknown command
227 Entering Passive Mode (68,178,232,94,13,42)
150 Accepted data connection
100% |*************************************|   130     940.39 KB/s    00:00 ETA
226-File successfully transferred
226 0.098 seconds (measured here), 1.29 Kbytes per second
130 bytes sent in 00:00 (1.28 KB/s)
''ftp> exit''
221-Goodbye. You uploaded 1 and downloaded 0 kbytes.
221 Logout.
IMAC:~ bradleyarsenault$ exit

I’ve italicized the user input.

Those are some useful unix commands… but the most important one is…

man command

$ man ftp

Displays many screens of documentation.

For all of these demos I’ve changed the “IMAC:~ bradleyarsenault$” to simply “$” for simplicity. That “IMAC:~ bradleyarsenault$” will differ machine to machine as it’s really “MACHINE NAME:~ USERNAME$” .