I often have to login to one of several servers and go to one of several directories on those machines. Currently I do something of this sort:
localhost ~]$ ssh somehost Welcome to somehost! somehost ~]$ cd /some/directory/somewhere/named/Foo somehost Foo]$
I have scripts that can determine which host and which directory I need to get into but I cannot figure out a way to do this:
localhost ~]$ go_to_dir Foo Welcome to somehost! somehost Foo]$
Is there an easy, clever or any way to do this?
simply modify your home with the command:
usermod -d /newhome username
Another way of going to directly after logging in is create "Alias". When you login into your system just type that alias and you will be in that directory.
Example : Alias = myfolder '/var/www/Folder'
After you log in to your system type that alias (this works from any part of the system)
this command if not in bashrc will work for current session. So you can also add this alias to bashrc to use that in future
$ myfolder => takes you to that folder
going one step further with the
-t
idea. I keep a set of scripts calling the one below to go to specific places in my frequently visited hosts. I keep them all in~/bin
and keep that directory in my path.I use the environment variable CDPATH