Page 1 of 1

Editing .bash_profile from within the 'Macs' terminal app

Posted: Tue Oct 18, 2005 3:32 pm
by mikebr
I have not much experiance using ssh or unix commands and I am trying to alter some information in the 'bash_profile' on my linux server, I have access to do this. I log in as root using ssh from my Mac's terminal app. I read that to access this script I should use:

pico .bash_profile

on doing this I am told:

-bash: pico: command not found
root@ms1 [~]#

I am also trying to alter a ssh legal message using:

pico /etc/motd

but I get the same error.

Anyone any ideas on how I do this.

Many thanks

Posted: Tue Oct 18, 2005 3:39 pm
by Chris Corbyn
nano .bash_profile ;)

Posted: Tue Oct 18, 2005 3:45 pm
by redmonkey
vi /etc/motd
vi .bash_profile

Not sure if they made any changes but the Mac I have has my bash profile in the file .profile

Posted: Tue Oct 18, 2005 3:48 pm
by Chris Corbyn
redmonkey wrote:vi /etc/motd
vi .bash_profile

Not sure if they made any changes but the Mac I have has my bash profile in the file .profile
He's SSH'ing to a linux box. vi (to me at least) requires supreme knowledge to use too... nano is easy :P

On all the recent verions of bash the file has been at ~/.bash_profile for me.

On the old redhat boxes at university I used to edit .profile so I guess it changed somewhere along the way :?

Posted: Tue Oct 18, 2005 3:55 pm
by timvw
Imho sshing as root isn't a good practice.
But you might want to start with installing an editor that you can use..

Posted: Tue Oct 18, 2005 3:56 pm
by redmonkey
Ah, never noticed he was going via ssh to a linux box.

simple editing in vi is extremely easy and quick (or at least to me it is). Most linux distros store their bash profile in one of a few different files, either .bash_profile, .profile or .bashrc, these are the most common/likey ones.

Posted: Tue Oct 18, 2005 3:56 pm
by mikebr
OK great, 'nano' got me in.

BTW, Yes, I am SSH'ing to a linux box.... from a Mac.

I get quite a few SSHD Authentication Failures: listed in the servers Logwatch, so as a safety alert 'I read' I could add the following line at the bottom of the 'bash_profile' to make the server notify me by e-mail if someone logged in as root:

echo 'ALERT - Root Shell Access on:' `date` `who` | mail -s "Alert: Root Access from `who | awk '{print $6}'`" your@email.com

To be honest I am a little nervous about doing this having the limited knowlage I do on SSH and Linux, but it seems like a good warning to have. Maybe some experianced users can confirm this is a good thing to do and that the command line is correct, I don't want to screw anything up.

Thanks

Posted: Tue Oct 18, 2005 3:57 pm
by timvw
imho, using vi is pure sm... use vim instead...

my ~/.bash_profile

Code: Select all

# include .bashrc if it exists
if [ -f ~/.bashrc ]; then
        source ~/.bashrc
fi
my ~/.bashrc

Code: Select all

umask 077

# set PATH so it includes user's private bin if it exists
if [ -d ~/bin ] ; then
        PATH=~/bin:"${PATH}"
fi

# If running interactively, then:
if [ "$PS1" ]; then
        # enable color support of ls and also add handy aliases
        eval `dircolors -b`
        alias ls='ls --color=auto'
        alias dir='ls --color=auto --format=vertical'
        alias vdir='ls --color=auto --format=long'

        # some more ls aliases
        alias ll='ls -l'
        alias la='ls -A'
        alias l='ls -CF'

        # set a fancy prompt
        PS1='\u@\h:\w\$ '

fi