Comentum Site Map
 
 

Comentum Corp.

 
 

Creative Services

Interactive Multimedia Concept Marketing Broadband Technology
 
Unix Getting Started Manual
 
Contents:
File Management

Miscellaneous

System Status




File Managment Commands
catJoin 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 file.
Examples:
cat hello.txtDisplays the file hello.txt
cat hello.txt world.txt > helloworld.txtCombines files hello.txt and world.txt into one file called helloworld.txt
cdChange working directory
Examples:
cdChanges working directory to user's home directory.
cd dir1Changes working directory to dir1.
cd ..Changes working directory one level up.
chmodChange access modes on files
Only the owner of a file or a privileged user may change its mode.
Syntax: chmod [option] mode files
Options: -R Recursively descend thgrough directoy setting modes to files
Mode: Composed of who, opcode and permission.
WhouUser
gGroup
oOther
aAll (default)
Opcode+Add permission
-Remove permission
=Assign permission (and remove permission of the unspecified fields)
Permission rReadOR*4Read
wWrite2Write
xExecute1Execute
*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.

Examples:
chmod u+x fileAdds execute-by-user permission to file
chmod 751 file
chmod u=rwx,g=rx,o=x 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.
cpCopy files
Syntax: cp [options] file1 file2
       cp [options] files directory
Examples:
cp file1 file2Copies file1 into file2.
cp file1 file2 file3 dir1 Copies file1, file2 and file3 to directory dir1, preserving the files' names
cp -r dir1 dir2Recursivle copy directory dir1, its files and subdirectories to a destination directory dir2 (duplicating the tree structure).
headShow the first few lines of a file
Examples:
head -20 file1Displays the first 20 lines of file1
lsList files or directories
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:
-aList all files, including the normally hidden . files
-cList files by creation/modification time
-lLong format listing (includes permissions, owner, size, modification time, etc.)
mkdirCreate a directory
Syntax: mkdir directories
Create one or more directories. You must have write permission in the parent directory in order to create a directory.
Examples:
mkdir dir1Creates a directory named dir1.
mkdir dir1 dir2 dir3Creates directories named dir1, dir2 and dir3.
moreDisplay files by screenful
Syntax: more files
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.
mvMove or rename files or directories
Syntax: mv sources target
Basic command to move files and directories around on the system or to rename them. The following table summarizes how mv works.
pwdPrint your working directory
rmRemove files
rmdirRemove directories
tailShow the last few lines of a file
wcCount lines, words, and characters
Back to top


Miscellaneous Commands
bcPrecision calculator
Input can be taken from files or read from the standard input. To exit, type "quit" or "EOF".
For mor information type "man bc".
calDisplay 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.
Examples:
cal 10 2003Displays one-month calendar for October, 2003
cal 2005Displays 12-month calendar for 2005
clearClear the screen
manDisplay information from the on-line reference manuals.
Syntax: man [command]
Example: man mkdir  Display manual pages for command "mkdir".
tarTape archiver
Syntax: tar [options] [files]
Copy files to or restor files from tape. If any files are directories, tar acts on the entire subtree.
Options-zcvf archCreate a new tape arch.
-ztvf archPrint names of files in arch.
-zrvf archAppend files to tape arch.
-zxvf archExtract files from tape arch.

Examples:
tar -zcvf arch file1 file2Creat an archive of file1 and file2 and store it in arch
tar -zxvf archExtract all the files in arch.
viVisual text editor
Syntax: vi [file] If file exists, open file for editting. Otherwise, create file and open for editing. If no file is specified, vi opens wiht an empty buffer.
Some vi commands:
aAppend after the cursor.
AAppend at end of line.
iInsert before cursor.
IInsert at beginning of line.
oOpen a line below current line.
OOpen a line above current line.
ddDelete current line.
:wWrite to file. (use :w! to force write)
:qQuit vi. (use :q! to force quit)
hMove one character to the left.
jMove one line down.
kMove one line up.
lMove one character to the right.
Back to top


System Status Commands
chgrpChange 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 privileged user to suceed this command.
Example:
chgrp hello.txt group1Changes the group for file hello.txt to group1
chgrp -R dir1 group1Recursively descends through directory dir1, including subdirectories, setting group to group1
chownChange file owner
Syntax: chown [options] newowner files
Change the ownership of one or more files to newowner.
Example:
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.
dateDisplay the current date and time. Priviledged users may also set a date and time.
fingerPoint out information about users.
Syntax: finger [options] users
Displays data about one or more users.
hostnamePrint the name of the host machine.
psReport on active processes
Syntax: ps [options]
Options-AList all processes.
-u usersList processes only for usernames in users.

For more options type man ps.
whoList the names of users currently logged into the system.
whoamiPrint the effective username.
Back to top