SlideShare a Scribd company logo
1 of 20
Linux Commands
(Linux commands for file creation)
How to create a file in Linux?
There is no specific command used for such purposes.
Use any command: command >Filename or >Filename
Following commands are commonly used to create a file in
Linux terminal:
• cat
• touch
• vi or vim (Note: To create a file, we can use any text editor name and then filename.)
• nano
• echo or printf
cat command:
cat
create file
overwrite
concatenate
copy
output
(view) of file
File creation with cat command:
cat >file1
------------
----text---
------------
Ctrl + D to save and exit.
Note:
“>” is used to redirect output.
Overwrite a file with cat command:
cat >file1
-------------------------------------
----------------text----------------
-------- to be overwritten------
--------------------------------------
Ctrl + D to save and exit.
Note: “>” is used to redirect output.
cat file1 >file2 used to overwrite data of file1 into file2.
Concatenate text into a file with cat command:
cat >>file1
--------------------------------
-------------text--------------
---to be concatenated----
--------------------------------
Ctrl + D to save and exit.
Note:
“>>” is used to concatenate redirected output with existing file.
Copy text of two files into a new file with cat
command: (Merging)
cat file1 file2 >file3
Copy text of a file into a new file with cat
command:
cat file3 >file4
Note: It’ll create file4 with the content of file3.
To view output text of one or more files with
cat command:
To view output of a single file:
cat file1
To view output of multiple files:
cat file1 file2 file3 file4
tac command:
tac command is also used to view file or set of files but tac command
produces opposite result as compare to cat command. It is used to see
the content from bottom to top.
To view output text of one or more files with
tac command:
To view output of a single file: tac file1
To view output of multiple files: tac file1 file2 file3 file4
touch command:
touch
Create a single
or multiple
empty files
change all
timestamps
of a file
change
access time
of a file
change
modify time
of a file
Create a single or multiple empty files with
touch command:
• To create a single empty file:
touch file1
• To create multiple empty files:
touch file1 file2 file3 file4
3 Types of Time Stamp:
• Access time (last time when a file was accessed).
touch -a
E.g. touch -a file1
• Modify time (last time when a file was modified).
touch -m
E.g. touch -m file1
• Change time (last time when file’s metadata was changed) is
automatically updated when a single time stamp is modified.
stat command:
stat command is used to check information of a file including time
stamps.
Syntax:
stat Filename
E.g. stat file1
vi editor:
vi editor stands for “Visual Instrument”. It is a full screen text editor. It
is already installed in every Unix or Linux system.
An improved version of vi editor is vim but most Linux systems have vi
editor installed.
Syntax to create a file with vi editor: vi Filename
Syntax to create a file with vim editor: vim Filename
Modes of operation:
Two modes of operation in vi are entry mode and command mode.
Command mode is used to type commands that perform
specific vi functions. Command mode is the default mode for vi.
Entry or Insert mode is used to type text into a file.
Type “i” for insert mode and press “Esc” key to return to
command mode.
vi editing commands:
• i - Insert at cursor (goes into insert mode).
• :w - To save.
• :wq - To save and quit.
• :q - Quit.
• :q! - Quit forcefully.
nano editor:
nano file1
--------------------------
--------------------------
----------Text-----------
--------------------------
Ctrl + X to exit.
After it press Y to save.
Concatenate text into a file with nano editor:
nano file1
--------------------------
--------------------------
----------Text-----------
--------------------------
--------New text------
--------------------------
Ctrl + O to concatenate.
Ctrl + X to exit.
After it press Y to save
echo command:
echo “---------text---------” >file1
printf command:
printf “---------text---------” >file1
printf “---------text---------n” >file1
Create a hidden file:
To create a hidden file you have to place a dot ( . ) before file name.
Examples:
>.file1
touch .file2

More Related Content

What's hot

Unix(introduction)
Unix(introduction)Unix(introduction)
Unix(introduction)meashi
 
Linux Commands - Cheat Sheet
Linux Commands - Cheat Sheet Linux Commands - Cheat Sheet
Linux Commands - Cheat Sheet Isham Rashik
 
101 3.2 process text streams using filters
101 3.2 process text streams using filters101 3.2 process text streams using filters
101 3.2 process text streams using filtersAcácio Oliveira
 
Rakesh Kaushik
Rakesh KaushikRakesh Kaushik
Rakesh Kaushikitplant
 
Quick Guide with Linux Command Line
Quick Guide with Linux Command LineQuick Guide with Linux Command Line
Quick Guide with Linux Command LineAnuchit Chalothorn
 
Useful Linux and Unix commands handbook
Useful Linux and Unix commands handbookUseful Linux and Unix commands handbook
Useful Linux and Unix commands handbookWave Digitech
 
linux-commandline-magic-Joomla-World-Conference-2014
linux-commandline-magic-Joomla-World-Conference-2014linux-commandline-magic-Joomla-World-Conference-2014
linux-commandline-magic-Joomla-World-Conference-2014Peter Martin
 
