Learn about the ability to use general utilities to create a loopback filesystem.
- [Instructor] Hi and welcome to the third section of this course, file in, file out. Unix treats every object in the operating system as a file. We can find files associated with every action performed and can make use of them for different system or process-related manipulations. For example, the command terminal that we use is associated with a device file. We can write to the terminal by writing to the corresponding device file for that specific terminal. Files take different forms such as directories, regular files, block devices, special character devices, symbolic links, sockets, named pipes, and so on.
Filename, size, file type, modification time, access time, change time, inode, links associated and the final system that the file is on are all attributes and properties that files can have. This section will teach you how to handle operations of properties related to files. Now we will see the first video of section 3, generating files of any size. In this video, we'll see how to create a look back file system to by using general utilities. For various reasons, you may need to generate a file filled with random data.
It may be for creating a test file to perform tests such as an application efficiency test that uses large files as input, or to test the splitting of files into many parts or to create loop back file systems. Loop back files are files that contain a file system itself, and these files can be mounted similarly to a physical device using the mount command. It takes effort to create such files by writing specific programs, so we use general utilities. The easiest way to create a large size file with the given size is to use the dd command.
The dd command clones the given input and writes an exact copy to the output. Input can be standard in, a device file, a regular file, or so on. Output can be standard out, a device file, a regular file, or so on. An example of the dd command is as follows. The preceding command will create a file called junk.data which is exactly 1 megabyte in size. Let's go through the parameters. if stands for the input file. Of stands for the out output file.
Bs stands for bytes for a block, and count stands for the number of blocks of bs specified to be copied. Be careful while using the dd command. It operates on a very low level with the devices. If you make a mistake, you might end up wiping your disk or corrupting data otherwise. So always double-check your dd command syntax, especially your of equals parameter for correctness. In the previous example, we are only creating a file which is 1 megabyte in size by specifying bs as 1 MB with a total of 1.
If bs was set to 2M, and count to 2, then the total file size would be 4 megabyte. We can use various units for block size, bs, as follows. Append any of the following characters to the number to specify the size in bytes. Byte, 1B, c. Word, 2B, w. Block, 512B, b. Kilobyte, 1024B, k. Megabyte, 1024KB, M.
Gigabyte, 1024MB, G. We can generate a file of any size using this. Instead of MB, we can use any other unit notations, such as the ones mentioned in the previous table. /dev/zero is a character special device which infinitely returns 0 byte / zero. If the input parameter, if, is not specified, it will read the input from std in by default. Similarly, if the output parameter, of, is not specified, it will use standard out as the default output sync.
The dd command can also be used to measure the speed of memory operations by transferring a large quantity of data and checking the command output. For example, 1038476 bytes, 1 megabyte, copied 0.00702656 seconds, 149 megabits per second as seen in the previous example. Great, we successfully learned about generating files of any size. In the next video, we'll learn about the intersection and set difference, A-B, on text files.
Released
7/17/2017Note: This course was created by Packt Publishing. We are pleased to host this training in our library.
- Printing in the terminal
- Performing math in the Linux shell
- Getting and setting dates
- Working with functions and arguments
- Reading output
- Making comparisons
- Concatenating text
- Finding, editing, generating, and deleting files
- Running parallel processes
- Using regular expressions
- Downloading webpages
- Parsing data from a website
- Finding broken links
- Backing up and archiving
- Transferring files and data through the network
- Monitoring your Linux system
- Gathering data for system administration
Skill Level Intermediate
Duration
Views
Related Courses
-
Learning Bash Scripting (2013)
with Scott Simpson1h 25m Beginner -
Linux: Bash Shell and Scripts
with Kevin Dankwardt2h 46m Intermediate
-
1. Shell Something Out
-
Printing in the terminal6m 4s
-
Math with the shell3m 5s
-
Visiting aliases2m 25s
-
Debugging the script2m 46s
-
Functions and arguments4m 31s
-
Comparisons and tests6m 22s
-
-
2. Have a Good Command
-
Concatenating with cat5m 30s
-
Finding files and file listing18m 46s
-
Playing with xargs11m 41s
-
Translating with tr6m 51s
-
Checksum and verification4m 46s
-
Splitting files and data4m 53s
-
Automating interactive input4m 10s
-
-
3. File In, File Out
-
Generating files of any size4m 24s
-
Making files immutable2m 13s
-
Using loopback files6m 15s
-
Printing the directory tree3m 18s
-
-
4. Texting and Driving
-
Using regular expressions9m 25s
-
-
5. Tangled Web? Not at All
-
Downloading from a web page5m 15s
-
A primer on cURL7m 11s
-
Image crawler and downloader3m 36s
-
Web photo album generator1m 54s
-
-
6. The Backup Plan
-
Archiving with tar10m 33s
-
Archiving with cpio2m 31s
-
Compressing data with gzip5m 27s
-
Faster archiving with pbzip23m 15s
-
Backup snapshots with rsync6m 55s
-
-
7. The Old-Boy Network
-
Let us ping4m 53s
-
Creating arbitrary sockets2m 45s
-
-
8. Put on the Monitor's Cap
-
Logging with syslogd2m 44s
-
Monitoring disk activity1m 41s
-
9. Administration Calls
-
Gathering system information1m 57s
-
Scheduling with cron7m 7s
-
User administration script5m 16s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.
CancelTake notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.
Share this video
Embed this video
Video: Generating files of any size