- Syntax: cat filename
Copies the contents of filename to standard output. If no files are
input is copied to standard output.
- Syntax: head filename
copies the first ten lines of filename to standard output
- Syntax: tail filename
copies the last ten lines of filename to standard output
- Syntax: more filename
copies one screenful of filename on standard output. Press spacebar to
display another screenful, and q to quit.
- Syntax: ls -options filenames, ls -options
lists information about files and directories. If no argument is given ls lists the
contents of the current directory. Options: a=all;
- Syntax: cp fromfilename tofilename
The above command copies the contents of fromfilename to
tofilename in the current directory.
cp file1 file2 directory
this command copies file1 and file2 to the specified
directory. Use . (period) to specify the current directory.
- Syntax: mv fromfile tofile
This command renames (moves) the fromfilename to
tofilename in the current directory.
mv fromfile directory
This command moves the fromfile from the current directory to the specified
- Syntax: rm file1 file2
erases file1 and file2
- Syntax: chmod permissions filenames directories
changes the access previleges for files and directories to permissions
chmod ugo+rwx file1
This command adds read (r), write (w), and execute (x) previleges to user (u), group
(g), and all others (o) for file1.
- Syntax: cd dir
changes directory from the current directory to dir. If no directory is
specified the current directory is changed to the user's home directory.
- Syntax: mkdir dir
creates a directory named dir under the current directory.
- Syntax: rmdir dir
erases the dir directory. Note it will only erase an empty
- Syntax: pwd
displays the current directory on the standard output.
vi Editor Commands
- Syntax: vi filename
loads filename into buffer for editing. If filename
does not exist then a new file named filename is created.
- Syntax: ZZ
saves the contents of the edit buffer to file invoked with the vi command, and
quits. The command :wq also will do the same.
- Syntax: :q
will quit from the buffer without saving the file. If changes have been made to the
file in the buffer during the edit session, you must use :q! to quit without
- Syntax: :w
writes to file which was invoked with the vi command.
- Syntax: i
change to insert mode. Type i anywhere within the file in order to insert new
data. i allows you to insert data before the current cursor position. To insert data
after the current cursor position type a (lowercase a).
- Syntax: ESC (press the escape key) or
change to command mode. You must be in the command mode in order to
make any changes other than inserting new data into the file.
- Syntax: o (lowercase o)
inserts a new line after the current lineand toggle into insert mode. An O
(uppercase O) will insert a new line before the current line and toggle into insert
Deleting Characters and Lines, Moving Lines, and Copying Lines
- Syntax: x (lowercase x), nx
nx will delete n characters starting from the
current cursor position. x is interpreted as 1x.
- Syntax: dw, ndw
ndw will delete n words starting from the word
at the current cursor position. dw is interpreted as 1dw.
- Syntax: dd, ndd
dd will delete the current line. ndd will delete
n lines, starting with the current line.
- Syntax: p, P
p (lowercase p) will paste the last deleted line(s) or character(s) after the
current line or character. P (uppercase P) will paste the last deleted line(s) or
character(s) before the current line or character.
- Syntax: yy, nyy
yy will copy current line into a temporary buffer. This line may then be copied
to another location in the file by using the p or P (paste) command. The
command nyy copies n lines into the temporary buffer.
These lines may then be pasted to some other location by using the p or
- Syntax: . (period)
repeats the last command. Used frequently to copy a line repeatedly.
- Syntax: u (lowercase u)
will undo the most recent change.
- Syntax: U (uppercase U)
will restore the current line.
- Syntax: $
positions cursor at the end of the current line.
- Syntax: ^
positions cursor at the beginning of the current line.
- Syntax: w
moves cursor (forward) to the end of the current word.
- Syntax: b
moves cursor (backward) to the beginning of the current word.
- Syntax: G (uppercase G), nG
nG positions cursor on the nth line,
G positions cursor on the last line.
Last Modified On: