Get back to default login shell after running /bin/bash

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











up vote
1
down vote

favorite
3












When logging in the prompt is different than it is after executing /bin/bash



-bash-4.2$ exec bash
bash-4.2$


How do I get the - back in front of the bash. There are certain commands like tcp dump that only work in the orignal



-bash-4.2$ tcpdump -i port1 -w /home/user/$HOSTNAME-port1.pcap -c10000 -G300
tcpdump: WARNING: port1: no IPv4 address assigned
tcpdump: listening on port1, link-type EN10MB (Ethernet), capture size 65535 bytes
0 packets captured
0 packets received by filter
0 packets dropped by kernel
-bash-4.2$ exec bash
bash-4.2$ tcpdump -i port1 -w /home/user/$HOSTNAME-port1.pcap -c10000 -G300
tcpdump: port1: You don't have permission to capture on that device
(socket: Operation not permitted)


Update for @ctrl-alt-delor



-bash-4.2$ groups
nuage
-bash-4.2$ exec bash
bash-4.2$ groups
nuage


update for @Mikel



bash-4.2$ exec bash -l
bash-4.2$


Update for @Mark Plotnick



-bash-4.2$ type tcpdump
tcpdump is aliased to 'sudo /usr/sbin/tcpdump'
-bash-4.2$ exec bash
bash-4.2$ type tcpdump
tcpdump is /usr/sbin/tcpdump
[root@host nuage]# cat /etc/sudoers | grep nuage
[root@host nuage]# exit
bash-4.2$ group
bash-4.2$ groups
nuage
bash-4.2$ whoami
nuage






share|improve this question





















  • Can you run groups before and after. Put the result in the question.
    – ctrl-alt-delor
    Jul 11 at 16:09







  • 1




    The - just means it's a login shell. Try exec bash -l. I wonder if this is somehow related to SELinux or some other role-based access control system. But why are you doing exec bash in the first place?
    – Mikel
    Jul 11 at 16:10










  • @Mikel Updated in original, this was the simplest form of the problem, the reason I need to find out how to run things as the original shell is because I must run a script and #!/bin/bash has different permissions than what was used to create the definition for the script.
    – Xander May
    Jul 11 at 17:21











  • Can you show us the output of type tcpdump before and after?
    – Mark Plotnick
    Jul 11 at 17:37






  • 1




    Try exec -a -bash bash ; I think that ought to set things up so that your shell init files are read in by the new bash and thus you'll see all your aliases.
    – Mark Plotnick
    Jul 11 at 17:56














up vote
1
down vote

favorite
3












When logging in the prompt is different than it is after executing /bin/bash



-bash-4.2$ exec bash
bash-4.2$


How do I get the - back in front of the bash. There are certain commands like tcp dump that only work in the orignal



-bash-4.2$ tcpdump -i port1 -w /home/user/$HOSTNAME-port1.pcap -c10000 -G300
tcpdump: WARNING: port1: no IPv4 address assigned
tcpdump: listening on port1, link-type EN10MB (Ethernet), capture size 65535 bytes
0 packets captured
0 packets received by filter
0 packets dropped by kernel
-bash-4.2$ exec bash
bash-4.2$ tcpdump -i port1 -w /home/user/$HOSTNAME-port1.pcap -c10000 -G300
tcpdump: port1: You don't have permission to capture on that device
(socket: Operation not permitted)


Update for @ctrl-alt-delor



-bash-4.2$ groups
nuage
-bash-4.2$ exec bash
bash-4.2$ groups
nuage


update for @Mikel



bash-4.2$ exec bash -l
bash-4.2$


Update for @Mark Plotnick



-bash-4.2$ type tcpdump
tcpdump is aliased to 'sudo /usr/sbin/tcpdump'
-bash-4.2$ exec bash
bash-4.2$ type tcpdump
tcpdump is /usr/sbin/tcpdump
[root@host nuage]# cat /etc/sudoers | grep nuage
[root@host nuage]# exit
bash-4.2$ group
bash-4.2$ groups
nuage
bash-4.2$ whoami
nuage






share|improve this question





















  • Can you run groups before and after. Put the result in the question.
    – ctrl-alt-delor
    Jul 11 at 16:09







  • 1




    The - just means it's a login shell. Try exec bash -l. I wonder if this is somehow related to SELinux or some other role-based access control system. But why are you doing exec bash in the first place?
    – Mikel
    Jul 11 at 16:10










  • @Mikel Updated in original, this was the simplest form of the problem, the reason I need to find out how to run things as the original shell is because I must run a script and #!/bin/bash has different permissions than what was used to create the definition for the script.
    – Xander May
    Jul 11 at 17:21











  • Can you show us the output of type tcpdump before and after?
    – Mark Plotnick
    Jul 11 at 17:37






  • 1




    Try exec -a -bash bash ; I think that ought to set things up so that your shell init files are read in by the new bash and thus you'll see all your aliases.
    – Mark Plotnick
    Jul 11 at 17:56












