Linux Command Line - part 2
Table of contents
Exploring the Filesystem.
Tree
The tree command is a good way to get a bird’s-eye view of the filesystem tree.
Use tree -d to view just the directories.
tree #listing all the file system including files and directories in the tree view.
tree -d #list all the directories alone in tree view.
Hard Links
syntax is
ln (original file path) (new file path)
.The link is between the filename and the actual data stored on the filesystem. Creating an hard link to a file means :
First, you create a new filename pointing to the exact same data as the old filename. This means that the two filenames, though different, point to identical data.
For example, if I create file
/home/sohail/file1
and write hello world in the file, I have a single hard link between the file namefile1
and the file content hello world.# Suppose that file1 already exists. # A hard link, called file2, is created with the command: $ ln file1 file2
Note that two files now appear to exist. However, a closer inspection of the file listing shows that this is not quite true.
if i create another hardlink we can see that both are having the “same inode no” and the integer count in the output increased from (1 to 2).
$ ls -li file1 file2
Hard links are very useful and they save space, but you have to be careful with their use, sometimes in subtle ways.
For one thing, if you remove either file1 or file2 in the example, the inode object (and the remaining file name) will remain, which might be undesirable, as it may lead to subtle errors later if you recreate a file of that name.
Soft (Symbolic) Link
Soft (or Symbolic) links are created with the -s option, as in:
$ ln -s file1 file3 $ ls -li file1 file3
here, Notice file3 no longer appears to be a regular file, and it clearly points to file1 and has a different inode number.
Symbolic links take no extra space on the filesystem (unless their names are very long). They are extremely convenient, as they can easily be modified to point to different places.
"HAPPY LEARNING - HAPPY SCRIPTING"
More Commands in next blog till then Cyaaaaaa, Have a good day :)
Quote Of The Day~~
"Do something today that your future self will thank you for."
Subscribe to my newsletter
Read articles from Smd Sohail directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Smd Sohail
Smd Sohail
Hello there, I am a Cloud intern | Ex- SDE Odoo Developer | a passionated techie from India, i like to work with machines by training and testing them. In my free time, I often blog to share my experiences as well as read more blog posts to learn and enrich my knowledge. #Developer📔#Tech enthusiast💡 #Machine learning🤖 #blogger #writer