Where to put shell commands to run at login?
-
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 tocommon.c: unimplemented subshell type 1
-
Install the Shellcmd package.
-
@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.
-
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
-
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.
-
It's a firewall not a Unix workstation.
-
@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 ;)
-
@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.
-
@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.
-
@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.