Iguana wrote:I was wondering how would I password protect a folder that has spaces in the folder's name?
If there is a way please do tell..
You need to escape the spaces. Generally, you do that with a backslash (i.e. \)
So - in Unix - a name with an escaped space would look like this:
- Code: Select all
My\ Documents
NOTE: You can always use the TAB key to auto-complete names with spaces. So - as an example, if you had a folder on your desktop called "My Documents", you could start by typing:
- Code: Select all
cd ~/Desktop/My
then hit the TAB key. The bash shell will autocomplete the command:
- Code: Select all
cd ~/Desktop/My\ Documents
Iguana wrote:One more thing, how do I access a rooted protected folder, without changing back the permissions?
Well - normally you'd use the terminal window with the
su command. But - I don't think that's exactly what you're asking. I think the question you're asking is: "From the GUI, logged in as a normal user, how do I open a folder that's been assigned to root user?"
Well - the only real way is to log off as the normal user, and re-login as root. This obviously isn't what you really want to do.
See - the deal is that Unix doesn't really have the concept of a password protected folder. Instead, unix has the concept of access permissions for folders.
What you would normally do is create a separate user account for everyone on your system. Then, use the access permissions to customize access to folders based on that login. You can do this with the
chmod command.
Here's an example.
Let's say you have a user "fred". You want to allow folks to see into fred's home directory and into a sub-folder named f_public, but not into a folder called f_private. In addition, you want full write permissions for f_public
So - as root - here's the content of my /home directory:
- Code: Select all
[root@localhost home]# ls -al
total 16
drwxr-xr-x 4 root root 4096 Jun 28 22:27 .
drwxr-xr-x 26 root root 4096 Jun 28 22:07 ..
drwx------ 3 fred fred 4096 Jun 28 22:27 fred
drwx------ 110 paulp paulp 4096 Jun 28 22:16 paulp
[root@localhost home]#
So - to allow others to see fred's directory, use
chmod a+rwx This allows all to look in the directory:
- Code: Select all
[root@localhost home]# chmod a+rwx fred
[root@localhost home]# ls -al
total 16
drwxr-xr-x 4 root root 4096 Jun 28 22:27 .
drwxr-xr-x 26 root root 4096 Jun 28 22:07 ..
drwxrwxrwx 5 fred fred 4096 Jun 28 22:35 fred
drwx------ 110 paulp paulp 4096 Jun 28 22:16 paulp
[root@localhost home]#
NOTE: We don't want to do this for every folder in /home/fred, so we leave out the -R
Now, let's create the f_private and f_public folders. We'll use the su command from root to temporarily become fred:
- Code: Select all
[root@localhost home]# su fred
[fred@localhost home]$ cd fred
[fred@localhost ~]$ mkdir f_public
[fred@localhost ~]$ mkdir f_private
[fred@localhost ~]$ ls -al
total 36
drwxr--r-- 5 fred fred 4096 Jun 28 22:32 .
drwxr-xr-x 4 root root 4096 Jun 28 22:27 ..
-rw------- 1 fred fred 8 Jun 28 22:31 .bash_history
-rw-r--r-- 1 fred fred 33 Jun 28 22:27 .bash_logout
-rw-r--r-- 1 fred fred 176 Jun 28 22:27 .bash_profile
-rw-r--r-- 1 fred fred 124 Jun 28 22:27 .bashrc
drwxrwxr-x 2 fred fred 4096 Jun 28 22:32 f_private
drwxrwxr-x 2 fred fred 4096 Jun 28 22:32 f_public
drwxr-xr-x 4 fred fred 4096 Jun 28 22:27 .mozilla
[fred@localhost ~]$
Note that f_private and f_public have full access rights for user, group, and read/execute access for other. So - let's remove read, write & execute permissions from f_private for group & others and add write permissions for others to f_public:
- Code: Select all
[fred@localhost ~]$ chmod -R go-rwx f_private
[fred@localhost ~]$ chmod -R o+w f_public/
[fred@localhost ~]$ ls -al
total 36
drwxrwxrwx 5 fred fred 4096 Jun 28 22:46 .
drwxr-xr-x 4 root root 4096 Jun 28 22:27 ..
-rw------- 1 fred fred 189 Jun 28 22:36 .bash_history
-rw-r--r-- 1 fred fred 33 Jun 28 22:27 .bash_logout
-rw-r--r-- 1 fred fred 176 Jun 28 22:27 .bash_profile
-rw-r--r-- 1 fred fred 124 Jun 28 22:27 .bashrc
drwx------ 2 fred fred 4096 Jun 28 22:35 f_private
drwxrwxrwx 2 fred fred 4096 Jun 28 22:46 f_public
drwxr-xr-x 4 fred fred 4096 Jun 28 22:27 .mozilla
[fred@localhost ~]$
Now - only fred has access to f_private, but everyone has full access f_public.
Let's test this. I'll open a new terminal window as myself:
- Code: Select all
paulp@localhost ~]$ cd /home/fred
[paulp@localhost fred]$ ls
f_private f_public
[paulp@localhost fred]$ cd f_public
[paulp@localhost f_public]$ ls
[paulp@localhost f_public]$ cd ..
[paulp@localhost fred]$ ls
f_private f_public
[paulp@localhost fred]$ cd f_private
bash: cd: f_private: Permission denied
[paulp@localhost fred]$
No passwords required. Fred can access both folders - and I - paulp - can only access /home/fred & /home/fred/f_public. This works for the terminal window and for the GUI as well.
If you need more control, you would use the group parameter and set up groups that have shared access.
Cheers,
Paul
P.S. Root user is special. You normally don't use root for day to day computing. Instead, you use that account for system administrative functions. So - assigning a folder to root on your normal login desktop is not the standard way to protect your folder.