Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    Where to put shell commands to run at login?

    Scheduled Pinned Locked Moved General pfSense Questions
    10 Posts 7 Posters 1.3k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • ssbarneaS
      ssbarnea
      last edited by ssbarnea

      I want to add some aliases to pfsense shell in a way that I would not lose them on system upgrade and if possible to keep them between system restores.

      How can I do this?

      As far as I seen the files like .profile state that they are part of pfsense, none of them mentioning that user is welcomed to add his changes to them.

      I only want to add alias mc="mc -u" in order to avoid failure to start due to common.c: unimplemented subshell type 1

      1 Reply Last reply Reply Quote 0
      • NogBadTheBadN
        NogBadTheBad
        last edited by

        Install the Shellcmd package.

        Andy

        1 x Netgate SG-4860 - 3 x Linksys LGS308P - 1 x Aruba InstantOn AP22

        ssbarneaS 1 Reply Last reply Reply Quote 1
        • ssbarneaS
          ssbarnea @NogBadTheBad
          last edited by

          @nogbadthebad said in Where to put shell commands to run at login?:

          Shellcmd

          Thanks, this looks like the proper way to add extra commands.

          The irony is that something is preventing the alias command from having any effect. I tried "alias dir=ls" but it does nothing. Running "alias" reports no aliases at all.

          1 Reply Last reply Reply Quote 0
          • stephenw10S
            stephenw10 Netgate Administrator
            last edited by

            You have to use the complete path to the command in shellcmd. Also the tcsh shell doesn't require an = so you probably want:
            /usr/bin/alias dir ls

            Steve

            1 Reply Last reply Reply Quote 1
            • R
              revengineer
              last edited by

              I added "alias ll ls -la" to /etc/csh.cshrc. I previously put the alias in ~/csh.cshrc only to find that this files get overwritten frequently.

              GertjanG 1 Reply Last reply Reply Quote 1
              • DerelictD
                Derelict LAYER 8 Netgate
                last edited by

                It's a firewall not a Unix workstation.

                Chattanooga, Tennessee, USA
                A comprehensive network diagram is worth 10,000 words and 15 conference calls.
                DO NOT set a source address/port in a port forward or firewall rule unless you KNOW you need it!
                Do Not Chat For Help! NO_WAN_EGRESS(TM)

                1 Reply Last reply Reply Quote 0
                • ssbarneaS
                  ssbarnea
                  last edited by

                  @stephenw10 After more searching on StackOverflow I was able to narrow down why it was not working, I must use single quotes, this version being alias mc 'mc -u' being the correct one.

                  On the other hand I made a grim discovery regarding shellcmd extension, it seems to run the command at boot time and not at login time, which is what is needed for aliases. I am not willing to ruin the uptime of the router by rebooting it for that, even if is my home-office one.

                  The interesting thing is that there are few already defined aliases inside /root/.cshrc file but they are not loaded. $SHELL reports /bin/sh but $0 reports /bin/tcsh which explains why the only way to make it work was to add that line to the end of /root/.tcshrc file, with ansible and hopefully to run ansible again after each upgrade. Maybe someone will find a more persistent solution.

                  I will try to avoid starting a flame war regarding non-constructive comments that can only alienate users and convince them to move to alternatives ;)

                  GrimsonG 1 Reply Last reply Reply Quote 0
                  • R
                    revengineer
                    last edited by

                    @ssbarnea: Not sure you have seen my post. Have you tried /etc/csh.cshrc?

                    Derelict has a point in that some people try to do too much on the firewall and thereby risk making the firewall vulnerable to attacks. However, I have found myself several times in a situation with a corrupted database from a package (probably from power outages) that did require fixing via shell. Having basic aliases defined for such maintenance is helpful.

                    1 Reply Last reply Reply Quote 1
                    • GertjanG
                      Gertjan @revengineer
                      last edited by

                      @revengineer said in Where to put shell commands to run at login?:

                      I added "alias ll ls -la" to /etc/csh.cshrc. I previously put the alias in ~/csh.cshrc only to find that this files get overwritten frequently.

                      Although I agree with @Derelict **, 'll' is the alias I use very often - on any system.

                      No "help me" PM's please. Use the forum, the community will thank you.
                      Edit : and where are the logs ??

                      1 Reply Last reply Reply Quote 0
                      • GrimsonG
                        Grimson Banned @ssbarnea
                        last edited by

                        @ssbarnea said in Where to put shell commands to run at login?:

                        I am not willing to ruin the uptime of the router by rebooting it for that, even if is my home-office one.

                        There is nothing to be proud about a high uptime. A high uptime only showcases that you're late with updates.

                        1 Reply Last reply Reply Quote 1
                        • First post
                          Last post
                        Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.