Skip to main content

Linux Commands

 1. cd command

This Command is used to change Directory.

Syntax:

cd <Directory Name>

Output:




 2. mkdir command

This Command is used to create new directory.

Syntax:

mkdir <Directory Name>

Output:




 3. ls command

This Command is used to check the list of present files in particular Directory

Syntax:

ls

Output:







 4. rm command

This Command is used to remove directory or file

Syntax:

rm -r <directory_name>,rm <file_Name>

Output:





 5. pwd command

This Command is used to know the current location

Syntax:

pwd

Output:




 6. vi command

This Command is used to edit and create text file

Syntax:

vi <FileName>

Output:





 7. cat command

This Command is used to display text files.

Syntax:

cat <FileName>

Output:




 8. cp command

This Command is used to copy file or directory to some other place.

Syntax:

cp <file/dir name/path> <location path >

Output:









 9. mv command

This Command is used to move and rename a file or directory.

Syntax:

mv <file/dir name/path> <location path >   --- for moving file

mv <file/dir name> <Another Name>         --- for renaming

Output:










10. vi command

vi(vim)            --------sysntax vi <filename/filepath>

i (insert)          --------Press i button to go in insert(editing) mode

esc(button)     ---------To come out of insert mode

shift+:w          ---------pres button to write in file

shift+:q           ---------press button to quit from file

shift+wq         ---------press button to write and quit from file

shift+q!           ---------press button to quit forcefully from file

shift+wq!        ---------press button to write and quit forcefully from file.


Use the following commands in command mode:

h - Moves the cursor to the left by one character; you can also press the left arrow.

j - Moves the cursor one line down; you can also press the down arrow.

k - Moves the cursor one line up; you can also press the up arrow.

l - Moves the cursor to the right by one character; you can also press the right arrow.

w - Moves the cursor one full word to the right.

b - Moves the cursor one full word to the left.

0 - Moves the cursor to the beginning of the current line.

$ - Moves the cursor to the end of the current line.

~ - Changes the case of the current character.

dd - Deletes the current line.

D - Deletes everything on the line to the right of the cursor’s current position.

x - Deletes the current character.

u - Undo the last command.

. - Repeats the last command.

:w - Saves current file, but does not exit.

:wq - Saves current file, and quits.


The following commands place you into insert mode:

i - Inserts to the left of the current cursor position.

a - Appends to the right of the current cursor position.

dw - Deletes the current word.

cw - Changes the current word.


 9. grep command

This Command is used to grep word or line from a or many files.

Syntax:

grep <description> <word/line> <FileName/Path>

-c : This prints only a count of the lines that match a pattern

-h : Display the matched lines, but do not display the filenames.

-i : Ignores, case for matching

-l : Displays list of a filenames only.

-n : Display the matched lines and their line numbers.

-v : This prints out all the lines that do not matches the pattern

-o : Print only the matched parts of a matching line,

 with each such part on a separate output line.

-A n : Prints searched line and nlines after the result.

































-e exp : Specifies expression with this option. Can use multiple times.

-f file : Takes patterns from file, one per line.

-B n : Prints searched line and n line before the result.

-C n : Prints searched line and n lines after before the result.





















Comments