|
The command
pwd is used to display the
full path name of the current directory.
top
of page
To switch to another
directory, the command cd is used.
| Examples |
What
it does |
| cd |
Will
place you in your home directory |
| cd
/ |
Will
move you to the root directory |
| cd
/etc |
Will
move you to the /etc directory |
| cd
../ |
Will
move you back one directory |
top
of page
The command
mkdir is used to create a new directory.
The command
rmdir or rm -r is used to delete a directory or
directories. Be careful in testing the following
delete commands. You will probably want to create sample directories
first.
| Examples |
What
it does |
| mkdir
mydirectory |
Will
create a new directory named 'mydirectory' |
| rmdir
existingdirectory |
Will
delete the existing directory named 'existingdirectory' |
| rm
-r existingdirectories |
Will
delete the existing directory named 'existingdirectories'
and all directories and files below it. |
top
of page
The command
ls is used to the contents of a directory.
| Options |
What
it does |
| -l |
long
listing |
| -R |
list
current directory and all other directories within current
directory |
| -a |
list
hidden files |
| -CF |
list in column format and append '*' to executable files,
'@' to symbolic linked files, '/' to directories |
| -r |
list in reverse alphabetically order |
| -t |
list
more recent accessed files first |
| filename(s) |
Values
to match |
| Examples |
What
it does |
| ls |
only
list file/directory names in current directory |
| ls
-l |
list
all file/directory information in current directory(long version) |
| ls
-R |
list
all files in current directories and below |
| ls
-lt |
list
all files, sorted by most recent accessed first |
| ls
-lt /etc/rc* |
list
files in the '/etc/ directory, only starting with 'rc' and
sort results by most recent |
top
of page
Wildcard characters
are used to help find file or directory names
| Options |
What
it does |
| * |
asterisk symbol is used to represent any
character(s) |
| ? |
question mark is used to represent any single
character |
| [from-to
] |
Values entered within square brackets represent a range
(from-to) for a single character |
| [!from-to
] |
Values
entered within square brackets represent a range
(from-to) to exclude for a single character |
| Examples |
What
it does |
| a* |
all
files starting with the letter 'a' |
| *z |
all
files where the last character is a 'z' |
| a*m |
all
files that start with the letter 'a' and end with 'm' |
| th?? |
all
files that start with 'th' and are only four characters long |
| [a-c]* |
all
files that start with 'a, b or c' |
| x[A-C]* |
all
files that start with the letter 'x' and the second character
contains 'A, B or C' |
| [!M-O]* |
all
files except those that start with 'M, N or O' |
top
of page
To copy a
file, the command cp is used
Example:
cp oldfile myfile - Will
copy the existing file 'oldfile' to a new file 'myfile'
top
of page
The command
mv is used to rename a file
Example:
mv myfile yourfile
- Will rename the file 'myfile' to 'yourfile'
top
of page
| Examples |
What
it does |
| rm
myfile |
remove the file 'myfile' |
| rm
-i abc* |
prompt to remove each file in current directory starting with
'abc' |
| rm
abc* |
remove all files in current directory starting with 'abc'
automatically |
top
of page
The command
wc is used to count lines, words or characters in a file
or piped results from another command.
| Options |
What
it does |
| -c |
Number
of characters |
| -w |
Number of words |
| -l |
|
| filename |
file
name(s) to use |
| Examples |
What
it does |
| wc
/etc/sendmail.cf |
Lists
the number of lines, words and characters in the file 'sendmail.cf' |
| ls
/etc | wc -l |
Lists
the number of files and directories in the directory 'etc' |
top
of page |