This article discuss about Redirection, Search and Linux File Creation From Scratch
I discussed about lsof and ps(process status) commands in the last blog post. I strongly recommend you to read earlier blogs for better understanding . If you find something missing, Please provide feedback in comment box so that I can take corrective action.
I will be using redirection wherever it requires.
Redirection
- > Redirect output
- >> Redirect and append
- < Redirect input
- << Redirect input and append
- | Pipe
- tee Redirect to two objects . You may think it as Tee used in plumbing
Q: Standard Output i.e. stdout(FD=1) is Monitor screen , What can be Standard Input i.e. stdin(FD=0) ? …You know that
Search
As we observed that the root filesystem itself has a number of utilities and libraries for supporting linux based applications. The next requirement is to understand the search options. The most frequently used commands are :
- locate to find files or directories
- locate test6
- find to search file is more powerful if you are aware of options
- find -type f -name test6 //Did you face any problem ? Try the command given below
- find -type f -name test6 2>/dev/null
- Did you notice the errors going to /dev/null ? Like black hole
- grep to search pattern in each file or standard input
- Even if you use grep , You can’t avoid error messages without redirecting stderr to /dev/null
- find -type f -name test6 | grep “day”
- Please refer to man or help for any specific requirement with these commands
How can I create a Filesystem from scratch ?
Since Kernel takes care of resource management and the software architecture has flexibility to pick necessary utilities for Filesystem, There should be a method to design the entire filesystem from scratch. Following is the method to achieve the same :
- One can use dd(Data Definition) and mke2fs to create an etx2 file system
sanjay@sanjay-VirtualBox:~/linux_day5$ dd if=/dev/zero of=myfile1.img bs=1024 count=102400 102400+0 records in 102400+0 records out 104857600 bytes (105 MB, 100 MiB) copied, 0.248331 s, 422 MB/s sanjay@sanjay-VirtualBox:~/linux_day5$ mke2fs myfile1.img - sudo mount myfile1.img tmp/ -o loop
If we create partition table in the file image above, It will become virtual hard disk image. Loop device is a pseudo device which makes a filesystem appear as a block device. After mounting the filesystem, we can copy the required files inside this.
As I discussed earlier /dev directory nodes provide device access to user space application . However there is another directory /sys which provides device configuration and status specific information. /proc provides information related to kernel running status.
References
This particular article is discussed at Linux File System Creation
Thanks for reading till end. I am trying to improve usability of my site. Did you find this discussion helpful ? If so, Please subscribe to YouTube channel Embedkari as well for additional embedded related stuff.