You can use cd to change into nested directories. For example, starting in the home directory, type
~> cd html cd lowerand (assuming that the html directory exists in your home directory and that the directory lower exists in your html directory) you'll see a prompt that looks like this:
[gtowell@lasath lower]$This line says "you login name is gtowell, you are logged in on the machine lasath and you are in a directory named lower"
[gtowell@lasath lower]$ cd .. [gtowell@lasath html]$
[gtowell@lasath html]$ cd ../.. [gtowell@lasath home]$This leaves you in a rather strange place (if you have been typing along) so for now enter "cd ~/html" (explanation forthcoming)
[gtowell@lasath html]$ cd ../apr [gtowell@lasath apr]$
[gtowell@lasath html]$ cd ~ [gtowell@lasath gtowell]$Also if you enter the command "cd" you will go back to your home directory. E.g.,
[gtowell@lasath html]$ cd [gtowell@lasath gtowell]$ ~>Finallym a dash is a shortcut for the last directory you were in:
[gtowell@lasath html]$ cd ~/bin [gtowell@lasath bin]$ cd - [gtowell@lasath html]$
mkdir new_directoryname
rmdir old_directoryname
Note that with this command, you can't remove a directory if it has any files or subdirectories in it.
ls filename[s]
Typing ls alone will list the files in the current directory. There are a variety of arguments to ls that give you more information about files.
ls -t sorts files by modification time (or date).
ls -l lists copious information about each file,
including size in kilobytes and date of last modification.
ls -F appends a / to each directory and a * to each
executable file.
Combining arguments can be useful:
ls -rlt sorts by and displays modification time (I find this one to be especially useful)
ls -F | grep "/" lists only directories.
* (asterisk) stands for zero or more of any character;
alone, it means "all files in the directory"
m* matches all files beginning with m
m*.txt matches all files beginning with m and ending with
.txt
? (question mark) stands for any single character in a file
name