50 most frequently used unix linux commands (with examples)
50 most frequently used unix   linux commands (with examples)50 most frequently used unix   linux commands (with examples)
50 most frequently used unix linux commands (with examples)Rodrigo Maia
 
Command line for the beginner - Using the command line in developing for the...
Command line for the beginner -  Using the command line in developing for the...Command line for the beginner -  Using the command line in developing for the...
Command line for the beginner - Using the command line in developing for the...Jim Birch
 
Linux powerpoint
Linux powerpointLinux powerpoint
Linux powerpointbijanshr
 
Linuxppt
LinuxpptLinuxppt
LinuxpptReka
 
101 3.4 use streams, pipes and redirects
101 3.4 use streams, pipes and redirects101 3.4 use streams, pipes and redirects
101 3.4 use streams, pipes and redirectsAcácio Oliveira
 
Linux Command Line Basics
Linux Command Line BasicsLinux Command Line Basics
Linux Command Line BasicsWe Ihaveapc
 
Linux Basic commands and VI Editor
Linux Basic commands and VI EditorLinux Basic commands and VI Editor
Linux Basic commands and VI Editorshanmuga rajan
 
101 3.5 create, monitor and kill processes
101 3.5 create, monitor and kill processes101 3.5 create, monitor and kill processes
101 3.5 create, monitor and kill processesAcácio Oliveira
 

What's hot (20)

Unix(introduction)
Unix(introduction)Unix(introduction)
Unix(introduction)
 
Linux Commands - Cheat Sheet
Linux Commands - Cheat Sheet Linux Commands - Cheat Sheet
Linux Commands - Cheat Sheet
 
Basic Linux day 2
Basic Linux day 2Basic Linux day 2
Basic Linux day 2
 
101 3.2 process text streams using filters
101 3.2 process text streams using filters101 3.2 process text streams using filters
101 3.2 process text streams using filters
 
Rakesh Kaushik
Rakesh KaushikRakesh Kaushik
Rakesh Kaushik
 
Quick Guide with Linux Command Line
Quick Guide with Linux Command LineQuick Guide with Linux Command Line
Quick Guide with Linux Command Line
 
Unix slideshare
Unix slideshareUnix slideshare
Unix slideshare
 
Useful Linux and Unix commands handbook
Useful Linux and Unix commands handbookUseful Linux and Unix commands handbook
Useful Linux and Unix commands handbook
 
linux-commandline-magic-Joomla-World-Conference-2014
linux-commandline-magic-Joomla-World-Conference-2014linux-commandline-magic-Joomla-World-Conference-2014
linux-commandline-magic-Joomla-World-Conference-2014
 
50 most frequently used unix linux commands (with examples)
50 most frequently used unix   linux commands (with examples)50 most frequently used unix   linux commands (with examples)
50 most frequently used unix linux commands (with examples)
 
Command line for the beginner - Using the command line in developing for the...
Command line for the beginner -  Using the command line in developing for the...Command line for the beginner -  Using the command line in developing for the...
Command line for the beginner - Using the command line in developing for the...
 
Linux powerpoint
Linux powerpointLinux powerpoint
Linux powerpoint
 
Linuxppt
LinuxpptLinuxppt
Linuxppt
 
Linuxppt
LinuxpptLinuxppt
Linuxppt
 
101 3.4 use streams, pipes and redirects
101 3.4 use streams, pipes and redirects101 3.4 use streams, pipes and redirects
101 3.4 use streams, pipes and redirects
 
Linux Command Line Basics
Linux Command Line BasicsLinux Command Line Basics
Linux Command Line Basics
 
Linux Basic commands and VI Editor
Linux Basic commands and VI EditorLinux Basic commands and VI Editor
Linux Basic commands and VI Editor
 
Piping into-php
Piping into-phpPiping into-php
Piping into-php
 
Know the UNIX Commands
Know the UNIX CommandsKnow the UNIX Commands
Know the UNIX Commands
 
101 3.5 create, monitor and kill processes
101 3.5 create, monitor and kill processes101 3.5 create, monitor and kill processes
101 3.5 create, monitor and kill processes
 

Similar to Linux or Unix commands (commands for file creation)

Similar to Linux or Unix commands (commands for file creation) (20)

Unix_QT.ppsx
Unix_QT.ppsxUnix_QT.ppsx
Unix_QT.ppsx
 
Unix_QT.ppsx
Unix_QT.ppsxUnix_QT.ppsx
Unix_QT.ppsx
 
Linux Command.pptx
Linux Command.pptxLinux Command.pptx
Linux Command.pptx
 
Unix Shell Script - 2 Days Session.pptx
Unix Shell Script - 2 Days Session.pptxUnix Shell Script - 2 Days Session.pptx
Unix Shell Script - 2 Days Session.pptx
 
Lesson 3 Working with Files in Linux
Lesson 3 Working with Files in LinuxLesson 3 Working with Files in Linux
Lesson 3 Working with Files in Linux
 
Batch programming and Viruses
Batch programming and VirusesBatch programming and Viruses
Batch programming and Viruses
 
