• Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Search
  • Register
  • Login
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.
  • S
    ssbarnea
    last edited by ssbarnea Jan 1, 2019, 10:47 AM Jan 1, 2019, 10:44 AM

    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
    • N
      NogBadTheBad
      last edited by Jan 1, 2019, 10:48 AM

      Install the Shellcmd package.

      Andy

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

      S 1 Reply Last reply Jan 1, 2019, 11:18 AM Reply Quote 1
      • S
        ssbarnea @NogBadTheBad
        last edited by Jan 1, 2019, 11:18 AM

        @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
        • S
          stephenw10 Netgate Administrator
          last edited by Jan 1, 2019, 7:04 PM

          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 Jan 1, 2019, 9:16 PM

            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.

            G 1 Reply Last reply Jan 2, 2019, 1:50 PM Reply Quote 1
            • D
              Derelict LAYER 8 Netgate
              last edited by Jan 1, 2019, 9:34 PM

              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
              • S
                ssbarnea
                last edited by Jan 2, 2019, 9:03 AM

                @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 ;)

                G 1 Reply Last reply Jan 2, 2019, 2:23 PM Reply Quote 0
                • R
                  revengineer
                  last edited by Jan 2, 2019, 1:15 PM

                  @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
                  • G
                    Gertjan @revengineer
                    last edited by Jan 2, 2019, 1:50 PM

                    @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
                    • G
                      Grimson Banned @ssbarnea
                      last edited by Jan 2, 2019, 2:23 PM

                      @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
                      10 out of 10
                      • First post
                        10/10
                        Last post
                      Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.
                        This community forum collects and processes your personal information.
                        consent.not_received