Adding a command alias for ssh

Status
Not open for further replies.

SkyMonkey

Contributor
Joined
Mar 13, 2013
Messages
102
Again, perhaps a dumb question, but here goes...

I've created a non-root user for general purposes and configuration who has a user directory on my zpool. SSHing in with this user (who is in wheel and can su, and has csh selected as the user shell in the webgui) puts me in that directory, where there is a .cshrc, but adding aliases in this file does not work.

An 'alias' shows several that aren't in .cshrc. Adding one via 'alias <cmds>' works, but it doesn't persist past a reboot, and it doesn't show up in the .cshrc in the user directory.

Where are the command aliases stored? And how can I make some that persist past reboot?

Thanks.
 

ProtoSD

MVP
Joined
Jul 1, 2011
Messages
3,348
Check the ownership and permissions, you have the correct file. Also you can do a "source .cshrc" and then "alias" to see if it picked up your aliases. Also, try "whoami" to make sure you are who you think you are and are in the correct home directory.
 

SkyMonkey

Contributor
Joined
Mar 13, 2013
Messages
102
The user owns the file/directory, and I am indeed the user I thought I was. I actually misspoke above, adding an alias via 'alias <cmd>' works, but only for the session. If I logout and log back in it's gone. I poked around a bit after adding one to try to find a .cshrc that had the alias in it, perhaps in var or something, but couldn't find one. My user's home directory name isn't identical to his username, but I don't think that matters, as he is the owner.

I also attempted to add some aliases for the root user and had the same problems.
 
J

James

Guest
Aliases added at the command line are only for that login session. Which line are you trying to add to .cshrc?
 

SkyMonkey

Contributor
Joined
Mar 13, 2013
Messages
102
The one I was attempting to add was to check cpu temps: sysctl -a |egrep -E "cpu\.[0-9]+\.temp".

Doing this via command line works fine (for the session) 'alias ctemp sysctl -a |egrep -E "cpu\.[0-9]+\.temp"'.

Adding the same alias to the set of aliases already in my user's .cshrc does not work (no such command). I don't believe I tried anything simpler.

One interesting (to me) thing to note is that typing 'alias' at the command line to show the active aliases for my user shows at least one which doesn't appear in my .cshrc at all.
 

SkyMonkey

Contributor
Joined
Mar 13, 2013
Messages
102
Any ideas? Problem still exists, and my research suggests that I'm doing things correctly....
 

titan_rw

Guru
Joined
Sep 1, 2012
Messages
586
Both these two examples work for me:

Code:
alias ctemp="sysctl -a |egrep -E cpu\.[0-9]+\.temp"


And,


Code:
alias ctemp="sysctl -a |egrep -E 'cpu\.[0-9]+\.temp'"


However, I changed the shell to bash, as I'm more used to it after using linux for so long.

There's no spaces in the regex, so I'm not too surprised it doesn't have to be quoted. It's all one 'argument'.

Similar to another alias I use:

Code:
alias gstat='gstat -f ^[a-z]+[0-9]+$'
 

SkyMonkey

Contributor
Joined
Mar 13, 2013
Messages
102
I still never got this to work for c shell for root or any user account. I effectively cannot add aliases. :(
 

William Grzybowski

Wizard
iXsystems
Joined
May 27, 2011
Messages
1,754
Clearly you're doing something wrong, paste the exact commands and file with paths that you're using.
 

dztrbd

Dabbler
Joined
Dec 6, 2013
Messages
36
Ok So what exactly did you type in the end? Cause im not sure what you missed?
 
Status
Not open for further replies.
Top