up vote
1
down vote

favorite
3









up vote
1
down vote

favorite
3






3





When logging in the prompt is different than it is after executing /bin/bash



-bash-4.2$ exec bash
bash-4.2$


How do I get the - back in front of the bash. There are certain commands like tcp dump that only work in the orignal



-bash-4.2$ tcpdump -i port1 -w /home/user/$HOSTNAME-port1.pcap -c10000 -G300
tcpdump: WARNING: port1: no IPv4 address assigned
tcpdump: listening on port1, link-type EN10MB (Ethernet), capture size 65535 bytes
0 packets captured
0 packets received by filter
0 packets dropped by kernel
-bash-4.2$ exec bash
bash-4.2$ tcpdump -i port1 -w /home/user/$HOSTNAME-port1.pcap -c10000 -G300
tcpdump: port1: You don't have permission to capture on that device
(socket: Operation not permitted)


Update for @ctrl-alt-delor



-bash-4.2$ groups
nuage
-bash-4.2$ exec bash
bash-4.2$ groups
nuage


update for @Mikel



bash-4.2$ exec bash -l
bash-4.2$


Update for @Mark Plotnick



-bash-4.2$ type tcpdump
tcpdump is aliased to 'sudo /usr/sbin/tcpdump'
-bash-4.2$ exec bash
bash-4.2$ type tcpdump
tcpdump is /usr/sbin/tcpdump
[root@host nuage]# cat /etc/sudoers | grep nuage
[root@host nuage]# exit
bash-4.2$ group
bash-4.2$ groups
nuage
bash-4.2$ whoami
nuage






share|improve this question













When logging in the prompt is different than it is after executing /bin/bash



-bash-4.2$ exec bash
bash-4.2$


How do I get the - back in front of the bash. There are certain commands like tcp dump that only work in the orignal



-bash-4.2$ tcpdump -i port1 -w /home/user/$HOSTNAME-port1.pcap -c10000 -G300
tcpdump: WARNING: port1: no IPv4 address assigned
tcpdump: listening on port1, link-type EN10MB (Ethernet), capture size 65535 bytes
0 packets captured
0 packets received by filter
0 packets dropped by kernel
-bash-4.2$ exec bash
bash-4.2$ tcpdump -i port1 -w /home/user/$HOSTNAME-port1.pcap -c10000 -G300
tcpdump: port1: You don't have permission to capture on that device
(socket: Operation not permitted)


Update for @ctrl-alt-delor



-bash-4.2$ groups
nuage
-bash-4.2$ exec bash
bash-4.2$ groups
nuage


update for @Mikel



bash-4.2$ exec bash -l
bash-4.2$


Update for @Mark Plotnick



-bash-4.2$ type tcpdump
tcpdump is aliased to 'sudo /usr/sbin/tcpdump'
-bash-4.2$ exec bash
bash-4.2$ type tcpdump
tcpdump is /usr/sbin/tcpdump
[root@host nuage]# cat /etc/sudoers | grep nuage
[root@host nuage]# exit
bash-4.2$ group
bash-4.2$ groups
nuage
bash-4.2$ whoami
nuage








share|improve this question












share|improve this question




share|improve this question








edited Jul 11 at 17:47
























asked Jul 11 at 15:29









Xander May

164




164











  • Can you run groups before and after. Put the result in the question.
    – ctrl-alt-delor
    Jul 11 at 16:09







  • 1




    The - just means it's a login shell. Try exec bash -l. I wonder if this is somehow related to SELinux or some other role-based access control system. But why are you doing exec bash in the first place?
    – Mikel
    Jul 11 at 16:10










  • @Mikel Updated in original, this was the simplest form of the problem, the reason I need to find out how to run things as the original shell is because I must run a script and #!/bin/bash has different permissions than what was used to create the definition for the script.
    – Xander May
    Jul 11 at 17:21











  • Can you show us the output of type tcpdump before and after?
    – Mark Plotnick
    Jul 11 at 17:37






  • 1




    Try exec -a -bash bash ; I think that ought to set things up so that your shell init files are read in by the new bash and thus you'll see all your aliases.
    – Mark Plotnick
    Jul 11 at 17:56
















  • Can you run groups before and after. Put the result in the question.
    – ctrl-alt-delor
    Jul 11 at 16:09







  • 1




    The - just means it's a login shell. Try exec bash -l. I wonder if this is somehow related to SELinux or some other role-based access control system. But why are you doing exec bash in the first place?
    – Mikel
    Jul 11 at 16:10










  • @Mikel Updated in original, this was the simplest form of the problem, the reason I need to find out how to run things as the original shell is because I must run a script and #!/bin/bash has different permissions than what was used to create the definition for the script.
    – Xander May
    Jul 11 at 17:21











  • Can you show us the output of type tcpdump before and after?
    – Mark Plotnick
    Jul 11 at 17:37






  • 1




    Try exec -a -bash bash ; I think that ought to set things up so that your shell init files are read in by the new bash and thus you'll see all your aliases.
    – Mark Plotnick
    Jul 11 at 17:56















