|
To list the contents of the working directory, you can use the
ls command.
ls has a ridiculous number of options documented in its
manual page, but you will most likely
use only -l (detailed listing), -d (don't recurse into
the specified directory), -R (recurse into all subdirectories),
and -a (show hidden files; i.e., files that start with a dot).
$ ls
$ ls -la
$ ls -ld SomeDir
$ ls -R SomeDir
cat can be used to display the entire contents of a text file
to the terminal:
$ cat ~/ToDo.txt
It is also common to concatenate files together using cat:
$ cat ToAppend.txt >> TargetFile.txt
The cp (copy) command will copy one or more files. To create a copy of
SourceFile named NewFile, you would use:
$ cp SourceFile NewFile
cp can also copy a file into a given directory:
$ cp Image.jpg ~/www/MyImages/
Entire directories can be copied in the same way. We can use the
-p (preserve) option to preserve all file attributes:
$ cp -Rp Images ~/www/MyImages/
The mv (move) command will move (i.e., rename) files or
directories:
$ mv SomeFile TargetFile
$ mv SomeFile ~/MyDir/
$ mv SomeDir ~/MyDir/
The touch utility is useful for creating empty files (or updating
the modification time on an existing file):
$ touch EmptyFile
The mkdir command will create a new directory:
$ mkdir NewDir
The rm (remove) command will delete single files, or entire
directories if used with the -R option:
$ rm EmptyFile
$ rm -iR NewDir
Unless the -i option is used, rm will never prompt for
confirmation before deleting files.
rm does not perform any backup.
The only way to recover data deleted by mistake is to recover from backup.
You can request backup restores from us (or perform the recovery yourself by
logging into a backup server).
Occasionally, files with a dash (-) as the first character in
the file name are created, usually by mistake. If you need to delete such
a file, use the backslash as an escape character (quotes alone will not
work in this case):
$ rm \-StupidFile
tail is used to display the last few lines of a text file. It
is very useful for displaying log files:
$ tail -f ~/www/logs/access
$ tail -f ~/www/logs/error
Symbolic links are used to create short cuts, or multiple names for a
single file or directory (possibly across directories). They are created
with the ln command. The example below will create a new name for
MyFile:
$ ln -s MyFile LinkToMyFile
|