Posted by: isaraffee | August 9, 2009

Moving a User and Its Home Directory

Moving a User and Its Home Directory

In this project, you are going to move the user, user1 from his directory /home/user1 to /home/home2/eng.

Check the disk usage on /home to make sure there is enough space on the partition for user1’s home directory:

[root@venus /root]# df -k /home

Filesystem 1k-blocks Used Available Use% Mounted on

/dev/hda5 1408570 518 1349823 0% /home

Move user1’s home directory over to /home/home2/eng by using tar command with a pipe:

[root@venus /home]# tar -cf – user1 | (cd /home/home2/eng;tar -xvpf -)

user1/

user1/.bash_logout

user1/.bash_profile

user1/.bashrc

user1/.mailcap

user1/tmp/

user1/tmp/somefile.txt

user1/.screenrc

user1/.xauth/

user1/.ssh/

user1/.ssh/id_dsa

user1/.ssh/id_dsa.pub

user1/.ssh/known_hosts

user1/.bash_history

user1/business.txt

Check to see if user1’s files are transported to the new directory /home/home2/user1 directory:

[root@venus /home]# cd /home/home2

[root@venus home2]# ls

eng/

[root@venus home2]# cd eng

[root@venus eng]# ls

user1/

[root@venus eng]# ll

total 1

drwx—— 5 user1 user1 1024 May 21 18:11 user1/

[root@venus eng]# cd user1

[root@venus user1]# ll

total 1

-rw-r–r– 1 root root 0 May 21 18:11 business.txt

drwx—— 2 user1 user1 1024 May 21 18:11 tmp/

[root@venus user1]# cd tmp

[root@venus tmp]# ll

total 0

-rw-r–r– 1 root root 0 May 21 18:11 somefile.txt

Yes all the files have been moved to the newly created directory.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: