Commands

Commands

cd

target_directory

Change directory. This command makes target_directory your current working directory. It is a strong contender for the single most commonly used command in Linux. target_directory may be either a relative path, an absolute path, a shell symbol, or a shell variable.

Example: In the examples on the usage of the cd command presented next, assume that the shell variable $BOB stands for /home/bob. The directory tree is the same as the sample directory tree printed in the front of this chapter:

Starting Directory

target_directory Type

Example Command

Ending Directory

/home/shawkins

relative

cd linux

/home/shawkins/linux

/home/shawkins

absolute

cd /home

/home

/home/shawkins

shell symbol

cd ..

/home

/home/shawkins

shell variable

cd $BOB

/home/bob

mkdir

[OPTION] NAME

Create a directory.

Example: To create a new directory called tcl_stuff under your current working directory, use

mkdir tcl_stuff

Example: To create a new directory called tcl_stuff under your current working directory with read, write, and execute permissions for the owner, but no permissions for anyone else, use

mkdir -m 700 tcl_stuff

-m MODE, --mode=MODE

Set the file permissions as specified.

-p, --parents

Make any missing parent directories for each argument.

--verbose

Verbose output. Display a message for each directory created.

pwd

Display the fully resolved name (i.e., the full pathname starting at the root directory) of the current directory.

Example: To display the current directory, use

pwd

rmdir

[OPTION] DIRECTORY

Remove the specified directory(ies). All directories specified must (a) exist and (b) be empty.

Example: To remove the directory tcl_stuff, use

rmdir tcl_stuff

Example: To remove the directory tcl_stuff and any empty parent directories it may have, use

rmdir -p tcl_stuff

-p, --parents

Tell rmdir to remove any parent directories that may become empty after one of the subdirectories is removed.

symlinks

[ -cdrv ] dirlist

This command scans directories for symbolic links, listing them to standard output. Each link is classified as one of the following:

relative

A link expressed as a path relative to the directory in which the link resides.

absolute

A link given as an absolute path from the root directory.

dangling

A link whose target does not currently exist.

messy

A link containing unnecessary slashes or dots in the path.

lengthy

A length using "../" more than necessary in the path.

other_fs

A link whose target resides on a different filesystem.

Example: To search all the subdirectories under your home directory (-r option) for symbolic links, removing any dangling links found (-d option), use

symlinks -r -d ~

-c

Convert absolute links to relative links.

-d

Remove dangling links.

-r

Recursive operation (within a single filesystem).

-s

Detach lengthy links.

-t

Test what would happen if -c was specified but don't change anything.

-v

Include relative links in the output. (By default, they are excluded.)

 



Linux Desk Reference
Linux Desk Reference (2nd Edition)
ISBN: 0130619892
EAN: 2147483647
Year: 2000
Pages: 174
Authors: Scott Hawkins

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net