Asked By
jemes
10 points
N/A
Posted on - 08/20/2011
Hi Guys,
I am a new user in Red Hat Linux. Now I want to change my present directory.
But I do not know how can I change my present directory.
Can anybody give me any solution about this?
Please help me.
Answered By
srknitk
0 points
N/A
#115747
How to change directory in Red Hat Linux
Â
Do you mean home directory? (The directory where you can write files and place your personal files)
Â
There are 2-3 methods to change the home directory.
Â
1. To change the home directory without moving the contents in the old home directory
-
Open the terminal
-
login as root
-
execute the commandÂ
-
#usermod -d <absolute path of new home directory> <username>
-
For ex: #usermod -d /home/user1 user3
-
in the above example user3 is the name of that user and /home/user1 is the absolute path of the new home directory
2. To change the home directory and also moving the contents in the old home directory
-
Open the terminal
-
login as root
-
execute the command
-
#usermod -md <absolute path of new home directory> <username>
3. By editing the /etc/passwd file
-
Open the terminal
-
login as root
-
#vi /etc/passwd
-
move the cursor to the line where you find the entry like the one below. (your username in place of user3 and the uid=1000 may change)
-
user3:x:1000:1000:User3,,,:/home/user3:/bin/bash
-
press Insert button on the keyboard and replace the /home/user3 with the new home directory you want
-
for ex:
-
user3:x:1000:1000:User3,,,:/home/user1:/bin/bash
-
now save the file(press Esc and then type 😡 and press Enter) and logout and login to that user.
Answered By
alman007
0 points
N/A
#115748
How to change directory in Red Hat Linux
Â
Changing directory is easy when you know where you are:
Â
Determine current directory with pwd
Â
pwd stands for print working directory. when you type pwd, you asked linux system to display your current location. By default , the Bash Prompt in Red Hat Enterprise Linux shows just the current directory.
Â
[alman@alman yen]$ pwd
Â
/home/yen
Â
[alman@alman yen]$
Â
the example shows that you are in the yen's directory, which is in the home directory.
Â
Changing directories with cd
Â
to change directory use the cd command. Typing cd by itself returns you to your home directory, moving to any other directory requires a pathname.
Â
there are two types of pathname: absolute and relative.
Â
Absolute path start at the top of the file system with " / " which referred as root.and then look down for the requested directory.
Â
Relative path look down from your current directory . The below attachment illustrate how cd operates:
Â
/
Â
/directory1
Â
/directory1/directory2
Â
/directory1/directory2/directory3
Â
if you are in directory 3 & you want to move to directory 1, you need to move up in the directory tree by execuding:
Â
cd directory1
Â
while you are in directory 3,if presents any error that there is no such directory .This happens because there is no directory 1 below directory 3 .
Â
to move up to directory 1 , type  cd/directory1
Â
this is an example of absolute path.using absolute path to change directory it needs to know and type the entire path. where using relative path allows to change directory relative to the directory you currently in. now follow the attachments. thank you.
Â