Migrate to Linux: disks, files, and file systems

Source: Internet
Author: User

Migrate to Linux: disks, files, and file systems

Installing and using Linux on your main desktop will help you quickly familiarize yourself with the tools and methods you need.

This is the second article in our migration to Linux series. If you miss the first article, you can find it here. As mentioned earlier, there are several reasons for migrating data to Linux. You can develop and use code for Linux in your work, or you may just want to try new things.

For whatever reason, having a Linux on your main desktop computer will help you quickly get familiar with the tools and methods you need. In this article, I will introduce Linux Files, file systems, and disks.

 

Where is my C?

If you are a Mac user, Linux should be very familiar to you. Mac files, file systems, and disks are very similar to Linux. On the other hand, if your experience is Windows, access to disks in Linux may seem a bit confusing. Generally, Windows assigns a drive letter (such as C: \) to each disk :\). Linux is not like this. In your Linux system, it is a single hierarchical structure of files and directories.

Let's look at an example. Assume that your computer uses a master hard diskBooksAndVideosThe CD-ROM of the directory, andTransferDirectory U disk, in your WIndows, you should see the following:

  1. C: \ [Hard Disk]
  2. ├System
  3. ├System32
  4. ├ProgramFiles
  5. ├ProgramFiles(x86)
  6. Other <more directories>
  7. D:\ [CD-ROM]
  8. ├Books
  9. └Videos
  10. E: \ [U disk]
  11. └Transfer

A typical Linux system is like this:

  1. /(The top-level directory, called the root directory) [Hard Disk]
  2. ├ bin
  3. ├ etc
  4. ├ lib
  5. ├ sbin
  6. ├ usr
  7. Other <more directories>
  8. └ media
  9. Login <your username>
  10. ├ cdrom [CD-ROM]
  11. │├Books
  12. │└Videos
  13. └ Kingme_USB [U disk]
  14. └Transfer

If you use a graphical environment, typically, file manager in Linux will appear like a drive icon for CD-ROM and a USB portable drive, so you don't have to know where the media is located.

 

File System

Linux calls these things a file system. The file system maintains a group of structures that track all files and directories on the media (such as hard disks. If there is no file system for storing data, all our information will be messy and we do not know which file the block belongs. You may have heard of names such as ext4, XFS, and Btrfs, all of which are Linux file systems.

Each media that stores files and directories has a file system on it. Different media types may use specific file systems optimized for it. For example, the CD-ROM uses the ISO9660 or UDF file system type. USB portable drivers generally use FAT32 so that they can be easily shared with other computer systems.

Windows also uses the file system. However, we will not discuss it too much. For example, when you insert a CD-ROM, Windows will read the ISO9660 file system structure, assign a drive letter to it, and then display the file and directory under the drive letter (for example, D. Of course, if you go into the details, technically, Windows assigns a drive letter to a file system, not the entire drive.

In the same example, Linux also reads the structure of the file system ISO9660, but it does not assign a drive letter. It attaches the file system to a directory (this process is called mount ). Linux will then be in the mounted directory (for example,/media/<your user name>/cdrom) To display files and directories on the CD-ROM.

Therefore, on Linux, I will answer "Where is my C ?" The answer to this question is that there is no C: \ here, and they work differently.

 

File

Windows stores files and directories (also known as folders) in its file system. However, Linux also allows you to put other things in the file system. These other types of things are the native objects of the file system, and they are actually different from common files. In addition to common files and directories, Linux also allows you to create and use hard links, symbolic links, named pipes named pipe, device node, and socket. Here, we will not discuss the types of all file system objects, but there are several frequently used types.

A hard link is used to create one or more aliases for a file. The name of each alias pointing to the same content on the disk is different. If you edit a file under a file name, this change also appears on other file names. For example, you haveMyResume_2017.docIt also hasJaneDoeResume.doc. (Note: The hard link is from the command line, usingln). You can find and editMyResume_2017.doc, And then findJaneDoeResume.docAnd you find that it keeps a trail-it contains all your updates.

Symbolic Links are a bit like shortcuts in Windows. The file system portal contains a path to other files or directories. In many ways, they work in a similar way as hard links. They can create aliases for other files. However, a symbolic link can also create an alias for a directory like a file, and the symbolic link can point to different file systems on different media, but hard links cannot do this. (Note: You can use-sOptionallnCommand to create a symbolic link)

 

Permission

Another major difference between Windows and Linux is that it involves the permissions of File System Objects (files, directories, and others. Windows implements a complex set of permissions on files and directories. For example, users and user groups can have the permission to read, write, run, modify, and so on. Users and user groups can be authorized to access all contents in directories except for exceptions, or not all contents in directories except exceptions.

However, most users who use Windows do not have specific permissions. Therefore, they are surprised when they find that a set of default permissions is enforced on Linux! Linux uses SELinux or AppArmor to enforce a more complex set of permissions. However, most Linux installation versions only use the built-in default permissions.

In the default permission, each entry in the file system has a set of permissions set for its file owner, the group where the file is located, and others. These permissions allow them to read, write, and run. The permissions granted to them are inherited in layers. First, it checks whether this (LOGIN) user is the owner of the file and has permissions. If not, check whether the user has permissions in the group where the file is located and the group where the file is located. If not, it then checks the permissions of others. The permissions of others are set here. However, the three sets of permissions are used in most cases.

If you use the command line, enterls -lYou can see the following permissions:

  1. rwxrw-r--1 stan dndgrp 25Oct33rd25:01 rolldice.sh

The first letter,rwxrw-r--, Showing permissions. In this example, the owner (stan) can read, write, and run this file (the first three letters,rwx); Members of the dndgrp group can read and write this file, but cannot run (three letters in the second group,rw-); Others can only read this file (the last three letters,r--).

(Note: To generate a runable script in Windows, your generated file must have a specific extension, such.batIn Linux, the extension does not make any sense in the operating system. Instead, you need to set the executable permissions for this file)

If you receive a "permission denied" error, you may have tried to test run a program or command that requires administrator permissions, or try to access a file that your account does not have access permissions. If you try to do something that requires administrator permissions, you must switch toroot. Or you can usesudo. It allows yourootPermission to run. Of course,sudoYou are required to enter the password to ensure that you have permissions.

 

Hard Disk File System

Windows uses a hard drive file system called NTFS. On Linux, you can also select a hard disk file system that you want to use. Different file system types present different features and different performance features. Currently, the mainstream native Linux File System is Ext4. However, when installing Linux, you also have a wide range of file system types to choose from, such as Ext3 (the predecessor of Ext4), XFS, Btrfs, and UBIFS (for Embedded Systems) and so on. If you are not sure which one to use, Ext4 is a good choice.

Via: https://www.linux.com/blog/learn/intro-to-linux/2017/11/migrating-linux-disks-files-and-filesystems

Author: john bonesio Translator: qhwdw Proofreader: wxy

This article was originally compiled by LCTT and launched with the honor of Linux in China

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.