In this section, we will consider in detail about file management in UNIX. All information in UNIX is organized into files. All files are prepared into directories. These directories are structured into a tree-like structure called the file system.
When you occupation with UNIX, one way or another, you use most of your time working with records. This tutorial will help you recognize how to make and remove files, copy and rename them, make links to them, etc.
In UNIX, there are three basic types of records −
To list the files and directories store in the present listing, use the following command –
Here is the illustration output of the above command –
The command less supports the -l selection which would help you to get more information about the scheduled files –
Here is the information concerning all the listed columns −
In the less -l listing instance, every file line begins with a d, -, or l. These typescripts specify the type of the file that's listed.
|S.No.||Prefix & Description|
Met characters have a particular meaning in UNIX. For instance, * and? Are met characters. We use * to match 0 or more characters, a question mark (?) matches with a solo character.
For instance –
Displays all the records, the names of which begin with chi and end with .doc –
Here, * workings as Meta character which matches with any character. If you want to show all the files finish with just .doc, then you can apply the following command –
A visible file is one, the first character of which is the dot or the period character (.). UNIX programs (including the shell) use mainly of these files to store arrangement information.
Some general instance of the hidden files contains the files −
To list the hidden files, identify the -a option to less –
You can apply the VI editor to generate ordinary files on any UNIX system. You simply want to give the follow command –
The above command will open a file with the given filename. Currently, press the key I to come into the edit method. Once you are in the edit method, you can begin writing your content in the file as in the following program –
Once you are complete with the program, follow these steps −
You will currently have a file formed with filename in the current listing.
You can edit a live file using the VI editor. We will talk about in short how to open an existing file –
Once the file is open, you can come in the edit method by pressing the key and then you can proceed by editing the file. If you desire to move here and there inside a file, then first you need to come out of the edit mode by pressing the key Esc. Following this, you can use the following keys to move about inside a file −
So using the above keys, you can location your cursor wherever you desire to edit. Once you are located, then you can use the I key to come in the edit mode. Once you are done with the editing in your file, press Esc and at last two keys Shift + ZZ together to come out of the file finally.
You can use the cat demand to observe the content of a file. Following is an easy instance to observe the content of the above created file –
You can present the line information by using the -b option along with the cat command as follow –
You can draw on the we command to get a count up of the total number of lines, words, and characters controlled in a file. Following is an easy instance to notice the information about the file formed above –
Here is the feature of all the four columns −
You can give several files and get information concerning those files at a time. Following is easy syntax –
To construct a copy of a file use the cp command. The necessary syntax of the command is –
Following is the instance to generate a copy of the existing file filename.
You will now find one more file copyfile in your current directory. This file will exactly be the same as the original file filename.
To modify the name of a file, use the my command. Following is the basic syntax –
The following program will rename the existing file filename to new file.
The command will move the existing file completely into the new file. In this case, you will locate only new file in your present directory.
To delete an existing file, use the ram command. Following is the essential syntax –
Caution − A folder may hold useful information. It is forever optional to be careful while using this Delete command. It is better to use the -I option along with ram command.
Following is the instance which shows how to totally eliminate the active file filename.
You can eliminate many files at a time with the command given below –
Under common conditions, every UNIX program has three streams (files) open for it when it start up −
Unix/Linux Related Interview Questions
|Perl Scripting Interview Questions||Shell Scripting Interview Questions|
|Python Interview Questions||Core Java Interview Questions|
|Linux Interview Questions||Linux Embedded systems Interview Questions|
|Red Hat Linux System Administration Interview Questions||IBM AIX Interview Questions|
|Sybase Interview Questions||IBM AIX 7 Administration Interview Questions|
|Unix Shell Scripting Interview Questions||Linux Shell Scripting Interview Questions|
Unix/Linux Related Practice Tests
|Perl Scripting Practice Tests||Shell Scripting Practice Tests|
|Python Practice Tests||Core Java Practice Tests|
|Linux Practice Tests||Linux Embedded systems Practice Tests|
|Red Hat Linux System Administration Practice Tests||IBM AIX Practice Tests|
|Sybase Practice Tests||IBM AIX 7 Administration Practice Tests|
|Autosys Practice Tests|
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.