Linux file commands and shell scripts
Linux file commands and shell scriptsLinux file commands and shell scripts
Linux file commands and shell scripts
 
Linux
LinuxLinux
Linux
 
Introduction to Unix
Introduction to UnixIntroduction to Unix
Introduction to Unix
 
5_File_Handling_Commands__vi_editor_and_environment_variables
5_File_Handling_Commands__vi_editor_and_environment_variables5_File_Handling_Commands__vi_editor_and_environment_variables
5_File_Handling_Commands__vi_editor_and_environment_variables
 
LinuxCommands (1).pdf
LinuxCommands (1).pdfLinuxCommands (1).pdf
LinuxCommands (1).pdf
 
Batch file programming
Batch file programmingBatch file programming
Batch file programming
 
Foss manual (1)
Foss manual (1)Foss manual (1)
Foss manual (1)
 
Linux basic commands
Linux basic commandsLinux basic commands
Linux basic commands
 
Linux
LinuxLinux
Linux
 
Nithi
NithiNithi
Nithi
 
Linuxppt
LinuxpptLinuxppt
Linuxppt
 
Linuxs1
Linuxs1Linuxs1
Linuxs1
 
Group13
Group13Group13
Group13
 
cisco
ciscocisco
cisco
 

Recently uploaded

Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docxPoojaSen20
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterMateoGardella
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxnegromaestrong
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Shubhangi Sonawane
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin ClassesCeline George
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.MateoGardella
 

Recently uploaded (20)

Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 

Linux or Unix commands (commands for file creation)

  • 1. Linux Commands (Linux commands for file creation)
  • 2. How to create a file in Linux? There is no specific command used for such purposes. Use any command: command >Filename or >Filename Following commands are commonly used to create a file in Linux terminal: • cat • touch • vi or vim (Note: To create a file, we can use any text editor name and then filename.) • nano • echo or printf
  • 4. File creation with cat command: cat >file1 ------------ ----text--- ------------ Ctrl + D to save and exit. Note: “>” is used to redirect output.
  • 5. Overwrite a file with cat command: cat >file1 ------------------------------------- ----------------text---------------- -------- to be overwritten------ -------------------------------------- Ctrl + D to save and exit. Note: “>” is used to redirect output. cat file1 >file2 used to overwrite data of file1 into file2.
  • 6. Concatenate text into a file with cat command: cat >>file1 -------------------------------- -------------text-------------- ---to be concatenated---- -------------------------------- Ctrl + D to save and exit. Note: “>>” is used to concatenate redirected output with existing file.
  • 7. Copy text of two files into a new file with cat command: (Merging) cat file1 file2 >file3 Copy text of a file into a new file with cat command: cat file3 >file4 Note: It’ll create file4 with the content of file3.
  • 8. To view output text of one or more files with cat command: To view output of a single file: cat file1 To view output of multiple files: cat file1 file2 file3 file4
  • 9. tac command: tac command is also used to view file or set of files but tac command produces opposite result as compare to cat command. It is used to see the content from bottom to top. To view output text of one or more files with tac command: To view output of a single file: tac file1 To view output of multiple files: tac file1 file2 file3 file4
  • 10. touch command: touch Create a single or multiple empty files change all timestamps of a file change access time of a file change modify time of a file
  • 11. Create a single or multiple empty files with touch command: • To create a single empty file: touch file1 • To create multiple empty files: touch file1 file2 file3 file4
  • 12. 3 Types of Time Stamp: • Access time (last time when a file was accessed). touch -a E.g. touch -a file1 • Modify time (last time when a file was modified). touch -m E.g. touch -m file1 • Change time (last time when file’s metadata was changed) is automatically updated when a single time stamp is modified.
  • 13. stat command: stat command is used to check information of a file including time stamps. Syntax: stat Filename E.g. stat file1
  • 14. vi editor: vi editor stands for “Visual Instrument”. It is a full screen text editor. It is already installed in every Unix or Linux system. An improved version of vi editor is vim but most Linux systems have vi editor installed. Syntax to create a file with vi editor: vi Filename Syntax to create a file with vim editor: vim Filename
  • 15. Modes of operation: Two modes of operation in vi are entry mode and command mode. Command mode is used to type commands that perform specific vi functions. Command mode is the default mode for vi. Entry or Insert mode is used to type text into a file. Type “i” for insert mode and press “Esc” key to return to command mode.
  • 16. vi editing commands: • i - Insert at cursor (goes into insert mode). • :w - To save. • :wq - To save and quit. • :q - Quit. • :q! - Quit forcefully.
  • 18. Concatenate text into a file with nano editor: nano file1 -------------------------- -------------------------- ----------Text----------- -------------------------- --------New text------ -------------------------- Ctrl + O to concatenate. Ctrl + X to exit. After it press Y to save
  • 19. echo command: echo “---------text---------” >file1 printf command: printf “---------text---------” >file1 printf “---------text---------n” >file1
  • 20. Create a hidden file: To create a hidden file you have to place a dot ( . ) before file name. Examples: >.file1 touch .file2