Tag Info

Hot answers tagged

19

you can try to abort (ctrl+C) before the exit part of your .bashrc is executed. I tried by adding the following at the top of a testuser's bashrc, it works, it's just a matter of timing. Very easy in my case: sleep 3 echo "Too late... bye" exit 0


9

I think your only options are: ssh in as another user and su to your account; use something like ftp or smbclient, if the relevant services are enabled on the host; find an open vulnerability in an open network service and exploit it :). get an admin to fix the problem.


9

I usually address this with a short cron wrapper script: #!/bin/bash [ -r $HOME/.bashrc ] && . $HOME/.bashrc [ -r $HOME/.profile ] && . $HOME/.profile exec "$@" Then just prefix the command in crontab with your wrapper: * * * * 1-5 ~/scripts/cron-wrapper ~/scripts/myscript.sh * * * * 1-5 ~/scripts/cron-wrapper ~/scripts/myotherscript.sh ...


6

Use the pathmunge() function available in most distro's /etc/profile: pathmunge () { if ! echo $PATH | /bin/egrep -q "(^|:)$1($|:)" ; then if [ "$2" = "after" ] ; then PATH=$PATH:$1 else PATH=$1:$PATH fi fi } edit: For zsh users, typeset -U <variable_name> will deduplicate path entries.


5

It depends somewhat on how you personally use shells. An interactive shell is anything that has a terminal connected to its input and output. Login shells are spawned by /bin/login. Login shells source your .bash_profile. Most terminal emulators such as xterm start an interactive shell that is not a login shell. Interactive, non-login shells source your ...


5

Add alias k='kate'. Here is a link to some more information on bash aliases. You can't pass a parameter into an alias. You can do the cd dir_name"=>"cd dir_name; ls -l with a function and an alias like so mcd () { cd "$1" && ls -l; } alias cd='mcd' That will only execute the ls -l if the cd is successful.


5

Could you describe how do you test these 2 files? Did you try login or non-login shell? Here is the difference: When you login your system and see the command line prompt, it’s a login shell, and it executes these files in order: /etc/profile ~/.bash_profile ~/.bashrc /etc/bashrc A non-login shell will only execute the two files in order: /etc/bashrc ...


4

From the bash manpage: Aliases are not expanded when the shell is not interactive, unless the expand_aliases shell option is set using shopt (see the description of shopt under SHELL BUILTIN COMMANDS below). You need to shopt -s expand_aliases in your remote .bashrcs, and check that those .bashrc are processed when non-interactive; the ...


4

I think It's good idea to use .bashrc but if you want a global way then you can put your file with functions in this place /etc/profile.d/your_file_with_functions.sh Also you can use other way /etc/bash.bashrc and put there [ -r /path/to/your/file ] && . /path/to/your/file


4

I had a similar problem. I looked in my /etc/sudoers file and I saw these lines: Defaults env_reset Defaults env_keep = "COLORS DISPLAY HOSTNAME HISTSIZE INPUTRC KDEDIR \ LS_COLORS MAIL PS1 PS2 QTDIR USERNAME \ LANG LC_ADDRESS LC_CTYPE LC_COLLATE LC_IDENTIFICATION \ ...


4

Add to your ~/.bashrc: export myip="1.2.3.4" Then you can use $myip on the command line after logging in or running source ~/.bashrc: ping $myip Aliases only work as commands, so you use it to replace commands which might include your IP: alias myping='ping 1.2.3.4' alias myssh='ssh user@1.2.3.4'


3

If you have root-level access to the server you can install and enable auditd which tracks filesystem-level changes and will help you identify what is responsible for removing the file. You'd then set up a watch for writes to your home directory (deleting a file from a directory requires writing to the directory containing it) possibly tagging it so you can ...


3

What may actually be happening is that .bashrc is being run more than you think. If it's run and there's no X screen or DISPLAY variable, rdesktop will fail and then the shutdown will run. @dimmer's fix should handle that, though there's a cleaner way. It should work if you put the shutdown command after the startx command and put the rdesktop command in ...


3

First, JAVA_HOME should only contain the actual Java installation directory. Normally, additional classes should be added to CLASSPATH, with directories separated by : eg export CLASSPATH=$CLASSPATH:/usr/local/tomcat/lib/:/somewhere/else/ Unfortunately, it seems that Tomcat does its own thing, and that thing has changed with every major version of Tomcat. ...


3

Yes, ':' is a valid command in bash, so that error message indicates that for some reason the shell is finding that as a command to execute in the .bashrc shell script. Try a few things: 'cat -tve .bashrc' to see if it has any hidden special characters that are messing things up. 'bash -x .bashrc' to see if executing your .bashrc directly causes problems. ...


