To find out the name of the directory you are currently in, type the pwd command:
$ pwd /usr/local/lib/xml
The pwd command displays the name of the current working directory.
To see a list of files in the current directory, type the ls command. This displays the names of files (in two or more columns, if they'll fit).
$ ls backup office bin restore.odf Desktop styles.tex holding ucc.png lib vehicle.dat menus word.log n800 $
Unless you specify otherwise, it lists the names from the current directory. See the pwd command for how to find out what your current working directory is.
You can specify a different directory to list by following the ls command with the name of that directory. See section 1.2, ‘The Unix file system’ for details of how to refer to your own and other directories on the computer.
$ ls /usr/local/share/texmf/bibtex/bst/
abstyles computational-complexity IEEEtran oxford
achemso dinat ifacmtg perception
[lots more left out here to save space]
bibhtml harvard natbib
camel hc nature
chem-journal ieeepes opcit
$
To see a list with all the file details (the ‘long’ format), type ls -l (The l option stands for ‘long’.) This shows the permissions, links, owner, group, size, date, time, and name of each file and directory (folder).
The first letter on each
line shows the type of file: d
for a
directory; l
for a link (shortcut or
alias), and -
(dash) for a normal
file.
$ ls -l total 15 drwxr--r-- 3 ontology webster 14 Dec 28 14:22 images drwxr--r-- 2 ontology ontology 256 Feb 15 22:37 Mail -rwxr--r-- 1 ontology ontology 123847 Jan 22 15:35 thesis.pdf lrwxrwxrwx 1 root root 31 Feb 27 2005 web -> /var/www/html/ontology $
In this example, the user has subdirectories called images and Mail, a file called thesis.pdf, and a soft link (alias or shortcut) called web which goes to their web site.
You can see the directory entry for a single file by following the ls command and the l option with the filename you're interested in:
$ ls -l thesis.pdf -rwxr--r-- 1 ontology ontology 123847 Jan 22 15:35 thesis.pdf
To change your current working directory, type cd dirname (replacing dirname with the name of the directory you want to change into.
When you want to do some work in another directory, you need to change to it:
$ cd staff
See the ls command for how to find out what directories you have got. See section 1.2, ‘The Unix file system’ for details of how to refer to your own and other directories on the computer.
Some systems display the name of the current directory before the dollar prompt. If not, to find out what directory you are in, use the pwd command.
To create a new directory, type mkdir dirname (replacing dirname with the name of the new directory you want to create).
$ mkdir reports
You can then use the cd command to change into the new directory.
If you need to create a directory and a subdirectory within it (and maybe a subsubdirectory within that), you can do so all in one command by adding the option p before the new path.
$ mkdir -p reports/management/2009/financial
See section 1.2, ‘The Unix file system’ for details of how to refer to your own and other directories on the computer.
If you want to provide a shortcut to a directory or file, the ln -s command links a new name to an existing one. It lets you create an alias or alternative name for a file or directory. The s option creates a ‘soft’ link; there are other types but this is the one you want.
Suppose you have created homepage.htm but it ought to have been called index.html; but you have already publicised the existence of homepage.htm and people are using it, so you can't just rename the file or you'll break their existing links. You create an alias:
$ cd web $ ln -s homepage.htm index.html
Now people can refer to either name, and they'll get the same file.
Keep up to date with our RSS newsfeed |
Electronic Publishing Unit • 2008-11-19 • (other) |