Sponsored Content
Top Forums Shell Programming and Scripting Sourcing as root automatically Post 302752015 by dasx on Saturday 5th of January 2013 09:03:16 AM
Old 01-05-2013
Sourcing as root automatically

Hey everyone!

I have my .bash_profile file which is read automatically when I launch Terminal therefore I can run my own functions.

BUT.

When I do:
Code:
sudo -s

Code:
sudo su

Code:
sudo su -

No matter what I do, I can't get the .bash_profile file to be sourced automatically so I end up having to run different commands.

Example: I have this function:

Code:
aaa(){
	if [ `id -u` -eq 0 ]
		then	rm ~/Whatever/*
		else	echo PERMISSION DENIED
	fi
}

Running:
Code:
aaa

Output:
Code:
PERMISSION DENIED

Running:
Code:
sudo aaa

Output:
Code:
sudo: aaa: command not found

So I end up having to type:
Code:
sudo -s
source ~/.bash_profile
aaa

Any possible way I can make shell source .bash_profile automatically when logging as sudo?

Thanks!


P.S: I know I can just add it to the bashrc file in /etc/, I'd just like to avoid that workaround.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

arguments in sourcing file

Hello ! I want to make a script like that. #!/bin/csh -f setenv toto me setenv titi you setenv tata $1 in which tata is visible outside the script, after sourcing this script. It seems that you can only do source script and not source script arg How can I do that ? ... (4 Replies)
Discussion started by: Nathe
4 Replies

2. UNIX for Dummies Questions & Answers

sourcing the .bashrc

Hello, I am quite new to Linux... I need to set some aliases and I can't get it to work. Can somebody tell me what's wrong? I modified the .bashrc file in my home directory. I added: alias pmv= '/home/vera/MGLTools-1.4.5/share/bin/pmv' saved it and ran source .bashrc The shell... (3 Replies)
Discussion started by: Nusy
3 Replies

3. Shell Programming and Scripting

Change root password automatically

I need to change root password automatically in some servers all three months. I want to run this process in one of the servers and reply it to the others. The password must be known by the administrator. (3 Replies)
Discussion started by: Alrica
3 Replies

4. Solaris

rootsh on Solaris 10 is not sourcing root's .profile

I'm attempting to setup rootsh on Solaris 10 to log the activity of users who require root access. However it does not appear to be sourcing root's .profile file even when run with the '-i' option. I was wondering if anybody else has run into this and might have a solution. Thank you. (9 Replies)
Discussion started by: kungfusnwbrdr
9 Replies

5. Solaris

Root file system automatically reduced from 90 to 40%

Greetings. i have solaris 9. I had a problem with root file system day before yesterday when it got 100% full, i reduced it to 90% but then after one day it was automatically reduced to 40%!!! no human intervention was done. no reboot done. Last time when i checked in proc FS there were a lot... (3 Replies)
Discussion started by: mr_os
3 Replies

6. Shell Programming and Scripting

sourcing .profile for other users

Hi Team, Thank you for your time. i have a situation where the user IDs of the applicatio users have been locked down to Read only. Hence I am writing a script to invoke their old .profile every time they login. My problem is : when i run . $userpath/.profile from within the ksh script... (9 Replies)
Discussion started by: anitha111
9 Replies

7. Solaris

Migration of system having UFS root FS with zones root to ZFS root FS

Hi All After downloading ZFS documentation from oracle site, I am able to successfully migrate UFS root FS without zones to ZFS root FS. But in case of UFS root file system with zones , I am successfully able to migrate global zone to zfs root file system but zone are still in UFS root file... (2 Replies)
Discussion started by: sb200
2 Replies

8. Red Hat

Crontab sourcing PATH?

Hi, Im trying to run script A which requires path /sbin. I have a crontab entry to run script A every 10 minutes. Script A is executed fine by cron, but because script A requires /sbin in its path it fails to run. My situation is script A get overwritten from time to time so I can't modify... (4 Replies)
Discussion started by: wilsonee
4 Replies

9. Shell Programming and Scripting

How to run script automatically on reboot as root user?

Hi friends,,, I am running one server on Ubuntu 12.04 LTS 32-bit, some times my pc restarts automatically, with no reason, I have a script to start server which requires root password. in this directory /myserver/start_server.sh How can I do this ? and some scripts I am having that I... (1 Reply)
Discussion started by: Akshay Hegde
1 Replies

10. Shell Programming and Scripting

Sourcing variables from another script

My manager required that i keep the hostnames and username and password in a separate file when creating my sftp script. (Don't mention passwords and sftp...I've talk to him about this several times) I have a list of hostnames that have to be read in a loop in my main script. I don't know... (3 Replies)
Discussion started by: MJCreations
3 Replies
Locale::Codes::LangExt(3pm)				 Perl Programmers Reference Guide			       Locale::Codes::LangExt(3pm)

NAME
Locale::Codes::LangExt - standard codes for language extension identification SYNOPSIS
use Locale::Codes::LangExt; $lext = code2langext('acm'); # $lext gets 'Mesopotamian Arabic' $code = langext2code('Mesopotamian Arabic'); # $code gets 'acm' @codes = all_langext_codes(); @names = all_langext_names(); DESCRIPTION
The "Locale::Codes::LangExt" module provides access to standard codes used for identifying language extensions, such as those as defined in the IANA language registry. Most of the routines take an optional additional argument which specifies the code set to use. If not specified, the default IANA language registry codes will be used. SUPPORTED CODE SETS
There are several different code sets you can use for identifying language extensions. A code set may be specified using either a name, or a constant that is automatically exported by this module. For example, the two are equivalent: $lext = code2langext('acm','alpha'); $lext = code2langext('acm',LOCALE_LANGEXT_ALPHA); The codesets currently supported are: alpha This is the set of three-letter (lowercase) codes from the IANA language registry, such as 'acm' for Mesopotamian Arabic. This is the default code set. ROUTINES
code2langext ( CODE [,CODESET] ) langext2code ( NAME [,CODESET] ) langext_code2code ( CODE ,CODESET ,CODESET2 ) all_langext_codes ( [CODESET] ) all_langext_names ( [CODESET] ) Locale::Codes::LangExt::rename_langext ( CODE ,NEW_NAME [,CODESET] ) Locale::Codes::LangExt::add_langext ( CODE ,NAME [,CODESET] ) Locale::Codes::LangExt::delete_langext ( CODE [,CODESET] ) Locale::Codes::LangExt::add_langext_alias ( NAME ,NEW_NAME ) Locale::Codes::LangExt::delete_langext_alias ( NAME ) Locale::Codes::LangExt::rename_langext_code ( CODE ,NEW_CODE [,CODESET] ) Locale::Codes::LangExt::add_langext_code_alias ( CODE ,NEW_CODE [,CODESET] ) Locale::Codes::LangExt::delete_langext_code_alias ( CODE [,CODESET] ) These routines are all documented in the Locale::Codes::API man page. SEE ALSO
Locale::Codes The Locale-Codes distribution. Locale::Codes::API The list of functions supported by this module. http://www.iana.org/assignments/language-subtag-registry The IANA language subtag registry. AUTHOR
See Locale::Codes for full author history. Currently maintained by Sullivan Beck (sbeck@cpan.org). COPYRIGHT
Copyright (c) 2011-2012 Sullivan Beck This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.16.2 2012-10-11 Locale::Codes::LangExt(3pm)
All times are GMT -4. The time now is 06:44 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy