UNIX VI

Download as pdf or txt
Download as pdf or txt
You are on page 1of 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

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy