0

On my machine there are user accounts. My question is how to restrict access to ones user files. Meaning no one else can access my files at all. How can I setup this restriction?

How many root users are possible for one Linux machine?

Edit: I'm one of the user of my system with name TOM(actually my system has two users TOM and JERRY),
I installed all the packages as root using

yum install <package name>

Restriction: No one else access my package and file which are containing in TOM user

1
  • I edited your question to make it IMHO more readable. Please roll it back if that changed the intention of your questions.
    – Anthon
    Dec 5 '13 at 9:20
-1

You can't use yum command with regular user like TOM, Yum command just can be used by root power and if you have install a package with yum, every user can use it. But if you have tar package you can change installation directory like following: ( If that package generated with GNU auto tools)

./configure --prefix=/home/myusername/bin
make; make install

and put /home/myusername/bin in your PATH variable. With this solution that package just run with myusername username!

But if your file is a binary or txt file you just can set proper permission and if we look more precise and you want to write a program which works just with specific UID and USERNAME you can simply check UID variable because it's readonly and you can trust it. see below script and put it in a check.sh file: ( I wrote SHELLSCRIPT because here is Unix & Linux forum )

#!/bin/bash

COUNTER=0
FLAG=0
declare -r MYUID=500
declare -r USNAME=Sepahrad

for i in `cut -d: -f3 /etc/passwd`
do
    COUNTER=$(( COUNTER + 1 ))
    [ $i -eq $MYUID ] && TMP=$(head -n`echo $COUNTER` /etc/passwd | tail -n1 | cut -d: -f1) && [ "$TMP" == "$USER" ] && [ $MYUID -eq $UID ] &&  FLAG=1
done

if [ $FLAG -eq 1 ]
then

    echo "Hello $USNAME ($UID)"
elif [ $FLAG -eq 0 ]
then
    echo "You don't have permission to see thi file $USER ($UID)"; exit 1
fi

This script just runs for the user which has UID=500 and Sepahrad username. (You can change it by an editor) but if you don't want any user see your source even root you can compile it with shc command like: shc -v -r -T check.sh

0
4

The typical way to restrict access to your files is to have the permissions on your home directory chmod 700 (in case the group owner of the homedirectory is shared with others), or chmod 770 in case you have your 'own' group that no one else is a member of.

root users (which uid 0) can always access those files.

There can be only one user with name root, but there can be multiple names associated with uid 0, so you could multiple users with root privileges.

If others have root access to the machine your home-directory is on, you should not keep sensitive information on there unless in encrypted form (but the encryption should be done on a different system).

3
  • my machine two users there(tom and jerry).All files are installed in tom user.New user is Jerry,when jerry is login into machine,he also using my installed files(all files is installed by using root).How set privileges to root(already have root password) Dec 5 '13 at 9:34
  • @user3021349 Can you update your question with that info? And also with Linux type and commands used to install packages? Which packages specifically? Root installed packages are normally meant for access by all users, or by root only. You probably have to install as 'tom' (from source) to prevent access by 'jerry'
    – Anthon
    Dec 5 '13 at 9:47
  • I updated my question see once @Anthon Dec 5 '13 at 10:01
2

'access' as used by you can be explained in more detail as read/write/delete etc. Sticky bit will help you with delete for others you can follow what @Anthon said. root is superuser, so yes don't keep 'sensitive' data unless....

Have you tried setting up sticky bit on your dir? I am assuming you're using linux.

e.g. http://www.thegeekstuff.com/2013/02/sticky-bit/ The example here is self explanatory for your case.

[ https://serverfault.com/questions/10353/what-is-the-sticky-bit-in-unix-file-systems-when-is-it-used ]

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.