3

An alternative (although not necessarily better) option would be to add these into root's crontab, and have the entry use su with a dash to become the user in question. The environment variables would then be pulled in automatically via the user's default shell environment in ~/.bashrc, or the like. eg: * * * * 1-5 su - scriptuser ...


3

I actually discovered a fairly elegant solution by adding the '-l' (--login) flag to my bash command, which causes it to source all login files, including .bashrc. Hence my crontab command is simply: * * * * 1-5 /usr/bin/bash -lc '/mnt/group/core/deploy/scripts/test.sh' > /dev/null 2>&1


3

The output you just posted indicates that you aren't actually running bash. This is why you are getting errors sourcing .bashrc. To fix this problem, you need to check your login shell to make sure it's actually set to bash: chsh -l will list the available shells, and chsh -s /path/to/bash will change your login shell to bash. Then logout and log ...


2

To answer your headline question yes, it is possible to mount your /media/ant from a .bashrc simply put mount /media/ant in the relevant file. Unfortunately you have to run mount as root so you have to arrange arrange for the particular user to be able to run mount as root e.g. via sudo. This gets complicated and introduces other security issues. As ...


2

Apparently, I found a command that will work [ex@uid377 ~]$ echo 'help!' >& .bashrc This overwrote the .bashrc and I was able to log back in. In retrospect doing export LD_LIBRARY_PATH='' would also fix this problem.


2

This is normal, .bash_profile is sourced for login shells, .bashrc is sourced for interactive non-login shells. In CentOS the top of .bash_profile usually has: if [ -f ~/.bashrc ]; then . ~/.bashrc fi So you can put things in .bashrc. Mac OS X Terminal reads .bash_profile when you open a new windows. gnome-terminal can be made to do that with Run ...


2

The default Ubuntu ~/.bashrc will overwrite any earlier values of PS1 which is what you're seeing. You could make PS1 read only declare -r PS1=... but this will cause the default ~/.bashrc to emit -bash: PS1: readonly variable which may not be desirable. You can edit /etc/skel/.bashrc to remove the lines that set PS1 so that new users will not get ...


2

To get your shell back, just use this procedure. Hope you remember the contents of .bashrc what were earlier there. It should be something like this: # .bashrc # Source global definitions if [ -f /etc/bashrc ]; then . /etc/bashrc fi Put them into a file with the same name, .bashrc, on the machine from where you can access your Linode ...


2

People already have asked you how to fix this. But why this has happened to you? In Debian/Ubuntu, there's this piece of code in ~/.profile: # if running bash if [ -n "$BASH_VERSION" ]; then # include .bashrc if it exists if [ -f "$HOME/.bashrc" ]; then . "$HOME/.bashrc" fi fi So, by default, ~/.profile is including ~/.bashrc. If you tell ...


2

You'll need to add the same logic that exists in your .profile to your .bash_profile. .profile isn't used if .bash_profile exists, so your .bashrc isn't being sourced. The check for whether you're running bash is not necessary in .bash_profile, though. This is sufficient: [[ -f ~/.bashrc ]] && source ~/.bashrc


2

the configuration files are all dependent upon the software that uses them. in most cases, the file is named .<programname>rc in some cases it's a config file in a 'hidden' . directory, i.e. ~/.fluxbox/init there is nothing wrong with putting your aliases in the .bashrc file, .bash_alias is another shell script called from within .bashrc, some people ...


2

The actual capabilities are tsl (To Status Line) and fsl (From Status Line), but of course not all terminals have then. In Linux in particular you need to set your terminal to xterm+sl or something similar. You can test this with export TERM=xterm+sl echo `tput tsl` Hello world `tput fsl`; sleep 10 I wouldn't bother and keep those escapes in .bashrc


2

If tomcat started when the machine booted, making changes to your .bashrc will do no good, since tomcat probably is not run by your user. If tomcat was installed from a .deb package, you could have a look in /etc/default/tomcat6, you will probably find similar variables there. Otherwise, we need to know more about how the start script looks.


2

Try(error in the lack of space after '['): export CATALINA_HOME=/tomcat/directory tomcat() { case "$1" in -s) ${CATALINA_HOME}/bin/startup.sh;; -x) ${CATALINA_HOME}/bin/shutdown.sh;; *) "Enter '-s' to start Tomcat, '-x' to shutdown." esac }



Only top voted, non community-wiki answers of a minimum length are eligible