0% found this document useful (0 votes)
61 views2 pages

UNIX VI

The document provides a primer on common UNIX commands and the vi text editor. It lists common UNIX commands like cp, mv, rm, and ls along with brief explanations of their functions. It also covers basic vi commands for editing files, including commands for inserting and deleting text, moving the cursor, searching, and saving files. The document aims to introduce some basic but essential UNIX and vi commands for newcomers to get started with these tools.

Uploaded by

Anna Croft
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views2 pages

UNIX VI

The document provides a primer on common UNIX commands and the vi text editor. It lists common UNIX commands like cp, mv, rm, and ls along with brief explanations of their functions. It also covers basic vi commands for editing files, including commands for inserting and deleting text, moving the cursor, searching, and saving files. The document aims to introduce some basic but essential UNIX and vi commands for newcomers to get started with these tools.

Uploaded by

Anna Croft
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

A primer of common UNIX commands

UNIX command lines tend to be quite terse and are probably not terribly intuitive. Here is a list of the common UNIX commands you may used from time to time.
Command vi cp mv rm Variants Meaning Edit the specified file Make a copy of the specified file Rename (move) the specified file Delete a specified file Remove a directory and all files in it Remove a file, but ask first to confirm List the files in a directory List the files in order of creation List the files in reverse order of creation List files with extra information (eg date of modification, file permissions etc) Make a new directory (folder) Remove a specified directory Change to a subdirectory Change to the home directory Change up to a new directory Use vi h2o.com cp h2o.com test.com mv h2o.com h3o.com rm h3o.com rm r junk ls

r m -r r m -i ls ls -lat ls -rt ls -Flags mkdir r mdir cd cd cd ../

mkdir water rmdir water cd water cd cd ../water

A primer for vi
The built in editor on pretty much all UNIX machines (including MacOSX machines) is vi. It is pretty versatile and powerful although the commands are not immediately intuitive. To begin editing a file, issue the command: vi filename Here are some more common vi editing commands that you will come across. Note that upper and lower case commands have distinct meanings ie commands are case sensitive.
Initiating Input Mode i a O o #s r R cw C (same as c$) ESC Delete dw dd x Inserts before cursor Inserts after cursor Inserts before current line Inserts after current line Replaces # characters (# = number) Replaces a single character Replaces as many characters as are typed Replaces a word Replaces to the end of the current line Exit from input mode

Delete a word Delete current line Delete character

Move the cursor l (or spacebar) h (or backspace) j (or +) k (or ) $ ^ e b #G Move the screen CTRL-D CTRL-F CTRL-B CTRL-L Search (and replace) / ? n :%s/pattern1/pattern2/g Misc (#)yy p P u . File Commands ZZ :w :w! :q! :r filename

Move to the right Move to the left Move down a line Move up a line Move to the end of the line Move to the start of a line Move to the end of a word Move to the beginning of a word Move to line number #

Scroll forward half a screen Scroll forward a full screen Scroll backwards a full screen Redraw screen

Search forward Search backwards Next occurrence Search for and replace all patern1 with pattern2

Yank a (#) line(s) Paste it below current line Paste it above Undo last command Repeat last action

Write file and quit Write file and dont quit Write file and dont complain (or quit) Quit, dont save and dont complain Read in filename after the cursor

You might also like