Can you run groups before and after. Put the result in the question.
– ctrl-alt-delor
Jul 11 at 16:09





Can you run groups before and after. Put the result in the question.
– ctrl-alt-delor
Jul 11 at 16:09





1




1




The - just means it's a login shell. Try exec bash -l. I wonder if this is somehow related to SELinux or some other role-based access control system. But why are you doing exec bash in the first place?
– Mikel
Jul 11 at 16:10




The - just means it's a login shell. Try exec bash -l. I wonder if this is somehow related to SELinux or some other role-based access control system. But why are you doing exec bash in the first place?
– Mikel
Jul 11 at 16:10












@Mikel Updated in original, this was the simplest form of the problem, the reason I need to find out how to run things as the original shell is because I must run a script and #!/bin/bash has different permissions than what was used to create the definition for the script.
– Xander May
Jul 11 at 17:21





@Mikel Updated in original, this was the simplest form of the problem, the reason I need to find out how to run things as the original shell is because I must run a script and #!/bin/bash has different permissions than what was used to create the definition for the script.
– Xander May
Jul 11 at 17:21













Can you show us the output of type tcpdump before and after?
– Mark Plotnick
Jul 11 at 17:37




Can you show us the output of type tcpdump before and after?
– Mark Plotnick
Jul 11 at 17:37




1




1




Try exec -a -bash bash ; I think that ought to set things up so that your shell init files are read in by the new bash and thus you'll see all your aliases.
– Mark Plotnick
Jul 11 at 17:56




Try exec -a -bash bash ; I think that ought to set things up so that your shell init files are read in by the new bash and thus you'll see all your aliases.
– Mark Plotnick
Jul 11 at 17:56










1 Answer
1






active

oldest

votes

















up vote
1
down vote



accepted










Problem : After executing exec bash the aliases present in the default login prompt are lost causing some commands to not work as expected, such as tcpdump in the following example



-bash-4.2$ tcpdump -i port1 -w /home/user/$HOSTNAME-port1.pcap -c10000 -G300
tcpdump: WARNING: port1: no IPv4 address assigned
tcpdump: listening on port1, link-type EN10MB (Ethernet), capture size 65535 bytes
0 packets captured
0 packets received by filter
0 packets dropped by kernel
-bash-4.2$ exec bash
bash-4.2$ tcpdump -i port1 -w /home/user/$HOSTNAME-port1.pcap -c10000 -G300
tcpdump: port1: You don't have permission to capture on that device
(socket: Operation not permitted)


The Fix : You can do what I did and figure out how the aliases change between the different prompts



-bash-4.2$ type tcpdump
tcpdump is aliased to 'sudo /usr/sbin/tcpdump'
-bash-4.2$ exec bash
bash-4.2$ type tcpdump
tcpdump is /usr/sbin/tcpdump


and then change the script to use those sudo tcpdump instead of plain tcpdump.



