In linux how to change directory

How do I change directories in the terminal, and know which directory I’m in?

How do I tell what is in which directory and how do I navigate the directory. I know I must be leaving out something simple.

You always need a space after the command such as «cd». Your command would work if you enter «cd /», and would move to the root directory.

3 Answers 3

In your session ls displays the content of the current directory (but not hidden files starting with a dot in the filename). You navigate into another directory by typing cd dirname . Here you have to substitude «dirname» by a directory’s name you want to change into. Normally you start out with your home directory as current working directory. In your case that is most likely /home/christy . If ls shows you a directory called «Template» you can change into «Template» (=make it your current working directory) by typing (mind the space) the command:

you will change your current working directory to «Templates» or print «No such file or directory», if a dir of that name does not exist in your current direcotry. Typing pwd will always give you the full patch to your current working directory including parents.

You can supply optional arguments to each command. For cd the string «Templates» was such an optional argument. If you type ls -a for instance, the ls command will print out hidden files as well. Or with ls Templates it will print the content of the Tempaltes directory instead of you current working dir’s content. Arguments must be separated by at least one space from the command name and from each other. The lack of a space between the two was the reason your command did not work.

Since the space character has a special meaning, you will need to quote or escape it, if it’s part of an argument. So if for instance you want to change your current working directory to «Source Files» you need to type one of these commands:

cd Source\ Files cd "Source Files" 

The upper line being «escaped» while the lower line is «quoted».

If you want to learn more the better guide for you might be: Introduction to Linux (pdf) (html)

Okay now, sorry I didn’t see your link there. Your post was a bit misleading, now I think I got you:

So you want to install tex-live from the source archive that is linked in the «Getting Started» guide you posted. To do that you must first remove any pre-existing installation of tex-live. You do that by opening a terminal doing this:

christy@ubuntu:~$ pwd /home/christy #  

At this point you have to enter you password and will be rewarded with a few boring messages, that I will omit here. Then you'll have to download the archive named install-tl-unx.tar.gz (you already did that and don't have to download it again, but I show you how to do it none the less just in case):

christy@ubuntu:~$ wget http://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz --2012-07-09 15:08:23-- http://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz Resolving mirror.ctan.org. 80.237.159.15 Connecting to mirror.ctan.org|80.237.159.15|:80. connected. HTTP request sent, awaiting response. 302 Found # . some more stuff like this . Saving to: `install-tl-unx.tar.gz' 100%[=====================================>] 2,530,831 --.-K/s in 0.1s 2012-07-09 15:08:23 (17.3 MB/s) - `install-tl-unx.tar.gz' saved [2530831/2530831] 

Now that you have downloaded the archive you can unpack it

christy@ubuntu:~$ tar xvf install-tl-unx.tar.gz install-tl-20120701/ install-tl-20120701/readme-txt.dir/ install-tl-20120701/readme-txt.dir/README.RU-cp1251 # . bla bla skipping over some more messages like this . install-tl-20120701/readme-html.dir/readme.sr.html install-tl-20120701/readme-html.dir/readme.ru.html install-tl-20120701/readme-html.dir/readme.de.html 

Now that you've unpacked the archive you can change into the directory that was unpacked.

christy@ubunut:~$ ls | grep install-tl- #  

The number "20120701" is a timestamp saying which version of tex-live you have. This number might be different for you but the command ls | grep install-t1- will tell you what to use instead. If all this worked, you can run the install script from here:

christy@ubuntu:~$ sudo ./install-tl [sudo] password for jan: Loading http://ftp.univie.ac.at/packages/tex/systems/texlive/tlnet/tlpkg/texlive.tlpdb Installing TeX Live 2012 from: http://ftp.univie.ac.at/packages/tex/systems/texlive/tlnet Platform: x86_64-linux => 'x86_64 with GNU/Linux' # . bla bla and so on bla . Actions: start installation to hard disk help quit Enter command: I # . and so on . 

From here on just answer the questions you're asked by the install script and you should be fine.

Источник

Linux cd command

Computer Hope

On Unix-like operating systems, the cd command ("change directory") changes the shell's current working directory.

This page covers the bash built-in version of cd.

Description

cd is among the commands you use most on the command line. It changes your working directory. Use it to move around in the hierarchy of your file system.

Syntax

