0% found this document useful (0 votes)
192 views

Unix Commands

This document provides instructions for navigating directories, viewing and editing files using common Linux commands like cat, cd, cp, mkdir, mv, rm, rmdir, vi, tail, and more. It explains how to view the contents of a file using cat, navigate directories using cd, copy a file using cp, create subdirectories using mkdir, move and remove files and directories using mv and rm, view the last lines of a file using tail, and edit files using vi commands like i for insert mode, :w to write, and / to search. The document also lists vi commands for inserting, deleting, copying, pasting, searching, and replacing text.

Uploaded by

Sreedhar Narra
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
192 views

Unix Commands

This document provides instructions for navigating directories, viewing and editing files using common Linux commands like cat, cd, cp, mkdir, mv, rm, rmdir, vi, tail, and more. It explains how to view the contents of a file using cat, navigate directories using cd, copy a file using cp, create subdirectories using mkdir, move and remove files and directories using mv and rm, view the last lines of a file using tail, and edit files using vi commands like i for insert mode, :w to write, and / to search. The document also lists vi commands for inserting, deleting, copying, pasting, searching, and replacing text.

Uploaded by

Sreedhar Narra
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

To view the contents of a file named swathi.txt , enter: cat swathi.

txt
cd /Benefits/DIR-A/TEST to come out from Test type cd .. enter > /Benefits/DIR-A pwd : enter-- /Benefits/DIR-A

cp

/Benefits/DIR-A/TEST/ swathi.txt /FED/Benefits/mydocs

cd /FED/Benefits/mydocs
ls - swathi.txt

To create a subdirectory named mystuff in the current directory, enter: mkdir mystuff
mv rm newhw/hw1(space means TO) oldhw/firsthw swathi.txt(removes the file)

rmdir oldstuff ( removes the directory oldstuff) vi swathi.txt( creates a file if not exits vi swathi.txt( opens for edit if already exists tail swathi.txt ( by default will display the last 10 lines of a file.) tail -50 swathi.txt displays last 50 lines more displys more lines VI COMMANDS

Vi editor.
vi command launches a vi sual editor. To edit a file type vi filename vi editor is a default editor of all Unix systems. It has several modes. In order to write characters you will need to hit i to be in insert mode and then start typing. Make sure that your terminal has correct settings, vt100 emulation works good if you are logged in using pc. Once you are done typing then to be in command mode where you can write/search/ you need to

hit :w filename to write and in case you are done writing and want to exit :w! will write and exit.

options:

i for insert mode. o I inserts text at the curson o A appends text at the end of the line. o a appends text after cursor. o O open a new line of text above the curson. o o open a new line of text below the curson. : for command mode. o <escape> to invoke command mode from insert mode. o :!sh to run unix commands. o x to delete a single character. o dd to delete an entire line o ndd to delete n number of lines. o d$ to delete from cursor to end of line. o yy to copy a line to buffer. o P to paste text from buffer. o nyy copy n number of lines to buffer. o :%s/stringA/stringb /g to replace stringA with stringB in whole file. o G to go to last line in file. o 1G to go to the first line in file. o w to move forward to next word. o b to move backwards to next word. o $ to move to the end of line. o J join a line with the one below it. /string to search string in file. n to search for next occurence of string.

You might also like