safe way to add aliases for another user?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












At work I have a personal account, but I'm doing development on a program which is run by a machine account. By "machine account" I just mean that it isn't tied to a person - it doesn't have any special sysadmin role, but it runs our batch jobs. This account has been around for a while and might do a lot of different things.



During development I'm doing most of my work in this account, so I wanted to setup some aliases, for example "alias e=emacs -nw".



But I'm worried if I edit the .profile-user to add these, I could mess something up. What if e is also the name of some other command it uses which I would be overriding?



So, how can I do this safely? I could just try out the aliases I want one-by-one and verify that they show "command not found" so that there wouldn't be a conflict. But I guess that doesn't account for conflicts in cases where the string might become a command under certain circumstances (e.g. the machine account has a program that cd's to a certain directory and then runs a file which happens to be the same name as my alias).



Just curious if anybody has thought about this before and knows a good way around it, or if you think I really shouldn't introduce aliases on this account.







share|improve this question




















  • Check the return status of the type command for the aliases in question i.e. "type e" This will tell you whether you can set them up or not.
    – Raman Sailopal
    Dec 6 '17 at 15:16










  • If your scripts aren't explicitely loading ~/.bashrc or set BASH_ENV, you should be fine to add aliases.
    – Richard Neumann
    Dec 6 '17 at 15:18











  • Question based on the other question Richard linked to: How does bash decide if the shell is "interactive"? Couldn't my machine account be running in interactive mode, like for example if a job server logs in under the machine account to run the jobs?
    – Stephen
    Dec 6 '17 at 15:23







  • 2




    Either create a new user for yourself, or put your own aliases & functions in a separate file and load them from there when starting a shell. Really, if you run interactive shells on a system, you do want to have personal configuration files for the shells. (not just aliases but prompts and shell settings too.)
    – ilkkachu
    Dec 6 '17 at 16:17










  • What I was thinking is if there's a way to say "if the user which sudo'd to this user = myrealusername, alias xyz." That way it would be guaranteed to only be invoked if it's me running this particular user.
    – Stephen
    Dec 7 '17 at 15:50














up vote
0
down vote

favorite












At work I have a personal account, but I'm doing development on a program which is run by a machine account. By "machine account" I just mean that it isn't tied to a person - it doesn't have any special sysadmin role, but it runs our batch jobs. This account has been around for a while and might do a lot of different things.



During development I'm doing most of my work in this account, so I wanted to setup some aliases, for example "alias e=emacs -nw".



But I'm worried if I edit the .profile-user to add these, I could mess something up. What if e is also the name of some other command it uses which I would be overriding?



So, how can I do this safely? I could just try out the aliases I want one-by-one and verify that they show "command not found" so that there wouldn't be a conflict. But I guess that doesn't account for conflicts in cases where the string might become a command under certain circumstances (e.g. the machine account has a program that cd's to a certain directory and then runs a file which happens to be the same name as my alias).



Just curious if anybody has thought about this before and knows a good way around it, or if you think I really shouldn't introduce aliases on this account.







share|improve this question




















  • Check the return status of the type command for the aliases in question i.e. "type e" This will tell you whether you can set them up or not.
    – Raman Sailopal
    Dec 6 '17 at 15:16










  • If your scripts aren't explicitely loading ~/.bashrc or set BASH_ENV, you should be fine to add aliases.
    – Richard Neumann
    Dec 6 '17 at 15:18











  • Question based on the other question Richard linked to: How does bash decide if the shell is "interactive"? Couldn't my machine account be running in interactive mode, like for example if a job server logs in under the machine account to run the jobs?
    – Stephen
    Dec 6 '17 at 15:23







  • 2




    Either create a new user for yourself, or put your own aliases & functions in a separate file and load them from there when starting a shell. Really, if you run interactive shells on a system, you do want to have personal configuration files for the shells. (not just aliases but prompts and shell settings too.)
    – ilkkachu
    Dec 6 '17 at 16:17










  • What I was thinking is if there's a way to say "if the user which sudo'd to this user = myrealusername, alias xyz." That way it would be guaranteed to only be invoked if it's me running this particular user.
    – Stephen
    Dec 7 '17 at 15:50












up vote
0
down vote

favorite









up vote
0
down vote

favorite











At work I have a personal account, but I'm doing development on a program which is run by a machine account. By "machine account" I just mean that it isn't tied to a person - it doesn't have any special sysadmin role, but it runs our batch jobs. This account has been around for a while and might do a lot of different things.



During development I'm doing most of my work in this account, so I wanted to setup some aliases, for example "alias e=emacs -nw".



But I'm worried if I edit the .profile-user to add these, I could mess something up. What if e is also the name of some other command it uses which I would be overriding?



So, how can I do this safely? I could just try out the aliases I want one-by-one and verify that they show "command not found" so that there wouldn't be a conflict. But I guess that doesn't account for conflicts in cases where the string might become a command under certain circumstances (e.g. the machine account has a program that cd's to a certain directory and then runs a file which happens to be the same name as my alias).



Just curious if anybody has thought about this before and knows a good way around it, or if you think I really shouldn't introduce aliases on this account.







share|improve this question












At work I have a personal account, but I'm doing development on a program which is run by a machine account. By "machine account" I just mean that it isn't tied to a person - it doesn't have any special sysadmin role, but it runs our batch jobs. This account has been around for a while and might do a lot of different things.



During development I'm doing most of my work in this account, so I wanted to setup some aliases, for example "alias e=emacs -nw".



But I'm worried if I edit the .profile-user to add these, I could mess something up. What if e is also the name of some other command it uses which I would be overriding?



So, how can I do this safely? I could just try out the aliases I want one-by-one and verify that they show "command not found" so that there wouldn't be a conflict. But I guess that doesn't account for conflicts in cases where the string might become a command under certain circumstances (e.g. the machine account has a program that cd's to a certain directory and then runs a file which happens to be the same name as my alias).



Just curious if anybody has thought about this before and knows a good way around it, or if you think I really shouldn't introduce aliases on this account.









share|improve this question











share|improve this question




share|improve this question










asked Dec 6 '17 at 15:05









Stephen

1245




1245











  • Check the return status of the type command for the aliases in question i.e. "type e" This will tell you whether you can set them up or not.
    – Raman Sailopal
    Dec 6 '17 at 15:16










  • If your scripts aren't explicitely loading ~/.bashrc or set BASH_ENV, you should be fine to add aliases.
    – Richard Neumann
    Dec 6 '17 at 15:18











  • Question based on the other question Richard linked to: How does bash decide if the shell is "interactive"? Couldn't my machine account be running in interactive mode, like for example if a job server logs in under the machine account to run the jobs?
    – Stephen
    Dec 6 '17 at 15:23







  • 2




    Either create a new user for yourself, or put your own aliases & functions in a separate file and load them from there when starting a shell. Really, if you run interactive shells on a system, you do want to have personal configuration files for the shells. (not just aliases but prompts and shell settings too.)
    – ilkkachu
    Dec 6 '17 at 16:17










  • What I was thinking is if there's a way to say "if the user which sudo'd to this user = myrealusername, alias xyz." That way it would be guaranteed to only be invoked if it's me running this particular user.
    – Stephen
    Dec 7 '17 at 15:50
















  • Check the return status of the type command for the aliases in question i.e. "type e" This will tell you whether you can set them up or not.
    – Raman Sailopal
    Dec 6 '17 at 15:16










  • If your scripts aren't explicitely loading ~/.bashrc or set BASH_ENV, you should be fine to add aliases.
    – Richard Neumann
    Dec 6 '17 at 15:18











  • Question based on the other question Richard linked to: How does bash decide if the shell is "interactive"? Couldn't my machine account be running in interactive mode, like for example if a job server logs in under the machine account to run the jobs?
    – Stephen
    Dec 6 '17 at 15:23







  • 2




    Either create a new user for yourself, or put your own aliases & functions in a separate file and load them from there when starting a shell. Really, if you run interactive shells on a system, you do want to have personal configuration files for the shells. (not just aliases but prompts and shell settings too.)
    – ilkkachu
    Dec 6 '17 at 16:17










  • What I was thinking is if there's a way to say "if the user which sudo'd to this user = myrealusername, alias xyz." That way it would be guaranteed to only be invoked if it's me running this particular user.
    – Stephen
    Dec 7 '17 at 15:50















Check the return status of the type command for the aliases in question i.e. "type e" This will tell you whether you can set them up or not.
– Raman Sailopal
Dec 6 '17 at 15:16




Check the return status of the type command for the aliases in question i.e. "type e" This will tell you whether you can set them up or not.
– Raman Sailopal
Dec 6 '17 at 15:16












If your scripts aren't explicitely loading ~/.bashrc or set BASH_ENV, you should be fine to add aliases.
– Richard Neumann
Dec 6 '17 at 15:18





If your scripts aren't explicitely loading ~/.bashrc or set BASH_ENV, you should be fine to add aliases.
– Richard Neumann
Dec 6 '17 at 15:18













Question based on the other question Richard linked to: How does bash decide if the shell is "interactive"? Couldn't my machine account be running in interactive mode, like for example if a job server logs in under the machine account to run the jobs?
– Stephen
Dec 6 '17 at 15:23





Question based on the other question Richard linked to: How does bash decide if the shell is "interactive"? Couldn't my machine account be running in interactive mode, like for example if a job server logs in under the machine account to run the jobs?
– Stephen
Dec 6 '17 at 15:23





2




2




Either create a new user for yourself, or put your own aliases & functions in a separate file and load them from there when starting a shell. Really, if you run interactive shells on a system, you do want to have personal configuration files for the shells. (not just aliases but prompts and shell settings too.)
– ilkkachu
Dec 6 '17 at 16:17




Either create a new user for yourself, or put your own aliases & functions in a separate file and load them from there when starting a shell. Really, if you run interactive shells on a system, you do want to have personal configuration files for the shells. (not just aliases but prompts and shell settings too.)
– ilkkachu
Dec 6 '17 at 16:17












What I was thinking is if there's a way to say "if the user which sudo'd to this user = myrealusername, alias xyz." That way it would be guaranteed to only be invoked if it's me running this particular user.
– Stephen
Dec 7 '17 at 15:50




What I was thinking is if there's a way to say "if the user which sudo'd to this user = myrealusername, alias xyz." That way it would be guaranteed to only be invoked if it's me running this particular user.
– Stephen
Dec 7 '17 at 15:50










1 Answer
1






active

oldest

votes

















up vote
0
down vote













I'm assuming that the "machine account" is not typically used interactively but that it's an account that runs various services.



Adding aliases to the account's .profile should then be safe as this file is only read by login shells.



Aliases are furthermore not inherited by child processes, so if you log in to the account and start a script or program from the command line, then the alias in the .profile file will not be defined for that script or program, unless it explicitly sources the .profile file directly or indirectly (which it should not do).






share|improve this answer




















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f409234%2fsafe-way-to-add-aliases-for-another-user%23new-answer', 'question_page');

    );

    Post as a guest






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote













    I'm assuming that the "machine account" is not typically used interactively but that it's an account that runs various services.



    Adding aliases to the account's .profile should then be safe as this file is only read by login shells.



    Aliases are furthermore not inherited by child processes, so if you log in to the account and start a script or program from the command line, then the alias in the .profile file will not be defined for that script or program, unless it explicitly sources the .profile file directly or indirectly (which it should not do).






    share|improve this answer
























      up vote
      0
      down vote













      I'm assuming that the "machine account" is not typically used interactively but that it's an account that runs various services.



      Adding aliases to the account's .profile should then be safe as this file is only read by login shells.



      Aliases are furthermore not inherited by child processes, so if you log in to the account and start a script or program from the command line, then the alias in the .profile file will not be defined for that script or program, unless it explicitly sources the .profile file directly or indirectly (which it should not do).






      share|improve this answer






















        up vote
        0
        down vote










        up vote
        0
        down vote









        I'm assuming that the "machine account" is not typically used interactively but that it's an account that runs various services.



        Adding aliases to the account's .profile should then be safe as this file is only read by login shells.



        Aliases are furthermore not inherited by child processes, so if you log in to the account and start a script or program from the command line, then the alias in the .profile file will not be defined for that script or program, unless it explicitly sources the .profile file directly or indirectly (which it should not do).






        share|improve this answer












        I'm assuming that the "machine account" is not typically used interactively but that it's an account that runs various services.



        Adding aliases to the account's .profile should then be safe as this file is only read by login shells.



        Aliases are furthermore not inherited by child processes, so if you log in to the account and start a script or program from the command line, then the alias in the .profile file will not be defined for that script or program, unless it explicitly sources the .profile file directly or indirectly (which it should not do).







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 10 at 14:25









        Kusalananda

        104k14206324




        104k14206324



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f409234%2fsafe-way-to-add-aliases-for-another-user%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            Displaying single band from multi-band raster using QGIS

            How many registers does an x86_64 CPU actually have?