How To Mount A Windows NTFS Disk In Linux The New Technology File System (NTFS) is a proprietary file system created by Microsoft and is used extensively in Microsoft’s Windows operating systems.By default, a lot of Linux distributions will not be able to mount NTFS, though it is possible to install a driver which allows us to do this so that we are able to read and write data to an NTFS disk.In the example below, we will attach the VMDK file from a Windows-based virtual machine to a CentOS 7 Linux virtual machine.Once we run ‘fdisk –I’, we can see that the disk is recognized (after a system reboot), but it is not yet mounted for us to access the data. We should be able to see the primary disk for the Linux system /dev/sda, while /dev/sdb is our 1GB NTFS disk, which has the /dev/sdb1 NTFS partition. [[email protected] ~]# fdisk -l Disk /dev/sda: 21.5 GB, 21474836480 bytes, 41943040 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x0004c930 Device Boot Start End Blocks Id System /dev/sda1 * 2048 616447 307200 83 Linux /dev/sda2 616448 4810751 2097152 82 Linux swap / Solaris /dev/sda3 4810752 41943039 18566144 83 Linux Disk /dev/sdb: 1073 MB, 1073741824 bytes, 2097152 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0xfc757b2a Device Boot Start End Blocks Id System /dev/sdb1 128 2091135 1045504 7 HPFS/NTFS/exFAT By default, once we attempt to mount the NTFS disk, we will receive the error below: [[email protected] ~]# mkdir /windows [[email protected] ~]# mount /dev/sdb1 /windows/ mount: unknown filesystem type 'ntfs' Install Required Packages If you want to perform the mount, you have to install the NTFS-3G package, which is a Linux NTFS userspace driver. This package will arrive from EPEL if you are using CentOS/RHEL, so if you have not yet configured your system to use the EPEL repository, run the command below: [[email protected] ~]# yum install epel-release -y Now we will be able to install the ntfs-3g package from the EPEL repository. [[email protected] ~]# yum install ntfs-3g -y Otherwise, if you are using Ubuntu/Debian, you will be able to simply run ‘apt-get install ntfs-3g’ straight away. In our Debian 8 installation, it was already available, so we were able to mount NTFS without any issues. Mount The NTFS Disk We can now successfully perform the mount without any errors. [[email protected] ~]# mount /dev/sdb1 /windows/ [[email protected] ~]# blkid /dev/sdb1 /dev/sdb1: LABEL="NTFS" UUID="CA4A1FD94A1FC0DD" TYPE="ntfs" We can confirm that the NTFS disk is seen as mounted by the operating system. [[email protected] ~]# df -h /windows/ Filesystem Size Used Avail Use% Mounted on /dev/sdb1 1021M 11M 1011M 2% /windows At this point, you will be able to read and write data to the mounted NTFS disk. Automatically Mount NTFS We may now create an entry in the /etc/fstab file, so that our NTFS disk will automatically mount on system boot. Below, you’ll see an example of the entry that I have placed in my fstab file. This will mount the disk to the /ntfs directory. /dev/sdb1 /windows ntfs-3g defaults 0 0 After this configuration has been added, the NTFS disk should mount automatically on system boot. Before performing a reboot, it is recommended that you first run the ‘mount –a’ command and confirm that the disk mounts without any issues. If any issues occur during boot, you will be left with a system that does not properly boot, so it’s important to test first. Summary We have seen that it is possible to easily mount an NTFS disk in CentOS 7 Linux once the ntfs-3g package, which provides us with the necessary drivers, has been installed.
How to Change Permissions and Owners via Command Line Introduction In this tutorial, we will teach you how to change file or folder permissions and owners using a command line on Linux or Unix systems. There are two simple commands that can be used to accomplish this task; they are Chmod and Chown. Change Permissions and Owners via Command Line For this guide you will require the following:– Access to the command line Step 1 — Changing file and folder permissions via command line Chmod is a command that is used to change the permissions of a file or a folder.Simply put, each file has three types of users who can interact with it: Owner – The user who made and owns the file or directory. Group – Each user who is also a member of the group. Others – Every other user on the system who are neither a member or an owner of the group. The command ‘ls -1’ can be used to view file permissions and owners of a file or folder. For example, ‘1s and -1 file1.txt’ will display: -rwxr–rw- 1 user user 0 Jan 19 12:59 file1.txt ‘-rwxr–rw-‘ - This is the part of the line which shows permissions. There are 4 main letters which you will usually see in this part of the line: r,w,x,d. The letter ‘d’ means that the type of the file is a directory.1 – This is the number of hard links. A hard link is just an extra name for a file which already exists.User user – This helps you view who the owner and group owner of the file is.0 – This shows how big the file is.Jan 19 12:59 – This is the date of the last edit.File1.txt – This shows the name of the file or folder.Let’s return to the command ‘Chmod’. This command grants us the ability to change the permissions of a file or folder. We will show you how to do this by simply appending numbers. Each permission type will have its own number: r(read) – 4 w(write) – 2 x(execute) – 1 For example, if we would like to set the permissions of ‘file1.txt’ to those: -rwxr–rw- 1 user user 0 Jan 19 12:59 file1.txt We would have to type the command: chmod 746 file1.txt User Permissions Every number in the command represents a permission for one of the user types, such as the owner, group owner, or others.‘chmod 777 file2.txt’ is a different example, this command will grant every permission for every type of user (owner, group, or other).This is a list of the most common permissions for files: -rw——- 600 Owner can read and write. -rw-r–r– 644 Owner can read and write, the group and others can read. -rw-rw-rw- 666 Owner, group and others can read and write. -rwx—— 700 Owner can read, write and execute, group and others cannot do anything with the file. -rwx–x–x 711 Owner can read, write and execute, the group and others can execute. -rwxr-xr-x 755 Owner can read, write and execute, the group and others can read and execute. rwxrwxrwx 777 Owner, group and others can read, write and execute. The usual permissions for directories: drwx—— 700 Only owner can read and write in this directory. drwxr-xr-x 755 Owner, group and others can read the directory, but only owner can change its contents. There are plenty of ways to change permissions of a file using the chmod command. However, our suggestion is to learn one of them and use it each time; in this situation, the numbering way. Step 2 — Changing file and folder owners via command line Chown is a command that is used to change the owners of a file or a folder. The most basic syntax of the Chown command is this: chown [owner/group owner] [file name] Usually, if we have a file called ‘demo.txt’ and would like to set the owner and group owner of the file to ‘Jerry’ and ‘clients’ respectively, we would use the command below: chown jerry:clients demo.txt As you can see, the owner and group owner are separated using a colon symbol ‘:’. If the goal was to change the owner of the file only, then we would use the command below: chown jerry demo.txt In the command above, we left out the group owner, instead only typing in the new owner of the file; in this way, the group owner will stay unchanged.If we wanted to change the group owner of the file but not the owner, then we would use the command below: chown :clients demo.txt In this case, only the group owner has been changed to ‘clients’, leaving the owner unchanged. Step 3 — Using additional options with chmod and chown commands There’s one way which should work with both commands, it is ‘–R’ in which the R stands for recursive.This option allows you to replace the permissions or owners in the given directory and all other files and folders within that directory. Different options for “chmod” and “chown”: “-f” – Silent, stealthy, and simple. Force is not going to show most error messages. “-v” – Will provide you with a diagnostic of every file which has been affected by the command. “-c” – This is similar to ‘-v’. However, it will only provide information in a case where changes were actually made. Conclusion Using the skills we have taught you in this guide, you will be able to manage your Server or VPS in a more simple manner by changing permissions and owners of files and folders with a command line.