I am on AIX 7.1.
I have a bunch of aliases defined in my personal .profile.
alias df='df -k'
alias cl=clear
alias h=history
alias ll='ls -al'
alias lt='ls -latr'
alias ls='ls -Fa'
alias psj='ps -ef | grep java'
If I issue a 'sudo su' or 'sudo su other_user' command, I am not able to use these aliases. I was under the impression that using a 'sudo su' without a '-' (sudo su -) would make me root while using my personal .profile?
jg10371@asdepdm1: /home/jg10371
$ ll
total 88
drwx------ 3 jg10371 unxusers 4096 May 29 09:21 ./
drwxr-xr-x 154 bin bin 12288 May 29 09:35 ../
-rw------- 1 root system 200 Jul 04 2010 .bash_history
-rw-r--r-- 1 jg10371 unxusers 1943 May 29 09:35 .profile
-rw------- 1 jg10371 unxusers 6944 May 29 09:36 .sh_history
drwx------ 2 jg10371 unxusers 256 May 28 11:06 .ssh/
-rw------- 1 jg10371 unxusers 44 May 28 12:21 .vas_disauthcc_9168
-rwx------ 1 jg10371 unxusers 28 May 28 12:21 .vas_logon_server*
-rwx------ 1 jg10371 unxusers 18 Mar 28 18:06 .vi_history*
jg10371@asdepdm1: /home/jg10371
$ sudo su
Password:
jg10371@asdepdm1: /home/jg10371
$ ll
ksh: ll: not found.
jg10371@asdepdm1: /home/jg10371
Best Answer
Well, as you already noticed, it does not. The manpage entry says "sudo - execute a command as another user", which means, that aliases and bash variables will change accordingly. And when doing "sudo ll", the system notices, that user root does not know anything about ll.
If you want your aliases available as root, you can either copy the definitions to the roots profile file or create a separate alias file and include it using the source command. (It is possible to include the users profile file itself, but you may have some lines in it that shall not be adopted by root.)