How to use password with special character in mount command linux ?

I faced a problem while using mount command with a password containing special characters. The error that I got was “permission denied”. On analyzing the root cause, I figured out that because of the special character, the authentication failed.

The syntax of the mount command is given below.

> mount -t cifs -o username= ,password=[password] [windows-share-dir-path] [dir-in-linux]

Here my password was something like below. It has so many special characters.

> i2_Gw$wF?Xs4zq??K

Solution

The solution is simple. Create a text file and enter the credentials into that file.

I have created a file with the name credentials.ini

username=[username]
password=[password]

Now save this file and use this credentials file in the mount command. The syntax is given below.

mount -t cifs -o credentials=credentials.ini [windows-share-dir-path] [dir-in-linux]

 

Now execute this command and your problem will be solved. !!!!

How to verify/validate the entries in fstab without a system reboot ?

/etc/fstab contains information about the disks. It has the details about where the partitions and storage devices should be mounted. We usually configure automount, disk quota, mount points etc in this fstab.

Inorder to test the entries or modifications in fstab without restart the following commands will be helpful

mount -a

The above command will mount all the filesystems mentioned in the fstab. This is just like a refresh command to activate the entries in fstab.

mount -fav

The above command will help if you don’t want to apply the modifications in the fstab and want to validate the entries only.  This will just fake the entries in the fstab without applying the changes. This is a very useful command.