cd [-L | -P [-e]] directory

Options

-L Force symbolic links to be followed. In other words, if you tell cd to move into a "directory", which is actually a symbolic link to a directory, it moves into the directory the symbolic link points to. This option is the default behavior of cd; normally, it always acts as if -L was specified.
-P Use the physical directory structure without following symbolic links. In other words, only change into the specified directory if it actually exists as named; symbolic links are not followed. This option is the opposite of the -L option, and if they are both specified, this option is ignored.
-e If the -P option is specified, and the current working directory cannot be determined, this option tells cd to exit with an error. If -P is not specified with this option, this option has no function.

Directories

To help you organize your files, your file system contains special files called directories. Think of them like folders in a file cabinet: they have names, like files, but their function is to "contain" other files, and other directories. In this way, you can keep the files on your system separate and sorted according to their function or purpose.

All files and directories on your system stem from one main directory: the root directory. There are no directories "above" the root directory; all other directories are "below" the root directory.

Any directory contained inside another directory is called a subdirectory. Subdirectories "branch" off the "root" of the directory "tree." Unlike a real tree, directory trees are upside-down: the root is at the top and the branches reach down. When you move into a subdirectory, you are moving "down" the tree; when you move into a directory's parent directory, you are moving "up" the tree.

All directories on your file system are subdirectories of the root directory.

By default, when you open a terminal and begin using the command line, you are placed in your home directory.

How directories are represented

Directories are separated by a forward slash ("/"). For instance, the directory name "documents/work/accounting" means "the directory named accounting, which is in the directory named work, which is in the directory named documents, which is in the current directory."

To change into this directory, and make it our working directory, we would use the command:

cd documents/work/accounting

If the first character of a directory name is a slash, that denotes that the directory path begins in the root directory. So, in contrast to the example above, the directory name "/documents/work/accounting" (note the beginning slash) means "the directory named accounting, which is in the directory named work, which is in the directory named documents, which is in the root directory."

To change into this directory, making it our working directory, we would use the command:

cd /documents/work/accounting

The root directory

The root directory is the first directory in your filesystem hierarchy. All other directories are subdirectories of the root directory.

The root directory is represented by a single slash ("/").

To change into the root directory, making it your working directory, use the command:

You cannot make any changes to the root directory on your system unless you are logged in as root, or using the sudo command. Unless you are certain of what you're doing, don't make any changes here. Making a mistake could destroy your system!

The working directory

The current directory, regardless of which directory it is, is represented by a single dot (".").

. would change us into the current directory. In other words, it would do nothing.

What's actually happening is the dot represents the "assumed" directory; it's a placeholder, and you can use the dot anywhere in a directory name. So, the command:

. is the same as the command:

In all of these examples, the dot represents "the directory assumed to be there". You can use it as a placeholder anywhere you want to tell the shell that a directory goes in that place, and to assume the appropriate value.

The parent directory

The parent directory of the current directory — in other words, the directory one level up from the current directory, which contains the directory we're in now — is represented by two dots ("..").

So, If we were in the directory /home/username/documents, and we executed the command:

. we would be placed in the directory /home/username.

The double-dot ("..") directory notation can be used anywhere in a directory name to represent going up one level. For instance, if we have two directories, /home/username/documents and /home/username/downloads, and we are currently in /home/username/documents, we could type the following:

. and we would be placed in /home/username/downloads.

Another "useless" command, but one that illustrates the way you can use the double-dot notation, is this one:

. which will place us in the directory one level above the subdirectory documents — in other words, the current directory. Note that this only work if the subdirectory documents already exists.

. is functionally the same as this command:

Your home directory

Your home directory is the directory you're placed in, by default, when you open a new terminal session. It's the directory that holds all your settings, your mail, your default documents and downloads folder, and other personal items. It has a special representation: a tilde ("~").

So, if our username is username, and our home directory is /home/username, the command:

. is functionally the same as the command:

. and we can always access the subdirectories of our home directory by placing the tilde as the first component of the directory name. For instance, if your documents folder is named /home/username/documents, you can always move into that directory using the command:

The previous working directory

After you change directory, you can change back to the previous working directory by representing it with a dash ("-"). When you do this, the shell automatically tells you the new directory name.

Источник

Читайте также:  Virtual machine manager установка linux
Оцените статью
Adblock
detector