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

LinuxBasicCommands

This document provides an overview of basic Linux commands, including their functions and usage examples. It covers 15 essential commands such as 'man', 'pwd', 'cd', 'ls', 'touch', 'cat', 'mkdir', 'cp', 'mv', 'rm', 'vi', 'grep', 'head', 'tail', and 'history'. The tutorial aims to help users familiarize themselves with the Linux terminal and perform file management operations.

Uploaded by

postbox181
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

LinuxBasicCommands

This document provides an overview of basic Linux commands, including their functions and usage examples. It covers 15 essential commands such as 'man', 'pwd', 'cd', 'ls', 'touch', 'cat', 'mkdir', 'cp', 'mv', 'rm', 'vi', 'grep', 'head', 'tail', and 'history'. The tutorial aims to help users familiarize themselves with the Linux terminal and perform file management operations.

Uploaded by

postbox181
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

Linux Basic Commands

By TechNow Tamil
Top 15 Commands
man mv
pwd rm
cd vi
ls grep
touch head
cat tail
mkdir history
cp
By TechNow Tamil
Objective
Get started with the Linux terminal & begin using terminal commands.

Primary goals
Here are a list of things you will learn in this tutorial:

▪ Get familiar with the Linux terminal.

▪ Learn the commands necessary to navigate directories and files.

▪ Perform file management operations - create, read, update and delete.

▪ Search directories for files and search files for interesting patterns.

By TechNow Tamil
1. man
In Linux, the man command is used to display the documentation/user manual on just about any Linux
command that can be executed on the terminal. It includes the name of the bash command, its detailed
synopsis, a short description, existing versions of the command as well as authors of the bash command.

man ls
This command is used to display the documentation on the 'ls' command in
Linux.

By TechNow Tamil
2. pwd
The pwd command in Linux translates to "Print Working Directory" and is used to
display the path of the current working directory inside the terminal.

Syntax:
pwd --(Options)
The pwd command has two tags:
-L: It displays the symbolic version of the existing path.
-P: It displays the actual existing path, without symbolic links.

By TechNow Tamil
3. cd
The cd command in Linux expands to 'change directory' which gives a fair hint as to what the command
does. Yes, it is used to change the current working directory to a specified folder inside the terminal.

Syntax:
cd [Options] [Directory]
Example:
cd /var/log – Change Directory to /var/log

cd .. – Change Working Directory (/var/log) to previous folder (/var)

By TechNow Tamil
4. ls
The ls command in Linux is used to display a directory's files and folders.
This command is super useful if you want to explore the contents of a given directory inside the terminal
without navigating to the GUI folder.

Syntax:
ls [Options]
Example:
ls – Simply list contents available in current working directory

Commands You can try,


ls -l
ls -lrth
By TechNow Tamil
5. touch
The touch command in Linux is used to create new files without any content inside it.
This command is super useful if you want to explore the contents of a given directory inside the terminal
without navigating to the GUI folder.

Syntax:
touch (file name)
Example:
touch test1.txt – Simply creates empty file on present directory

Commands You can try,


touch tes1.txt test2.txt – Creates two files in present directory.
touch test{1..10}.txt – Creates test1.txt, test2.txt, test3.txt like that upto 10 files at a same time.
By TechNow Tamil
6. cat
The cat command in Linux is used to read the contents of one or more files and display
their contents inside the terminal.

Syntax:
cat (Options) (file name)
Example:
cat file1.txt – Read contents of file1.txt

Commands You can try,


cat file1.txt file2.txt – Read two file contents at a time.
cat –n file1.txt file2.txt – Read two file contents with line number at a time.

By TechNow Tamil
7. mkdir
The mkdir command in Linux is used to create new directories inside an existing working directory from the
terminal.

Syntax:
mkdir (Options) (directory name)
Example:
mkdir folder1 – Creates folder in present working directory

Commands You can try,


mkdir –p folder1/subfolder/folder/ – -p will create ‘subfolder’ & ‘folder’ if those folder not available
inside folder1 .

By TechNow Tamil
8. cp
The cp command in Linux translates to 'copy'. It is used to copy files/directories from one location to
another from inside the terminal.

Syntax:
cat (Options) (Source) (Destination)
Example:
cp file1.txt folder1/ – Copy file1.txt to the directory folder1.

Commands You can try,


cp –r folder1 folder2 – -r used to copy directories.
cp -i file1.txt folder1/ – If file exists on destination this will ask for overwrite the file.

By TechNow Tamil
9. mv
The mv command in Linux translates to 'move'. It performs two major functions in Linux.
• You can rename a file/directory using this command.
• You can easily move a file/directory from one location to another.
Syntax:
mv (Source) (Destination)
Example:
For Moving a file (or) folder:
mv file1.txt folder1/ – Moving file1.xt to the directory folder1. Same procedure for move a directory.

For Renaming a file (or) folder:


mv folder1 folder2 – This will rename folder1 into folder2 in same directory.

By TechNow Tamil
10. rm
The rm command in Linux helps you delete files and directories.

Syntax:
rm [Options] [file name]
Example:
rm file1.txt – Delete file1.txt from the present directory.

More ‘rm’ commands to try:


rm -r (directory) – Delete directory.
rm -r file1.txt file2.txt – Delete multiple files at a time.
rm -r *.txt – Delete files with extension .txt

By TechNow Tamil
11. vi (or) vim
The vi command in Linux allows a user to edit any text content inside the
Vim text editor from the terminal.
Syntax:
vi (Options) (file name)
Example: vi file1.txt – Read contents of file1.txt
Here's a list of commonly used keyboard shortcuts used
inside the Vim editor in Linux:
i - Used to enter insert mode in Vim editor.
dd - Delete a line quickly. (Use the Esc key to exit out of insert mode)
yy - Copy a line/lines inside the editor.
p/P - Paste command
u - Undo command
Ctrl+r - Redo command
:wq - Save and quit Vim editor.
:q - Quit Vim editor without saving a file.
By TechNow Tamil
12. grep
The grep command in Linux searches through a specified file and prints all lines that match a given
pattern.

Syntax:
grep (Options) (SearchingPattern) (Directory name)
Example:
grep Hello file1.txt – Find Hello word inside the file1.txt file.

Commands You can try,


grep -i hello file1.txt – Find “Hello” word without case sensitive inside the file1.txt file.
ls –lrt |grep file – Combine with ‘ls’ and finds the file names starts with “file”

By TechNow Tamil
13. head
The head command in Linux prints the first N lines of a given file content. Yes, it's that simple.

Syntax:
head (Options) (File name)
Example:
head -n 2 file1.txt – Prints first 2 lines of the file.

By TechNow Tamil
14. tail
The tail command in Linux prints the last N lines of a given file content. Yes, it's that simple.

Syntax:
tail (Options) (File name)
Example:
tail -n 2 file1.txt – Prints Last 2 lines of the file.

By TechNow Tamil
15. history
The history command in Linux is used to view a history of all the commands previously executed inside the
bash terminal. The total number of executed commands will vary from one system to another.

Syntax:
history
Example:
history

Commands You can try,


history |grep ls – find out how many ls commands executed previously.
By TechNow Tamil
THKANKS
Please Do Practice Every commands
Subscribe TechNow Tamil channel for more videos.

You might also like