Unix Commands Reference and Getting Started Manual

File Management Commands

Join files or display them
Read one or more files and print them on the screen (or standard output).
You can then use the > operator to combine several files into a new filee.

cat hello.txt Displays the file hello.txt
cat hello.txt world.txt >
Combines files hello.txt and world.txt into
one file called helloworld.txt

Change working directory

cd Changes working directory to user's home
cd dir1 Changes working directory to dir1.
cd .. Changes working directory one level up.

Change access modes on files
Only the owner of a file or a priviledged user may change its mode.
Syntax: chmod [option] mode files
Options: -R Recursively descend through directory setting modes to files
Mode: Composed of who, opcode and permission.

Who u User
  g Group
  o Other
  a All (default)
Opcode + Add permission
  - Remove permission
  = Assign permission (and remove permission of the unspecified fields)
Permission r Read OR* 4 Read
  w Write   2 Write
  x Execute   1 Execute

*Permissions may also be specified by a 3 digit sequence. The first digit designates owner permission; the second, group permission; and the third, others permission. Permissions are calculated by adding the values in the table.

chmod u+x file Adds execute-by-user permission to file
chmod 571 file Both these examples assign read-write-execute permission by owner (7), read-write permission by group (5), and execute-only permission by others (1) to file.
chmod u=rwx, g=rx, o=x file

Copy files
Syntax: cp [options] file1 file2
cp [options] files directory

cp file1 file2 Copies file1 into file2.
cp file1 file2 file3 dir1 Copies file1, file2, and file3 to directory dir1, preserving the files' names.
cp -r dir1 dir2 Recursive copy directory dir1, its files and subdirectories to a destination directory dir2 (duplicating the tree structure).

Show the first few lines of a file

head -20 Displays the first 20 lines of file1

List of files or directories
Syntax ls [options][names]
If no names are given, list the files into the current directory. With one or more names, list files contained in a directory name or that match a file name.

Some Options:
-a List all files, including the normally hidden files
-c List files by creation/modification time
-l Long format listing (includes permissions, owner, size, modification time, etc.)

Create a directory
Syntax: ls [options][names]
If no names are given, list the files in the current directory. With one or more names, list files contained in a directory name or that match a file name.

Some Options:
mkdir dir1 Creates a directory named dir1.
mkdir dir1 dir2 dir3 Creates directories named dir1, dir2 and dir3.

Display files by screenful
Syntax: more file
Display the named files on a terminal, one screenful at a time. After each screen is displayed, press RETURN to display the next line or press the spacebar to display the next screenful.


Print your working directory


Remove files


Remove directories


Show the last few lines of a file


Count lines, words, and characters

Back to Top

Miscellaneous Commands

Precision calculator
Input can be taken from files or read from the standard input. To exit, type "quite" or "EOF".
For more information type "man bc".


Display calendar
With no arguments, cal prints the calendar for the current month. Otherwise, print either a 12-month calendar (beginning with January) for the given year or a one-month calendar of the given month and year.

cal 10 2003 Displays one-month calendar for October, 2003.
cal 2005 Displays 12-month calendar for 2005

Clear the screen


Display information form the on-line reference manuals.
Syntax: man[command]

man mkdir Display manual pages from command "mkdir".

Tape archiver
Syntax: tar[options][files] Copy files to or restore files from tape. If any files are directories, tar acts on the entire subtree.

Options -zcvf arch Create a new tape arch.
-ztvf arch Print names of files in arch.
-zrvf arch Append files to tape arch.
-zxvf arch Extract files tape arch.

Visual text editor
Syntax: vi [file] If file exists, open file for editing. Otherwise, create file and open for editing. If no file is specified, vi opens with an empty buffer.

Some vi commands:
a Append afer the cursor.
A Append at end of line.
i Insert before cursor.
I Insert at beginning of line.
o Open a line below current line.
O Open a line above current line.
dd Delete current line.
:w Write to file. (use :w! to force write)
:q Quit vi. (use :q! to force quit)
h Move one character to the left.
j Move one line down
k Move one line up.
l Move one character to the right.
Back to Top

System Status Commands

Change file group
Syntax: chgrp [options] newgroup files
Change the ownership of one or more files to newgroup. You must own the file or be a priviledged user to succeed this command.

chgrp hello.txt group1 Changes the group for file hello.txt to group1
chgrp -R dir1 group1 Recursively descends through directory dir1, including subdirectories, setting group to group1

Change file owner
Syntax: chown [options] newowner files
Change the ownership of one or more files to newowner.

chown user1 file1 file2 Changes the owner of file1 and file2 to user1.
chown -R user1 dir1 Recursively descends through directory dir1, including subdirectories, setting the owner to user1.

Display the current date and time. Priviledged users may also set a date and time.


Point out information about users.
Syntax: finger [options] users
Displays data about one or more users.


Print the name of the host machine.


Report on active process
Syntax: ps [options]

Options -A List all processes.
-u users List processes only for usernames in users.

For more options type man ps.


List the names of users currently logged into the system.


Print the effective username.

Back to Top
For Information Contact:
Comentum Corp
6222 Ferris Sq.
San Diego, CA 92121
Phone: 619-990-1212

Hours: Mon. - Fri., 9 a.m. - 5 p.m. PST

Contact Us »

Mobile App Development

iPhone, Google Android, BlackBerry, Windows Mobile
In-house development team.
San Diego, CA, USA.

Learn More

Web App Estimator

Select and unselect modules such CMS or eCommerce for your web application and watch the cost update in real time.

Try It »