Or alternatively you can restore all the aliases present in the original prompt by running exec -a -bash bash (which is apaprently not recommended, see @ctrl-alt-delor's comment)






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%2f454717%2fget-back-to-default-login-shell-after-running-bin-bash%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
    1
    down vote



    accepted










    Problem : After executing exec bash the aliases present in the default login prompt are lost causing some commands to not work as expected, such as tcpdump in the following example



    -bash-4.2$ tcpdump -i port1 -w /home/user/$HOSTNAME-port1.pcap -c10000 -G300
    tcpdump: WARNING: port1: no IPv4 address assigned
    tcpdump: listening on port1, link-type EN10MB (Ethernet), capture size 65535 bytes
    0 packets captured
    0 packets received by filter
    0 packets dropped by kernel
    -bash-4.2$ exec bash
    bash-4.2$ tcpdump -i port1 -w /home/user/$HOSTNAME-port1.pcap -c10000 -G300
    tcpdump: port1: You don't have permission to capture on that device
    (socket: Operation not permitted)


    The Fix : You can do what I did and figure out how the aliases change between the different prompts



    -bash-4.2$ type tcpdump
    tcpdump is aliased to 'sudo /usr/sbin/tcpdump'
    -bash-4.2$ exec bash
    bash-4.2$ type tcpdump
    tcpdump is /usr/sbin/tcpdump


    and then change the script to use those sudo tcpdump instead of plain tcpdump.



    Or alternatively you can restore all the aliases present in the original prompt by running exec -a -bash bash (which is apaprently not recommended, see @ctrl-alt-delor's comment)






    share|improve this answer

























      up vote
      1
      down vote



      accepted










      Problem : After executing exec bash the aliases present in the default login prompt are lost causing some commands to not work as expected, such as tcpdump in the following example



      -bash-4.2$ tcpdump -i port1 -w /home/user/$HOSTNAME-port1.pcap -c10000 -G300
      tcpdump: WARNING: port1: no IPv4 address assigned
      tcpdump: listening on port1, link-type EN10MB (Ethernet), capture size 65535 bytes
      0 packets captured
      0 packets received by filter
      0 packets dropped by kernel
      -bash-4.2$ exec bash
      bash-4.2$ tcpdump -i port1 -w /home/user/$HOSTNAME-port1.pcap -c10000 -G300
      tcpdump: port1: You don't have permission to capture on that device
      (socket: Operation not permitted)


      The Fix : You can do what I did and figure out how the aliases change between the different prompts



      -bash-4.2$ type tcpdump
      tcpdump is aliased to 'sudo /usr/sbin/tcpdump'
      -bash-4.2$ exec bash
      bash-4.2$ type tcpdump
      tcpdump is /usr/sbin/tcpdump


      and then change the script to use those sudo tcpdump instead of plain tcpdump.



      Or alternatively you can restore all the aliases present in the original prompt by running exec -a -bash bash (which is apaprently not recommended, see @ctrl-alt-delor's comment)






      share|improve this answer























        up vote
        1
        down vote



        accepted







        up vote
        1
        down vote



        accepted






        Problem : After executing exec bash the aliases present in the default login prompt are lost causing some commands to not work as expected, such as tcpdump in the following example



        -bash-4.2$ tcpdump -i port1 -w /home/user/$HOSTNAME-port1.pcap -c10000 -G300
        tcpdump: WARNING: port1: no IPv4 address assigned
        tcpdump: listening on port1, link-type EN10MB (Ethernet), capture size 65535 bytes
        0 packets captured
        0 packets received by filter
        0 packets dropped by kernel
        -bash-4.2$ exec bash
        bash-4.2$ tcpdump -i port1 -w /home/user/$HOSTNAME-port1.pcap -c10000 -G300
        tcpdump: port1: You don't have permission to capture on that device
        (socket: Operation not permitted)


        The Fix : You can do what I did and figure out how the aliases change between the different prompts



        -bash-4.2$ type tcpdump
        tcpdump is aliased to 'sudo /usr/sbin/tcpdump'
        -bash-4.2$ exec bash
        bash-4.2$ type tcpdump
        tcpdump is /usr/sbin/tcpdump


        and then change the script to use those sudo tcpdump instead of plain tcpdump.



        Or alternatively you can restore all the aliases present in the original prompt by running exec -a -bash bash (which is apaprently not recommended, see @ctrl-alt-delor's comment)






        share|improve this answer













        Problem : After executing exec bash the aliases present in the default login prompt are lost causing some commands to not work as expected, such as tcpdump in the following example



        -bash-4.2$ tcpdump -i port1 -w /home/user/$HOSTNAME-port1.pcap -c10000 -G300
        tcpdump: WARNING: port1: no IPv4 address assigned
        tcpdump: listening on port1, link-type EN10MB (Ethernet), capture size 65535 bytes
        0 packets captured
        0 packets received by filter
        0 packets dropped by kernel
        -bash-4.2$ exec bash
        bash-4.2$ tcpdump -i port1 -w /home/user/$HOSTNAME-port1.pcap -c10000 -G300
        tcpdump: port1: You don't have permission to capture on that device
        (socket: Operation not permitted)


        The Fix : You can do what I did and figure out how the aliases change between the different prompts



        -bash-4.2$ type tcpdump
        tcpdump is aliased to 'sudo /usr/sbin/tcpdump'
        -bash-4.2$ exec bash
        bash-4.2$ type tcpdump
        tcpdump is /usr/sbin/tcpdump


        and then change the script to use those sudo tcpdump instead of plain tcpdump.



        Or alternatively you can restore all the aliases present in the original prompt by running exec -a -bash bash (which is apaprently not recommended, see @ctrl-alt-delor's comment)







        share|improve this answer













        share|improve this answer



        share|improve this answer











        answered Jul 11 at 19:09









        Xander May

        164




        164






















             

            draft saved


            draft discarded


























             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f454717%2fget-back-to-default-login-shell-after-running-bin-bash%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?

            Bahrain

            Postfix configuration issue with fips on centos 7; mailgun relay