Table of contents
No headings in the article.
We can create File in Linux in different ways:
Touch Command: The Touch command is the easiest way to create new empty files.
Ex- # touch filename i.e #touch f (f is a filename) - It will create an empty file in pwd (present working directory)
- Create a file in a specific folder
# touch /home/f1 - under root folder.
# touch f1 f2 f3 f4 - Create multiple files.
Cat or Concatenate Command: It is used to create multiple text files together.
Ex- #cat >file1 Press enter
type text here
Ctrl+D to save.
#cat file1 - To see the content of the file.
#cat file1 fil2 > file3 - All file file1 and file text move to file3.
Vi/Vim: It is a programmer text editor used to edit all kinds of plain text and also we can create files with vi command.
Ex- #vi file1 - Press enter
Press i to insert the text
Type here .....
Press Esc then: colon
:wq
Note - Keywords used in vi editor
:wq or :x - To save and quit
:w - To save
:q - Quit
:q! - Force quit no save.
Nano Command:
#nano file1
type here...
Ctrl+X then Press y.
*tac command - it shows file content in reverse. i.e last line of text will display first.
#tac file
* stat command - stat is a Linux command line utility that displays detailed information about a file or a file system like access, modify, change date etc.
#stat file
* List Files and dir
#ls
#ls -la - List all
*Linux File System Hierarchy:
/home - Home dir of other users
/root - Home dir for root users
/boot - Contains bootable files for Linux. ex- initd
/etc - Contains all configuration files
/usr - By default software are install in this dir
/bin - Contains command used by all users
/sbin - Contains command used by root users
/opt - Optional application software package
/dev - Essential device file include terminal devices, usb or any devices attached to the system