LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to change to a dirrectory in ubuntu (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-change-to-a-dirrectory-in-ubuntu-822463/)

sanjayagayan 07-27-2010 12:38 PM

How to change to a dirrectory in ubuntu
 
I can change to a nother directory in home folder using cd command.I have several partitions in my hard drive.But i want to know ho to cheng to a directory in nother partition or flash drive using command line.how can i do that

GrapefruiTgirl 07-27-2010 12:48 PM

You do that the same way you use the `cd` command to navigate around your home folder.

Remember, everything is somewhere off of the / directory (that means root of the filesystem, not the "root user").

Other disks or partitions are going to be mounted somewhere, i.e. onto a folder somewhere. The `mount` command will show you what is mounted where.

So, if you want to `cd` to some flash drive partition, and that partition is mounted at /media/usb/ then you would do:
Code:

cd /media/usb
If you omit the leading slash, then the `cd` command expects to find the folder you tell it to go to, inside the current directory you are in. Use the leading slash for cd'ing to absolute paths; omit it to cd to paths off of your current directory.
To go backwards one or two or three levels, use:
Code:

cd ..
cd ../..
cd ../../..

To cd to your home directory, use:
Code:

cd ~
There's probably more in the man page (or maybe not much more, as cd is a pretty simple tool):
Code:

man cd

jefro 07-27-2010 03:13 PM

cd may also bring you to home. Haa. Sasha missed one finally! :) Ok I gave her a did it help point.

Might help to know paths. They can sometimes help in less direct moves.

Flash drives may be found in one of two places usually. /mnt or /media. It would help us to know your distro too for exact help.

Partitons may be something either a name or somewhat of a drive code. Like /hda1 or sda2 or such. Might even show up as /Maxtor 60lmcbw whatever.

sanjayagayan 07-28-2010 11:56 AM

I change to dev directory using
"cd /dev" command.There are several partitions in my heard disk.So i try to go to sda7 partition using cd sda7.It says sda7 is not a directory.So please if someone can , teach me how to go to a folder inside sda7 partition using command line.Every time, when i want to do some work in a folder in separate partition,i have to copy the folder to Desktop.Because i don't know how to go to that folder using command line.

GrapefruiTgirl 07-28-2010 12:13 PM

The stuff in the /dev folder is mostly NOT folders; therefore you cannot cd into any of that stuff, except the very few places in /dev that actually are folders. However, cd'ing into those folders will not get you where you want to go.

Follow along here, doing the same commands I do, on your machine:
Code:

sasha@reactor: mount
/dev/root on / type ext4 (rw,noatime,barrier=1,data=ordered)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
usbfs on /proc/bus/usb type usbfs (rw)
tmpfs on /dev/shm type tmpfs (rw)
/dev/hda12 on /home type ext4 (rw,noatime)
sasha@reactor:

So, see above I typed mount. That tells me what hard disk partitions are mounted, and it tells me WHERE they are mounted. That is the important part - WHERE the partition is mounted.

Let's look at my last line from above:

Code:

/dev/hda12 on /home type ext4 (rw,noatime)
That line, says that /dev/hda12 (partition #12 on my /dev/hda disk) is mounted on /home. So, if I want to go into my /dev/hda12 and see what's in there, I would do this:
Code:

sasha@reactor: cd /home
Below is what NOT TO DO because it will not work:
Code:

sasha@reactor: cd /dev/hda12
bash: cd: /dev/hda12: Not a directory
sasha@reactor:

See? Did not work. You must cd into folders, not devices.

Try that - if you need further help, just ask. :)

MrCode 07-28-2010 12:31 PM

Quote:

Originally Posted by sanjayagayan
I change to dev directory using
"cd /dev" command.There are several partitions in my heard disk.So i try to go to sda7 partition using cd sda7.It says sda7 is not a directory.

The files in the /dev directory aren't really "files" in the traditional sense. They're what are called "device nodes", and are used by the OS/kernel to directly access all the devices currently attached to your machine.

In any UNIX-like OS, everything is a "file", i.e. it is an object that can be written to/read from, and has permissions/flags/etc.

One example that somewhat demonstrates how this works is if you type cat /dev/urandom > /dev/dsp into a terminal (turn your speakers way down though! :eek:). What this does is it redirects the "contents" of /dev/urandom (the pseudorandom number generator) into /dev/dsp (the device node for the audio controller), resulting in white noise. You're reading from one device "file" (/dev/urandom) and writing to another device "file" (/dev/dsp).

sanjayagayan 07-29-2010 11:39 AM

Thank
 
I got the answer,and now i can do it thanks to all of your help.Thank you very much.


All times are GMT -5. The time now is 02:51 AM.