0

This is a very specific request, I am afraid. I am a non-root user at a CentOS Linux 7 machine. The admin team is normally very helpful but there is zero response for that case, unfortunately.

So I have no root power here and I would like to block/restrict some commands for myself: links, links2, lynx. Don't ask me why, please, treat this a weird challenge, perhaps?

Is there any way to achieve that being a non-root user?

3
  • 3
    Probably not in a way you couldn't also undo yourself.
    – ilkkachu
    CommentedMay 3, 2022 at 20:05
  • Yes! Kind of a "trick" I did was overriding built-in command by alias. But, unfortunately, in process of searching for a solution I also learnt that '\command' over-override the alias I put in the .bashrc. I am not power-user by any means, running my own small desktop with Mint and using CentOS machine for basic but time-consuming calculations. I won't be able to "undo" restrictions anyway (probably).
    – P. Dobro
    CommentedMay 3, 2022 at 20:21
  • If your aim is, as I suspect, not to spend too much time browsing the Web, the best way you can accomplish this is through self-discipline.
    – dr_
    CommentedMay 4, 2022 at 13:24

1 Answer 1

3

You can create a directory in your home, create some files with the names of programs you want to restrict and prepend it to your $PATH. For example:

$ mkdir ~/bin 

Create ~/bin/links with the following contents:

#!/usr/bin/env sh echo you are not allowed to use links 

and make it executable. Prepend ~/bin to $PATH:

PATH=$HOME/bin:$PATH 

Now when you call links:

$ links you are not allowed to use links 

It won't be possible to bypass it with \ as it would be if alias was used:

$ \links you are not allowed to use links 

Note that links is still there in the $PATH:

$ type -a links links is /home/ja/bin/links links is /usr/bin/links 

And that nothing can stop you or other processes from calling the real links binary using an absolute path /usr/bin/links.

    You must log in to answer this question.

    Start asking to get answers

    Find the answer to your question by asking.

    Ask question

    Explore related questions

    See similar questions with these tags.