No .profile file


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers No .profile file
# 1  
Old 06-24-2010
No .profile file

Hi All,
I just have a small question. I was wondering what would happen if there was no .profile file. I understand that the aliases and my path related commands wouldnt work, however i wanted to know if i would still be able to use the ls,cp,mv.... commands without a .profile file. If yes, how. From where are all these commands being referred without using /usr/bin...
# 2  
Old 06-24-2010
Just try it. If your shell is ksh or bash, run
Code:
env -i $0
unalias $( alias | sed -e 's/^alias//' | cut -d= -f1 )
unset $( env | cut -d= -f1 )

and check what's still working, and what isn't.
# 3  
Old 06-24-2010
Cant do that..

i am on a server at work and im relatively new to unix. I have no idea what your suggestion would do and do not want to take chancesSmilie... I just wanted to know theoritically what would happen in such a scenario... or if you could tell me what would happen if i do what you have mentioned, then if there s no risk in it i would do it...Smilie
# 4  
Old 06-24-2010
Very wise, not automatically entering commands you've seen on the net in blind faith. Keep to that.

Quick rundown:
Code:
# Run the current shell (which has it's name in $0) again, in an clean
# environment. User-specific configuration will still be read. See man env 
env -i ${0#-}

# alias lists all currently set aliases. sed will remove the string "alias"
# from the beginning of the line, and cut will only return the stuff up to the
# equal sign. The result of that is passed to unalias to unset those 
unalias $( alias | sed -e 's/^alias//' | cut -d= -f1 )

# env will return the complete environment. Cut will return only the variable
# names, which are then passend to unset to be removed from the environment 
unset $( env | cut -d= -f1 )

After you're done, just hit Ctrl+D or enter "exit" or "logout" to leave this bare shell.

Example with bash on Linux:
Code:
pludi@desktop:/tmp> env | wc -l; alias | wc -l
89
19
pludi@desktop:/tmp> env -i ${0#-}
pludi@desktop:/tmp> unalias $( alias | sed -e 's/^alias//' | cut -d= -f1 )
pludi@desktop:/tmp> unset $( env | cut -d= -f1 )
pludi@desktop:/tmp> env | wc -l; alias | wc -l
bash: wc: No such file or directory
bash: env: No such file or directory
bash: wc: No such file or directory
pludi@desktop:/tmp> /usr/bin/env | /usr/bin/wc -l; alias | /usr/bin/wc -l
1
0

This User Gave Thanks to pludi For This Post:
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Where to see my .profile file in UNIX?

Hi where to see my .profile file in unix thanks Dharma (2 Replies)
Discussion started by: na.dharma
2 Replies

2. UNIX for Dummies Questions & Answers

Modify .profile file

Hi there, I am really new to unix (about 3 days using it). In my assignment spec i have been told to modify my .profile file and create an environmental file. Until now all tasks have been file manipulation, etc learn how to use chmod or grep etc. I literally can't find this .profile file, I... (1 Reply)
Discussion started by: paulbuckley221
1 Replies

3. Solaris

Profile file bash

Hi Experts, Profile file was not found for one of the users on solaris box. Default shell is bash for the user. <prod>>:/home/produser::echo $SHELL /usr/bin/bash <prod>>:/home/produser::ls -lta |grep bash -rw------- 1 produser prod 4157 Oct 19 17:32 .bash_history... (1 Reply)
Discussion started by: sai_2507
1 Replies

4. Shell Programming and Scripting

.Profile file not running

Hi, I have a machine running Solaris 9. We are having a application user login. While connecting using putty in telnet directly we will give the application name in username field and it wont prompt for password and directly it will open the application menu. The executable for the application... (1 Reply)
Discussion started by: sol_user
1 Replies

5. UNIX for Advanced & Expert Users

.profile file on each terminal

Hello All, I create an oracle user, on my Solaris OS. i modified my .profile file on the oracle home. the problem that each time i want my variables to work, ORACLE_HOME, ORACLE_BASE ... i have to run the .profile file (. ./.profile) and each time i exit the terminal i have to run again so... (7 Replies)
Discussion started by: beayni33
7 Replies

6. UNIX for Advanced & Expert Users

.profile file not found

Hi I am trying to load the profile file using . /home/user/.profile it says file not found, but I can see the file in the /hom/user directory. Any help ? Thanks, Murty. (5 Replies)
Discussion started by: murtymvvs
5 Replies

7. Infrastructure Monitoring

trap in etc/profile and user .profile

Hello I really wonder what's trap in etc/profile and in each user .profile. I try to google for it but I think I have no luck. Mostly hit is SNMP traps which I think it is not the same thing. I want to know ... 1. What's a "trap 2 3" means and are there any other value I can set... (4 Replies)
Discussion started by: Smith
4 Replies

8. Shell Programming and Scripting

How to read the .profile file

Hi , I need to read the .profile file path from perl script. Could you please help me in this :) Regards, Kalai (1 Reply)
Discussion started by: kalpeer
1 Replies

9. Shell Programming and Scripting

Can I modify the .bashrc file instead of .profile file to customize my login?

Hello, I got this question which tells me to customize my login script. Some people in the forums suggested to modify the .profile file in my home directory. I did so, but none of my customizations show up when I open the terminal after. So, I tried to modify other files in my home directory,... (1 Reply)
Discussion started by: Hyunkel
1 Replies

10. UNIX for Dummies Questions & Answers

changed .profile but didnt ./.profile, yet reflected changes

hi , i added ls -F to .profile. and i need to do ./.profile for the effect to take effect BUT i didnt and YET the next day when i came to work and log in, the changes took effect. i am on aix. please explain.. thanks (4 Replies)
Discussion started by: yls177
4 Replies
Login or Register to Ask a Question